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:
shweet committed 2026-11-22 11:00:43 -05:00
1 parent 8dbeb1bc4a
commit 6a11163842
184 files changed
+16980 -1419

No files matched your search

+166
View File
@@ -490,6 +490,171 @@ static EffectUpdateEnd fissure_spawner_update(Entity_Effect& spawner)
return EFFECT_UPDATE_FINISH;
}
// A smoke cloud: green poison gas, or (subtype 1) a poop spell's flammable gas, pulsing purple, that a fire or an
// explosion sets off. It fades in and out by a thirtieth a frame, its last 30 frames fading. An enemy's cloud lasts
// 60 more frames once its room is clear (or it dies), and while its parent lives it never runs out.
constexpr int SMOKE_FLAMMABLE = 1;
constexpr int SMOKE_FADE_FRAMES = 30;
constexpr int SMOKE_LINGER_FRAMES = 60;
constexpr int SMOKE_ENEMY_SPAWNERS = 10;
constexpr float SMOKE_SCALE_MIN = 1;
constexpr float SMOKE_SCALE_SPAN = 0.4f;
constexpr float SMOKE_HEIGHT = -20;
constexpr float SMOKE_BEAST_LAYER_ALPHA = 0.5f;
// The flammable gas pulses every 6 frames, catches within 60 of its scale from a fire every other frame while
// thicker than a quarter, and goes up in a 15 damage explosion.
constexpr int SMOKE_PULSE_FRAMES = 6;
constexpr float SMOKE_PULSE_RED = 1.6f;
constexpr float SMOKE_PULSE_GREEN = 0.3f;
constexpr float SMOKE_PULSE_BLUE = 1.8f;
constexpr float SMOKE_CATCH_ALPHA = 0.25f;
constexpr int SMOKE_CATCH_PERIOD = 2;
constexpr float SMOKE_CATCH_REACH = 60;
constexpr float SMOKE_BLAST_DAMAGE = 15;
constexpr ColorMod SMOKE_BLAST_COLOR = color_make({1, 1, 1, 1}, {1, 1, 0, 0.5f});
// The poison gas hurts within 40 of its scale while thicker than a half (a friendly cloud a fifth): an enemy's
// cloud the players, a friendly one (a player's) the enemies every 10 frames, poisoning them for 60 frames at 3.5.
// An enemy already hit by a cloud this frame only takes the stronger of the two hits.
constexpr float SMOKE_HURT_REACH = 40;
constexpr float SMOKE_HURT_ALPHA = 0.5f;
constexpr float SMOKE_FRIENDLY_HURT_ALPHA = 0.2f;
constexpr float SMOKE_HURT_PERIOD = 10;
constexpr int SMOKE_HURT_COUNTDOWN = 30;
constexpr int SMOKE_POISON_FRAMES = 60;
constexpr float SMOKE_POISON_DAMAGE = 3.5f;
constexpr float SMOKE_FRICTION_START = 0.8f;
constexpr float SMOKE_FRICTION_GROWTH = 0.01f;
constexpr float SMOKE_FRICTION_MAX = 0.9f;
// The fires that set the flammable gas off: an explosion, a hot bomb's, a blue or a red candle's flame.
constexpr std::array<int, 4> SMOKE_IGNITING_EFFECTS = {EFFECT_BOMB_EXPLOSION, EFFECT_HOT_BOMB_FIRE, EFFECT_BLUE_FLAME,
EFFECT_RED_CANDLE_FLAME};
// The smoke cloud part of 005cdb20 (Init): the gas tinted by its kind (deeper in the Beast's dungeon), invisible,
// raised 20 and sized 1 to 1.4, mirrored and started on a frame at random.
static void smoke_cloud_init(Entity_Effect& cloud)
{
if (cloud.subtype == SMOKE_FLAMMABLE) cloud.sprite.color = color_make({1, 0.6f, 0.5f, 1}, {}, {0.2f, 0.2f, 0});
else if (g_game->room->IsBeastDungeon())
{
cloud.sprite.color = color_make({0.9f, 1.8f, 0.5f, 1}, {}, {0, 0.3f, 0});
cloud.sprite.GetLayer(0)->color._tint[3] = SMOKE_BEAST_LAYER_ALPHA;
}
else cloud.sprite.color = color_make({0.6f, 1, 0.5f, 1}, {}, {0, 0.2f, 0});
cloud.sprite.color._tint[3] = 0;
float scale = cloud.dropRNG.RandomFloat() * SMOKE_SCALE_SPAN + SMOKE_SCALE_MIN;
cloud.sprite.scale = vector_make(scale, scale);
cloud.sprite.offset = vector_make(0, SMOKE_HEIGHT);
cloud.sprite.isFlipX = cloud.dropRNG.RandomInt(2) != 0;
cloud.sprite.Play("Idle");
cloud.sprite.SetFrame((float)cloud.dropRNG.RandomInt(cloud.sprite.animState.GetAnimationLength()));
}
// Whether an entity sets the flammable gas off: a fire effect not yet spent, a burning fireplace or a fire shot.
static bool is_smoke_igniter(Entity& entity)
{
if (entity.type == ENTITY_EFFECT && std::ranges::count(SMOKE_IGNITING_EFFECTS, entity.variant) &&
!entity.HasEntityFlags(FLAG_NO_BLOOD_SPLASH))
return true;
if (entity.type == ENTITY_FIREPLACE && entity.entityCollisionClass != ENTCOLL_NONE) return true;
return entity.type == ENTITY_PROJECTILE && entity.variant == PROJECTILE_FIRE;
}
// The flammable gas pulses, and blows up the frame after a fire (an explosion by its blast's scale) touches it.
static EffectUpdateEnd smoke_flammable_update(Entity_Effect& cloud)
{
float pulse = std::sin((float)(g_game->frameCount % SMOKE_PULSE_FRAMES) * 2 * PI_F / SMOKE_PULSE_FRAMES) * 0.5f + 0.5f;
ColorMod& color = cloud.sprite.color;
color._colorize[0] = SMOKE_PULSE_RED;
color._colorize[1] = SMOKE_PULSE_GREEN;
color._colorize[2] = SMOKE_PULSE_BLUE;
color._colorize[3] = pulse * 0.5f;
if (cloud.state == 1)
{
explosion_effects({.color = SMOKE_BLAST_COLOR, .position = cloud.pos, .source = &cloud, .damage = SMOKE_BLAST_DAMAGE});
cloud.Remove();
return EFFECT_UPDATE_RETURN;
}
if (color._tint[3] <= SMOKE_CATCH_ALPHA || !cloud.IsFrame(SMOKE_CATCH_PERIOD, 0)) return EFFECT_UPDATE_FINISH;
float reach = cloud.sprite.scale.x * SMOKE_CATCH_REACH;
for (Entity* entity : g_game->room->entityList.updateEL)
{
if (!is_smoke_igniter(*entity)) continue;
float fire = entity->size;
if (entity->type == ENTITY_EFFECT && entity->variant == EFFECT_BOMB_EXPLOSION)
fire = entity->sprite.scale.x * SMOKE_CATCH_REACH;
Vector offset = vector_sub(entity->pos, cloud.pos);
if (offset.x * offset.x + offset.y * offset.y >= (reach + fire) * (reach + fire)) continue;
cloud.state = 1;
break;
}
return EFFECT_UPDATE_FINISH;
}
// Raises an enemy's pending hit from another smoke cloud to this cloud's damage, or says there is none.
static bool is_smoke_hit_raised(Entity& enemy, float damage, int variant)
{
for (DamageEvent& event : enemy.damageEvents)
{
if (event.source.type != ENTITY_EFFECT || event.source.variant != variant) continue;
event.damage = std::max(event.damage, damage);
return true;
}
return false;
}
// The poison gas hurts the players (an enemy's) or the enemies but its spawner (a friendly one) inside it.
static void smoke_poison_update(Entity_Effect& cloud)
{
bool isFriendly = cloud.HasEntityFlags(FLAG_FRIENDLY) || cloud.spawnerType == ENTITY_PLAYER;
float alpha = cloud.sprite.color._tint[3];
if (alpha <= SMOKE_HURT_ALPHA && (!isFriendly || alpha <= SMOKE_FRIENDLY_HURT_ALPHA)) return;
float reach = cloud.sprite.scale.x * SMOKE_HURT_REACH;
for (Entity* entity : entity_query_radius(cloud.pos, reach, QUERY_ENEMIES | QUERY_PLAYERS))
{
if (entity->is_player() && !isFriendly)
{
Vector offset = vector_sub(entity->pos, cloud.pos);
if (offset.x * offset.x + offset.y * offset.y < reach * reach && entity->entityCollisionClass != ENTCOLL_NONE)
entity->TakeDamage(0, DAMAGE_POISON_BURN, EntityRef(&cloud), SMOKE_HURT_COUNTDOWN);
continue;
}
if (!entity->IsVulnerableEnemy(nullptr) || !isFriendly || entity == cloud.spawnerEntity) continue;
if (!entity->GetIntervalTicks(SMOKE_HURT_PERIOD, 0)) continue;
if (is_smoke_hit_raised(*entity, cloud.collisionDamage, cloud.variant)) continue;
entity->TakeDamage(cloud.collisionDamage, 0, EntityRef(&cloud), SMOKE_HURT_COUNTDOWN);
entity->AddPoison(EntityRef(&cloud), SMOKE_POISON_FRAMES, SMOKE_POISON_DAMAGE, false);
}
}
// 005d6910 (Update's case 141) Lingers, fades, then sets off (flammable) or hurts (poison), slowing as it ages.
static EffectUpdateEnd smoke_cloud_update(Entity_Effect& cloud)
{
Room& room = *g_game->room;
if ((cloud.timeout > SMOKE_LINGER_FRAMES || cloud.timeout < 0) && cloud.spawnerType >= SMOKE_ENEMY_SPAWNERS &&
((room.IsClear() && room.GetAliveEnemiesCount() <= 0) || cloud.isDead))
cloud.timeout = SMOKE_LINGER_FRAMES;
if (cloud.timeout < SMOKE_LINGER_FRAMES && cloud.parent && !cloud.parent->isDead) cloud.timeout = SMOKE_LINGER_FRAMES;
if (cloud.timeout == 0 && cloud.isDead) cloud.Remove();
float& alpha = cloud.sprite.color._tint[3];
if (cloud.timeout >= 0 && cloud.timeout < SMOKE_FADE_FRAMES) alpha = std::max(alpha - 1.0f / SMOKE_FADE_FRAMES, 0.0f);
else alpha = std::min(alpha + 1.0f / SMOKE_FADE_FRAMES, 1.0f);
if (cloud.subtype == SMOKE_FLAMMABLE)
{
if (smoke_flammable_update(cloud) == EFFECT_UPDATE_RETURN) return EFFECT_UPDATE_RETURN;
}
else smoke_poison_update(cloud);
cloud.friction *= std::min((float)cloud.FrameCount() * SMOKE_FRICTION_GROWTH + SMOKE_FRICTION_START, SMOKE_FRICTION_MAX);
return EFFECT_UPDATE_FINISH;
}
constexpr auto HAZARD_BEHAVIOURS = std::to_array<EffectBehaviour>({
{EFFECT_DEVIL, nullptr, effect_finishing<statue_update>, nullptr},
{EFFECT_ANGEL, nullptr, effect_finishing<statue_update>, nullptr},
@@ -500,6 +665,7 @@ constexpr auto HAZARD_BEHAVIOURS = std::to_array<EffectBehaviour>({
{EFFECT_SHOCKWAVE_RANDOM, shockwave_random_init, effect_finishing<shockwave_random_update>, nullptr},
{EFFECT_HALLOWED_GROUND, hallowed_ground_init, hallowed_ground_update, nullptr},
{EFFECT_FISSURE_SPAWNER, fissure_spawner_init, fissure_spawner_update, nullptr},
{EFFECT_SMOKE_CLOUD, smoke_cloud_init, smoke_cloud_update, nullptr},
});
std::span<const EffectBehaviour> hazard_effect_behaviours()