Curation round 11: effects, room clears, items, Continue, bombs, active items, the boss and Basement II
This commit is contained in:
1 parent
d8385e6c64
commit
698eeb74e9
74 files changed
+13965
-2078
No files matched your search
@@ -0,0 +1,271 @@
|
||||
#include "npc_basement.h"
|
||||
#include "boss_ai.h"
|
||||
#include "entity_effect.h"
|
||||
#include "level.h"
|
||||
|
||||
// The headless enemies this AI runs: the Gusher and Pacer, Blubber and Half Sack, Splasher and the Black Globin's body.
|
||||
constexpr int ENTITY_GUSHER = 11;
|
||||
constexpr int ENTITY_BLUBBER = 210;
|
||||
constexpr int ENTITY_HALF_SACK = 211;
|
||||
constexpr int ENTITY_SPLASHER = 238;
|
||||
constexpr int ENTITY_BLACK_GLOBIN_BODY = 280;
|
||||
|
||||
constexpr int SOUND_BLOBBY_WIGGLE = 3;
|
||||
constexpr int SOUND_BLOODSHOOT = 178;
|
||||
constexpr int SOUND_BOIL_HATCH = 181;
|
||||
constexpr int CONTROLLER_ACTION_SHOOT = 9;
|
||||
constexpr uint64_t PROJECTILE_EXPLODE = 1ull << 1;
|
||||
constexpr uint64_t FLAG_DISTRACTED = FLAG_CONFUSION | FLAG_FEAR | FLAG_SHRINK;
|
||||
constexpr uint64_t DAMAGE_TNT = 1ull << 12;
|
||||
constexpr float WALK_THRESHOLD_GUSHER = 0.1f;
|
||||
constexpr float GUSHER_DEADZONE = 0.1f;
|
||||
|
||||
// The flooded floors' shots are tears, the Dross's puke.
|
||||
constexpr int STAGE_ID_FLOODED_CAVES = 6;
|
||||
constexpr int STAGE_ID_DOWNPOUR = 27;
|
||||
constexpr int STAGE_ID_DROSS = 28;
|
||||
constexpr int PROJECTILE_TEAR = 4;
|
||||
constexpr int PROJECTILE_PUKE = 3;
|
||||
|
||||
// Gushers wait 20 to 39 frames to start, 40 to 59 between shots (Splashers 60 to 89), shooting at 5 along their walk
|
||||
// at targets within 1000. Blubbers wait 30 to 59 between bursts of three to five.
|
||||
constexpr int GUSHER_START_MIN = 20;
|
||||
constexpr int GUSHER_START_RANGE = 20;
|
||||
constexpr int GUSHER_COOLDOWN = 40;
|
||||
constexpr int GUSHER_COOLDOWN_RANGE = 20;
|
||||
constexpr int SPLASHER_COOLDOWN = 60;
|
||||
constexpr int SPLASHER_COOLDOWN_RANGE = 30;
|
||||
constexpr int BLUBBER_COOLDOWN = 30;
|
||||
constexpr int BLUBBER_COOLDOWN_RANGE = 30;
|
||||
constexpr float GUSHER_RANGE = 1000;
|
||||
constexpr int GUSHER_RANGE_FRAMES = 7;
|
||||
constexpr float GUSHER_SHOT_SPEED = 5;
|
||||
constexpr float GUSHER_SHOT_FALL_SPEED = -5;
|
||||
constexpr float GUSHER_SHOT_FALL_ACCEL = 0.3f;
|
||||
constexpr float BLUBBER_SHOT_HEIGHT = -15;
|
||||
constexpr float BLUBBER_SHOT_FALL_SPEED = 5;
|
||||
constexpr float BLUBBER_SHOT_DROP = 5;
|
||||
constexpr float BLUBBER_SHOT_TRAJECTORY = 10;
|
||||
constexpr int BLUBBER_SHOTS_MIN = 3;
|
||||
constexpr int BLUBBER_SHOTS_RANGE = 3;
|
||||
|
||||
// They wander, slowed to three quarters (and more while fleeing), bleeding every 10 frames.
|
||||
constexpr float GUSHER_FRICTION = 0.75f;
|
||||
constexpr float FLEE_FRICTION = 0.8f;
|
||||
constexpr float BLEED_TICKS = 10;
|
||||
constexpr float SPLAT_MIN = 0.2f;
|
||||
constexpr float SPLAT_RANGE = 0.3f;
|
||||
constexpr float BLUBBER_SPLAT_MIN = 0.4f;
|
||||
constexpr float BLUBBER_SPLAT_RANGE = 0.4f;
|
||||
constexpr float WIGGLE_TICKS = 50;
|
||||
constexpr float WIGGLE_VOLUME = 0.7f;
|
||||
constexpr float GUSHER_OVERKILL = -25;
|
||||
|
||||
// The Black Globin's body throws a spider every 90 or 180 frames while fewer than five enemies are left.
|
||||
constexpr int SPIDER_ENEMY_LIMIT = 5;
|
||||
constexpr int SPIDER_COOLDOWN = 90;
|
||||
constexpr float SPIDER_AIM_REACH = 80;
|
||||
constexpr float SPIDER_THROW_HEIGHT = -30;
|
||||
constexpr float SPIDER_SOUND_VOLUME = 0.5f;
|
||||
constexpr float SPIDER_BLOOD_RISE = -10;
|
||||
|
||||
constexpr ColorMod SPLASHER_SPLAT_COLOR = {{0.5f, 0.5f, 0.5f, 1},
|
||||
{0, 0, 0, 0},
|
||||
{-0.19607845f, 0.50980395f, 0.19607845f}};
|
||||
constexpr ColorMod SPLASHER_CREEP_COLOR = {{0, 1, 0, 1}, {0, 0, 0, 0}, {0, 0.5f, 0}};
|
||||
constexpr ColorMod SPLASHER_SHOT_COLOR = {{1, 1, 1, 1}, {0.4f, 2, 0.5f, 1}, {0, 0, 0}};
|
||||
|
||||
static bool is_bleeding_gusher(Entity_NPC& npc)
|
||||
{
|
||||
return (npc.type == ENTITY_GUSHER && npc.variant == 0) || npc.type == ENTITY_SPLASHER;
|
||||
}
|
||||
|
||||
// The first frame: wandering, a shot 20 to 39 frames away, and the blood overlay of a Gusher or Splasher (whose
|
||||
// splats are green).
|
||||
static void gusher_init(Entity_NPC& npc)
|
||||
{
|
||||
npc.state = NPC_STATE_MOVE;
|
||||
if (npc.type == ENTITY_SPLASHER) npc.splatColor = SPLASHER_SPLAT_COLOR;
|
||||
npc.projectileCooldown = (int)(Random() % GUSHER_START_RANGE) + GUSHER_START_MIN;
|
||||
if (is_bleeding_gusher(npc)) npc.sprite.PlayOverlay("Blood");
|
||||
}
|
||||
|
||||
// A Splasher ignores explosions but the players' own, friendly ones' and TNT's.
|
||||
static void splasher_explosions_ignore(Entity_NPC& npc)
|
||||
{
|
||||
for (DamageEvent& event : npc.damageEvents)
|
||||
{
|
||||
bool isPlayerMade = event.source.type == ENTITY_PLAYER || event.source.spawnerType == ENTITY_PLAYER ||
|
||||
event.source.spawnerType == ENTITY_FAMILIAR;
|
||||
if ((event.damageFlags & DAMAGE_EXPLOSION) && !(event.source.flags & ENTITY_REF_FRIENDLY) && !isPlayerMade &&
|
||||
!(event.damageFlags & DAMAGE_TNT))
|
||||
event.damage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// The shot's look: the flooded floors' tears and the Dross's puke.
|
||||
static void stage_projectile_apply(ProjectileParams& params)
|
||||
{
|
||||
uint32_t stage = Level::GetStageID();
|
||||
if (stage == STAGE_ID_FLOODED_CAVES || stage == STAGE_ID_DOWNPOUR) params.variant = PROJECTILE_TEAR;
|
||||
else if (stage == STAGE_ID_DROSS) params.variant = PROJECTILE_PUKE;
|
||||
}
|
||||
|
||||
// A Gusher or Splasher spurts a shot the way it walks (or its player steers) off cooldown. The Splasher's explode
|
||||
// green.
|
||||
static void gusher_shoot_update(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.projectileCooldown >= 1 || npc.HasEntityFlags(FLAG_DISTRACTED))
|
||||
{
|
||||
npc.projectileCooldown -= npc_ticks_get(npc);
|
||||
return;
|
||||
}
|
||||
bool isControlled = npc.controllerID != -1;
|
||||
if (isControlled && !npc.IsTargetInAttackRange(GUSHER_RANGE, GUSHER_RANGE_FRAMES, false)) return;
|
||||
|
||||
float speed = vector_length(npc.velocity);
|
||||
Vector aim = vector_make(0, 0);
|
||||
if (isControlled) aim = npc.GetControllerMovementInput(GUSHER_DEADZONE);
|
||||
else if (speed > 0) aim = vector_make(npc.velocity.x / speed, npc.velocity.y / speed);
|
||||
if (vector_is_zero(aim)) return;
|
||||
|
||||
if (npc.type == ENTITY_GUSHER)
|
||||
npc.projectileCooldown = (isControlled ? 0 : (int)(Random() % GUSHER_COOLDOWN_RANGE)) + GUSHER_COOLDOWN;
|
||||
ProjectileParams params;
|
||||
params.fallingAccelModifier = GUSHER_SHOT_FALL_ACCEL;
|
||||
params.fallingSpeedModifier = GUSHER_SHOT_FALL_SPEED;
|
||||
if (npc.type == ENTITY_SPLASHER)
|
||||
{
|
||||
npc.projectileCooldown = (isControlled ? 0 : (int)(Random() % SPLASHER_COOLDOWN_RANGE)) + SPLASHER_COOLDOWN;
|
||||
params.bulletFlags |= PROJECTILE_EXPLODE;
|
||||
params.color = SPLASHER_SHOT_COLOR;
|
||||
}
|
||||
stage_projectile_apply(params);
|
||||
npc.FireProjectiles(npc.pos, vector_scale(aim, GUSHER_SHOT_SPEED), PROJECTILES_SINGLE, params);
|
||||
npc.PlaySound(SOUND_BLOODSHOOT, 1, 2, false, 1);
|
||||
}
|
||||
|
||||
// A moving Blubber bursts three to five arcing shots off cooldown.
|
||||
static void blubber_shoot_update(Entity_NPC& npc)
|
||||
{
|
||||
bool isControlled = npc.controllerID != -1;
|
||||
bool isReady = npc.projectileCooldown < 1 && !npc.HasEntityFlags(FLAG_DISTRACTED) &&
|
||||
(!isControlled || npc.IsTargetInAttackRange(GUSHER_RANGE, GUSHER_RANGE_FRAMES, false) ||
|
||||
npc.IsControllerActionPressed(CONTROLLER_ACTION_SHOOT));
|
||||
if (!isReady)
|
||||
{
|
||||
npc.projectileCooldown -= npc_ticks_get(npc);
|
||||
return;
|
||||
}
|
||||
if (vector_length(npc.velocity) <= 0) return;
|
||||
|
||||
npc.projectileCooldown = (isControlled ? 0 : (int)(Random() % BLUBBER_COOLDOWN_RANGE)) + BLUBBER_COOLDOWN;
|
||||
ProjectileParams params;
|
||||
params.heightModifier += BLUBBER_SHOT_HEIGHT;
|
||||
params.fallingSpeedModifier = BLUBBER_SHOT_FALL_SPEED;
|
||||
params.positionOffset = vector_make(0, BLUBBER_SHOT_DROP);
|
||||
int count = (int)(Random() % BLUBBER_SHOTS_RANGE) + BLUBBER_SHOTS_MIN;
|
||||
npc.FireBossProjectiles(count, vector_make(0, 0), BLUBBER_SHOT_TRAJECTORY, params);
|
||||
npc.PlaySound(SOUND_BLOODSHOOT, 1, 2, false, 1);
|
||||
}
|
||||
|
||||
// Wanders, or flees its target while feared or shrunk.
|
||||
static void gusher_wander(Entity_NPC& npc)
|
||||
{
|
||||
npc.friction *= GUSHER_FRICTION;
|
||||
if (!npc.HasEntityFlags(FLAG_FEAR | FLAG_SHRINK) || npc.controllerID != -1)
|
||||
{
|
||||
npc.pathfinder.MoveRandomly(STATUS_OBEYED);
|
||||
return;
|
||||
}
|
||||
npc.pathfinder.EvadeTarget(npc.GetPlayerTarget()->pos, STATUS_OBEYED);
|
||||
if (npc.pathfinder.evadeMovementCountdown > 0) npc.friction *= FLEE_FRICTION;
|
||||
}
|
||||
|
||||
// Every 10 frames it bleeds: a Half Sack red creep (unless shrunk), the others splats, a Blubber a big one besides,
|
||||
// a Splasher a green one.
|
||||
static void gusher_bleed(Entity_NPC& npc)
|
||||
{
|
||||
if (!npc.GetIntervalTicks(BLEED_TICKS, 0)) return;
|
||||
|
||||
if (npc.type == ENTITY_HALF_SACK)
|
||||
{
|
||||
if (npc.HasEntityFlags(FLAG_SHRINK)) return;
|
||||
|
||||
Entity* creep = g_game->Spawn({.position = npc.pos,
|
||||
.spawner = &npc,
|
||||
.type = ENTITY_EFFECT,
|
||||
.variant = EFFECT_CREEP_RED,
|
||||
.seed = Random()});
|
||||
float scale = random_unit() * SPLAT_RANGE + SPLAT_MIN;
|
||||
creep->sprite.scale = vector_make(scale, scale);
|
||||
creep->Update();
|
||||
return;
|
||||
}
|
||||
if (npc.type == ENTITY_BLUBBER) npc.MakeSplat(random_unit() * BLUBBER_SPLAT_RANGE + BLUBBER_SPLAT_MIN);
|
||||
Entity_Effect* splat = npc.MakeSplat(random_unit() * SPLAT_RANGE + SPLAT_MIN);
|
||||
if (npc.type == ENTITY_SPLASHER) splat->SetColor(SPLASHER_CREEP_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
||||
}
|
||||
|
||||
// The Black Globin's body throws a spider (where its player aims) with a burst of blood, while few enemies are left.
|
||||
// True when it waited instead.
|
||||
static bool globin_body_spiders_update(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.projectileCooldown > 0)
|
||||
{
|
||||
npc.projectileCooldown -= npc_ticks_get(npc);
|
||||
return true;
|
||||
}
|
||||
bool isControlled = npc.controllerID != -1;
|
||||
if (npc.GetAliveEnemyCount() >= SPIDER_ENEMY_LIMIT ||
|
||||
(isControlled && !npc.IsTargetInAttackRange(GUSHER_RANGE, GUSHER_RANGE_FRAMES, false)))
|
||||
return false;
|
||||
|
||||
Vector target = vector_make(0, 0);
|
||||
Vector aim = isControlled ? npc.GetControllerMovementInput(GUSHER_DEADZONE) : vector_make(0, 0);
|
||||
if (!vector_is_zero(aim)) target = vector_add(vector_scale(aim, SPIDER_AIM_REACH), npc.pos);
|
||||
Entity_NPC::ThrowSpider(npc.pos, &npc, target, false, SPIDER_THROW_HEIGHT);
|
||||
npc.PlaySound(SOUND_BOIL_HATCH, SPIDER_SOUND_VOLUME, 2, false, 1);
|
||||
|
||||
Vector rise = vector_make(0, SPIDER_BLOOD_RISE);
|
||||
Entity* blood = blood_explosion_spawn(1, npc.pos, rise, COLOR_DEFAULT, vector_make(0, 0));
|
||||
blood->renderDepthOffset = 1;
|
||||
static_cast<Entity_Effect*>(blood)->FollowParent(&npc);
|
||||
npc.projectileCooldown = isControlled ? SPIDER_COOLDOWN : (int)((Random() & 1) + 1) * SPIDER_COOLDOWN;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 0050af90 The headless enemies' AI: they wander bleeding. Gushers and Splashers spurt shots along their walk,
|
||||
// Blubbers burst arcs and get up as Half Sacks one time in two, the Black Globin's body throws spiders, and the fat
|
||||
// ones wiggle audibly.
|
||||
void npc_gusher_update(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.state == NPC_STATE_INIT) return gusher_init(npc);
|
||||
if (npc.isDead && npc.type == ENTITY_BLUBBER)
|
||||
{
|
||||
if (npc.health <= GUSHER_OVERKILL || (Random() & 1) != 0) return;
|
||||
|
||||
npc.Morph(ENTITY_HALF_SACK, 0, 0, -1);
|
||||
npc.isDead = false;
|
||||
npc.health = npc.maxHitPoints;
|
||||
return;
|
||||
}
|
||||
if (npc.type == ENTITY_SPLASHER && npc.pendingDamage > 0) splasher_explosions_ignore(npc);
|
||||
|
||||
npc.AnimWalkFrame("WalkHori", "WalkVert", WALK_THRESHOLD_GUSHER);
|
||||
if (is_bleeding_gusher(npc))
|
||||
{
|
||||
npc_overlay_loop(npc.sprite, "Blood");
|
||||
gusher_shoot_update(npc);
|
||||
}
|
||||
else if (npc.type == ENTITY_BLUBBER) blubber_shoot_update(npc);
|
||||
else if (npc.type == ENTITY_BLACK_GLOBIN_BODY) npc_overlay_loop(npc.sprite, "Spiders");
|
||||
|
||||
gusher_wander(npc);
|
||||
gusher_bleed(npc);
|
||||
if (npc.type == ENTITY_BLACK_GLOBIN_BODY && globin_body_spiders_update(npc)) return;
|
||||
|
||||
bool isFat = npc.type == ENTITY_BLUBBER || npc.type == ENTITY_HALF_SACK;
|
||||
if (isFat && npc.GetIntervalTicks(WIGGLE_TICKS, (float)(npc.index % (uint32_t)WIGGLE_TICKS)) && (Random() & 1) == 0)
|
||||
npc.PlaySound(SOUND_BLOBBY_WIGGLE, WIGGLE_VOLUME, 2, false, 1);
|
||||
}
|
||||
Reference in new issue
Block a user