Curation round 21: rock drops, Boss Rush and room setup, Dross, Ashpit and Gehenna enemies, Book of Virtues wisps and Dream Catcher, the last familiars and effects, player damage branches, a Corpse floor and Abyss crash fix, shared constants (186 duplicates)
This commit is contained in:
1 parent
8dbeb1bc4a
commit
6a11163842
184 files changed
+16980
-1419
No files matched your search
+38
-20
@@ -1,8 +1,10 @@
|
||||
#include "npc_ai.h"
|
||||
#include "active_items.h"
|
||||
#include "entity_effect.h"
|
||||
#include "entity_familiar.h"
|
||||
#include "entity_player.h"
|
||||
#include "game.h"
|
||||
#include "menu_manager.h"
|
||||
#include "room.h"
|
||||
|
||||
constexpr int DIP_BIG_CORN = 3;
|
||||
@@ -25,26 +27,38 @@ constexpr float HURT_VOLUME = 0.8f;
|
||||
constexpr int HURT_SOUND_DELAY = 15;
|
||||
constexpr float CORN_AIM_LEAD = 0.1f;
|
||||
constexpr float CORN_SHOT_SPEED = 10;
|
||||
constexpr float CONTROLLER_DEADZONE = 0.1f;
|
||||
constexpr ColorMod DIP_SPLAT = {{0, 0, 0, 1}, {0, 0, 0, 0}, {0.25490198f, 0.16078432f, 0.13725491f}};
|
||||
constexpr ColorMod BROWNIE_SPLAT = {{0, 0, 0, 1}, {0, 0, 0, 0}, {0.6f, 0.4f, 0}};
|
||||
|
||||
// A hop: a random way (away from its target while it fears it), faster for the corn dips.
|
||||
// The Drip hops slower (5 to 8), one time in three at its target, pushed back by the room's current, slides with
|
||||
// less friction and may hop again from frame 10 of its hop, one time in three.
|
||||
constexpr float DRIP_HOP_SPEED_RANGE = 3;
|
||||
constexpr int DRIP_AIM_ODDS = 3;
|
||||
constexpr float DRIP_CURRENT_PUSH = 8;
|
||||
constexpr float DRIP_FRICTION = 0.9f;
|
||||
constexpr int DRIP_REHOP_FRAME = 10;
|
||||
constexpr int DRIP_REHOP_ODDS = 3;
|
||||
constexpr float CONTROLLER_DEADZONE = 0.1f;
|
||||
|
||||
// A hop: a random way (away from its target while it fears it), faster for the corn dips. The Drip hops at its
|
||||
// target one time in three and against the room's current.
|
||||
static void dip_hop(Entity_NPC& npc)
|
||||
{
|
||||
npc.state = NPC_STATE_MOVE;
|
||||
bool isDrip = npc.type == ENTITY_DRIP;
|
||||
bool isFleeing = npc.HasEntityFlags(FLAG_FEAR | FLAG_SHRINK) && npc.controllerID == -1;
|
||||
Vector direction;
|
||||
if (isFleeing) direction = vector_normalized(vector_sub(npc.pos, npc.GetPlayerTarget()->pos));
|
||||
else
|
||||
{
|
||||
direction = random_direction();
|
||||
bool isAimed = isDrip && Random() % DRIP_AIM_ODDS == 0;
|
||||
direction = isAimed ? vector_normalized(vector_sub(npc.GetPlayerTarget()->pos, npc.pos)) : random_direction();
|
||||
if (npc.controllerID != -1) direction = npc.GetControllerInput(0);
|
||||
}
|
||||
|
||||
float speed = random_unit() * HOP_SPEED_RANGE + HOP_SPEED_MIN;
|
||||
bool isDoubled = npc.variant == DIP_CORN || (isFleeing && npc.variant == DIP_BROWNIE);
|
||||
float speed = random_unit() * (isDrip ? DRIP_HOP_SPEED_RANGE : HOP_SPEED_RANGE) + HOP_SPEED_MIN;
|
||||
bool isDoubled = !isDrip && (npc.variant == DIP_CORN || (isFleeing && npc.variant == DIP_BROWNIE));
|
||||
Vector hop = vector_scale(direction, isDoubled ? speed * 2 : speed);
|
||||
Vector current = g_game->room->waterCurrent;
|
||||
if (isDrip && !isFleeing && !vector_is_zero(current)) hop = vector_sub(hop, vector_scale(current, DRIP_CURRENT_PUSH));
|
||||
if (npc.friction != 0)
|
||||
npc.velocity = vector_add(npc.velocity, vector_scale(hop, npc.speedMultiplier / npc.friction));
|
||||
}
|
||||
@@ -61,12 +75,11 @@ static void dip_corn_shoot(Entity_NPC& npc)
|
||||
PROJECTILES_SINGLE, params);
|
||||
}
|
||||
|
||||
// 00534860 The Dip's AI: it rests, hops about (fleeing what it fears), slides to a stop and leaves poop splats. Dirty
|
||||
// Mind and the Dipping trinket turn it into the players' own dip.
|
||||
// 00534860 The Dip's and the Drip's AI: it rests, hops about (fleeing what it fears), slides to a stop and leaves
|
||||
// poop splats. Dirty Mind and the Dipping trinket turn it into the players' own dip.
|
||||
void npc_dip_update(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.type != ENTITY_DIP) reconstruction_missing("npc_dip_update 00534860: the other dip kin");
|
||||
|
||||
bool isDrip = npc.type == ENTITY_DRIP;
|
||||
PlayerManager& players = g_game->playerManager;
|
||||
bool isTamed = players.FirstCollectibleOwner(COLLECTIBLE_DIRTY_MIND_ID, LAZARUS_SHARE_CHECK) ||
|
||||
players.AnyoneHasTrinket(TRINKET_DIPPING_TRINKET_ID);
|
||||
@@ -78,8 +91,8 @@ void npc_dip_update(Entity_NPC& npc)
|
||||
{
|
||||
npc.entityCollisionClass = ENTCOLL_NONE;
|
||||
npc.Remove();
|
||||
bool isCorn = npc.variant == DIP_CORN || npc.variant == DIP_BIG_CORN;
|
||||
int dip = npc.variant == DIP_BROWNIE ? FAMILIAR_DIP_BROWNIE : isCorn ? FAMILIAR_DIP_CORN : 0;
|
||||
bool isCorn = !isDrip && (npc.variant == DIP_CORN || npc.variant == DIP_BIG_CORN);
|
||||
int dip = !isDrip && npc.variant == DIP_BROWNIE ? FAMILIAR_DIP_BROWNIE : isCorn ? FAMILIAR_DIP_CORN : 0;
|
||||
Entity_Familiar::ThrowDip(dip, npc.pos, owner);
|
||||
return;
|
||||
}
|
||||
@@ -88,10 +101,11 @@ void npc_dip_update(Entity_NPC& npc)
|
||||
if (npc.state == NPC_STATE_INIT)
|
||||
{
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
npc.splatColor = npc.variant == DIP_BROWNIE ? BROWNIE_SPLAT : DIP_SPLAT;
|
||||
npc.splatColor = npc.variant == DIP_BROWNIE ? LIGHT_POOP_SPLAT_COLOR : POOP_SPLAT_COLOR;
|
||||
return;
|
||||
}
|
||||
bool isFloating = npc.variant == DIP_BIG_CORN && g_game->room->waterAmount > 0;
|
||||
bool isBigCorn = npc.type == ENTITY_DIP && npc.variant == DIP_BIG_CORN;
|
||||
bool isFloating = (isDrip || isBigCorn) && g_game->room->waterAmount > 0;
|
||||
npc.entityGridCollisionClass = isFloating ? GRIDCOLL_NOPITS : GRIDCOLL_GROUND;
|
||||
|
||||
if (npc.state == NPC_STATE_IDLE || npc.state == NPC_STATE_SPECIAL)
|
||||
@@ -101,13 +115,17 @@ void npc_dip_update(Entity_NPC& npc)
|
||||
(npc.controllerID == -1 ? Random() % HOP_ODDS == 0
|
||||
: !vector_is_zero(npc.GetControllerInput(CONTROLLER_DEADZONE)));
|
||||
if (isHopping) dip_hop(npc);
|
||||
npc.friction *= HOP_FRICTION;
|
||||
npc.friction *= isDrip ? DRIP_FRICTION : HOP_FRICTION;
|
||||
}
|
||||
else if (npc.state == NPC_STATE_MOVE)
|
||||
{
|
||||
npc.sprite.Play("Move");
|
||||
npc.friction *= SLIDE_FRICTION;
|
||||
if (vector_length_squared(npc.velocity) < 1) npc.state = NPC_STATE_IDLE;
|
||||
bool isRehop = isDrip && npc.sprite.GetFrame() == DRIP_REHOP_FRAME &&
|
||||
(Random() % DRIP_REHOP_ODDS == 0 || npc.controllerID != -1);
|
||||
if (isRehop) npc.state = NPC_STATE_SPECIAL;
|
||||
else if (isDrip ? !npc.sprite.IsPlaying() : vector_length_squared(npc.velocity) < 1)
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
}
|
||||
|
||||
npc.sprite.isFlipX = npc.velocity.x < 0;
|
||||
@@ -116,7 +134,7 @@ void npc_dip_update(Entity_NPC& npc)
|
||||
->SetColor(npc.splatColor, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
||||
if (npc.pendingDamage > 0 && (Random() & 1) == 0)
|
||||
npc.PlaySound(SOUND_DIP_HURT, HURT_VOLUME, HURT_SOUND_DELAY, false, 1);
|
||||
if (npc.variant == DIP_BIG_CORN && npc.controllerID != -1)
|
||||
reconstruction_missing("npc_dip_update 00534860: a controlled corn dip bursting");
|
||||
if (npc.isDead && npc.variant == DIP_BIG_CORN && !npc.HasEntityFlags(FLAG_SHRINK)) dip_corn_shoot(npc);
|
||||
if (isBigCorn && npc.controllerID != -1 && input_is_action_pressed(ACTION_BOMB, npc.controllerID, &npc))
|
||||
npc.Kill(EntityRef());
|
||||
if (npc.isDead && isBigCorn && !npc.HasEntityFlags(FLAG_SHRINK)) dip_corn_shoot(npc);
|
||||
}
|
||||
Reference in new issue
Block a user