Curation round 12: basement enemies, projectiles, tear flags, lighting and blend modes, actives, boss deaths, familiars, shops and secret rooms
This commit is contained in:
1 parent
698eeb74e9
commit
f8ce24fc6c
146 files changed
+16389
-3104
No files matched your search
+39
-204
@@ -1,6 +1,9 @@
|
||||
#include "entity_npc.h"
|
||||
#include "boss_death.h"
|
||||
#include "entity_config.h"
|
||||
#include "entity_effect.h"
|
||||
#include "entity_familiar.h"
|
||||
#include "entity_pickup.h"
|
||||
#include "entity_player.h"
|
||||
#include "entity_projectile.h"
|
||||
#include "data.h"
|
||||
@@ -9,6 +12,7 @@
|
||||
#include "log.h"
|
||||
#include "manager.h"
|
||||
#include "npc_ai.h"
|
||||
#include "npc_basement.h"
|
||||
#include "persistent_game_data.h"
|
||||
#include "platform.h"
|
||||
#include "room.h"
|
||||
@@ -19,21 +23,11 @@
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
|
||||
constexpr int ENTITY_FLY = 13;
|
||||
constexpr int ENTITY_POOTER = 14;
|
||||
constexpr int ENTITY_ATTACKFLY = 18;
|
||||
constexpr int ENTITY_MULLIGAN = 16;
|
||||
constexpr int ENTITY_HIVE = 22;
|
||||
constexpr int ENTITY_SPIDER = 85;
|
||||
constexpr int ENTITY_ETERNAL_FLY = 96;
|
||||
constexpr int ENTITY_FEAR_IMMUNE = 205;
|
||||
constexpr int ENTITY_DEATHS_HEAD = 212;
|
||||
constexpr int ENTITY_NO_DECOY_TYPE = 213;
|
||||
constexpr int ENTITY_COLLISION_SPAWNER_SPECIAL = 873;
|
||||
constexpr int ENTITY_BIG_HORN = 411;
|
||||
constexpr int ENTITY_MOMS_HEART_PLAYER_PICK = 53;
|
||||
constexpr int ENTITY_DEATH_REWARD_EXEMPT = 885;
|
||||
constexpr int ENTITY_ROTGUT = 911;
|
||||
constexpr int ENTITY_UNREACHABLE_EXEMPT = 886;
|
||||
constexpr int ENTITY_FLICKER_TYPE = 252;
|
||||
constexpr int ENTITY_DEATH_SPARK_TYPE = 882;
|
||||
@@ -56,11 +50,7 @@ constexpr int DEATH_HEAD_LAYER_TYPE = 405;
|
||||
constexpr int DEATH_NO_BURST_FIRST = 74;
|
||||
constexpr int DEATH_NO_BURST_LAST = 76;
|
||||
constexpr int MULLIGAN_VARIANT_FLEEING = 2;
|
||||
constexpr int FAMILIAR_BLUE_FLY = 43;
|
||||
constexpr int CHALLENGE_KILL_CHARGE = 33;
|
||||
constexpr int COLLECTIBLE_SKATOLE_ID = 9;
|
||||
constexpr int COLLECTIBLE_BURSTING_SACK_ID = 377;
|
||||
constexpr int COLLECTIBLE_E_COLI_ID = 236;
|
||||
constexpr int COLLECTIBLE_LIL_PORTAL_ID = 661;
|
||||
constexpr std::string_view BIG_HORN_SPIT_EVENT = "Item";
|
||||
constexpr std::string_view DIRT_LAYER = "dirt";
|
||||
@@ -71,7 +61,6 @@ constexpr int DIRT_SAMPLE_FRAMES = 15;
|
||||
constexpr float DIRT_GREEN = 0.9f;
|
||||
constexpr float DIRT_LERP = 0.1f;
|
||||
constexpr int MORPH_COLOR_PRIORITY = -1000;
|
||||
constexpr int COLOR_PRIORITY_DEFAULT = 255;
|
||||
constexpr ColorMod COLOR_INVISIBLE = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0}};
|
||||
constexpr int UNREACHABLE_CHECK_FRAMES = 60;
|
||||
constexpr int UNREACHABLE_GRACE_FRAMES = 900;
|
||||
@@ -89,10 +78,6 @@ constexpr int FEAR_RETARGET_RANGE = 15;
|
||||
constexpr int FEAR_RETARGET_MIN = 5;
|
||||
constexpr float MOVEMENT_DEADZONE = 0.1f;
|
||||
constexpr float ATTACK_PREDICT_FRAMES = 5;
|
||||
constexpr int LINE_CHECK_PROJECTILE = 3;
|
||||
constexpr int LINE_MODE_GROUND = 0;
|
||||
constexpr int LINE_MODE_PROJECTILE = 3;
|
||||
constexpr float LINE_STEP = 10;
|
||||
constexpr int LINE_BLOCKED_MAX = 8;
|
||||
// The corners of the band a line check samples around each step.
|
||||
struct LineCorner
|
||||
@@ -104,8 +89,6 @@ constexpr std::array<LineCorner, 4> LINE_CORNERS = {{{-5, -5}, {-5, 5}, {5, 5},
|
||||
constexpr int GRID_PATH_PIT = 3000;
|
||||
constexpr uint32_t GRID_PATH_BAND = 1000;
|
||||
constexpr int STAGE_BEAST_DUNGEON = 35;
|
||||
constexpr int LINE_CHECK_THRESHOLD = 999;
|
||||
constexpr float KNOCKBACK_IMPACT_SPEED = 6;
|
||||
constexpr float SHIELD_SECOND = 30;
|
||||
constexpr float SHIELD_BASE = 0.09f;
|
||||
constexpr float SHIELD_FALLOFF = 0.18f;
|
||||
@@ -115,66 +98,27 @@ constexpr int SOUND_POOP_DEATH = 237;
|
||||
constexpr float POOP_DEATH_VOLUME = 0.9f;
|
||||
constexpr uint32_t DEBUG_HEALTH_VALUES = 1 << 6;
|
||||
constexpr uint64_t FLAG_FRIENDLY_BALL_DYING = 1ull << 60;
|
||||
constexpr uint64_t PROJECTILE_ANY_HEIGHT_ENTITY_HIT = 1ull << 17;
|
||||
|
||||
// The burst effects a dead NPC leaves besides blood (Lua's EffectVariant).
|
||||
enum DeathBurst : int
|
||||
{
|
||||
EFFECT_SPIDER_EXPLOSION = 38,
|
||||
EFFECT_POOP_EXPLOSION = 43,
|
||||
EFFECT_BURST_810 = 130,
|
||||
EFFECT_BURST_853 = 131,
|
||||
EFFECT_BURST_818 = 145
|
||||
};
|
||||
|
||||
// Lua's DamageFlag bits the NPC code reads beyond entity.h's.
|
||||
enum NpcDamageFlag : uint64_t
|
||||
{
|
||||
DAMAGE_ACID = 1ull << 4,
|
||||
DAMAGE_INVINCIBLE = 1ull << 13,
|
||||
DAMAGE_SPAWN_FLY = 1ull << 14,
|
||||
DAMAGE_SPAWN_BLACK_HEART = 1ull << 23,
|
||||
DAMAGE_SPAWN_RED_HEART = 1ull << 26,
|
||||
DAMAGE_SPAWN_COIN = 1ull << 27,
|
||||
DAMAGE_IGNORE_ARMOR = 1ull << 30,
|
||||
DAMAGE_SPAWN_CARD = 1ull << 31,
|
||||
DAMAGE_SPAWN_RUNE = 1ull << 32
|
||||
};
|
||||
constexpr int ENTITY_SUCKER = 61;
|
||||
constexpr int ENTITY_SIREN_HELPER = 966;
|
||||
constexpr int ENTITY_BABY_PLUM = 908;
|
||||
constexpr int ENTITY_EXORCIST = 832;
|
||||
constexpr int ENTITY_ISAAC_BOSS = 102;
|
||||
constexpr int ENTITY_HORNFEL = 906;
|
||||
constexpr int ENTITY_GIDEON = 907;
|
||||
constexpr int ENTITY_SHADOW_CHARGER = 23;
|
||||
constexpr int ENTITY_ULTRA_GREED_DOOR = 889;
|
||||
constexpr int ENTITY_MONSTRO = 45;
|
||||
constexpr int ENTITY_GURDY_JR = 78;
|
||||
constexpr int SUCKER_VARIANT_BULB = 5;
|
||||
constexpr int FAMILIAR_PUNCHING_BAG = 67;
|
||||
constexpr int SHADOW_CHARGER_SUBTYPE = 1;
|
||||
constexpr int TYPE_NO_TICK_A = 274;
|
||||
constexpr int TYPE_NO_TICK_B = 275;
|
||||
|
||||
// The effects the NPC code spawns (Lua's EffectVariant).
|
||||
enum NpcEffect : int
|
||||
{
|
||||
EFFECT_BLOOD_EXPLOSION = 2,
|
||||
EFFECT_FLY_EXPLOSION = 3,
|
||||
EFFECT_BLOOD_SPLAT = 7,
|
||||
EFFECT_POOF01 = 15,
|
||||
EFFECT_POOF02 = 16,
|
||||
EFFECT_TARGET = 19,
|
||||
EFFECT_HEART = 49,
|
||||
EFFECT_PLAYER_CREEP_GREEN = 53,
|
||||
EFFECT_WATER_RIPPLE = 99
|
||||
};
|
||||
|
||||
constexpr int ENTITY_KEY_TEAR_A = 43;
|
||||
constexpr int ENTITY_KEY_TEAR_B = 44;
|
||||
constexpr int PICKUP_COIN = 20;
|
||||
constexpr int COIN_PENNY = 1;
|
||||
|
||||
// The items and seeds whose effects the NPC update reads, by Lua id.
|
||||
constexpr int COLLECTIBLE_HOURGLASS_ID = 66;
|
||||
@@ -421,7 +365,7 @@ Entity* game_nearest_target_player(const Vector& position, Entity* source, bool
|
||||
{
|
||||
for (Entity* decoy : g_game->room->entityList.mainEL)
|
||||
{
|
||||
if (decoy->type != ENTITY_FAMILIAR || decoy->variant != FAMILIAR_PUNCHING_BAG) continue;
|
||||
if (decoy->type != ENTITY_FAMILIAR || decoy->variant != Entity_Familiar::PUNCHING_BAG) continue;
|
||||
float distance = vector_length_squared(vector_sub(decoy->pos, position));
|
||||
if (distance >= best) continue;
|
||||
best = distance;
|
||||
@@ -488,11 +432,12 @@ static int line_cell_collision(Room& room, int column, int row)
|
||||
}
|
||||
|
||||
// 007f0df0 Whether a line from start to end is clear, walked in steps of 10: mode 0 checks a 10 wide band for grid
|
||||
// collision and for more than 8 cells walked past their grid path threshold, mode 3 the same band for shots (which
|
||||
// fly over pits). The other modes, crushable rocks and the stop position are left to come.
|
||||
// collision and for more than 8 cells walked past their grid path threshold, mode 1 the same on the line's own cells,
|
||||
// mode 3 the band for shots (which fly over pits). The other modes, crushable rocks and the stop position are left
|
||||
// to come.
|
||||
bool room_check_line(const Vector& start, const Vector& end, int mode, int gridPathThreshold)
|
||||
{
|
||||
if (mode != LINE_MODE_GROUND && mode != LINE_MODE_PROJECTILE)
|
||||
if (mode != LINE_MODE_GROUND && mode != LINE_MODE_CELL && mode != LINE_MODE_PROJECTILE)
|
||||
reconstruction_missing("Room::CheckLine 007f0df0: the single cell modes");
|
||||
|
||||
Room& room = *g_game->room;
|
||||
@@ -515,6 +460,16 @@ bool room_check_line(const Vector& start, const Vector& end, int mode, int gridP
|
||||
for (float walked = 0; walked < length; walked += LINE_STEP)
|
||||
{
|
||||
at = vector_sub(at, step);
|
||||
if (mode == LINE_MODE_CELL)
|
||||
{
|
||||
int column = cellOf(at.x, GRID_CELL);
|
||||
int row = cellOf(at.y, GRID_TOP);
|
||||
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
|
||||
int cellIndex = isInside ? row * room.gridWidth + column : -1;
|
||||
if (room.GetGridCollision(cellIndex) != COLLISION_NONE) return false;
|
||||
if (cellIndex != startIndex && cellIndex >= 0 && room.GetGridPath(cellIndex) > gridPathThreshold) blocked++;
|
||||
continue;
|
||||
}
|
||||
for (const LineCorner& corner : LINE_CORNERS)
|
||||
{
|
||||
int column = cellOf(at.x + corner.x, GRID_CELL);
|
||||
@@ -611,7 +566,7 @@ void Entity_NPC::Init(int entityType, int entityVariant, int entitySubType, uint
|
||||
hitList.clear();
|
||||
secondaryHitList.clear();
|
||||
pathfinder.Reset();
|
||||
if (isBoss) reconstruction_missing("Entity_NPC::Init 006b8b20: the room's boss count (Room+0x7224)");
|
||||
if (isBoss) g_game->room->bossesRemaining++;
|
||||
totalDamageTaken = 0;
|
||||
lua_engine_get().PostNPCInit(this);
|
||||
}
|
||||
@@ -646,12 +601,12 @@ void Entity_NPC::boss_color_roll()
|
||||
RoomDescriptor* descriptor = game.room->descriptor;
|
||||
RNG rng = {descriptor ? descriptor->spawnSeed : 0, 1, 11, 16};
|
||||
if (rng.RandomFloat() < boss_color_chance_get()) subtype = (int)rng.RandomInt(colors) + 1;
|
||||
if (config->id == ENTITY_MONSTRO && subtype == 2 && game.challenge == CHALLENGE_BEANS) subtype = 0;
|
||||
if (config->id == ENTITY_MOM && subtype == 2 && game.challenge == CHALLENGE_BEANS) subtype = 0;
|
||||
}
|
||||
if (game.stageType == STAGETYPE_REPENTANCE || game.stageType == STAGETYPE_REPENTANCE_B)
|
||||
{
|
||||
if (config->id == ENTITY_MONSTRO) subtype = 3;
|
||||
else if (config->id == ENTITY_GURDY_JR) subtype = 1;
|
||||
if (config->id == ENTITY_MOM) subtype = 3;
|
||||
else if (config->id == ENTITY_MOMS_HEART) subtype = 1;
|
||||
}
|
||||
if (subtype == 0 || subtype > colors) return;
|
||||
|
||||
@@ -805,11 +760,11 @@ void Entity_NPC::UpdateDirtColor(bool isImmediate)
|
||||
{
|
||||
if (isImmediate || IsFrame(DIRT_SAMPLE_FRAMES, (int)index))
|
||||
{
|
||||
if (!isChampion || championColorIdx != CHAMPION_GREEN)
|
||||
reconstruction_missing("Entity_NPC::UpdateDirtColor 006c04b0: Room::GetFloorColorAt");
|
||||
dirtColor._tint[0] = 0;
|
||||
dirtColor._tint[1] = DIRT_GREEN;
|
||||
dirtColor._tint[2] = 0;
|
||||
KColor floor = kcolor_rgba(0, DIRT_GREEN / 2, 0, 1);
|
||||
if (!isChampion || championColorIdx != CHAMPION_GREEN) floor = room_floor_color_get(*g_game->room, pos, size);
|
||||
dirtColor._tint[0] = floor._red * 2;
|
||||
dirtColor._tint[1] = floor._green * 2;
|
||||
dirtColor._tint[2] = floor._blue * 2;
|
||||
dirtColor._tint[3] = 1;
|
||||
}
|
||||
|
||||
@@ -927,13 +882,11 @@ constexpr int CHAMPION_FLICKER_RANGE = 30;
|
||||
constexpr int CHAMPION_SHOT_MIN = 40;
|
||||
constexpr int CHAMPION_SHOT_RANGE = 20;
|
||||
constexpr int EFFECT_PULLING = 57;
|
||||
constexpr int EFFECT_CREEP_GREEN = 23;
|
||||
constexpr int CHAMPION_CREEP_FRAMES = 7;
|
||||
constexpr int CHAMPION_CREEP_TIMEOUT = 30;
|
||||
constexpr float CHAMPION_SHOT_SPEED = 5;
|
||||
constexpr float CHAMPION_SHOT_FALL_ACCEL = 0.3f;
|
||||
constexpr float CHAMPION_SHOT_FALL_SPEED = -5;
|
||||
constexpr int SOUND_BLOODSHOOT = 178;
|
||||
constexpr float FLICKER_FADE = 0.05f;
|
||||
constexpr ColorMod FRIENDLY_COLOR = {{0.8f, 0.8f, 0.8f, 1}, {1, 1, 1, -0.5f}, {0.1f, 0.1f, 0.1f}};
|
||||
constexpr ColorMod FROZEN_COLOR = {{0.8f, 0.8f, 0.8f, 1}, {1, 1, 1, 0.5f}, {0.3f, 0.5f, 0.8f}};
|
||||
@@ -953,7 +906,7 @@ constexpr ColorMod PULLING_RED_COLOR = {{1, 0.2f, 0.2f, 1}, {0, 0, 0, 0}, {0, 0,
|
||||
|
||||
// 00505b80 The color a champion shows over a sprite without its sheets: its sheet color laid over its sprite color
|
||||
// (Color::__mul), or the sprite color for a look drawn on no sheet.
|
||||
static ColorMod champion_sprite_color_get(int championColor)
|
||||
ColorMod champion_sprite_color_get(int championColor)
|
||||
{
|
||||
const ChampionLook& look = CHAMPION_LOOKS[championColor];
|
||||
if (look.sheetColor._tint[3] <= 0) return look.spriteColor;
|
||||
@@ -1519,8 +1472,7 @@ void Entity_NPC::death_animation_update()
|
||||
if (std::ranges::find(DEATH_EVENT_TYPES, type) != DEATH_EVENT_TYPES.end())
|
||||
reconstruction_missing("Entity_NPC::Update 006c4b30: a boss's death animation events");
|
||||
|
||||
if (sprite.GetNullFrame("BloodGuide"))
|
||||
reconstruction_missing("Entity_NPC::Update 006c4b30: the blood guided gibs of a death animation");
|
||||
if (const NullFrame* bloodGuide = sprite.GetNullFrame("BloodGuide")) npc_blood_guide_update(*this, *bloodGuide);
|
||||
if (type == ENTITY_HUSH && sprite.IsEventTriggered("ash"))
|
||||
reconstruction_missing("Entity_NPC::Update 006c4b30: the ash a boss leaves");
|
||||
if (sprite.IsFinished() && isExists) trigger_kill_item_effects();
|
||||
@@ -1566,7 +1518,7 @@ void Entity_NPC::decoy_update()
|
||||
else if (decoyTargetTimer < -DECOY_TIMER_MAX) decoyTargetTimer = 0;
|
||||
|
||||
Entity* playerTarget = GetPlayerTarget();
|
||||
if (playerTarget->type == ENTITY_FAMILIAR && playerTarget->variant == FAMILIAR_PUNCHING_BAG) decoyTargetTimer++;
|
||||
if (playerTarget->type == ENTITY_FAMILIAR && playerTarget->variant == Entity_Familiar::PUNCHING_BAG) decoyTargetTimer++;
|
||||
else if (decoyTargetTimer != 0) decoyTargetTimer--;
|
||||
}
|
||||
|
||||
@@ -1821,7 +1773,7 @@ void Entity_NPC::ripple_spawn()
|
||||
if (!g_game->room->HasWater() || !IsFrame(RIPPLE_FRAMES, (int)index) || entityCollisionClass == ENTCOLL_NONE)
|
||||
return;
|
||||
|
||||
Entity* ripple = spawn_at(ENTITY_EFFECT, EFFECT_WATER_RIPPLE, 0, vector_add(pos, velocity), this);
|
||||
Entity* ripple = spawn_at(ENTITY_EFFECT, EFFECT_WATER_SPLASH, 0, vector_add(pos, velocity), this);
|
||||
float rippleScale = size * RIPPLE_SCALE * scale;
|
||||
ripple->sprite.scale = vector_make(rippleScale, rippleScale);
|
||||
ripple->renderDepthOffset = RIPPLE_DEPTH;
|
||||
@@ -2011,109 +1963,6 @@ float Entity_NPC::compute_speed_multiplier()
|
||||
return speed;
|
||||
}
|
||||
|
||||
// The NPC types whose collisions the generic rules below do not cover: bosses, segmented and special enemies.
|
||||
constexpr std::array<int, 82> COLLISION_SPECIAL_TYPES = {
|
||||
17, 19, 21, 23, 25, 28, 29, 30, 31, 32, 33, 35, 36, 39, 40, 41, 44, 55, 61, 62, 63,
|
||||
66, 89, 99, 206, 207, 212, 213, 216, 218, 222, 237, 239, 243, 245, 251, 256, 260, 261, 265, 274, 281,
|
||||
289, 291, 292, 293, 295, 296, 308, 401, 402, 404, 406, 407, 410, 412, 802, 808, 810, 815, 818, 819, 822,
|
||||
853, 866, 868, 873, 877, 878, 881, 889, 893, 903, 909, 910, 912, 915, 918, 919, 951, 964, 965};
|
||||
constexpr std::array<int, 18> COLLISION_SPECIAL_COLLIDERS = {21, 23, 28, 31, 35, 40, 55, 62, 89,
|
||||
212, 218, 239, 243, 260, 274, 281, 293, 918};
|
||||
constexpr int ENTITY_COLLISION_IGNORED = 291;
|
||||
constexpr float SPAWN_GRACE_FRAMES = 10;
|
||||
|
||||
// 006cd410 What it does on touching another entity, and whether that contact is ignored: it hurts a player it
|
||||
// touches (but for Skatole's flies and Bursting Sack's spiders), a shrunk enemy is squished, its friends and
|
||||
// shots pass, and enemies just spawned in a challenge or ambush do not touch yet.
|
||||
bool Entity_NPC::HandleCollision(Entity* collider, bool isLow)
|
||||
{
|
||||
LuaResult lua = static_cast<LuaEngine*>(g_luaEngine)->PreNPCCollision(this, collider, isLow);
|
||||
if (lua == LUA_RESULT_TRUE) return true;
|
||||
if (lua == LUA_RESULT_FALSE) return false;
|
||||
|
||||
bool isSpecial =
|
||||
std::ranges::find(COLLISION_SPECIAL_TYPES, type) != COLLISION_SPECIAL_TYPES.end() ||
|
||||
std::ranges::find(COLLISION_SPECIAL_COLLIDERS, collider->type) != COLLISION_SPECIAL_COLLIDERS.end() ||
|
||||
minecart || spawnerType == ENTITY_COLLISION_SPAWNER_SPECIAL;
|
||||
if (isSpecial) reconstruction_missing("Entity_NPC::HandleCollision 006cd410: a special enemy's contact");
|
||||
|
||||
bool isIgnored = true;
|
||||
bool isMagnetized = HasEntityFlags(FLAG_MAGNETIZED) || collider->HasEntityFlags(FLAG_MAGNETIZED);
|
||||
if (Entity::is_enemy_type(collider->type) && isMagnetized &&
|
||||
collider->GetStatusEffectTarget() != GetStatusEffectTarget())
|
||||
isIgnored = false;
|
||||
|
||||
if (aiCallFlags & AI_CALL_COLLISION)
|
||||
{
|
||||
collisionEntity = collider;
|
||||
isCollisionIsLow = isLow;
|
||||
collisionResult = -1;
|
||||
ai_call(AI_PHASE_COLLISION);
|
||||
if (collisionResult > 0) return false;
|
||||
if (collisionResult == 0) return isIgnored;
|
||||
}
|
||||
|
||||
if (HasEntityFlags(FLAG_SHRINK) && collider->type == ENTITY_PLAYER && !IsBoss())
|
||||
{
|
||||
Kill(EntityRef());
|
||||
return isIgnored;
|
||||
}
|
||||
if (IsFriendly() && IsDamageSourceFriendly(EntityRef(collider)))
|
||||
{
|
||||
if (collider->type == ENTITY_PLAYER || collider->type == ENTITY_FAMILIAR) return isIgnored;
|
||||
if (collider->IsEnemy() && collider->IsFriendly()) return isIgnored;
|
||||
}
|
||||
if (!isLow && collider->type == ENTITY_PROJECTILE) return isIgnored;
|
||||
|
||||
Room& room = *g_game->room;
|
||||
bool isGraceRoom = room.roomType == ROOM_CHALLENGE || room.roomType == ROOM_BOSSRUSH ||
|
||||
(g_game->IsGreedMode() && room.roomType == ROOM_DEFAULT) || HasEntityFlags(FLAG_AMBUSH);
|
||||
if (isGraceRoom && (state == NPC_STATE_APPEAR || g_game->frameCount - spawnFrame < SPAWN_GRACE_FRAMES))
|
||||
return isIgnored;
|
||||
if (collider->type == ENTITY_COLLISION_IGNORED) return isIgnored;
|
||||
|
||||
if (!isLow)
|
||||
{
|
||||
if (collider->type == ENTITY_PLAYER) player_contact(*static_cast<Entity_Player*>(collider));
|
||||
else if (collider->type == ENTITY_FAMILIAR)
|
||||
reconstruction_missing("Entity_NPC::HandleCollision 006cd410: an enemy hurting a familiar");
|
||||
}
|
||||
enemy_contact(*collider);
|
||||
if (HasEntityFlags(FLAG_KNOCKED_BACK) && vector_length(knockbackDirection) > KNOCKBACK_IMPACT_SPEED)
|
||||
reconstruction_missing("Entity_NPC::HandleCollision 006cd410: a knocked back enemy's impact");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Part of 006cd410: touching a player hurts it by the collision damage, unless Skatole spares flies or Bursting
|
||||
// Sack spiders. E. Coli turns the enemy to poop and a kill-on-touch enemy dies.
|
||||
void Entity_NPC::player_contact(Entity_Player& player)
|
||||
{
|
||||
PlayerManager& players = g_game->playerManager;
|
||||
bool isSpared = ((config->tags & ENTITY_TAG_FLY) && players.AnyoneHasCollectible(COLLECTIBLE_SKATOLE_ID)) ||
|
||||
((config->tags & ENTITY_TAG_SPIDER) && players.AnyoneHasCollectible(COLLECTIBLE_BURSTING_SACK_ID));
|
||||
if (!isSpared && collisionDamage > 0)
|
||||
{
|
||||
bool isHurt = player.TakeDamage(collisionDamage, 0, EntityRef(this), 0);
|
||||
if (isHurt && isChampion && championColorIdx == CHAMPION_ORANGE && player.numCoins > 0)
|
||||
reconstruction_missing("Entity_NPC::HandleCollision 006cd410: the orange champion's stolen coins");
|
||||
}
|
||||
if (player.HasCollectible(COLLECTIBLE_E_COLI_ID))
|
||||
reconstruction_missing("Entity_NPC::HandleCollision 006cd410: E. Coli's poop");
|
||||
if (isKillOnTouch) Kill(EntityRef());
|
||||
}
|
||||
|
||||
// Part of 006cd410: an active enemy meets another: a charmed one (or one targeting it) bumps it for damage once per
|
||||
// hit list.
|
||||
void Entity_NPC::enemy_contact(Entity& other)
|
||||
{
|
||||
if (!other.IsEnemy() || !IsActiveEnemy(DEAD_EXCLUDED) || !other.IsActiveEnemy(DEAD_EXCLUDED)) return;
|
||||
|
||||
bool isSameSide = HasEntityFlags(FLAG_CHARM) == other.HasEntityFlags(FLAG_CHARM);
|
||||
bool isTargeted = target.get() == &other || forcedTarget.get() == &other;
|
||||
if ((isSameSide && !isTargeted) || collisionDamage <= 0 || EntityList::HitListContains(hitList, other)) return;
|
||||
reconstruction_missing("Entity_NPC::HandleCollision 006cd410: a charmed enemy hurting another");
|
||||
}
|
||||
|
||||
// 006d60a0 Takes a hit as any entity (Entity::TakeDamage) and lets the items that react to it act: a player's hit
|
||||
// ends Pacifist, Betrayal turns it on its attacker, the pulsing champion spawns its flies, and a hit taken spawns
|
||||
// a blue fly for a hit that spawns one, marks a player's kill for Jar of Flies, and triggers the attacker's
|
||||
@@ -2130,7 +1979,7 @@ bool Entity_NPC::TakeDamage(float damage, uint64_t damageFlags, const EntityRef&
|
||||
reconstruction_missing("Entity_NPC::TakeDamage 006d60a0: Betrayal");
|
||||
if (players.FirstCollectibleOwner(COLLECTIBLE_JAR_OF_FLIES_ID, LAZARUS_SHARE_CHECK))
|
||||
{
|
||||
bool isBlueFly = source.type == ENTITY_FAMILIAR && source.variant == FAMILIAR_BLUE_FLY;
|
||||
bool isBlueFly = source.type == ENTITY_FAMILIAR && source.variant == Entity_Familiar::BLUE_FLY;
|
||||
bool isPlayerKill = source.type == ENTITY_PLAYER || (source.spawnerType == ENTITY_PLAYER && !isBlueFly) ||
|
||||
(damageFlags & ((uint64_t)DAMAGE_ACID | DAMAGE_POISON_BURN)) ||
|
||||
source.type == ENTITY_EFFECT;
|
||||
@@ -2362,7 +2211,7 @@ bool Entity_NPC::IsTargetInAttackRange(float range, int frameInterval, bool isPr
|
||||
isPredictVelocity ? vector_add(other->pos, vector_scale(other->velocity, ATTACK_PREDICT_FRAMES)) : other->pos;
|
||||
if (frameInterval != 0 && !IsFrame(frameInterval, (int)index)) return false;
|
||||
if (vector_length_squared(vector_sub(aim, pos)) >= range * range) return false;
|
||||
return room_check_line(pos, other->pos, LINE_CHECK_PROJECTILE, LINE_CHECK_THRESHOLD) ||
|
||||
return room_check_line(pos, other->pos, LINE_MODE_PROJECTILE, LINE_CHECK_THRESHOLD) ||
|
||||
championColorIdx == CHAMPION_TRANSPARENT;
|
||||
}
|
||||
|
||||
@@ -2551,15 +2400,13 @@ void Entity_NPC::projectile_params_apply(Entity_Projectile& projectile, const Pr
|
||||
projectile.renderDepthOffset = params.depthOffset - params.positionOffset.y;
|
||||
if (projectile.height < PROJECTILE_HEIGHT_LOW && !(projectile.projectileFlags & PROJECTILE_ANY_HEIGHT_ENTITY_HIT))
|
||||
projectile.entityCollisionClass = ENTCOLL_NONE;
|
||||
if (params.unknownA0 != 0)
|
||||
reconstruction_missing("Entity_NPC::FireProjectiles 006cb2e0: the projectile field at 0x470");
|
||||
projectile.motionHook = params.motionHook;
|
||||
}
|
||||
|
||||
// 006cb2a0 Hands a fired shot its shooter's champion color, scale and flags (Entity_Projectile::apply_spawn_flags).
|
||||
void Entity_NPC::fire_projectile_from_params(Entity_Projectile*)
|
||||
void Entity_NPC::fire_projectile_from_params(Entity_Projectile* projectile)
|
||||
{
|
||||
reconstruction_missing(
|
||||
"Entity_NPC::fire_projectile_from_params 006cb2a0: Entity_Projectile::apply_spawn_flags 006cb010");
|
||||
projectile->apply_spawn_flags({this, flags, scale, isChampion ? championColorIdx : -1});
|
||||
}
|
||||
|
||||
// The NPC types with their own interpolation or drawing, which the generic steps below do not cover.
|
||||
@@ -2715,8 +2562,8 @@ void Entity_NPC::update_damage_history()
|
||||
// rewards (sticky spiders, black hearts), Jar of Flies' count, its removal, the on-kill items and its record.
|
||||
void Entity_NPC::trigger_kill_item_effects()
|
||||
{
|
||||
if (isBoss) reconstruction_missing("Entity_NPC::trigger_kill_item_effects 006d5400: Room::TriggerBossDeath");
|
||||
if (isChampion) reconstruction_missing("Entity_NPC::trigger_kill_item_effects 006d5400: NpcHelper::ChampionDrop");
|
||||
if (isBoss) g_game->room->TriggerBossDeath(*this);
|
||||
else if (isChampion) reconstruction_missing("Entity_NPC::trigger_kill_item_effects 006d5400: NpcHelper::ChampionDrop");
|
||||
if (type == ENTITY_ROTGUT && variant == 1)
|
||||
reconstruction_missing("Entity_NPC::trigger_kill_item_effects 006d5400: Rotgut's death");
|
||||
if (HasEntityFlags(FLAG_SPAWN_STICKY_SPIDERS))
|
||||
@@ -2991,12 +2838,6 @@ void Entity_NPC::KillUnique()
|
||||
reconstruction_missing("Entity_NPC::KillUnique 006be760");
|
||||
}
|
||||
|
||||
// 006c1ac0
|
||||
void* Entity_NPC::shopkeeper_get_loot(void*, bool)
|
||||
{
|
||||
reconstruction_missing("Entity_NPC::shopkeeper_get_loot 006c1ac0");
|
||||
}
|
||||
|
||||
// 006c2750
|
||||
Entity_NPC* Entity_NPC::ThrowSpider(const Vector&, Entity*, Vector, bool, float)
|
||||
{
|
||||
@@ -3039,12 +2880,6 @@ bool Entity_NPC::CanReroll()
|
||||
reconstruction_missing("Entity_NPC::CanReroll 006d4db0");
|
||||
}
|
||||
|
||||
// 006d7520
|
||||
void Entity_NPC::update_blood_guide_gibs(float*)
|
||||
{
|
||||
reconstruction_missing("Entity_NPC::update_blood_guide_gibs 006d7520");
|
||||
}
|
||||
|
||||
// 006d88b0
|
||||
void Entity_NPC::TransferControl(Entity_NPC*)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user