#include "backdrop.h" #include "capsule.h" #include "entity_effect.h" #include "fx_layers.h" #include "entity_player.h" #include "game.h" #include "npc_ai.h" #include "npc_basement.h" #include "room.h" #include "room_grid.h" #include "sfx_manager.h" #include #include #include // The floor effects: splashes and ripples on the room's water, the tar's bubbles, the dirt piles and patches // shovels and diggers leave, and the haemolacria trail's drops. // A water splash: subtype 0 splashes where it lands, any other is a drop thrown up that falls back. constexpr float SPLASH_ALPHA_MIN = 0.05f; constexpr float SPLASH_ALPHA_SPAN = 0.15f; constexpr float SPLASH_SCALE_MIN = 0.5f; constexpr float SPLASH_SCALE_SPAN = 0.2f; constexpr float SPLASH_VOLUME_MIN = 0.5f; constexpr float SPLASH_VOLUME_SPAN = 0.5f; constexpr float SPLASH_PITCH_MIN = 1; constexpr float SPLASH_PITCH_SPAN = 2; constexpr float SPLASH_FRICTION = 0.9f; constexpr float SPLASH_DROP_GRAVITY = 0.5f; constexpr float SPLASH_DROP_HEIGHT = -10; constexpr float SPLASH_DROP_RISE_MIN = -1; constexpr float SPLASH_DROP_RISE_SPAN = 2; constexpr float SPLASH_DROP_SCALE_MIN = 0.5f; constexpr float SPLASH_DROP_SCALE_SPAN = 0.5f; constexpr float SPLASH_DROP_ALPHA_MIN = 0.1f; constexpr float SPLASH_DROP_ALPHA_SPAN = 0.3f; constexpr float SPLASH_DROP_DRAG = 0.9f; constexpr float SPLASH_DROP_PULL = 0.1f; constexpr float SPLASH_DROP_LANDED_HEIGHT = -5; // The big splash's subtypes 1 and 2 do not move with the game's time. constexpr int BIG_SPLASH_STATIC_FIRST = 1; constexpr int BIG_SPLASH_STATIC_LAST = 2; // The haemolacria trail's drops jitter by up to 2 units a frame. constexpr float HAEMO_JITTER = 2; // A tar bubble plays one of three bubbles. constexpr std::array BUBBLE_ANIMATIONS = {"Bubble1", "Bubble2", "Bubble3"}; // A dirt pile lasts 30 frames and takes the floor's color, brightened, unless its subtype says otherwise. constexpr int DIRT_PILE_FRAMES = 30; constexpr int DIRT_PILE_PLAIN = 0; constexpr float DIRT_PILE_BRIGHTEN = 2; // A dirt patch: idle while buried (state 0), dug up (1) or dug up with bones (2). Digging it raises 2 to 4 dust // clouds and 3 to 6 rocks, and the bones raise a lost soul. enum DirtPatchState : int { DIRT_PATCH_BURIED, DIRT_PATCH_DUG, DIRT_PATCH_BONES }; constexpr int DIRT_CLOUDS_MIN = 2; constexpr int DIRT_CLOUDS_SPAN = 3; constexpr float DIRT_CLOUD_SPEED = 5; constexpr float DIRT_CLOUD_SPREAD = 20; constexpr float DIRT_CLOUD_SPIN_MIN = 2; constexpr float DIRT_CLOUD_SPIN_SPAN = 10; constexpr int DIRT_CLOUD_FRAMES_MIN = 15; constexpr int DIRT_CLOUD_FRAMES_SPAN = 15; constexpr float DIRT_CLOUD_ALPHA_MIN = 0.2f; constexpr float DIRT_CLOUD_ALPHA_SPAN = 0.5f; constexpr int DIRT_ROCKS_MIN = 3; constexpr int DIRT_ROCKS_SPAN = 4; constexpr float DIRT_ROCK_SPREAD = 0.5f; constexpr float DIRT_ROCK_SPEED_MIN = 2; constexpr float DIRT_ROCK_SPEED_SPAN = 4; constexpr float DIRT_ROCK_FLATTEN = 0.5f; constexpr int ROCK_PARTICLE_THROWN = 1; // Big Horn's hand: it rises from a small hole, grabs (2) or slaps (3) its target, then sinks back (3) and goes. // Its hole is drawn by a helper effect at the floor's depth, in the floor's brightened color. enum BigHornHandState : int { HAND_RISING, HAND_GRABBING, HAND_SLAPPING, HAND_SINKING }; constexpr float HAND_HOLE_DEPTH = -5; constexpr int HAND_RISEN_FRAME = 4; constexpr float HAND_GRAB_DAMAGE = 20; constexpr float HAND_GRAB_BOSS_DAMAGE = 60; constexpr float HAND_CRUSH_DAMAGE = 20; constexpr float HAND_CRUSH_BOSS_DAMAGE = 50; constexpr float HAND_CRUSH_REACH = 20; constexpr int HAND_CRUSH_NEW_FRAMES = 3; constexpr int HAND_GRAB_SHAKE = 15; constexpr float HAND_GRAB_SLAMS = 5; constexpr float HAND_SLAP_FRICTION = 0.7f; constexpr float HAND_SLAP_RISE = -30; constexpr float HAND_SLAP_MARGIN = 10; constexpr float HAND_SLAP_PULL = 0.04f; constexpr float HAND_SLAP_SPEED = 4; constexpr float HAND_SLAP_KNOCKBACK = 5; constexpr float HAND_SLAP_DAMAGE = 12; constexpr int HAND_SLAP_SHAKE = 6; constexpr float HAND_SLAP_POOF_SIZE = 0.5f; constexpr ColorMod HAND_SLAP_POOF_COLOR = {{1, 1, 1, 0.6f}, {0.7f, 0.7f, 0.7f, 1}, {0, 0, 0}}; constexpr int HAND_DAMAGE_COUNTDOWN = 30; // The water a hand throws up in a flooded room: 8 to 13 drops where it slaps, 12 to 21 where it pops up, in an // ellipse 60 by 40 wide. constexpr float HAND_WATER_LEVEL = 0.2f; constexpr float HAND_SPLASH_SPREAD_X = 60; constexpr float HAND_SPLASH_SPREAD_Y = 40; constexpr int HAND_SLAP_SPLASHES_MIN = 8; constexpr int HAND_SLAP_SPLASHES_SPAN = 6; constexpr int HAND_POP_SPLASHES_MIN = 12; constexpr int HAND_POP_SPLASHES_SPAN = 10; constexpr float HAND_SPLASH_SPEED_MIN = 3; constexpr float HAND_SPLASH_SPEED_SPAN = 5; constexpr float HAND_SPLASH_GROWTH = 2; constexpr float HAND_SPLASH_RISE_MIN = -4; constexpr float HAND_SPLASH_RISE_SPAN = 8; constexpr float HAND_SPLASH_GRAVITY = 1.5f; constexpr int SPLASH_DROP = 1; // A water effect in the room's water color, faded to an alpha. static void water_color_set(Entity_Effect& effect, float alpha) { effect.sprite.color = g_game->room->fxLayers.fxParams.waterEffectColor; effect.sprite.color._tint[3] = alpha; } // A water splash: a splash of the room's water, heard, or a drop of it thrown up. static void water_splash_init(Entity_Effect& splash) { ANM2& sprite = splash.sprite; if (splash.subtype == 0) { water_color_set(splash, random_unit() * SPLASH_ALPHA_SPAN + SPLASH_ALPHA_MIN); sprite.isFlipX = random_below(2) == 0; float scale = random_unit() * SPLASH_SCALE_SPAN + SPLASH_SCALE_MIN; sprite.scale = vector_make(scale, scale); float pitch = random_unit() * SPLASH_PITCH_SPAN + SPLASH_PITCH_MIN; npc_sound_play(SOUND_WET_FEET, random_unit() * SPLASH_VOLUME_SPAN + SPLASH_VOLUME_MIN, 2, pitch); return; } splash.fallingAcceleration = SPLASH_DROP_GRAVITY; splash.height = SPLASH_DROP_HEIGHT; splash.fallingSpeed = SPLASH_DROP_RISE_MIN - random_unit() * SPLASH_DROP_RISE_SPAN; float scale = random_unit() * SPLASH_DROP_SCALE_SPAN + SPLASH_DROP_SCALE_MIN; sprite.scale = vector_make(scale, scale); water_color_set(splash, random_unit() * SPLASH_DROP_ALPHA_SPAN + SPLASH_DROP_ALPHA_MIN); } // 005ffe30 (Update's water splash case) A splash slows and goes once it ends. A drop falls back and goes once it // lands and its animation ends. static void water_splash_update(Entity_Effect& splash) { ANM2& sprite = splash.sprite; if (splash.subtype == 0) { sprite.Play("Splash"); if (sprite.IsFinished()) splash.Remove(); splash.friction *= SPLASH_FRICTION; return; } sprite.Play("Particle"); splash.fallingSpeed = splash.fallingSpeed * SPLASH_DROP_DRAG + SPLASH_DROP_PULL + splash.fallingAcceleration; splash.height += splash.fallingSpeed; splash.posOffset.y = splash.height; if (splash.height > SPLASH_DROP_LANDED_HEIGHT && sprite.IsFinished()) splash.Remove(); } // A big splash: static for subtypes 1 and 2, otherwise in the room's water color. static void big_splash_init(Entity_Effect& splash) { if (splash.subtype >= BIG_SPLASH_STATIC_FIRST && splash.subtype <= BIG_SPLASH_STATIC_LAST) splash.sprite.bitflags |= ANIM_RENDER_STATIC; else splash.sprite.color = g_game->room->fxLayers.fxParams.waterEffectColor; } // A pedestal's ripple, in the room's water color. static void pedestal_ripple_init(Entity_Effect& ripple) { ripple.sprite.color = g_game->room->fxLayers.fxParams.waterEffectColor; } // A rock's poof, mirrored by its own seed. static void rock_poof_init(Entity_Effect& poof) { poof.isUnknown176 = true; poof.sprite.isFlipX = poof.dropRNG.RandomInt(2) != 0; } static void haemo_trail_init(Entity_Effect& drop) { drop.sprite.Play("Poof"); } // 00602c78 (Update's haemolacria trail case) A drop jitters about and goes once its animation ends. static void haemo_trail_update(Entity_Effect& drop) { Vector direction = random_direction(); drop.velocity = vector_add(drop.velocity, vector_scale(vector_scale(direction, random_unit()), HAEMO_JITTER)); if (drop.sprite.IsFinished()) drop.Remove(); } // A tar bubble: one of its three bubbles, mirrored at random. static void tar_bubble_init(Entity_Effect& bubble) { bubble.sprite.Play(BUBBLE_ANIMATIONS[random_below((int)BUBBLE_ANIMATIONS.size())]); bubble.sprite.isFlipX = random_below(2) == 0; } // 005d4b7a (Update's shared poof case, tar bubble part) A tar bubble takes the color of its parent's first layer, // then goes like a poof. static EffectUpdateEnd tar_bubble_update(Entity_Effect& bubble) { if (bubble.parent && bubble.parent->sprite.animState.animData) { const AnimationFrame* frame = bubble.parent->sprite.animState.GetLayerFrame(0); if (frame) bubble.sprite.color = frame->color; } return effect_poof_update(bubble); } // A dirt pile: mirrored by its own seed, lasting 30 frames, in the floor's brightened color unless its subtype says. static void dirt_pile_init(Entity_Effect& pile) { pile.isUnknown176 = true; pile.sprite.isFlipX = pile.dropRNG.RandomInt(2) != 0; pile.SetTimeout(DIRT_PILE_FRAMES); pile.sprite.Play("Appear"); if (pile.subtype != DIRT_PILE_PLAIN) return; KColor floor = room_floor_color_get(*g_game->room, pile.pos, pile.size); pile.sprite.color = tint_color_make(floor._red * DIRT_PILE_BRIGHTEN, floor._green * DIRT_PILE_BRIGHTEN, floor._blue * DIRT_PILE_BRIGHTEN, 1); } // 005d8e78 (Update's dirt pile case) Gone at once over a solid cell, and once it has sunk back when its time is up. static void dirt_pile_update(Entity_Effect& pile) { if (room_grid_collision_at(pile.pos) > 0) pile.Remove(); if (!pile.isDead) return; pile.sprite.Play("Disappear"); if (pile.sprite.IsFinished()) pile.Remove(); } // A dirt patch: buried and kept, dark in the Dark Room. static void dirt_patch_init(Entity_Effect& patch) { patch.sprite.Play("Idle"); patch.sortingLayer = SORTING_BACKGROUND; patch.state = DIRT_PATCH_BURIED; patch.damageSource = 0; patch.AddEntityFlags(FLAG_DONT_OVERWRITE); if (g_game->room->backdropType != BACKDROP_DARK_ROOM) return; patch.sprite.ReplaceSpritesheet(0, "gfx/Effects/dirtpatch_darkroom.png"); patch.sprite.LoadGraphics(); } // The dust a dug patch raises, spinning away from where it was thrown. static void dirt_cloud_raise(Entity_Effect& patch) { Vector heading = random_direction(); Vector velocity = vector_scale(heading, random_unit() * DIRT_CLOUD_SPEED); uint32_t seed = Random(); Vector direction = random_direction(); Vector position = vector_add(patch.pos, vector_scale(direction, random_unit() * DIRT_CLOUD_SPREAD)); auto* cloud = static_cast(g_game->Spawn({.position = position, .velocity = velocity, .spawner = &patch, .type = ENTITY_EFFECT, .variant = EFFECT_DUST_CLOUD, .seed = seed})); float side = vector_dot(vector_sub(cloud->pos, patch.pos), vector_make(velocity.y, -velocity.x)) < 0 ? -1 : 1; cloud->rotation = (random_unit() * DIRT_CLOUD_SPIN_SPAN + DIRT_CLOUD_SPIN_MIN) * side; cloud->SetTimeout(random_below(DIRT_CLOUD_FRAMES_SPAN) + DIRT_CLOUD_FRAMES_MIN); cloud->SetColor(tint_color_make(1, 1, 1, random_unit() * DIRT_CLOUD_ALPHA_SPAN + DIRT_CLOUD_ALPHA_MIN), -1, COLOR_PRIORITY_DEFAULT, false, true); cloud->Update(); } // A rock a dug patch throws: a piece of rubble of the Dark Room's or the caves' rocks. static void dirt_rock_throw(Entity_Effect& patch) { Vector direction = random_direction(); Vector spread = vector_scale(vector_scale(direction, random_unit()), DIRT_ROCK_SPREAD); Vector position = vector_add(patch.pos, vector_scale(spread, patch.size)); Vector heading = random_direction(); Vector velocity = vector_scale(heading, random_unit() * DIRT_ROCK_SPEED_SPAN + DIRT_ROCK_SPEED_MIN); velocity.y *= DIRT_ROCK_FLATTEN; auto* rock = static_cast(g_game->Spawn( {.position = position, .velocity = velocity, .type = ENTITY_EFFECT, .variant = EFFECT_ROCK_PARTICLE, .seed = Random()})); ANM2& sprite = rock->sprite; sprite.Load("gfx/grid/grid_rock.anm2", GRAPHICS_DEFER); bool isDarkRoom = g_game->room->backdropType == BACKDROP_DARK_ROOM; sprite.ReplaceSpritesheet(0, isDarkRoom ? "gfx/grid/rocks_sheol.png" : "gfx/grid/rocks_caves.png"); sprite.LoadGraphics(); if (const AnimationData* rubble = sprite.GetAnimationData("rubble")) sprite.SetFrame("rubble", random_below(rubble->length)); rock->state = ROCK_PARTICLE_THROWN; rock->Update(); } // 006048ba (Update's dirt patch case) Shows its state, and the first time it changes after the patch's first frame // it is dug up: dust and rocks fly, a shovel digs, and bones raise a lost soul. static void dirt_patch_update(Entity_Effect& patch) { if (patch.damageSource != patch.state) { if (patch.FrameCount() > 1 && patch.damageSource == 0) { for (int i = random_below(DIRT_CLOUDS_SPAN) + DIRT_CLOUDS_MIN; i > 0; i--) dirt_cloud_raise(patch); for (int i = random_below(DIRT_ROCKS_SPAN) + DIRT_ROCKS_MIN; i > 0; i--) dirt_rock_throw(patch); npc_sound_play(SOUND_SHOVEL_DIG, 1, 2, 1); if (patch.state == DIRT_PATCH_BONES) { Entity* soul = g_game->Spawn({.position = patch.pos, .type = ENTITY_EFFECT, .variant = EFFECT_FORGOTTEN_SOUL, .seed = Random()}); soul->parent = &patch; patch.child = soul; soul->Update(); } } patch.damageSource = patch.state; } if (patch.state == DIRT_PATCH_BURIED) patch.sprite.Play("Idle"); else patch.sprite.Play(patch.state == DIRT_PATCH_BONES ? "DugUpBones" : "DugUp"); } // Big Horn's hand rising from its small hole, its hole handed to a helper drawn at the floor's depth in the floor's // brightened color. static void big_horn_hand_init(Entity_Effect& hand) { hand.sprite.Play("SmallHoleOpen"); hand.state = HAND_RISING; hand.renderDepthOffset = HAND_HOLE_DEPTH; LayerState* hole = hand.sprite.GetLayer("Hole"); if (!hole) return; Entity* helper = g_game->Spawn({.position = hand.pos, .spawner = &hand, .type = ENTITY_EFFECT, .variant = EFFECT_BIG_HORN_HOLE_HELPER, .seed = Random()}); helper->parent = &hand; static_cast(helper)->state = hole->layerData ? hole->layerData->id : -1; hand.child = helper; hole->isVisible = false; KColor floor = room_floor_color_get(*g_game->room, hand.pos, hand.size); hole->color = tint_color_make(floor._red * DIRT_PILE_BRIGHTEN, floor._green * DIRT_PILE_BRIGHTEN, floor._blue * DIRT_PILE_BRIGHTEN, 1); } // The hand hurts what it lands on: a boss takes a heavy hit, a player a crushing one, anything else dies. static void hand_crush(Entity_Effect& hand, Entity& victim, float damage, float bossDamage) { EntityRef source(&hand); if (victim.IsBoss()) victim.TakeDamage(bossDamage, DAMAGE_CRUSH, source, HAND_DAMAGE_COUNTDOWN); else if (victim.is_player()) victim.TakeDamage(damage, DAMAGE_CRUSH, source, HAND_DAMAGE_COUNTDOWN); else victim.Kill(source); } // The drops of water a hand throws up around a place in a flooded room. static void hand_water_splash(Vector place, int count) { if (g_game->room->waterAmount <= HAND_WATER_LEVEL) return; for (int i = 0; i < count; i++) { Vector direction = random_direction(); Vector offset = vector_make(HAND_SPLASH_SPREAD_X * direction.x, HAND_SPLASH_SPREAD_Y * direction.y); float speed = random_unit() * HAND_SPLASH_SPEED_SPAN + HAND_SPLASH_SPEED_MIN; // The original divides both parts by the horizontal spread. Vector velocity = vector_make(offset.x * speed / HAND_SPLASH_SPREAD_X, offset.y * speed / HAND_SPLASH_SPREAD_X); auto* drop = static_cast(g_game->Spawn({.position = vector_add(place, offset), .velocity = velocity, .subType = SPLASH_DROP, .type = ENTITY_EFFECT, .variant = EFFECT_WATER_SPLASH, .seed = Random()})); drop->sprite.scale = vector_scale(drop->sprite.scale, HAND_SPLASH_GROWTH); drop->fallingSpeed = HAND_SPLASH_RISE_MIN - random_unit() * HAND_SPLASH_RISE_SPAN; drop->fallingAcceleration = HAND_SPLASH_GRAVITY; drop->Update(); } } // The hand rising: gone if it rose for nothing, then grabbing an enemy target (slapping a boss), or sinking back. static void big_horn_hand_rise(Entity_Effect& hand) { Entity* target = hand.target; if (!hand.sprite.IsFinished()) return; if (target && target->IsEnemy()) { hand.sprite.Play(target->IsBoss() ? "HandSlap" : "HandGrab"); hand.state = target->IsBoss() ? HAND_SLAPPING : HAND_GRABBING; return; } hand.sprite.Play("SmallHoleClose"); hand.state = HAND_SINKING; } // The hand grabbing: its slam crushes the target and shakes the room, then for five frames it kills what it holds // and crushes what has just appeared under it. static void big_horn_hand_grab(Entity_Effect& hand) { ANM2& sprite = hand.sprite; Entity* target = hand.target; if (sprite.IsEventTriggered("Slam")) { if (target) hand_crush(hand, *target, HAND_GRAB_DAMAGE, HAND_GRAB_BOSS_DAMAGE); game_shake_screen(HAND_GRAB_SHAKE); hand.scale = HAND_GRAB_SLAMS; } if (sprite.WasEventTriggered("Slam") && hand.scale > 0) { hand.scale -= 1; if (target && !target->IsBoss() && !target->isDead && !target->is_player()) target->Kill(EntityRef(&hand)); for (Entity* entity : entity_query_radius(hand.pos, HAND_CRUSH_REACH, QUERY_ALL)) { if (entity->entityCollisionClass == ENTCOLL_NONE || !entity->IsEnemy()) continue; if (hand.IsDescendantOf(entity)) continue; if (entity->HasEntityFlags(FLAG_FRIENDLY) || entity->FrameCount() >= HAND_CRUSH_NEW_FRAMES) continue; hand_crush(hand, *entity, HAND_CRUSH_DAMAGE, HAND_CRUSH_BOSS_DAMAGE); } } if (!sprite.IsFinished()) return; sprite.Play("SmallHoleClose"); hand.state = HAND_SINKING; } // The hand slapping: it drifts over its target between its Move and Stop events, and its slam knocks back and hurts // what its Slam null reaches (but players, familiars and charmed enemies), raising dust, water and a thud. static void big_horn_hand_slap(Entity_Effect& hand) { ANM2& sprite = hand.sprite; Entity* target = hand.target; hand.friction = HAND_SLAP_FRICTION; if (target && sprite.WasEventTriggered("Move") && !sprite.WasEventTriggered("Stop")) { Vector above = g_game->room->GetClampedPosition(vector_add(target->pos, vector_make(0, HAND_SLAP_RISE)), HAND_SLAP_MARGIN); Vector pull = vector_scale(vector_sub(above, hand.pos), HAND_SLAP_PULL); if (vector_length(pull) > HAND_SLAP_SPEED) pull = vector_resized(pull, HAND_SLAP_SPEED); hand.AddVelocity(pull, false); } if (sprite.IsEventTriggered("Slam")) { Capsule slam; hand.GetNullCapsule(slam, "Slam"); if (slam.radius > 0) { for (Entity* entity : entity_query_radius(slam.center, slam.radius + slam.halfLength, QUERY_ALL)) { if (entity->entityCollisionClass == ENTCOLL_NONE || entity->entityGridCollisionClass == GRIDCOLL_BULLET) continue; if (entity == &hand || entity->is_player() || entity->IsFamiliar()) continue; if (entity->IsEnemy() && entity->HasEntityFlags(FLAG_CHARM)) continue; if (!Capsule::Collide(slam, entity->GetCollisionCapsule({}))) continue; Vector away = vector_normalized(vector_sub(entity->pos, hand.pos)); entity->AddVelocity(vector_scale(away, HAND_SLAP_KNOCKBACK), true); entity->TakeDamage(HAND_SLAP_DAMAGE, 0, EntityRef(&hand), HAND_DAMAGE_COUNTDOWN); } } hand.MakeGroundPoof(slam.center, HAND_SLAP_POOF_COLOR, HAND_SLAP_POOF_SIZE); hand_water_splash(slam.center, random_below(HAND_SLAP_SPLASHES_SPAN) + HAND_SLAP_SPLASHES_MIN); game_shake_screen(HAND_SLAP_SHAKE); npc_sound_play(SOUND_FORESTBOSS_STOMPS, 1, 2, 1); } if (!sprite.IsFinished()) return; sprite.Play("SmallHoleClose"); hand.state = HAND_SINKING; } // 005d52bd (Update's Big Horn hand case) Rises, grabs or slaps, sinks and goes. Water splashes where it pops up, and // an enemy it holds is pulled along with it. static EffectUpdateEnd big_horn_hand_update(Entity_Effect& hand) { switch (hand.state) { case HAND_RISING: if (!hand.target && hand.sprite.GetFrame() < HAND_RISEN_FRAME) { hand.Remove(); return EFFECT_UPDATE_RETURN; } big_horn_hand_rise(hand); break; case HAND_GRABBING: big_horn_hand_grab(hand); break; case HAND_SLAPPING: big_horn_hand_slap(hand); break; default: if (!hand.sprite.IsFinished()) break; hand.Remove(); return EFFECT_UPDATE_RETURN; } if (hand.sprite.IsEventTriggered("Poof")) hand_water_splash(hand.pos, random_below(HAND_POP_SPLASHES_SPAN) + HAND_POP_SPLASHES_MIN); Entity* target = hand.target; if (hand.state < HAND_SINKING && target && target->IsEnemy() && !target->isDead && !target->IsBoss() && !target->is_player()) target->velocity = vector_sub(hand.pos, target->pos); return EFFECT_UPDATE_FINISH; } // 005d510e (Update's Big Horn hole helper case) Stays on its hand on the floor, and goes with it. static void hole_helper_update(Entity_Effect& helper) { helper.sortingLayer = SORTING_BACKGROUND; if (!helper.parent) return helper.Remove(); helper.pos = helper.parent->pos; helper.velocity = {}; } // Draws the hand's hole layer (the helper's state) at the hand's place, shown only for this draw. static void hole_helper_render(Entity_Effect& helper, const Vector& offset) { Entity* hand = helper.parent; if (!hand) return; LayerState* hole = hand->sprite.GetLayer(helper.state); Vector screen = render_position_get(vector_add(hand->pos, hand->posOffset), RENDER_SNAPPED); hole->isVisible = true; hand->sprite.RenderLayer(helper.state, SpriteDraw{vector_add(screen, offset), {}, {}}); hole->isVisible = false; } // The Colostomia's puddle of poop: its bubbles rise within its BubbleGuide null (one frame in three while the null // shows), and while it does it burns the grounded players standing on its drawn poop (Callus and Socks spare them) for // 1, leaving them slippery with brown footprints. It ripples in time with the game and fades once its parent is gone. constexpr float PUDDLE_GUIDE_ALPHA = 0.5f; constexpr int PUDDLE_BUBBLE_ODDS = 3; constexpr float PUDDLE_BUBBLE_SPREAD = 4; constexpr float PUDDLE_SCREEN_SCALE = 0.65f; constexpr float PUDDLE_TEXEL_ALPHA = 0.5f; constexpr float PUDDLE_DAMAGE = 1; constexpr int PUDDLE_FADE_FRAMES = 15; constexpr int PUDDLE_SORTING_Z = 2000; constexpr std::string_view POOP_BUBBLE_SHEET = "gfx/effects/poop_bubble.png"; // Part of 005cdb20 (Init's case 168) The puddle lies on the floor over the creep and appears. static void colostomia_puddle_init(Entity_Effect& puddle) { puddle.sortingLayer = SORTING_BACKGROUND; puddle.renderZOffset = PUDDLE_SORTING_Z; puddle.sprite.Play("Appear"); } // A bubble of poop rising somewhere inside the puddle's guide. static void colostomia_bubble(Entity_Effect& puddle, const NullFrame& guide) { Vector direction = random_direction(); Vector spot = vector_scale(direction, std::sqrt(random_unit())); spot = vector_make(spot.x * guide.scale.x * PUDDLE_BUBBLE_SPREAD / PUDDLE_SCREEN_SCALE, spot.y * guide.scale.y * PUDDLE_BUBBLE_SPREAD / PUDDLE_SCREEN_SCALE); Entity* bubble = g_game->Spawn({.position = vector_add(puddle.pos, spot), .type = ENTITY_EFFECT, .variant = EFFECT_TAR_BUBBLE, .seed = Random()}); bubble->parent = &puddle; bubble->sprite.ReplaceSpritesheet(0, POOP_BUBBLE_SHEET); bubble->sprite.LoadGraphics(); bubble->Update(); } // Burns a grounded player standing on the puddle's drawn poop. static void colostomia_player_burn(Entity_Effect& puddle, Entity_Player& player) { bool isGrounded = !player.isDead && player.entityCollisionClass != ENTCOLL_NONE && player.entityGridCollisionClass == GRIDCOLL_GROUND; if (!isGrounded || player.HasTrinket(TRINKET_CALLUS) || player.HasCollectible(COLLECTIBLE_SOCKS)) return; float distance = vector_length(vector_sub(player.pos, puddle.pos)); if (distance >= puddle.size * puddle.sprite.scale.x + player.size) return; KColor texel = puddle.sprite.GetTexel({.renderPos = vector_scale(puddle.pos, PUDDLE_SCREEN_SCALE), .sample = vector_scale(player.pos, PUDDLE_SCREEN_SCALE), .alphaThreshold = PUDDLE_TEXEL_ALPHA, .layerId = 0}); if (texel._alpha <= PUDDLE_TEXEL_ALPHA) return; player.TakeDamage(PUDDLE_DAMAGE, DAMAGE_ACID, EntityRef(&puddle), HIT_COUNTDOWN); player.AddEntityFlags(FLAG_SLIPPERY_PHYSICS); player.SetFootprintColor(texel, false); } // 005dc0ef (Update's case 168) The puddle idles once it has appeared, rippling with the game's frames, bubbles and // burns while its guide shows, fades once its parent is gone, and disappears once dead. static void colostomia_puddle_update(Entity_Effect& puddle) { const NullFrame* guide = puddle.sprite.GetNullFrame("BubbleGuide"); if (puddle.sprite.GetAnimation().starts_with("A") && puddle.sprite.IsFinished()) puddle.sprite.Play("Idle"); AnimationState& anim = puddle.sprite.animState; if (anim.IsLoopingAnimation()) puddle.sprite.SetFrame((float)((int)g_game->frameCount % anim.GetAnimationLength())); if (puddle.timeout < 0 && (!puddle.parent || puddle.parent->isDead)) puddle.timeout = PUDDLE_FADE_FRAMES; if (guide && guide->color._tint[3] > PUDDLE_GUIDE_ALPHA) { if (random_below(PUDDLE_BUBBLE_ODDS) == 0) colostomia_bubble(puddle, *guide); for (Entity_Player* player : g_game->playerManager.playerList) colostomia_player_burn(puddle, *player); } if (!puddle.isDead) return; puddle.sprite.Play("Disappear"); if (puddle.sprite.IsFinished()) puddle.Remove(); } constexpr auto FLOOR_BEHAVIOURS = std::to_array({ {EFFECT_WATER_SPLASH, water_splash_init, effect_finishing, nullptr}, {EFFECT_HAEMO_TRAIL, haemo_trail_init, effect_finishing, nullptr}, {EFFECT_DIRT_PATCH, dirt_patch_init, effect_finishing, nullptr}, {EFFECT_TAR_BUBBLE, tar_bubble_init, tar_bubble_update, nullptr}, {EFFECT_BIG_SPLASH, big_splash_init, effect_poof_update, nullptr}, {EFFECT_PEDESTAL_RIPPLE, pedestal_ripple_init, effect_poof_update, nullptr}, {EFFECT_ROCK_POOF, rock_poof_init, effect_poof_update, nullptr}, {EFFECT_DIRT_PILE, dirt_pile_init, effect_finishing, nullptr}, {EFFECT_BIG_HORN_HOLE_HELPER, nullptr, effect_finishing, hole_helper_render}, {EFFECT_BIG_HORN_HAND, big_horn_hand_init, big_horn_hand_update, nullptr}, {EFFECT_COLOSTOMIA_PUDDLE, colostomia_puddle_init, effect_finishing, nullptr}, }); std::span floor_effect_behaviours() { return FLOOR_BEHAVIOURS; }