Curation round 27 (code only): Weapon_Bone::Fire and the fetus tear (no offline gaps left), TakeDamage's interleaved hit order, 74 SetAnimation reset flags corrected, and a parity audit of every boss, every enemy, the rest of the player and tears, effects and familiars; one normalize_angle_degrees, IsTargetInAttackRange defaults (59 duplicates)

This commit is contained in:
shweet committed 2026-11-23 12:08:14 -05:00
1 parent cc77c923e8
commit e66baf4063
215 files changed
+2046 -1093

No files matched your search

+1
View File
@@ -148,6 +148,7 @@ struct BezierPoint;
struct BitSet128;
struct BlendMode;
struct BombCostumeRule;
struct BoneFire;
struct BoomerangLoop;
struct BossId;
struct BossOverlay;
+6 -6
View File
@@ -140,10 +140,10 @@ void color_multiply(ColorMod& color, const ColorMod& other)
for (int i = 0; i < 3; i++) color._offset[i] = other._offset[i] + color._offset[i];
}
// An angle brought into [-180, 180] degrees.
static float angle_wrap(float angle)
// 00682740 An angle in degrees brought into -180 to 180.
float normalize_angle_degrees(float angle)
{
if (std::fabs(angle) > FULL_TURN_DEGREES) angle = (float)std::fmod((double)angle, (double)FULL_TURN_DEGREES);
if (std::fabs(angle) > FULL_TURN_DEGREES) angle = std::fmod(angle, FULL_TURN_DEGREES);
if (angle > HALF_TURN_DEGREES) return angle - FULL_TURN_DEGREES;
if (angle < -HALF_TURN_DEGREES) return angle + FULL_TURN_DEGREES;
return angle;
@@ -152,14 +152,14 @@ static float angle_wrap(float angle)
// 006828b0 An angle in degrees a fraction t of the way to another, the short way round.
float angle_lerp(float from, float to, float t)
{
from = angle_wrap(from);
to = angle_wrap(to);
from = normalize_angle_degrees(from);
to = normalize_angle_degrees(to);
if (std::fabs(to - from) > HALF_TURN_DEGREES)
{
if (to > from) from += FULL_TURN_DEGREES;
else to += FULL_TURN_DEGREES;
}
return angle_wrap((to - from) * t + from);
return normalize_angle_degrees((to - from) * t + from);
}
// Moves a keyframe's position, scale, colour and rotation a fraction t of the way between two keyframes.
+1
View File
@@ -527,6 +527,7 @@ struct AnmCache
static void LogMemoryUsage();
};
float normalize_angle_degrees(float angle);
float angle_lerp(float from, float to, float t);
ColorMod color_lerp(const ColorMod& from, const ColorMod& to, float t);
void color_multiply(ColorMod& color, const ColorMod& other);
+1 -1
View File
@@ -469,7 +469,7 @@ static void sad_bomb_spread(const Explosion& explosion)
{
Entity_Knife* knife = player->FireKnife({.parent = player, .subType = KNIFE_SUBTYPE_PATH});
knife->pos = position;
knife->rotation = angle_wrapped(angle);
knife->rotation = normalize_angle_degrees(angle);
knife->SetCollisionDamage((knife->collisionDamage + SAD_EXTRA_DAMAGE) * multiplier);
knife->parent = player;
knife->InitHomingPath(vector_from_angle(knife->rotation), player, 0);
+1 -1
View File
@@ -388,7 +388,7 @@ static bool cage_laser(Entity_NPC& npc)
{.position = npc.pos,
.posOffset = offset,
.source = &npc,
.angleDegrees = angle_wrap((float)direction * CAGE_LASER_QUARTER + HALF_TURN_DEGREES),
.angleDegrees = normalize_angle_degrees((float)direction * CAGE_LASER_QUARTER + HALF_TURN_DEGREES),
.timeout = CAGE_LASER_TIMEOUT,
.variant = CAGE_LASER_VARIANT});
laser->renderDepthOffset = direction == DIRECTION_UP ? CAGE_LASER_DEPTH_UP : CAGE_LASER_DEPTH;
+2 -1
View File
@@ -636,7 +636,8 @@ static void chimera_spray_fire(Entity_NPC& npc, float progress)
auto* shot = static_cast<Entity_Projectile*>(g_game->Spawn(
{.position = npc.pos, .velocity = velocity, .spawner = &npc, .type = ENTITY_PROJECTILE, .seed = Random()}));
float flight = vector_distance(npc.pos, landing) / vector_length(velocity);
float drag = std::max((std::pow(SPRAY_DRAG, flight) - 1) * SPRAY_DRAG_SUM, SPRAY_DRAG_MIN);
float decay = (float)std::pow((double)SPRAY_DRAG, (double)flight);
float drag = std::max((decay - 1) * SPRAY_DRAG_SUM, SPRAY_DRAG_MIN);
shot->fallingAccel = SPRAY_ACCEL;
shot->scale = CHIMERA_SPRAY_SCALE;
shot->projectileFlags = PROJECTILE_EXPLODE;
+1 -1
View File
@@ -340,7 +340,7 @@ static void dll_legs(Entity_NPC& npc)
copy->state = DLL_STOMP;
copy->i2 = npc.i2++;
copy->projectileDelay = delay;
if (copy->sprite.SetAnimation("StompArm", SWITCH_KEEP_FRAME) && copy->sprite.animState.animData)
if (copy->sprite.SetAnimation("StompArm") && copy->sprite.animState.animData)
{
copy->sprite.animState.SetFrameFloat(0);
copy->sprite.animState.isPlaying = false;
+3 -6
View File
@@ -69,7 +69,6 @@ constexpr int ACHIEVEMENT_GEHENNA = 414;
constexpr int ACHIEVEMENT_BRIMSTONE_BOMBS = 546;
constexpr int EVENT_BABY_PLUM_KILLS = 493;
constexpr int MUSIC_JINGLE_MINIBOSS_OVER = 92;
constexpr int GAME_STATE_PERFECTION_SPAWNED = 45;
constexpr RNG DEATH_RNG_SHIFTS = {0, 4, 3, 17};
@@ -117,8 +116,6 @@ constexpr float GUIDE_POOF_SHRINK = 0.4f;
constexpr int GUIDE_GUSHES = 4;
constexpr float GUIDE_GUSH_REACH = 3.8f;
constexpr float GUIDE_GUSH_DEPTH = 50;
constexpr int SOUND_DEATH_BURST_HUGE = 141;
constexpr int SOUND_DEATH_BURST_GUIDED = 72;
constexpr float GFUEL_EARLY_FRAMES = 10;
constexpr int GFUEL_DELAYED_COUNT = 2;
constexpr uint32_t GFUEL_SEED_MASK = 0xfffff;
@@ -286,7 +283,7 @@ uint32_t Room::GetBossVictoryJingle()
if (game.stage == STAGE_HOME && game.stageType == STAGE_TYPE_HOME_NIGHT) return 0;
if (game.get_secret_exit_kind() == SECRET_EXIT_MOMS_HEART && game.currentRoomIdx == ROOM_SECRET_EXIT_IDX) return 0;
if (game.room->roomType == ROOM_MINIBOSS || game.room->isSurpriseMiniboss) return MUSIC_JINGLE_MINIBOSS_OVER;
if (game.room->roomType == ROOM_MINIBOSS || game.room->isSurpriseMiniboss) return MUSIC_JINGLE_CHALLENGE_OUTRO;
if (game.stageType == STAGETYPE_REPENTANCE || game.stageType == STAGETYPE_REPENTANCE_B)
return MUSIC_JINGLE_BOSS_OVER3;
return descriptor->flags & ROOM_DESCRIPTOR_FLAG_ALT_BOSS_MUSIC ? MUSIC_JINGLE_BOSS_OVER2 : MUSIC_JINGLE_BOSS_OVER;
@@ -708,7 +705,7 @@ void Entity_NPC::update_blood_guide_gibs(const NullFrame& guide)
.amount = (int)(Random() & GUIDE_GIB_MASK) + GUIDE_GIB_MIN,
.gibFlags = GUIDE_GIB_FLAGS});
blood_explosion_spawn((int)(Random() & 1) + GUIDE_EXPLOSION_MIN, pos, offset, splatColor, {});
PlaySound(SOUND_DEATH_BURST_HUGE, random_unit() * GUIDE_VOLUME_SPAN + GUIDE_VOLUME, 2, false, 1);
PlaySound(SOUND_ROCKET_BLAST_DEATH, random_unit() * GUIDE_VOLUME_SPAN + GUIDE_VOLUME, 2, false, 1);
}
}
else if (isBleeding && (Random() & 1) == 0)
@@ -730,7 +727,7 @@ void Entity_NPC::update_blood_guide_gibs(const NullFrame& guide)
if (!isGfuel)
{
poof->SetColor(splatColor, -1, COLOR_PRIORITY_DEFAULT, false, true);
PlaySound(SOUND_DEATH_BURST_GUIDED, random_unit() * GUIDE_VOLUME_SPAN + GUIDE_VOLUME, 2, false, 1);
PlaySound(SOUND_MEAT_JUMPS, random_unit() * GUIDE_VOLUME_SPAN + GUIDE_VOLUME, 2, false, 1);
}
}
+10 -12
View File
@@ -55,8 +55,8 @@ constexpr uint32_t RAGE_STEPS = 3;
// He teleports every 300 to 899 frames, at most 30 frames after he leaves the camera's sight (checked 100 out from him
// at each corner), the damage he takes cutting it by half. He lands 160 to 320 out from his target along its way (any
// way while it stands still), at least 160 from every player: up to 20 more tries go round his target 90 degrees at a
// time, 40 further out each, from 320. Bosses that stay in place never teleport.
// way while it stands still), at least 160 from every player: 20 more spots go round his target 90 degrees at a time,
// 40 further out each, from 320, the last one never checked. Bosses that stay in place never teleport.
constexpr uint32_t TELEPORT_FRAMES_MIN = 300;
constexpr uint32_t TELEPORT_FRAMES_ROLL = 600;
constexpr uint32_t TELEPORT_HIDDEN_FRAMES = 30;
@@ -732,20 +732,18 @@ static void delirium_teleport(Entity_NPC& npc)
while (!is_clear_of_players(spot))
{
if (tries >= DELIRIUM_TELEPORT_TRIES)
{
log_printf(LOG_INFO, "??? teleport: %d tries\n", tries);
npc.deliriumFormAge = npc.deliriumFormAge + 1;
npc.deliriumTeleportTimer = Random() % TELEPORT_FRAMES_ROLL + TELEPORT_FRAMES_MIN;
return;
}
float ring = (float)tries * DELIRIUM_RING_STEP + TELEPORT_RING;
float angle = ((float)(tries % TELEPORT_QUARTERS) * TELEPORT_QUARTER_DEGREES + start) * DEGREES_TO_RADIANS;
Vector around = npc.GetPlayerTarget()->pos;
spot = room.GetClampedPositionImpl(
vector_make(std::cos(angle) * ring + around.x, std::sin(angle) * ring + around.y), DELIRIUM_TELEPORT_REACH,
DELIRIUM_TELEPORT_REACH, DELIRIUM_TELEPORT_REACH, DELIRIUM_TELEPORT_REACH);
tries++;
if (++tries < DELIRIUM_TELEPORT_TRIES) continue;
log_printf(LOG_INFO, "??? teleport: %d tries\n", tries);
npc.deliriumFormAge = npc.deliriumFormAge + 1;
npc.deliriumTeleportTimer = Random() % TELEPORT_FRAMES_ROLL + TELEPORT_FRAMES_MIN;
return;
}
log_printf(LOG_INFO, "??? teleport: %d tries\n", tries);
@@ -982,7 +980,7 @@ static void form_start(Entity_NPC& npc, float maxHealth)
npc_ai_update(npc);
form_chain_dress(npc, true, maxHealth);
}
if (npc.type == ENTITY_CHUB) npc.state = NPC_STATE_IDLE;
if (npc.type == ENTITY_CHUB) npc.state = NPC_STATE_APPEAR;
}
// Changes him into his next form: what the last one left goes, the new boss inits in his place (clamped into the
@@ -1038,7 +1036,7 @@ static void delirium_morph(Entity_NPC& npc, FormSeconds seconds)
npc.maxHitPoints = maxHealth;
npc.type = type;
npc.variant = variant;
Entity* cloud = spawn_at(ENTITY_EFFECT, EFFECT_POOF02, poof_size_get(npc, false), npc.pos, &npc);
Entity* cloud = spawn_at(ENTITY_EFFECT, EFFECT_POOF01, poof_size_get(npc, false), npc.pos, &npc);
cloud->posOffset = npc.posOffset;
cloud->renderDepthOffset = npc.posOffset.y + 1;
}
+2 -2
View File
@@ -202,12 +202,12 @@ constexpr float DOGMA_ANGEL_VOLUME = 0.6f;
constexpr int TECH_DOT_FADING = 1;
constexpr int DOGMA_LASER_END = 1;
// 004aaef0 Sets every layer's distortion from the Distortion null, 3 more while its hit timer (i2) runs down.
// 004aaef0 Sets every layer's distortion from the Distortion null's red tint, 3 more while its hit timer (i2) runs down.
static void dogma_distortion_update(Entity_NPC& npc)
{
float distortion = 0;
AnimationState& anim = npc.sprite.overlayAnimState.isPlaying ? npc.sprite.overlayAnimState : npc.sprite.animState;
if (const NullFrame* null = anim.GetNullFrame("Distortion")) distortion = null->pos.x;
if (const NullFrame* null = anim.GetNullFrame("Distortion")) distortion = null->color._tint[0];
if (npc.i2 > 0) distortion += DOGMA_DISTORTION_HIT;
npc.i2 = std::max(npc.i2 - npc_ticks_get(npc), 0);
for (LayerState& layer : npc.sprite.layerStates) layer.color._colorize[0] = distortion;
+4 -7
View File
@@ -95,8 +95,7 @@ static void push_away(Entity_NPC& npc, Entity& entity, float speed)
if (distanceSquared <= NEAR_SQUARED) return;
float distance = std::sqrt(distanceSquared);
Vector push = vector_scale(away, speed / distance);
if (entity.friction != 0)
entity.velocity = vector_add(entity.velocity, vector_scale(push, entity.speedMultiplier / entity.friction));
entity.AddVelocity_divided(push, false);
}
// A minion that starts at once and dies on touch.
@@ -133,8 +132,7 @@ static void duke_float(Entity_NPC& npc)
Vector drift = vector_make(npc.velocity.x > 0 ? 1 : -1, npc.velocity.y < DRIFT_DOWN_THRESHOLD ? -1 : 1);
npc.friction *= DUKE_FRICTION;
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity, vector_scale(drift, speed * npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(vector_scale(drift, speed), false);
if (isSuckerDuke) npc.friction *= SUCKER_DUKE_FRICTION;
if (!npc.HasEntityFlags(FLAG_FEAR | FLAG_SHRINK)) return;
@@ -142,8 +140,7 @@ static void duke_float(Entity_NPC& npc)
float distance = vector_length(away);
float strength = std::clamp((DUKE_FLEE_RANGE - distance) * DUKE_FLEE_STRENGTH, 0.0f, DUKE_FLEE_MAX);
if (distance > 0) away = vector_scale(away, strength / distance);
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity, vector_scale(away, npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(away, false);
}
// While floating it may cough up flies, spit a big fly, or burst its flies away, by how many flies it keeps
@@ -184,7 +181,7 @@ static void duke_choose(Entity_NPC& npc, int groupSize, int enemies)
}
if (attack.empty()) npc.sprite.Play("Walk");
else if (npc.sprite.SetAnimation(attack, SWITCH_KEEP_FRAME))
else if (npc.sprite.SetAnimation(attack))
{
npc.sprite.animState.Rewind();
npc.sprite.animState.isPlaying = true;
+1 -9
View File
@@ -205,14 +205,6 @@ static void charge_update(Entity_NPC& npc)
tracers_spawn(npc);
}
// An angle brought within -180 to 180, as the beams take it.
static float angle_wrap(float degrees)
{
if (std::abs(degrees) > 360) degrees = std::fmod(degrees, 360.0f);
if (degrees > 180) return degrees - 360;
return degrees < -180 ? degrees + 360 : degrees;
}
// The cross of four beams on Shoot, the spin's turning a quarter either way. From Shoot2 it drifts toward the target,
// slowing to a stop.
static void beams_update(Entity_NPC& npc)
@@ -252,7 +244,7 @@ static void beams_update(Entity_NPC& npc)
Entity_Laser* laser = Entity_Laser::ShootAngle({.position = from,
.posOffset = vector_make(0, -FALLEN_BEAM_RISE),
.source = &npc,
.angleDegrees = angle_wrap(angle),
.angleDegrees = normalize_angle_degrees(angle),
.timeout = isSpin ? SPIN_TIMEOUT : FALLEN_BEAM_TIMEOUT,
.variant = LASER_THICK_RED});
laser->renderDepthOffset = FALLEN_BEAM_DEPTH;
+1 -1
View File
@@ -74,7 +74,7 @@ static void famine_head(Entity_NPC& npc, Vector toTarget)
if (npc.GetIntervalTicks(FAMINE_HEAD_AIM_TICKS, (float)npc.index))
{
if (npc.projectileCooldown >= 1) npc.projectileCooldown--;
else if (npc.IsTargetInAttackRange(FAMINE_HEAD_RANGE, 0, false))
else if (npc.IsTargetInAttackRange(FAMINE_HEAD_RANGE, 0))
{
npc.projectileCooldown = FAMINE_HEAD_COOLDOWN;
npc_anim_restart(npc.sprite, "HeadAttack");
+10 -13
View File
@@ -45,7 +45,6 @@ constexpr float BABY_CLAMP_TOP = 30;
constexpr float BABY_CLAMP_BOTTOM = 10;
constexpr float BABY_PULL = 0.25f;
constexpr float BABY_SHOT_RANGE = 300;
constexpr int BABY_RANGE_FRAMES = 7;
constexpr int BABY_COOLDOWN = 35;
constexpr float BABY_SHOT_SPEED = 7;
constexpr float BABY_HARD_SHOT_SPEED = 10;
@@ -217,15 +216,14 @@ static void twin_state_update(Entity_NPC& npc)
// Pulls the baby back toward its twin past the leash: Steven's always, the rest past 76.
static void baby_leash_update(Entity_NPC& npc, Entity& baby, Vector offset, float distance)
{
if (npc.variant == GEMINI_STEVEN)
{
if (distance > 0 && baby.parent == &npc)
baby.AddVelocity_divided(vector_scale(offset, (distance - STEVEN_LEASH) * STEVEN_LEASH_PULL / distance),
false);
return;
}
if (distance > LEASH)
baby.AddVelocity_divided(vector_scale(offset, (distance - LEASH) * LEASH_PULL / distance), false);
float leash = npc.variant == GEMINI_STEVEN ? STEVEN_LEASH : LEASH;
float pull = npc.variant == GEMINI_STEVEN ? STEVEN_LEASH_PULL : LEASH_PULL;
bool isPulled = npc.variant == GEMINI_STEVEN ? distance > 0 && baby.parent == &npc : distance > LEASH;
if (!isPulled) return;
float stretch = distance - leash;
baby.AddVelocity_divided(
vector_make(stretch * offset.x * pull / distance, stretch * offset.y * pull / distance), false);
}
// Hangs Gemini's cord from its belly to the baby, sagging the more the slacker it is.
@@ -338,9 +336,8 @@ static void ovum_baby_update(Entity_NPC& npc, Vector toAim, Vector toTarget)
npc.stateFrame = 0;
npc.sprite.Play("Attack01", PLAY_FORCED);
npc.sprite.isFlipX = npc.v1.x < 0;
float angle = std::atan2(npc.v1.y, npc.v1.x);
following_effect_spawn(npc, {.offset = vector_make(0, OVUM_BABY_WARNING_HEIGHT),
.targetPosition = vector_make(std::cos(angle), std::sin(angle)),
.targetPosition = vector_from_angle(vector_angle(npc.v1)),
.color = OVUM_BABY_WARNING_COLOR,
.scale = OVUM_BABY_WARNING_SCALE,
.timeout = OVUM_BABY_WARNING_FRAMES});
@@ -430,7 +427,7 @@ static void leashed_update(Entity_NPC& npc, Vector toAim)
if (npc.state == NPC_STATE_MOVE)
{
if (npc.projectileCooldown < 1 && npc.IsTargetInAttackRange(BABY_SHOT_RANGE, BABY_RANGE_FRAMES, false))
if (npc.projectileCooldown < 1 && npc.IsTargetInAttackRange(BABY_SHOT_RANGE))
{
npc.state = NPC_STATE_ATTACK;
npc.sprite.Play("Attack01", PLAY_FORCED);
+2 -1
View File
@@ -675,7 +675,8 @@ void boss_gideon_update(Entity_NPC& npc)
gideon_shots_swallow(npc);
if (cooldown_get(npc, 0) != 0) cooldown_set(npc, 0, cooldown_get(npc, 0) - 1);
if (cooldown_get(npc, COOLDOWN_BITS) != 0) cooldown_set(npc, COOLDOWN_BITS, cooldown_get(npc, COOLDOWN_BITS) - 1);
npc.velocity = vector_scale(vector_sub(npc.targetPosition, npc.pos), 1 / npc.friction);
npc.velocity = vector_make((npc.targetPosition.x - npc.pos.x) / npc.friction,
(npc.targetPosition.y - npc.pos.y) / npc.friction);
if (npc.isDead) npc_sound_play(SOUND_MONSTER_ROAR_2, 1, 2, champion_pitch_get(npc));
}
+1 -1
View File
@@ -216,7 +216,7 @@ static void lil_haunt_chase(Entity_NPC& npc)
? npc.stateFrame > LIL_HAUNT_SHOOT_WAIT && distanceSquared < LIL_HAUNT_SHOOT_REACH_SQUARED &&
Random() % LIL_HAUNT_SHOOT_ODDS == 0
: npc.stateFrame > LIL_HAUNT_CONTROLLED_SHOOT_WAIT &&
npc.IsTargetInAttackRange(LIL_HAUNT_CONTROLLED_RANGE, 0, true);
npc.IsTargetInAttackRange(LIL_HAUNT_CONTROLLED_RANGE);
if (isShooting)
{
npc.UpdateControllerMovement(true);
+2 -1
View File
@@ -704,7 +704,8 @@ static LobArc lob_arc_solve(Entity_Projectile& shot, float distance)
for (int i = 0; i < LOB_TRIES; i++)
{
float time = distance / arc.speed;
float drag = std::max((std::pow(LOB_DRAG, time) - 1) * LOB_DRAG_SCALE, LOB_TIME_MIN);
float decay = (float)std::pow((double)LOB_DRAG, (double)time);
float drag = std::max((decay - 1) * LOB_DRAG_SCALE, LOB_TIME_MIN);
arc.fallingSpeed = (lift - (time - drag) * accel) / drag;
bool isPast =
(step > 0 && arc.fallingSpeed > LOB_FALL_SPEED) || (step < 0 && arc.fallingSpeed < LOB_FALL_SPEED);
+6 -3
View File
@@ -869,7 +869,8 @@ static void hornfel_flee(Entity_NPC& npc)
float goal = vector_angle(vector_sub(npc.pos, aim));
Vector heading = vector_from_angle(npc.v1.x);
npc.v1.x = angle_approach(npc.v1.x, goal, random_unit() * RUN_TURN_RANGE + RUN_TURN);
npc.velocity = vector_add(npc.velocity, vector_scale(heading, HORNFEL_RUN_SPEED * npc.speedMultiplier));
npc.velocity = vector_make(heading.x * HORNFEL_RUN_SPEED * npc.speedMultiplier + npc.velocity.x,
heading.y * HORNFEL_RUN_SPEED * npc.speedMultiplier + npc.velocity.y);
if (!npc.isCollidesWithGrid) return;
Vector normal = npc.gridCollisionNormal;
@@ -968,7 +969,8 @@ static void hornfel_throw_update(Entity_NPC& npc)
Entity* target = npc.GetPlayerTarget();
float lead = random_unit() * THROW_LEAD_RANGE + HORNFEL_THROW_LEAD;
float distance = vector_distance(npc.pos, target->pos);
Vector aimed = vector_add(target->pos, vector_scale(target->velocity, lead * distance));
Vector aimed = vector_make(distance * (target->velocity.x * lead) + target->pos.x,
distance * (target->velocity.y * lead) + target->pos.y);
aimed = room_free_pickup_position_find({.position = aimed});
for (size_t hand = 0; hand < 2; hand++)
{
@@ -1060,7 +1062,8 @@ static void hornfel_charge_finish_update(Entity_NPC& npc, Entity_NPC& cart)
params.color = FINISH_SHOT_COLOR;
Entity* target = npc.GetPlayerTarget();
float distance = vector_distance(npc.pos, target->pos);
Vector aimed = vector_add(target->pos, vector_scale(target->velocity, FINISH_SHOT_LEAD * distance));
Vector aimed = vector_make(target->velocity.x * FINISH_SHOT_LEAD * distance + target->pos.x,
target->velocity.y * FINISH_SHOT_LEAD * distance + target->pos.y);
Entity_Projectile* shot = npc.FireBossProjectiles(1, aimed, FINISH_SHOT_CURVE, params);
shot->scale = FINISH_SHOT_SCALE;
shot->fallingAccel -= FINISH_SHOT_FALL;
+2 -1
View File
@@ -485,7 +485,8 @@ static void horny_dance_cough(Entity_NPC& npc)
params.color = HORNY_LOB_COLOR;
Entity* target = npc.GetPlayerTarget();
float distance = vector_length(vector_sub(npc.pos, target->pos));
Vector lead = vector_add(target->pos, vector_scale(target->velocity, HORNY_AIM_LEAD * distance));
Vector lead = vector_make(target->velocity.x * HORNY_AIM_LEAD * distance + target->pos.x,
target->velocity.y * HORNY_AIM_LEAD * distance + target->pos.y);
for (int i = 0; i < HORNY_LOBS; i++)
{
Entity_Projectile* lob = npc.FireBossProjectiles(1, lead, HORNY_LOB_SPEED, params);
+2 -4
View File
@@ -108,12 +108,11 @@ constexpr int CURVE_REPEAT_PICKS = 3;
constexpr float FACE_ROAR_VOLUME = 0.5f;
// The face volleys: three faces, each a table of up to 16 rings of shots at its own period and offset, rebuilt each
// frame from i2's seed. 1.2 shots of 2 damage from 5 up, floating, every 7 frames, 5 at 5, unless a pattern changes it.
// frame from i2's seed. 1.2 shots of 2 damage, floating, every 7 frames, 5 at 5, unless a pattern changes it.
// The attack lasts 150 frames.
constexpr int FACE_COUNT = 3;
constexpr int FACE_VOLLEY_LIMIT = 16;
constexpr int FACE_MODES = 3;
constexpr float VOLLEY_HEIGHT = 5;
constexpr float VOLLEY_FALL_SPEED = -2;
constexpr float VOLLEY_FALL_ACCEL = -0.09f;
constexpr float VOLLEY_SCALE = 1.2f;
@@ -736,7 +735,7 @@ static void face_pattern_build(Entity_NPC& npc, FaceVolleys& faces, RNG& rng, co
{
FaceVolley& volley = volleys[i];
volley.count = 1;
volley.params.circleAngle = (float)i * PI_F * 2 / (float)count + f.angle + PI_F;
volley.params.circleAngle = (float)i * PI_F * 2 / (float)count + (f.angle + PI_F);
float spread = std::clamp((float)i / (float)count, 0.0f, 1.0f);
volley.params.bulletFlags |= PROJECTILE_CURVE_LEFT | PROJECTILE_NO_WALL_COLLIDE;
volley.params.curvingStrength = spread * SWIRL_CURVE - SWIRL_CURVE / 2;
@@ -759,7 +758,6 @@ static FaceVolleys face_volleys_build(Entity_NPC& npc, int phase)
FaceVolleys faces;
for (FaceVolley& volley : faces.volleys)
{
volley.params.heightModifier = VOLLEY_HEIGHT;
volley.params.fallingSpeedModifier = VOLLEY_FALL_SPEED;
volley.params.fallingAccelModifier = VOLLEY_FALL_ACCEL;
volley.params.scale = VOLLEY_SCALE;
+13 -7
View File
@@ -770,9 +770,12 @@ static void isaac_teleport(Entity_NPC& npc)
npc_sound_play(SOUND_HELL_PORTAL1, 1, 2, champion_pitch_get(npc));
}
// One frame of a light wall: every 8 frames a slanted line of beams one step further across. False once none fits.
// One frame of a light wall: every 8 frames a slanted line of beams one step further across. False once none fits
// (at once outside a wall's frames).
static bool wall_step(Entity_NPC& npc)
{
if (npc.i1 < WALL_FROM_LEFT || npc.i1 >= WALL_END) return false;
Room& room = *g_game->room;
bool isLeft = npc.i1 < WALL_FROM_RIGHT;
int frame = npc.i1 - (isLeft ? WALL_FROM_LEFT : WALL_FROM_RIGHT);
@@ -789,7 +792,9 @@ static bool wall_step(Entity_NPC& npc)
int index = frame / WALL_STEP_FRAMES;
float slant = (float)byte_get(npc, BYTE_WALL_SLANT) / WALL_SLANT_SCALE * (float)index;
Vector shift = vector_scale(vector_normalized(line), slant * WALL_STEP * std::sqrt(2.0f));
Vector across = vector_normalized(line);
float root2 = std::sqrt(2.0f);
Vector shift = vector_make(slant * across.x * WALL_STEP * root2, slant * across.y * WALL_STEP * root2);
Vector start = vector_add(vector_scale(step, (float)index), origin);
EntityConfig_Entity* config = g_manager->entityConfig.GetEntity(ENTITY_EFFECT, EFFECT_CRACK_THE_SKY, 0);
bool isInRoom = false;
@@ -831,7 +836,7 @@ static void wall_update(Entity_NPC& npc, int ticks)
return;
}
for (; ticks > 0 && npc.i1 >= WALL_FROM_LEFT && npc.i1 < WALL_END; ticks--, npc.i1++)
for (; ticks > 0; ticks--, npc.i1++)
if (!wall_step(npc))
{
npc.i1 = STEP_APPEAR;
@@ -922,7 +927,6 @@ constexpr int BABY_SPLAT_ODDS = 10;
constexpr float BABY_SPLAT_MIN = 0.2f;
constexpr float BABY_SPLAT_RANGE = 0.3f;
constexpr float ANGEL_SHOT_RANGE = 200;
constexpr int BABY_SHOT_FRAMES = 7;
constexpr int BABY_SHOT_COOLDOWN = 35;
constexpr float BABY_SHOT_VOLUME = 0.85f;
constexpr float BABY_SHOT_FALL_ACCEL = -0.05f;
@@ -1028,7 +1032,7 @@ static void imp_move_update(Entity_NPC& npc, int ticks)
if (npc.projectileDelay < 1)
{
bool isAttacking = false;
if (npc.controllerID != -1) isAttacking = npc.IsTargetInAttackRange(IMP_CONTROLLED_RANGE, BABY_SHOT_FRAMES, false);
if (npc.controllerID != -1) isAttacking = npc.IsTargetInAttackRange(IMP_CONTROLLED_RANGE);
else if (Random() % IMP_ATTACK_ODDS == 0) isAttacking = npc.IsHostileTo(npc.GetPlayerTarget());
if (isAttacking)
{
@@ -1045,7 +1049,7 @@ static void imp_move_update(Entity_NPC& npc, int ticks)
static void baby_move_update(Entity_NPC& npc, int ticks)
{
if (Random() % BABY_SPLAT_ODDS == 0) npc.MakeSplat(random_unit() * BABY_SPLAT_RANGE + BABY_SPLAT_MIN);
if (npc.projectileCooldown < 1 && npc.IsTargetInAttackRange(ANGEL_SHOT_RANGE, BABY_SHOT_FRAMES, false))
if (npc.projectileCooldown < 1 && npc.IsTargetInAttackRange(ANGEL_SHOT_RANGE))
{
npc.projectileCooldown = BABY_SHOT_COOLDOWN;
npc_anim_restart(npc.sprite, "Attack");
@@ -1170,7 +1174,9 @@ static void imp_dodge(Entity_NPC& npc, float targetDistanceSquared)
dodge = vector_add(dodge, vector_resized(side, push));
count++;
}
if (count > 0) npc.velocity = vector_add(npc.velocity, vector_scale(dodge, npc.speedMultiplier / (float)count));
if (count > 0)
npc.velocity = vector_make(dodge.x / (float)count * npc.speedMultiplier + npc.velocity.x,
dodge.y / (float)count * npc.speedMultiplier + npc.velocity.y);
}
// A controlled Imp dashes while its action is held, slowing as its charge fills, and recharges once released.
+8 -6
View File
@@ -52,7 +52,6 @@ constexpr int HEAD_DASH_FRAMES = 30;
constexpr int DASH_PAST_FRAMES = 8;
constexpr float DASH_PAST_SCALE = 0.5f;
constexpr int DASH_CRY_DELAY = 50;
constexpr float DASH_HOMING = 2;
// The spreads: whole, 12 exploding shots about him; alone, 15 big homing ones at his target. The body sends 12 and up
// to 4 attack flies at 10.
@@ -346,14 +345,17 @@ static void dash_update(Entity_NPC& npc)
npc.sprite.isFlipX = false;
if (npc.isCollidesWithGrid) npc.stateFrame = 0;
npc.velocity = vector_sub(npc.targetPosition, npc.pos);
if (npc.stateFrame != 0) npc.velocity = vector_scale(npc.velocity, 1 / (float)npc.stateFrame);
if (npc.stateFrame != 0)
npc.velocity = vector_make(npc.velocity.x / (float)npc.stateFrame, npc.velocity.y / (float)npc.stateFrame);
return;
}
npc.velocity = npc.v1;
if (npc.isCollidesWithGrid) npc.stateFrame = 0;
npc.sprite.isFlipX = npc.v1.x < 0;
Vector homing = vector_normalized(vector_sub(npc.CalcTargetPosition(0), npc.pos));
npc.velocity = vector_add(npc.velocity, vector_scale(homing, npc.aiFloat * DASH_HOMING * npc.speedMultiplier));
Vector pull = vector_scale(homing, npc.aiFloat);
npc.velocity = vector_make((pull.x + pull.x) * npc.speedMultiplier + npc.velocity.x,
(pull.y + pull.y) * npc.speedMultiplier + npc.velocity.y);
}
// 004830e0 One frame of the Lamb's long pattern, its shots every few frames: turning rings, rings bursting or wide,
@@ -379,7 +381,7 @@ static void lamb_pattern_fire(Entity_NPC& npc, int pattern, int frame)
float turn = (float)frame * (pattern == 0 ? TURNING_RATE : -TURNING_RATE);
speed = TURNING_SPEED;
count = TURNING_COUNT;
params.circleAngle = turn / TURNING_PERIOD * 2 * PI_F;
params.circleAngle = turn / TURNING_PERIOD * (2 * PI_F);
}
else
{
@@ -424,7 +426,7 @@ static void lamb_pattern_fire(Entity_NPC& npc, int pattern, int frame)
if (frame % TRIPLE_SPACING != 0) return;
count = TRIPLE_COUNT;
params.homingStrength = TRIPLE_HOMING;
params.circleAngle = (float)frame * -TURNING_RATE / TURNING_PERIOD * 2 * PI_F;
params.circleAngle = (float)frame * -TURNING_RATE / TURNING_PERIOD * (2 * PI_F);
}
else return;
}
@@ -439,7 +441,7 @@ static void pattern_step(Entity_NPC& npc)
if (npc.i2 < PATTERN_DRIFTING)
{
Vector toTarget = vector_normalized(vector_sub(npc.CalcTargetPosition(0), npc.pos));
npc.velocity = vector_scale(toTarget, npc.aiFloat * PATTERN_DRIFT);
npc.velocity = vector_make(npc.aiFloat * toTarget.x * PATTERN_DRIFT, npc.aiFloat * toTarget.y * PATTERN_DRIFT);
Room& room = *g_game->room;
int others = room.GetAliveEnemiesCount() - room.GetAliveBossesCount();
if (npc.i1 == LAMB_WHOLE && npc.stateFrame % PATTERN_FLY_SPACING == 0 && (Random() & 1) == 0 &&
+6 -12
View File
@@ -341,17 +341,15 @@ static void grub_charge(Entity_NPC& npc)
}
npc.friction *= GRUB_CHARGE_FRICTION;
float speed = npc.controllerID == -1 ? GRUB_CHARGE_SPEED : GRUB_CONTROLLED_CHARGE_SPEED;
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity, vector_scale(npc.targetPosition, speed * npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(vector_scale(npc.targetPosition, speed), false);
}
// A Hollow head bounces about the room in a long or tall gait, turning off the walls, and keeps away from its
// target while feared or shrunk. Confused, it wanders, unless a player controls it.
static void hollow_move(Entity_NPC& npc)
{
if (vector_length_squared(npc.velocity) < HOLLOW_STILL_SPEED_SQUARED && npc.friction != 0)
npc.velocity = vector_add(npc.velocity,
vector_scale(random_direction(), HOLLOW_NUDGE * npc.speedMultiplier / npc.friction));
if (vector_length_squared(npc.velocity) < HOLLOW_STILL_SPEED_SQUARED)
npc.AddVelocity_divided(vector_scale(random_direction(), HOLLOW_NUDGE), false);
Vector sign = vector_make(npc.velocity.x > 0 ? 1 : -1, npc.velocity.y > 0 ? 1 : -1);
bool isTilted = std::abs(npc.velocity.x) >= std::abs(npc.velocity.y) && npc.velocity.y > 0;
@@ -385,16 +383,12 @@ static void hollow_move(Entity_NPC& npc)
for (int i = 0; i < 3; i++) npc.pathfinder.MoveRandomlyBoss(STATUS_OBEYED);
return;
}
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity, vector_scale(vector_make(sign.x * npc.v1.x, sign.y * npc.v1.y),
npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(vector_make(sign.x * npc.v1.x, sign.y * npc.v1.y), false);
if (!npc.HasEntityFlags(FLAG_FEAR | FLAG_SHRINK) || npc.controllerID != -1) return;
Vector away = vector_sub(npc.pos, npc.GetPlayerTarget()->pos);
float strength = std::clamp((LARRY_FLEE_RANGE - vector_length(away)) * LARRY_FLEE_STRENGTH, 0.0f, LARRY_FLEE_MAX);
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity,
vector_scale(vector_resized(away, strength), npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(vector_resized(away, strength), false);
}
// A spitting Larry Jr. (subtype 1) now and then shoots along its way: one shot, three for the Hollow. A controlled
@@ -402,7 +396,7 @@ static void hollow_move(Entity_NPC& npc)
static void larry_spit(Entity_NPC& npc)
{
bool isControlled = npc.controllerID != -1;
if (!(isControlled ? npc.IsTargetInAttackRange(CONTROLLED_ATTACK_RANGE, 0, true) : Random() % SPIT_ODDS == 0)) return;
if (!(isControlled ? npc.IsTargetInAttackRange(CONTROLLED_ATTACK_RANGE) : Random() % SPIT_ODDS == 0)) return;
if (npc.projectileCooldown > 0)
{
npc.projectileCooldown -= npc_ticks_get(npc);
+11 -9
View File
@@ -165,8 +165,8 @@ static void blub_fountain_timer(Entity_Effect* timer)
{
Vector direction = random_direction();
uint32_t seed = Random();
Vector velocity = vector_scale(direction, random_unit() * speed);
Vector position = vector_add(origin, vector_scale(direction, FOUNTAIN_SPREAD * random_unit()));
Vector velocity = vector_scale(vector_scale(direction, random_unit()), speed);
Vector position = vector_add(vector_scale(vector_scale(direction, FOUNTAIN_SPREAD), random_unit()), origin);
auto* shot = static_cast<Entity_Projectile*>(g_game->Spawn({.position = position,
.velocity = velocity,
.type = ENTITY_PROJECTILE,
@@ -244,7 +244,7 @@ static void blub_big_leech_throw(Entity_NPC& npc)
{
Vector gap = vector_sub(npc.GetPlayerTarget()->pos, npc.pos);
float distance = vector_length(gap);
if (distance > BIG_LEECH_REACH) gap = vector_scale(gap, BIG_LEECH_REACH / distance);
if (distance > BIG_LEECH_REACH) gap = vector_scale(vector_normalized(gap), BIG_LEECH_REACH);
Entity_NPC* leech = blub_leech_throw(npc, vector_add(npc.pos, gap), true);
leech->spawnerType = npc.type;
leech->spawnerVariant = (uint32_t)npc.variant;
@@ -275,7 +275,8 @@ static void blub_spray_update(Entity_NPC& npc, float& leechPush)
params.variant = blub_shot_variant();
params.fallingAccelModifier = roll * BLUB_SPRAY_FALL_RANGE + BLUB_SPRAY_FALL;
params.scale = roll * BLUB_SPRAY_SCALE_RANGE + BLUB_SPRAY_SCALE;
Vector velocity = vector_scale(direction, BLUB_SPRAY_SPEED * (roll * SPRAY_SPEED_RANGE + SPRAY_SPEED_SHARE));
Vector velocity =
vector_scale(vector_scale(direction, BLUB_SPRAY_SPEED), roll * SPRAY_SPEED_RANGE + SPRAY_SPEED_SHARE);
Vector scatter = vector_scale(random_direction(), BLUB_SPRAY_SCATTER);
Vector position = vector_add(vector_add(scatter, vector_scale(direction, SPRAY_OUT)), npc.pos);
npc.FireProjectiles(position, velocity, PROJECTILES_SINGLE, params);
@@ -296,7 +297,7 @@ static bool blub_jumps_update(Entity_NPC& npc, float& leechPush, bool isHurt)
g_game->Spawn({.position = npc.pos, .type = ENTITY_EFFECT, .variant = EFFECT_BIG_SPLASH, .seed = Random()})->Update();
Entity* target = npc.GetPlayerTarget();
float distance = vector_distance(npc.pos, target->pos);
Vector lead = vector_add(target->pos, vector_scale(target->velocity, JUMP_LEAD * distance));
Vector lead = vector_add(target->pos, vector_scale(vector_scale(target->velocity, JUMP_LEAD), distance));
Vector landing = g_game->room->GetClampedPositionImpl(lead, BLUB_JUMP_MARGIN, 0, 0, 0);
Vector gap = vector_sub(landing, npc.pos);
float reach = isHurt ? JUMP_HURT_REACH : BLUB_JUMP_REACH;
@@ -332,7 +333,7 @@ static bool blub_jumps_update(Entity_NPC& npc, float& leechPush, bool isHurt)
else
{
npc.friction *= BLUB_JUMP_FRICTION;
npc.velocity = vector_scale(npc.v2, 1 / npc.friction);
npc.velocity = vector_make(npc.v2.x / npc.friction, npc.v2.y / npc.friction);
}
if (npc.stateFrame > 0)
{
@@ -387,8 +388,10 @@ static void blub_burst(Entity_NPC& npc)
for (uint32_t i = Random() % DEATH_LEECHES_RANGE + DEATH_LEECHES; i != 0; i--)
{
float angle = random_unit() * PI_ROUGH * 2;
float reach = random_unit() * DEATH_LEECH_REACH;
blub_leech_throw(npc, vector_add(npc.pos, vector_make(std::cos(angle) * reach, std::sin(angle) * reach)), false);
float reach = random_unit();
Vector spot = vector_make(std::cos(angle) * reach * DEATH_LEECH_REACH + npc.pos.x,
std::sin(angle) * reach * DEATH_LEECH_REACH + npc.pos.y);
blub_leech_throw(npc, spot, false);
}
}
@@ -409,7 +412,6 @@ void boss_lil_blub_update(Entity_NPC& npc)
npc.targetPosition = {};
npc.splatColor = blub_is_sewage() ? SEWAGE_SPLASH_COLOR : WATER_SPLASH_COLOR;
npc.projectileDelay = 0;
npc.stateFrame = 0;
break;
case BLUB_REST:
blub_rest_update(npc, leeches, isHurt);
+6 -10
View File
@@ -163,7 +163,7 @@ static bool horn_wander(Entity_NPC& npc)
Vector step = vector_sub(goal, npc.pos);
float length = vector_length(step);
if (length > MAX_STEP && length > 0) step = vector_scale(step, MAX_STEP / length);
if (npc.friction != 0) npc.velocity = vector_add(npc.velocity, vector_scale(step, npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(step, false);
return isNear;
}
@@ -445,9 +445,7 @@ static void ball_update(Entity_NPC& npc)
if (npc.speedMultiplier != 1)
damping = BALL_DAMPING / ((npc.speedMultiplier + BALL_DAMPING) - npc.speedMultiplier * BALL_DAMPING);
npc.velocity = vector_scale(npc.velocity, damping);
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity, vector_scale(vector_normalized(toward),
BALL_PULL * npc.scale * npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(vector_scale(vector_scale(vector_normalized(toward), BALL_PULL), npc.scale), false);
npc.mass = BALL_MASS;
auto keepOff = [&npc](Entity* other, float strength)
@@ -456,8 +454,7 @@ static void ball_update(Entity_NPC& npc)
Vector away = vector_sub(npc.pos, other->pos);
float distance = vector_length(away);
if (distance > 0) away = vector_scale(away, (BALL_SHY - distance) / distance);
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity, vector_scale(away, strength * npc.speedMultiplier / npc.friction));
npc.AddVelocity_divided(vector_scale(away, strength), false);
};
for (Entity* other : entity_query(ENTITY_LITTLE_HORN, HORN_BALL)) keepOff(other, BALL_SHY_BALLS);
for (Entity* bomb : entity_query(ENTITY_BOMB, -1)) keepOff(bomb, BALL_SHY_BOMBS);
@@ -484,10 +481,9 @@ static void ball_update(Entity_NPC& npc)
Vector scatter = random_direction();
float spread = random_unit();
float speed = vector_length(npc.velocity);
if (trail->friction != 0)
trail->velocity = vector_add(trail->velocity,
vector_scale(scatter, spread * speed * TRAIL_SCATTER * trail->speedMultiplier /
trail->friction));
trail->AddVelocity_divided(vector_make(scatter.x * spread * speed * TRAIL_SCATTER,
scatter.y * spread * speed * TRAIL_SCATTER),
false);
trail->sprite.offset = vector_make(0, SPRITE_HEIGHT);
trail->sprite.scale = vector_make(npc.scale, npc.scale);
}
+1 -1
View File
@@ -175,7 +175,7 @@ static void mask_face(Entity_NPC& npc)
int direction = npc.v1.x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
if (std::abs(npc.v1.x) <= std::abs(npc.v1.y)) direction = npc.v1.y >= 0 ? DIRECTION_DOWN : DIRECTION_UP;
if (npc.sprite.SetAnimation((*anims)[direction], SWITCH_KEEP_FRAME) && npc.sprite.animState.animData)
if (npc.sprite.SetAnimation((*anims)[direction]) && npc.sprite.animState.animData)
{
npc.sprite.animState.SetFrameFloat(0);
if (npc.sprite.animState.animData) npc.sprite.animState.isPlaying = false;
+6 -9
View File
@@ -125,8 +125,8 @@ constexpr int RAGE_LOOSE_FLASH_FRAMES = 15;
constexpr int LEAD_EVERY = 15;
constexpr uint32_t LEAD_CROWD_ODDS = 100;
// At a fifth of her health she bursts (a Fistula 40 out at 2 to 4, see below) and turns into a three-part Chub at a
// fifth of her health, her parts at her full health, in front of her.
// At a fifth of her health she bursts (a medium and two small Fistulas 40 out at 2 to 4) and turns into a three-part
// Chub at a fifth of her health, her parts at her full health, in front of her.
constexpr float DEATH_HEALTH = 0.2f;
constexpr int DEATH_BURST_FISTULAS = 3;
constexpr int CHUB_SUBTYPE = 1000;
@@ -276,7 +276,7 @@ static Vector matriarch_shot_aim(Entity_NPC& npc)
{
Entity* target = npc.GetPlayerTarget();
float distance = vector_distance(npc.pos, target->pos);
Vector aim = vector_add(target->pos, vector_scale(target->velocity, MATRIARCH_SHOT_LEAD * distance));
Vector aim = vector_add(vector_scale(vector_scale(target->velocity, MATRIARCH_SHOT_LEAD), distance), target->pos);
return g_game->room->GetClampedPositionImpl(aim, SHOT_MARGIN, SHOT_MARGIN, SHOT_MARGIN, SHOT_MARGIN);
}
@@ -409,12 +409,9 @@ static void matriarch_rage_update(Entity_NPC& npc)
static void matriarch_burst(Entity_NPC& npc)
{
npc_sound_play(SOUND_ROCKET_BLAST_DEATH, 1, 2, 1);
uint32_t burst = Random();
g_game->Spawn({.position = npc.pos, .spawner = &npc, .type = ENTITY_EFFECT, .variant = EFFECT_LARGE_BLOOD_EXPLOSION, .seed = burst});
// The original counts its Fistulas on from the burst's seed, so all but one seed in a billion throw one small Fistula.
uint32_t thrown = burst;
do matriarch_fistula_throw(npc, thrown != 0 ? ENTITY_FISTULA_SMALL : ENTITY_FISTULA_MEDIUM, random_direction());
while (++thrown < DEATH_BURST_FISTULAS);
g_game->Spawn({.position = npc.pos, .spawner = &npc, .type = ENTITY_EFFECT, .variant = EFFECT_LARGE_BLOOD_EXPLOSION, .seed = Random()});
for (int i = 0; i < DEATH_BURST_FISTULAS; i++)
matriarch_fistula_throw(npc, i != 0 ? ENTITY_FISTULA_SMALL : ENTITY_FISTULA_MEDIUM, random_direction());
if (Entity* led = npc.child.get())
{
+1 -1
View File
@@ -149,7 +149,7 @@ static void mega_maw_red_rings(Entity_NPC& npc)
PROJECTILES_RING, params);
case 1:
params.bulletFlags |= PROJECTILE_BOOMERANG;
params.circleAngle = angle_wrap(random_unit() * MEGA_MAW_FULL_TURN);
params.circleAngle = normalize_angle_degrees(random_unit() * MEGA_MAW_FULL_TURN);
break;
case 2:
params.bulletFlags |= PROJECTILE_MEGA_WIGGLE | PROJECTILE_NO_WALL_COLLIDE;
+4 -1
View File
@@ -445,7 +445,7 @@ void boss_mega_satan_hand_update(Entity_NPC& hand)
hand.sprite.Play("Appear");
}
}
else if (body && body->state == MEGA_HIDE && hand.state != MEGA_HIDE)
if (body && body->state == MEGA_HIDE && hand.state != MEGA_HIDE && hand.state != MEGA_RISE)
{
hand.state = MEGA_HIDE;
hand.stateFrame = 0;
@@ -1143,8 +1143,11 @@ static void summon_update(Entity_NPC& npc)
Room& room = *g_game->room;
Vector spot = vector_make(room.topLeftPos.x + WAVE_MARGIN, room.bottomRightPos.y - WAVE_MARGIN);
for (int i = 0; i < HOLLOW_SEGMENTS; i++)
{
spot = room_free_pickup_position_find({.position = spot});
g_game->Spawn({.position = spot, .spawner = &npc, .type = spawn.type, .variant = spawn.variant,
.seed = Random()});
}
}
}
if (npc_anim_is_done(npc))
+17 -9
View File
@@ -140,7 +140,7 @@ static void willo_siblings_spread(Entity_NPC& npc)
if (siblings.size() < 2) return;
float step = TAU / (float)siblings.size();
for (size_t i = 0; i < siblings.size(); i++) siblings[i]->v2.x = angle_wrap((float)i * step + lowest);
for (size_t i = 0; i < siblings.size(); i++) siblings[i]->v2.x = normalize_angle_degrees((float)i * step + lowest);
}
// 00558070 Where a Willo circles: its parent, or the players' middle (Tainted Forgotten's body aside), and how far
@@ -194,17 +194,23 @@ static void willo_place(Entity_NPC& npc, int slot, float distance)
// The way what it circles moves: its parent's velocity against its friction, or the players' on average, doubled.
static Vector willo_drift(Entity_NPC& npc)
{
if (npc.parent) return vector_scale(npc.parent->velocity, 2 / npc.parent->friction);
if (npc.parent)
{
Vector pace = vector_make(npc.parent->velocity.x / npc.parent->friction,
npc.parent->velocity.y / npc.parent->friction);
return vector_add(pace, pace);
}
Vector sum{};
int count = 0;
for (Entity_Player* player : g_game->playerManager.playerList)
if (player->variant == PLAYER_VARIANT_PLAYER)
{
sum = vector_add(sum, vector_scale(player->velocity, 2 / player->friction));
Vector pace = vector_make(player->velocity.x / player->friction, player->velocity.y / player->friction);
sum = vector_add(vector_add(sum, pace), pace);
count++;
}
return vector_scale(sum, 1 / (float)count);
return vector_make(sum.x / (float)count, sum.y / (float)count);
}
// 005581b0 A bound Willo steers to its slot (at most 10 a frame) on top of the drift of what it circles, its first
@@ -219,7 +225,7 @@ static void willo_orbit(Entity_NPC& npc)
Vector drift = willo_drift(npc);
Vector steer = vector_scale(vector_sub(slot, vector_add(npc.pos, drift)), WILLO_STEER);
if (vector_length(steer) > WILLO_STEER_MAX) steer = vector_scale(vector_normalized(steer), WILLO_STEER_MAX);
npc.velocity = vector_scale(vector_add(steer, drift), 1 / npc.friction);
npc.velocity = vector_make((steer.x + drift.x) / npc.friction, (steer.y + drift.y) / npc.friction);
}
// The fire shot Willos throw: a tear shot through walls.
@@ -466,12 +472,13 @@ static void min_min_head_update(Entity_NPC& npc)
{
Entity* target = npc.ParentNPC()->GetPlayerTarget();
float distance = vector_length(vector_sub(npc.pos, target->pos));
Vector lead = vector_add(target->pos, vector_scale(target->velocity, distance * THROW_LEAD));
npc.v1.x = angle_wrap(vector_angle(vector_sub(lead, npc.pos)) - npc.v2.x) <= 0 ? -HEAD_TURN : HEAD_TURN;
Vector lead = vector_make(target->velocity.x * distance * THROW_LEAD + target->pos.x,
target->velocity.y * distance * THROW_LEAD + target->pos.y);
npc.v1.x = normalize_angle_degrees(vector_angle(vector_sub(lead, npc.pos)) - npc.v2.x) <= 0 ? -HEAD_TURN : HEAD_TURN;
}
float home = vector_angle(vector_sub(npc.parent->pos, npc.pos));
float turn = npc.v1.x * npc.speedMultiplier;
npc.v2.x = std::abs(turn) <= std::abs(angle_wrap(npc.v2.x - home)) ? angle_wrap(npc.v2.x + turn) : home;
npc.v2.x = std::abs(turn) <= std::abs(normalize_angle_degrees(npc.v2.x - home)) ? normalize_angle_degrees(npc.v2.x + turn) : home;
if (min_min_willos(npc).empty()) npc.Remove();
}
@@ -686,7 +693,8 @@ static void min_min_throw(Entity_NPC& npc)
Entity* target = npc.GetPlayerTarget();
float distance = vector_length(vector_sub(npc.pos, target->pos));
Vector lead = vector_add(target->pos, vector_scale(target->velocity, distance * THROW_LEAD));
Vector lead = vector_make(target->pos.x + target->velocity.x * distance * THROW_LEAD,
target->pos.y + target->velocity.y * distance * THROW_LEAD);
Vector aim = vector_scale(vector_normalized(vector_sub(lead, npc.pos)), MIN_MIN_THROW_SPEED);
auto* head = static_cast<Entity_NPC*>(g_game->Spawn(
{.position = npc.pos, .spawner = &npc, .type = ENTITY_MIN_MIN, .variant = MIN_MIN_HEAD, .seed = Random()}));
+7 -5
View File
@@ -126,8 +126,6 @@ constexpr int CURSED_GLOBINS_MAX = 2;
// DamageRadius hurts with a 30 frame countdown, and passes 3.5 to the tear effects. Enemies are types 10 to 999.
constexpr int RADIUS_DAMAGE_COUNTDOWN = 30;
constexpr float RADIUS_TEAR_DAMAGE = 3.5f;
constexpr int ENTITY_NPC_FIRST = 10;
constexpr int ENTITY_NPC_LAST = 999;
// 006fed60 Game::DamageRadius: everything collidable within reach of a spot is hurt, players and familiars by 1 (2
// for a hit of the threshold or more) unless a friendly enemy dealt it, enemies (with the tear effects) only when a
@@ -156,7 +154,7 @@ void damage_radius(const RadiusDamage& hit)
float damage = hit.damage < hit.playerDamageThreshold ? 1 : 2;
entity->TakeDamage(damage, hit.damageFlags, sourceRef, RADIUS_DAMAGE_COUNTDOWN);
}
else if (entity->type >= ENTITY_NPC_FIRST && entity->type <= ENTITY_NPC_LAST && isDamageEnemies)
else if (entity->type >= ENTITY_FIRST_ENEMY && entity->type <= ENTITY_LAST_ENEMY && isDamageEnemies)
{
entity->TakeDamage(hit.damage, hit.damageFlags, sourceRef, RADIUS_DAMAGE_COUNTDOWN);
Entity_Tear::ApplyTearFlagEffects(entity, hit.position, hit.tearFlags, source, RADIUS_TEAR_DAMAGE);
@@ -594,8 +592,12 @@ static void part_update(Entity_NPC& npc, int prevState)
if (npc.state == NPC_STATE_ATTACK2 && sprite.animState.animData && sprite.IsEventTriggered("Appear"))
{
npc.PlaySound(SOUND_FORESTBOSS_STOMPS, ARM_VOLUME, 2, false, 1);
Vector reach = vector_scale(vector_from_angle(npc.sprite.rotation + 90), ARM_SLAP_REACH);
damage_radius({.position = vector_add(npc.pos, reach),
float turn = npc.sprite.rotation * DEGREES_TO_RADIANS;
float cosine = std::cos(turn);
float sine = std::sin(turn);
Vector slap = vector_make(cosine * 0 - sine * ARM_SLAP_REACH + npc.pos.x,
sine * 0 + cosine * ARM_SLAP_REACH + npc.pos.y);
damage_radius({.position = slap,
.source = &npc,
.damage = ARM_SLAP_DAMAGE,
.playerDamageThreshold = ARM_SLAP_STRONG,
+4 -7
View File
@@ -167,9 +167,6 @@ constexpr int DEATH_RING = 14;
constexpr float DEATH_RING_SPEED = 5;
constexpr int HEART_DEATH_BLOOD_FRAMES = 30;
constexpr int HEART_DEATH_BLOOD_DROPS = 7;
constexpr int ENTITY_MOTHER_BALL = 866;
constexpr int DEATH_TARGET_FIRST = 10;
constexpr int DEATH_TARGET_LAST = 1000;
// The sweeping lasers: 4 (the Mausoleum's 2) from 30 above the heart, after a 15 to 44 frame wait turning 2 a frame
// for 1 to 4 half turns either way. The Mausoleum's turn 0.3 a frame without end, a timeout so far below zero that it
@@ -872,13 +869,13 @@ static void heart_mausoleum_escape()
}
// Whether the heart's death takes an entity with it: an enemy (or a versus player) that holds the doors, not Mother's
// ball or a friendly one.
// Whether the heart's death takes an entity with it: an enemy (or a versus player) that holds the doors, not Dark Esau
// or a friendly one.
static bool is_death_target(Entity& entity)
{
bool isFoe = (entity.type >= DEATH_TARGET_FIRST && entity.type <= DEATH_TARGET_LAST) ||
bool isFoe = (entity.type >= ENTITY_FIRST_ENEMY && entity.type < ENTITY_EFFECT) ||
(g_game->deathmatchManager.is_active() && entity.type == ENTITY_PLAYER);
return isFoe && entity.CanShutDoors() && entity.type != ENTITY_MOTHER_BALL && !entity.HasEntityFlags(FLAG_FRIENDLY);
return isFoe && entity.CanShutDoors() && entity.type != ENTITY_DARK_ESAU && !entity.HasEntityFlags(FLAG_FRIENDLY);
}
// The heart's death: its cry, every enemy left killed by it, its beating sprite killed, blood from the walls, and in
+3 -2
View File
@@ -240,7 +240,7 @@ static int attack_roll(Entity_NPC& npc)
// it is told, or waits. Monstro II's spit shows a tracer where its laser will fire.
static void monstro_idle(Entity_NPC& npc, const MonstroControl* control)
{
if (npc.sprite.SetAnimation("Walk", SWITCH_KEEP_FRAME) && npc.sprite.animState.animData)
if (npc.sprite.SetAnimation("Walk") && npc.sprite.animState.animData)
{
npc.sprite.animState.SetFrameFloat(0);
npc.sprite.animState.isPlaying = false;
@@ -358,7 +358,8 @@ static void monstro_hop(Entity_NPC& npc, const Vector& target, const MonstroCont
if (distance == 0) distance = HOP_MIN_DISTANCE;
float pull = MONSTRO_HOP_PULL / distance * (is_quick(npc) ? QUICK_HOP_PULL : 1);
if (npc.friction != 0)
npc.velocity = vector_add(npc.velocity, vector_scale(toward, pull * npc.speedMultiplier / npc.friction));
npc.velocity = vector_make(toward.x * pull * npc.speedMultiplier / npc.friction + npc.velocity.x,
toward.y * pull * npc.speedMultiplier / npc.friction + npc.velocity.y);
npc.friction *= MONSTRO_FRICTION;
npc.sprite.isFlipX = npc.velocity.x > 0;
return;
+7 -3
View File
@@ -614,7 +614,8 @@ static void mother_transition_start(Entity_NPC& npc)
npc_sound_play(SOUND_MOTHER_DEATH1, 1, 2, 1);
}
// 00568cc0 Spawns her head and arms about her body, kept in its deque, the head as its child and an arm as the head's.
// 00568cc0 Spawns her head and arms about her body, kept in its deque, the left arm as its child and the right arm as
// the left arm's.
static void mother_parts_spawn(Entity_NPC& npc)
{
std::array<Entity_NPC*, 3> parts{};
@@ -672,8 +673,11 @@ static void mother_wall_spawn(Vector position, WallPiece piece)
for (size_t layer = 1; layer < sprite.layerStates.size(); layer++)
sprite.GetLayer((int)layer)->isVisible = false;
else sprite.GetLayer(0)->isVisible = false;
if (sprite.SetAnimation("Idle", SWITCH_KEEP_FRAME) && sprite.animState.animData) sprite.animState.SetFrameFloat(0);
if (sprite.animState.animData) sprite.animState.isPlaying = false;
if (sprite.SetAnimation("Idle") && sprite.animState.animData)
{
sprite.animState.SetFrameFloat(0);
if (sprite.animState.animData) sprite.animState.isPlaying = false;
}
if (piece == WALL_SHADE) sprite.GetLayer(0)->blendMode = MOTHER_WALL_SHADE_BLEND;
wall->sortingLayer = piece == WALL_SHADE ? SORTING_BACKGROUND : SORTING_DOOR;
}
+1 -1
View File
@@ -10,7 +10,7 @@ constexpr int RAINMAKER_RAIN_ABOUT = NPC_STATE_ATTACK2;
constexpr int RAINMAKER_GATHER = NPC_STATE_ATTACK3;
// It walks at its target at 0.5 (1.3 while raining about it), slowed to 0.7 a frame, and picks an attack one frame in
// 20: the line one time in three (crossways two times in three when the target is not level with it).
// 20: the line one time in three (crossways one time in two when the target is not level with it).
constexpr float RAINMAKER_FRICTION = 0.7f;
constexpr float RAINMAKER_WALK_SPEED = 0.5f;
constexpr float RAIN_WALK_SPEED = 1.3f;
+4 -3
View File
@@ -656,7 +656,7 @@ static void face_fall_pull(Entity_NPC& npc, Entity& entity, float pull)
if (vector_length_squared(vector_sub(npc.pos, entity.pos)) >= FALL_REACH_SQUARED) return;
bool isVersusPlayer = g_game->deathmatchManager.is_active() && entity.type == ENTITY_PLAYER;
bool isNpc = entity.type >= 10 && entity.type <= 999;
bool isNpc = entity.type >= ENTITY_FIRST_ENEMY && entity.type <= ENTITY_LAST_ENEMY;
if (isVersusPlayer || (isNpc && !entity.IsBoss()))
{
entity.Kill(EntityRef(&npc));
@@ -693,7 +693,7 @@ static void face_fall_update(Entity_NPC& npc, int ticks)
if (npc.stateFrame > FALL_FRAMES)
{
Game& game = *g_game;
game.leaveDoor = -1;
game.enterDoor = -1;
game.dungeonReturnPosition = npc.pos;
// 0057be90 The dungeon's return room, held between -20 and 168.
game.dungeonReturnRoomIndex =
@@ -835,7 +835,8 @@ static void maggot_suck(Entity_NPC& npc, float push)
{
if (entity == &npc) continue;
bool isVersusPlayer = g_game->deathmatchManager.is_active() && entity->type == ENTITY_PLAYER;
bool isNpc = entity->type >= 10 && entity->type <= 999 && entity->type != ENTITY_FIREPLACE;
bool isNpc =
entity->type >= ENTITY_FIRST_ENEMY && entity->type <= ENTITY_LAST_ENEMY && entity->type != ENTITY_FIREPLACE;
bool isPlayer = isVersusPlayer || entity->type == ENTITY_PLAYER;
if (!isNpc && !isPlayer && entity->type != ENTITY_TEAR && entity->type != ENTITY_PROJECTILE) continue;
+7 -5
View File
@@ -42,6 +42,7 @@ constexpr std::array<int, SCOURGE_ATTACKS> SCOURGE_ATTACK_STATES = {
SCOURGE_IDLE, SCOURGE_TRAP, SCOURGE_SLICE, SCOURGE_SLICE, SCOURGE_BROCCOLI, SCOURGE_HOVER};
constexpr std::array<uint8_t, SCOURGE_ATTACKS> SCOURGE_ATTACK_COOLDOWNS = {0, 90, 90, 54, 15, 90};
constexpr float SCOURGE_COOLDOWN_EVERY = 10;
constexpr int SCOURGE_TRAP_WEIGHT = 100;
constexpr int SCOURGE_ATTACK_WEIGHT = 10;
constexpr int SCOURGE_REST_WEIGHT = 1;
constexpr float SCOURGE_TRAP_BELOW = 0.95f;
@@ -169,7 +170,8 @@ constexpr float SCOURGE_SHOT_RAISE = 10;
constexpr float SCOURGE_SHOT_FALL = -0.14f;
constexpr float SCOURGE_FAN_INSET = 20;
constexpr float SCOURGE_FAN_MIN = 10;
constexpr float SCOURGE_FAN_DENSITY = 0.707f * 12;
constexpr float SCOURGE_FAN_ROUGH_DIAGONAL = 0.707f;
constexpr float SCOURGE_FAN_DENSITY = 12;
constexpr float SCOURGE_GAP_SWAY = 20;
constexpr float SCOURGE_GAP_WIDTH = 5;
constexpr float SCOURGE_FAN_SPEED = 4;
@@ -457,7 +459,7 @@ static void scourge_attack_pick(Entity_NPC& npc)
Vector toward = vector_sub(lead, npc.pos);
float length = vector_length(toward);
float down = length <= 0 ? toward.y : toward.y * (1 / length);
if (down > SCOURGE_TRAP_BELOW) picker.AddOutcomeWeight(SCOURGE_ATTACK_TRAP, SCOURGE_ATTACK_WEIGHT);
if (down > SCOURGE_TRAP_BELOW) picker.AddOutcomeWeight(SCOURGE_ATTACK_TRAP, SCOURGE_TRAP_WEIGHT);
}
if (cooldowns[SCOURGE_ATTACK_SLICE_BOTH] == 0 && isBelow)
picker.AddOutcomeWeight(SCOURGE_ATTACK_SLICE_BOTH, SCOURGE_ATTACK_WEIGHT);
@@ -516,10 +518,10 @@ static void scourge_volley(Entity_NPC& npc)
Vector second = vector_sub(chain_tip_position(npc.entityRef.get()), npc.pos);
first = vector_normalized(first);
second = vector_normalized(second);
float spread = angle_wrapped(vector_angle(first) - vector_angle(second));
float spread = normalize_angle_degrees(vector_angle(first) - vector_angle(second));
float half = std::max(std::abs(spread * HALF) - SCOURGE_FAN_INSET, SCOURGE_FAN_MIN);
Vector across = vector_sub(second, first);
int shots = std::max((int)(vector_length(across) * SCOURGE_FAN_DENSITY), 1) + 1;
int shots = std::max((int)(vector_length(across) * SCOURGE_FAN_ROUGH_DIAGONAL * SCOURGE_FAN_DENSITY), 1) + 1;
Random();
float gap = std::clamp((random_unit() - HALF) * SCOURGE_GAP_SWAY + npc.vectorDeque1[1].y, -half, half);
@@ -655,7 +657,7 @@ static void scourge_ring_update(Entity_NPC& npc, const Vector& center, int frame
shot->friction = SCOURGE_RING_BIG_FRICTION;
}
npc.vectorDeque1[0].x = angle_wrapped(npc.vectorDeque1[0].y + npc.vectorDeque1[0].x);
npc.vectorDeque1[0].x = normalize_angle_degrees(npc.vectorDeque1[0].y + npc.vectorDeque1[0].x);
npc.vectorDeque1[0].y = angle_approach(npc.vectorDeque1[0].y, npc.vectorDeque1[1].x, npc.speedMultiplier + npc.speedMultiplier);
if (Random() % SCOURGE_HOVER_REVERSE_ODDS == 0) npc.vectorDeque1[1].x = -npc.vectorDeque1[1].x;
}
+1 -1
View File
@@ -63,7 +63,7 @@ constexpr float ROLL_FRICTION = 0.7f;
// Sets its roll animation still at the frame its turn shows.
static void singe_ball_roll_set(Entity_NPC& npc, std::string_view animation)
{
if (npc.sprite.SetAnimation(animation, SWITCH_KEEP_FRAME) && npc.sprite.animState.animData)
if (npc.sprite.SetAnimation(animation) && npc.sprite.animState.animData)
{
npc.sprite.animState.SetFrameFloat(0);
if (npc.sprite.animState.animData) npc.sprite.animState.isPlaying = false;
-9
View File
@@ -105,15 +105,6 @@ struct SistersView
bool isSisterInactive = false;
};
// 00682740 An angle in degrees brought into -180 to 180.
float normalize_angle_degrees(float angle)
{
if (std::abs(angle) > FULL_TURN_DEGREES) angle = std::fmod(angle, FULL_TURN_DEGREES);
if (angle > HALF_TURN_DEGREES) return angle - FULL_TURN_DEGREES;
if (angle < -HALF_TURN_DEGREES) angle += FULL_TURN_DEGREES;
return angle;
}
// The angle a sister faces along a direction (left, up, right, down).
static float sisters_direction_angle(int direction)
{
+2 -2
View File
@@ -148,7 +148,7 @@ static void head_anim(Entity_NPC& npc)
return;
}
int frame = rotate_frame_get(angle_wrap(npc.v1.y)) * 2;
int frame = rotate_frame_get(normalize_angle_degrees(npc.v1.y)) * 2;
const NullFrame* bounce =
npc.sprite.overlayAnimState.animData ? npc.sprite.overlayAnimState.GetNullFrame("Bounce") : nullptr;
if (bounce && bounce->color._tint[0] > 0) frame++;
@@ -314,7 +314,7 @@ static void shell_head_roll(Entity_NPC& npc)
if (npc.isCollidesWithGrid)
{
npc.v1.y = vector_angle(npc.velocity);
float diagonal = angle_wrap(std::floor(npc.v1.y / SHELL_DIAGONAL_STEP) * SHELL_DIAGONAL_STEP + SHELL_DIAGONAL);
float diagonal = normalize_angle_degrees(std::floor(npc.v1.y / SHELL_DIAGONAL_STEP) * SHELL_DIAGONAL_STEP + SHELL_DIAGONAL);
npc.v1.y = angle_approach(npc.v1.y, diagonal, random_unit() * SHELL_TURN_RANGE + SHELL_TURN_MIN);
}
Entity_NPC* previous = &npc;
+5 -4
View File
@@ -107,14 +107,14 @@ static void knockdown_start(Entity_NPC& npc)
npc.PlaySound(SOUND_WAR_KNOCKDOWN, 1, 2, false, 1);
}
// Below half health War loses his horse in a blood explosion and goes on on foot (a Delirium form keeps its health).
// Below half health War loses his horse in an explosion and goes on on foot (a Delirium form keeps its health).
static void war_unhorse(Entity_NPC& npc)
{
float maxHealth = npc.maxHitPoints;
g_game->Spawn({.position = npc.pos,
.spawner = &npc,
.type = ENTITY_EFFECT,
.variant = EFFECT_BLOOD_EXPLOSION,
.variant = EFFECT_BOMB_EXPLOSION,
.seed = Random()});
npc.Morph(npc.type, WAR_ON_FOOT, npc.subtype, -1);
if (npc.HasEntityFlags(FLAG_DELIRIUM_FORM))
@@ -303,8 +303,9 @@ static void conquest_clone_spawn(Entity_NPC& npc)
npc.PlaySound(SOUND_MONSTER_YELL_A, CLONE_VOLUME, 2, false, 1);
float x = npc.velocity.x <= 0 ? room.bottomRightPos.x + WRAP_REACH : room.topLeftPos.x - WRAP_REACH;
float half = (room.bottomRightPos.y - room.topLeftPos.y) * 0.5f;
float y = random_unit() * half + (room.topLeftPos.y + CLONE_TOP_MARGIN);
y += (float)(npc.i2++ % 3) * half * 0.5f;
float rise = random_unit();
int lane = npc.i2++ % 3;
float y = (float)lane * half * 0.5f + rise * half + room.topLeftPos.y + CLONE_TOP_MARGIN;
if (room.bossId == BOSS_ID_MEGA_SATAN)
y = random_unit() * (room.bottomRightPos.y - HORSEMAN_MEGA_SATAN_FLOOR - MEGA_SATAN_CLONE_SPAN_CUT) +
MEGA_SATAN_CLONE_TOP;
+2 -2
View File
@@ -1317,7 +1317,7 @@ Vector Entity::GetNullOffset(std::string_view nullLayerName)
// 0085dcb0 Shows a frame of an animation, stopped.
void Entity::SetSpriteFrame(std::string_view animation, int frame)
{
if (!sprite.SetAnimation(animation, SWITCH_KEEP_FRAME) || !sprite.animState.animData) return;
if (!sprite.SetAnimation(animation) || !sprite.animState.animData) return;
sprite.animState.SetFrameFloat((float)frame);
if (sprite.animState.animData) sprite.animState.isPlaying = false;
@@ -1326,7 +1326,7 @@ void Entity::SetSpriteFrame(std::string_view animation, int frame)
// 0085dd00 Shows a frame of an overlay animation.
void Entity::SetSpriteOverlayFrame(std::string_view animation, int frame)
{
if (!sprite.SetOverlayAnimation(animation, SWITCH_KEEP_FRAME) || !sprite.overlayAnimState.animData) return;
if (!sprite.SetOverlayAnimation(animation) || !sprite.overlayAnimState.animData) return;
sprite.overlayAnimState.SetFrameFloat((float)frame);
}
+2 -2
View File
@@ -874,7 +874,7 @@ void Entity_Bomb::rocket_thrust_update()
// A boomerang rocket turns back toward its parent, harder as it speeds up.
void Entity_Bomb::rocket_boomerang_update()
{
float turn = angle_wrap(vector_angle(vector_sub(parent->pos, pos)) - rocketAngle);
float turn = normalize_angle_degrees(vector_angle(vector_sub(parent->pos, pos)) - rocketAngle);
float share = std::clamp((rocketSpeed - ROCKET_BOOMERANG_START) / ROCKET_BOOMERANG_RAMP, 0.0f, 1.0f);
rocketAngle += share * ROCKET_BOOMERANG_TURN * turn * speedMultiplier;
}
@@ -883,7 +883,7 @@ void Entity_Bomb::rocket_boomerang_update()
// other frame while it shows.
void Entity_Bomb::rocket_sprite_update(float shownAngle)
{
float angle = angle_wrap(shownAngle);
float angle = normalize_angle_degrees(shownAngle);
sprite.isFlipX = false;
if (HasEntityFlags(FLAG_HELD)) angle = 0;
else if (angle > RIGHT_ANGLE_DEGREES || angle < -RIGHT_ANGLE_DEGREES)
+1 -4
View File
@@ -17,9 +17,6 @@ constexpr float SHADOW_SIZE_SCALE = 100;
constexpr float BOSS_PORTRAIT_ORIGIN_X = 96;
constexpr float BOSS_PORTRAIT_ORIGIN_Y = 132;
// Types that share one id by variant, so a mod's clashing entity takes the next variant instead of the next type.
constexpr int ENTITY_FIRST_NPC = 10;
// What tags and gibFlags read, each name standing for its index's bit.
constexpr std::array<std::string_view, 10> ENTITY_TAG_NAMES = {
"fly", "spider", "poop", "ghost", "noreroll", "cansacrifice", "explosive_soul", "homing_soul", "brimstone_soul",
@@ -462,7 +459,7 @@ bool EntityConfig::LoadEntities(std::string_view path, ModEntry* mod)
while (mod && entities.contains(entity_key(entity.id, entity.variant, entity.subtype)))
{
int id = entity.id;
if (id == ENTITY_EFFECT || id == ENTITY_TEXT || id < ENTITY_FIRST_NPC) entity.variant++;
if (id == ENTITY_EFFECT || id == ENTITY_TEXT || id < ENTITY_FIRST_ENEMY) entity.variant++;
else entity.id += id + 1 == ENTITY_TEXT || id + 1 == ENTITY_EFFECT ? 2 : 1;
}
+2 -11
View File
@@ -147,15 +147,6 @@ EffectUpdateEnd effect_poof_update(Entity_Effect& effect)
return EFFECT_UPDATE_FINISH;
}
// An angle in degrees wrapped into -180 to 180, as approach_angle wraps it.
float angle_wrapped(float angle)
{
if (std::fabs(angle) > DEGREES_PER_TURN) angle = std::fmod(angle, DEGREES_PER_TURN);
if (angle > DEGREES_PER_TURN / 2) return angle - DEGREES_PER_TURN;
if (angle < -DEGREES_PER_TURN / 2) return angle + DEGREES_PER_TURN;
return angle;
}
// 00a10210 (Vector::Lerp) Moves a vector t of the way to a target.
void vector_lerp(Vector& v, Vector target, float t)
{
@@ -166,9 +157,9 @@ void vector_lerp(Vector& v, Vector target, float t)
// 00682a50 An angle in degrees turned toward a target by at most a step, reaching it when within the step.
float angle_approach(float current, float target, float maxStep)
{
float delta = angle_wrapped(target - current);
float delta = normalize_angle_degrees(target - current);
if (std::fabs(delta) <= maxStep) return target;
return angle_wrapped(delta > 0 ? current + maxStep : current - maxStep);
return normalize_angle_degrees(delta > 0 ? current + maxStep : current - maxStep);
}
// Plays a sound through the seeds' fart override.
-1
View File
@@ -440,7 +440,6 @@ void layer_normal_set(LayerState& layer);
// The degrees of a full turn.
constexpr float DEGREES_PER_TURN = 360;
float angle_wrapped(float angle);
float angle_approach(float current, float target, float maxStep);
void vector_lerp(Vector& v, Vector target, float t);
+2 -2
View File
@@ -225,7 +225,7 @@ static EffectUpdateEnd attract_update(Entity_Effect& ring)
if (!vector_is_zero(ring.targetPosition))
ring.velocity = vector_scale(vector_sub(ring.targetPosition, ring.pos),
std::min(ring.updateTime * RING_PULL_RATE, 1.0f));
ring.sprite.rotation = angle_wrap(ring.sprite.rotation + ring.rotation);
ring.sprite.rotation = normalize_angle_degrees(ring.sprite.rotation + ring.rotation);
ring.sprite.scale = vector_make(ring.scale * ring.maxRadius, ring.scale * ring.maxRadius);
alpha = faded * RING_ALPHA;
return EFFECT_UPDATE_FINISH;
@@ -248,7 +248,7 @@ static EffectUpdateEnd attract_update(Entity_Effect& ring)
}
else
{
ring.sprite.rotation = angle_wrap(ring.sprite.rotation + ring.rotation);
ring.sprite.rotation = normalize_angle_degrees(ring.sprite.rotation + ring.rotation);
float size = ring.scale * ring.maxRadius / RING_SIZE;
ring.sprite.scale = vector_make(size, size);
}
+31 -49
View File
@@ -29,7 +29,6 @@ constexpr float PULLING_PULSE_RATE = 0.1f;
constexpr int ROOM_BARREN_TYPE = 19;
constexpr int SOUND_DROPLET_SPLASH = 397;
constexpr int SOUND_SPAWNER_SUMMON = 265;
constexpr int DOOR_STATE_KEEPS_DECORATIONS = 7;
constexpr int RENDER_Z_DECORATION_LIMIT = 0x40000000;
constexpr float NEAR_PLAYER_RANGE_SQUARED = 10000;
@@ -157,15 +156,6 @@ static bool is_listed(const std::array<int, N>& list, int value)
return std::find(list.begin(), list.end(), value) != list.end();
}
// normalize_angle_degrees 00682740: an angle brought into -180 to 180.
static float angle_normalized(float angle)
{
if (std::abs(angle) > FULL_TURN_DEGREES) angle = std::fmod(angle, FULL_TURN_DEGREES);
if (angle > HALF_TURN_DEGREES) return angle - FULL_TURN_DEGREES;
if (angle < -HALF_TURN_DEGREES) angle += FULL_TURN_DEGREES;
return angle;
}
static float distance_squared(Vector a, Vector b)
{
@@ -279,7 +269,7 @@ static void tiny_bug_update(Entity_Effect& bug)
bug.AddVelocity_divided(vector_scale(vector_normalized(vector_sub(bug.pos, player->pos)), push), false);
bug.state = random_below(BUG_FLEE_SPAN) + BUG_FLEE_MIN;
}
bug.rotation = angle_normalized(random_unit() * BUG_TURN_SPAN + bug.rotation - BUG_TURN_BACK);
bug.rotation = normalize_angle_degrees(random_unit() * BUG_TURN_SPAN + bug.rotation - BUG_TURN_BACK);
bug.pos = room.GetClampedPosition(bug.pos, BUG_ROOM_MARGIN);
if (grid_collision_at(bug.pos) != COLLISION_NONE)
@@ -289,7 +279,7 @@ static void tiny_bug_update(Entity_Effect& bug)
if (grid && grid->type == GRID_PIT && grid_collision_at(bug.pos) != COLLISION_NONE)
{
bug.pos = bug.targetPosition;
bug.rotation = angle_normalized(random_unit() * FULL_TURN_DEGREES);
bug.rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
if (grid_collision_at(bug.pos) == COLLISION_PIT) bug.pos = vector_add(bug.pos, random_direction());
}
}
@@ -357,7 +347,7 @@ static void wall_bug_update(Entity_Effect& bug)
{
bug.velocity = {};
Vector previous = bug.targetPosition;
bug.rotation = angle_normalized(random_unit() * BUG_TURN_SPAN + bug.rotation - BUG_TURN_BACK);
bug.rotation = normalize_angle_degrees(random_unit() * BUG_TURN_SPAN + bug.rotation - BUG_TURN_BACK);
if (bug.state < 1)
{
if (random_below(BUG_BURST_ODDS) == 0) bug.state = random_below(BUG_BURST_SPAN) + BUG_BURST_MIN;
@@ -424,7 +414,6 @@ static void tiny_fly_update(Entity_Effect& fly)
Vector toPlayer = vector_sub(player->pos, fly.pos);
float distance = vector_length(toPlayer);
Vector direction = vector_scale(toPlayer, 1 / (distance == 0 ? MIN_DISTANCE : distance));
EntityList& entities = g_game->room->entityList;
fly.friction *= FLY_FRICTION;
if (fly.isDead)
@@ -467,31 +456,27 @@ static void tiny_fly_update(Entity_Effect& fly)
fly.AddVelocity_divided(vector_scale(pull, random_unit() * FLY_PULL), false);
}
if (fly.IsFrame(FLY_JITTER_FRAMES, (int)fly.index))
{
float angle = random_unit() * PI_ROUGH * 2;
Vector jitter = vector_make(std::cos(angle), std::sin(angle));
fly.AddVelocity_divided(vector_scale(jitter, random_unit() * FLY_JITTER), false);
}
fly.AddVelocity_divided(vector_scale(random_direction(), random_unit() * FLY_JITTER), false);
if (distance < FLY_FLEE_RANGE)
{
float push = (1 - distance * distance / (FLY_FLEE_RANGE * FLY_FLEE_RANGE)) * FLY_FLEE_PUSH;
fly.AddVelocity_divided(vector_scale(direction, push), false);
}
EntityList_EL shots;
entities.partitions[PARTITION_SHOTS].query_box(shots, fly.pos, vector_make(FLY_HIT_RADIUS, FLY_HIT_RADIUS));
bool isShot = std::any_of(shots.begin(), shots.end(), [&fly](Entity* shot) {
return !shot->HasEntityFlags(FLAG_INTERPOLATION_UPDATE) && shot->type == ENTITY_TEAR &&
is_within_reach(*shot, fly.pos, FLY_HIT_RADIUS + shot->size);
});
if (isShot) tiny_fly_burst(fly);
std::vector<Entity*> hazards(entities.updateEL);
for (Entity* hazard : hazards)
EntityList_EL shots = entity_query_radius(fly.pos, FLY_HIT_RADIUS, QUERY_TEARS);
if (std::any_of(shots.begin(), shots.end(), [](Entity* shot) { return shot->type == ENTITY_TEAR; }))
tiny_fly_burst(fly);
for (Entity* knife : entity_query(ENTITY_KNIFE, -1))
{
bool isKnife = hazard->type == ENTITY_KNIFE && is_within_reach(*hazard, fly.pos, hazard->size * FLY_KNIFE_REACH);
bool isFire = hazard->type == ENTITY_FIREPLACE && is_within_reach(*hazard, fly.pos, hazard->size + FLY_FIRE_REACH);
if (isKnife || isFire) tiny_fly_burst(fly);
if (!is_within_reach(*knife, fly.pos, knife->size * FLY_KNIFE_REACH)) continue;
tiny_fly_burst(fly);
break;
}
for (Entity* fire : entity_query(ENTITY_FIREPLACE, -1))
{
if (!is_within_reach(*fire, fly.pos, fire->size + FLY_FIRE_REACH)) continue;
tiny_fly_burst(fly);
break;
}
}
@@ -794,7 +779,7 @@ static void spawner_update(Entity_Effect& spawner)
.variant = (int)spawner.varData[0], .seed = spawner.initSeed});
if (entity->IsEnemy())
{
npc_sound_play(SOUND_SPAWNER_SUMMON, 1, 2, 1);
npc_sound_play(SOUND_SUMMONSOUND, 1, 2, 1);
entity->AddEntityFlags(FLAG_AMBUSH);
}
entity->Update();
@@ -933,9 +918,6 @@ constexpr float CREEP_BIGGEST = 2.1f;
constexpr std::array<float, 3> CORK_SMALL_GROWTH = {1, 1.25f, 1.5f};
constexpr std::array<float, 3> CORK_GROWTH = {1.65f, 1.9f, 2.15f};
// What spares a player creep: Callus, and the collectible 571 (Evil Charm's immunity is the player's).
constexpr int COLLECTIBLE_CREEP_IMMUNE = 571;
// The slowing creep: white slows more than the black and brown, for ten frames past touching it, tinted grey-blue.
constexpr int PLAYER_SLOW_FRAMES = -10;
constexpr int ENEMY_SLOW_FRAMES = -1;
@@ -1107,7 +1089,7 @@ static void creep_players_touch(Entity_Effect& creep, void (*touch)(Entity_Effec
{
if (player->isDead || player->entityCollisionClass == ENTCOLL_NONE) continue;
if (player->entityGridCollisionClass != GRIDCOLL_GROUND || player->HasTrinket(TRINKET_CALLUS)) continue;
if (player->HasCollectible(COLLECTIBLE_CREEP_IMMUNE)) continue;
if (player->HasCollectible(COLLECTIBLE_SOCKS)) continue;
float distance = vector_length(vector_sub(player->pos, creep.pos));
if (distance >= creep.size * creep.sprite.scale.x + player->size) continue;
@@ -1123,7 +1105,7 @@ static void creep_players_touch(Entity_Effect& creep, void (*touch)(Entity_Effec
// Whether a player shrugs creep off: Evil Charm against its kind, or the collectible 571.
static bool is_creep_immune(Entity_Effect& creep, Entity_Player& player)
{
return player.is_evil_charm_immune(EntityRef(&creep)) || player.HasCollectible(COLLECTIBLE_CREEP_IMMUNE);
return player.is_evil_charm_immune(EntityRef(&creep)) || player.HasCollectible(COLLECTIBLE_SOCKS);
}
// Red, green and yellow creep burn a player for a heart, as their parent's.
@@ -1249,7 +1231,7 @@ static void holy_water_trail_home(Entity_Effect& trail)
Vector pull = vector_sub(trail.target->pos, trail.pos);
if (vector_length(pull) > HOMING_MAX_PULL) pull = vector_resized(pull, HOMING_MAX_PULL);
trail.velocity = vector_add(trail.velocity, vector_scale(pull, 1 / HOMING_PULL_DIVISOR));
trail.velocity = vector_add(trail.velocity, vector_make(pull.x / HOMING_PULL_DIVISOR, pull.y / HOMING_PULL_DIVISOR));
}
// Every third frame the players' red, holy water and yellow creep burn the enemies over them they have not hit, and
@@ -1584,7 +1566,7 @@ constexpr float MOONLIGHT_DEPTH = 10;
static void tadpole_init(Entity_Effect& tadpole)
{
tadpole.sprite.Play("Idle");
tadpole.rotation = angle_normalized(random_unit() * FULL_TURN_DEGREES);
tadpole.rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
tadpole.sprite.GetLayer(0)->rotation = tadpole.rotation + HALF_TURN_DEGREES;
tadpole.height = 0;
tadpole.isUnknown176 = true;
@@ -1615,7 +1597,7 @@ static void tadpole_update(Entity_Effect& tadpole)
Vector inside = room.GetClampedPosition(tadpole.pos, TADPOLE_WALL_MARGIN);
if (inside.x != tadpole.pos.x || inside.y != tadpole.pos.y)
tadpole.rotation = angle_lerp(tadpole.rotation, vector_angle(vector_sub(inside, tadpole.pos)), TADPOLE_WALL_TURN);
tadpole.rotation = angle_normalized(random_unit() * TADPOLE_WOBBLE + tadpole.rotation - TADPOLE_WOBBLE / 2);
tadpole.rotation = normalize_angle_degrees(random_unit() * TADPOLE_WOBBLE + tadpole.rotation - TADPOLE_WOBBLE / 2);
tadpole.minRadius *= random_unit() * TADPOLE_TIRE_SPAN + TADPOLE_TIRE_MIN;
bool isKick = tadpole.minRadius <= TADPOLE_RESTING && random_below(TADPOLE_REST_KICK_ODDS) == 0;
@@ -1659,7 +1641,7 @@ static void tadpole_update(Entity_Effect& tadpole)
static void lil_ghost_init(Entity_Effect& ghost)
{
ghost.targetPosition = ghost.pos;
ghost.rotation = angle_normalized(random_unit() * FULL_TURN_DEGREES);
ghost.rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
ghost.sprite.Play("Idle");
float size = ghost.dropRNG.RandomFloat() * GHOST_SCALE_SPAN + 1;
ghost.sprite.scale = vector_make(size, size);
@@ -1913,7 +1895,7 @@ constexpr int BEETLE_SHADOW_LAYER = 1;
static void beetle_init(Entity_Effect& beetle)
{
beetle.sprite.Play("WalkHori");
beetle.rotation = angle_normalized(random_unit() * FULL_TURN_DEGREES);
beetle.rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
beetle.sprite.GetLayer(0)->rotation = beetle.rotation;
beetle.height = 0;
beetle.isUnknown176 = true;
@@ -1970,7 +1952,7 @@ static void beetle_crawl(Entity_Effect& beetle)
if (!isStill || random_below(BEETLE_STILL_TAKEOFF_ODDS) == 0) beetle.subtype = BEETLE_FLYING;
}
float wobble = beetle.state < 1 ? BEETLE_WALK_WOBBLE : BEETLE_RUN_WOBBLE;
beetle.rotation = angle_normalized(random_unit() * wobble + beetle.rotation - wobble / 2);
beetle.rotation = normalize_angle_degrees(random_unit() * wobble + beetle.rotation - wobble / 2);
beetle.pos = room.GetClampedPosition(beetle.pos, BUG_ROOM_MARGIN);
if (beetle.state < 1)
@@ -1994,7 +1976,7 @@ static void beetle_crawl(Entity_Effect& beetle)
if (grid && grid->type == GRID_PIT && grid_collision_at(beetle.pos) != COLLISION_NONE)
{
beetle.pos = beetle.targetPosition;
beetle.rotation = angle_normalized(random_unit() * FULL_TURN_DEGREES);
beetle.rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
if (grid_collision_at(beetle.pos) == COLLISION_PIT) beetle.pos = vector_add(beetle.pos, random_direction());
}
}
@@ -2043,15 +2025,15 @@ static void beetle_fly(Entity_Effect& beetle)
EntityList_EL tears = entity_query_radius(beetle.pos, BEETLE_HIT_RANGE, QUERY_TEARS);
bool isHit = std::any_of(tears.begin(), tears.end(), [](Entity* tear) { return tear->type == ENTITY_TEAR; });
for (Entity* entity : g_game->room->entityList.updateEL)
for (Entity* knife : entity_query(ENTITY_KNIFE, -1))
{
if (isHit) break;
if (entity->type == ENTITY_KNIFE) isHit = is_within_reach(*entity, beetle.pos, entity->size * FLY_KNIFE_REACH);
isHit = is_within_reach(*knife, beetle.pos, knife->size * FLY_KNIFE_REACH);
}
for (Entity* entity : g_game->room->entityList.updateEL)
for (Entity* fire : entity_query(ENTITY_FIREPLACE, -1))
{
if (isHit) break;
if (entity->type == ENTITY_FIREPLACE) isHit = is_within_reach(*entity, beetle.pos, entity->size + BEETLE_FIRE_REACH);
isHit = is_within_reach(*fire, beetle.pos, fire->size + BEETLE_FIRE_REACH);
}
if (!isHit) return;
beetle.isDead = true;
+1 -1
View File
@@ -365,7 +365,7 @@ static void mega_blast_update(Entity_Effect& blast)
if (blast.state == MEGA_BLAST_STARTING) return mega_blast_start(blast, color);
if (blast.GetIntervalTicks(BLAST_TICK_FRAMES, 0) == 0) return;
if (!is_room_blast(blast)) small_blast_rings(blast, color);
if (blast.subtype == 1) small_blast_rings(blast, color);
float step = std::clamp(blast.maxRadius / BLAST_STEP_SHARE, BLAST_STEP_MIN, BLAST_STEP_MAX);
blast.scale = std::min(blast.scale + step, blast.maxRadius);
float share = blast.subtype == 0 ? BLAST_TICK_SHARE : SMALL_BLAST_TICK_SHARE;
+9 -9
View File
@@ -32,9 +32,8 @@ constexpr int CRACK_SHAKE = 5;
// The crater it leaves.
constexpr int CRACK_CRATER_SUBTYPE = 1;
constexpr float CRACK_CRATER_SCALE = 0.5f;
constexpr int CRACK_BEAM_LAYER = 0;
constexpr int CRACK_HIT_NULL = 0;
constexpr int CRACK_STRUCK = 1;
constexpr int CRACK_NPC_TYPE_FIRST = 10;
// The cross beam: held at its frame while it waits, its target glowing up to the strike (frame 10 unless the "Hit"
// event says), then four white light beams lasting 30 frames 12 up.
@@ -83,7 +82,7 @@ static void crack_hit(Entity_Effect& crack)
float damage = isVersus ? CRACK_VERSUS_HIT_DAMAGE : CRACK_HOSTILE_DAMAGE;
entity->TakeDamage(damage, damageFlags, EntityRef(source), HIT_COUNTDOWN);
}
else if (entity->type >= CRACK_NPC_TYPE_FIRST)
else if (entity->type >= ENTITY_FIRST_ENEMY)
{
float damage = isHostile ? CRACK_HOSTILE_DAMAGE : crack.collisionDamage;
entity->TakeDamage(damage, 0, EntityRef(source), HIT_COUNTDOWN);
@@ -154,8 +153,8 @@ static void crack_cross_fire(Entity_Effect& crack)
}
// 005e96b5 (Update's case 19) The spotlight charges, strikes with a crater and a shake, hurts every third frame its
// beam shows, and goes once its animation ends.
static void crack_update(Entity_Effect& crack)
// HitNull shows, and goes once its animation ends. A cross beam run back to its start goes without Update's end.
static EffectUpdateEnd crack_update(Entity_Effect& crack)
{
if (crack.state == 0)
{
@@ -167,7 +166,7 @@ static void crack_update(Entity_Effect& crack)
bool isCross = crack.subtype == CRACK_DELAYED_CROSS;
if (isCross && !crack.sprite.IsEventTriggered("Hit") && !crack.sprite.WasEventTriggered("Hit") &&
!crack_cross_wait(crack))
return;
return EFFECT_UPDATE_RETURN;
if (crack.sprite.IsEventTriggered("Sound") && !isCross) npc_sound_play(SOUND_LIGHTBOLT_CHARGE, 1, 2, 1);
if (crack.sprite.IsEventTriggered("Hit"))
@@ -182,13 +181,14 @@ static void crack_update(Entity_Effect& crack)
if (isCross) crack_cross_fire(crack);
}
const AnimationFrame* beam = crack.sprite.animState.GetLayerFrame(CRACK_BEAM_LAYER);
if (crack.subtype < CRACK_PLAYER_STRUCK && beam && beam->isVisible)
const NullFrame* hitNull = crack.sprite.GetNullFrameById(CRACK_HIT_NULL);
if (crack.subtype < CRACK_PLAYER_STRUCK && hitNull && hitNull->isVisible)
{
if ((crack.state - 1) % CRACK_HIT_SPACING == 0) crack_hit(crack);
crack.state++;
}
if (crack.sprite.IsFinished()) crack.Remove();
return EFFECT_UPDATE_FINISH;
}
// Hush's lasers: the one hunting his target (96) every 10 frames aims 40 to one side of where its target will be in 5,
@@ -384,7 +384,7 @@ static EffectUpdateEnd siren_charm_update(Entity_Effect& charm)
// Hush's lasers and the poof of his shots have no Init case of their own.
constexpr auto BOSS_EFFECT_BEHAVIOURS = std::to_array<EffectBehaviour>({
{EFFECT_CRACK_THE_SKY, crack_init, effect_finishing<crack_update>, nullptr},
{EFFECT_CRACK_THE_SKY, crack_init, crack_update, nullptr},
{EFFECT_HUSH_LASER, nullptr, effect_finishing<hush_laser_update>, nullptr},
{EFFECT_HUSH_LASER_UP, nullptr, effect_finishing<hush_beam_update>, nullptr},
{EFFECT_BULLET_POOF_HUSH, nullptr, effect_poof_update, nullptr},
+6 -23
View File
@@ -7,6 +7,7 @@
#include "manager.h"
#include "npc_ai.h"
#include "room.h"
#include "room_grid.h"
#include "sfx_manager.h"
#include <algorithm>
#include <array>
@@ -322,15 +323,6 @@ bool is_combat_effect(int variant)
return is_listed(COMBAT_EFFECTS, static_cast<CombatEffect>(variant));
}
// normalize_angle_degrees 00682740: an angle wrapped into -180 to 180.
static float angle_wrap(float angle)
{
if (std::fabs(angle) > FULL_TURN_DEGREES) angle = std::fmod(angle, FULL_TURN_DEGREES);
if (angle > HALF_TURN_DEGREES) return angle - FULL_TURN_DEGREES;
if (angle < -HALF_TURN_DEGREES) return angle + FULL_TURN_DEGREES;
return angle;
}
// Plays a sound through the fart seeds.
static void sound_play(int sound, float volume, float pitch)
{
@@ -511,7 +503,7 @@ static void worm_init(Entity_Effect& effect)
if (effect.subtype >= 0 && effect.subtype < (int)WORM_ANIMATIONS.size())
effect.sprite.Play(WORM_ANIMATIONS[effect.subtype]);
effect.rotation = angle_wrap(random_unit() * FULL_TURN_DEGREES);
effect.rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
effect.sprite.rotation = effect.rotation;
effect.sortingLayer = SORTING_DOOR;
effect.fallingAcceleration = PARTICLE_GRAVITY;
@@ -1104,17 +1096,8 @@ static void rock_explosion_update(Entity_Effect& effect)
// Whether a dead tear lies within reach of a position (EntityList::QueryRadius over the tears).
static bool is_dead_tear_near(const Vector& position, float radius)
{
EntityList_EL shots;
g_game->room->entityList.partitions[PARTITION_SHOTS].query_box(shots, position, vector_make(radius, radius));
for (Entity* shot : shots)
{
float reach = radius + shot->size;
bool isNear = vector_length_squared(vector_sub(shot->pos, position)) < reach * reach;
if (!shot->HasEntityFlags(FLAG_INTERPOLATION_UPDATE) && isNear && shot->type == ENTITY_TEAR && shot->isDead)
return true;
}
return false;
EntityList_EL shots = entity_query_radius(position, radius, QUERY_TEARS);
return std::any_of(shots.begin(), shots.end(), [](Entity* shot) { return shot->type == ENTITY_TEAR && shot->isDead; });
}
// Pushes a worm out of the grid entity under it, other than a rock, to its cell's nearest edge. Still in a pit, it
@@ -1143,7 +1126,7 @@ static void worm_grid_push(Entity_Effect& effect)
if (grid->type != GRID_PIT || room_grid_collision_at(effect.pos) == COLLISION_NONE) return;
effect.pos = effect.targetPosition;
effect.rotation = angle_wrap(random_unit() * FULL_TURN_DEGREES);
effect.rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
if (room_grid_collision_at(effect.pos) == COLLISION_PIT) effect.pos = vector_add(effect.pos, random_direction());
}
@@ -1154,7 +1137,7 @@ static void worm_update(Entity_Effect& effect)
Room& room = *g_game->room;
float wobble = effect.state < 1 ? WORM_IDLE_WOBBLE : WORM_CRAWL_WOBBLE;
effect.rotation = angle_wrap(random_unit() * wobble + effect.rotation - wobble * HALF);
effect.rotation = normalize_angle_degrees(random_unit() * wobble + effect.rotation - wobble * HALF);
effect.sprite.rotation = effect.rotation;
effect.pos = room.GetClampedPosition(effect.pos, WORM_INNER_MARGIN);
if (effect.posOffset.y >= 0)
+4 -4
View File
@@ -131,7 +131,7 @@ static EffectUpdateEnd dogma_swirl_update(Entity_Effect& swirl)
swirl.Remove();
return EFFECT_UPDATE_RETURN;
}
swirl.sprite.rotation = angle_wrapped(swirl.sprite.rotation - swirl.speedMultiplier * SWIRL_SPIN);
swirl.sprite.rotation = normalize_angle_degrees(swirl.sprite.rotation - swirl.speedMultiplier * SWIRL_SPIN);
swirl.sprite.scale = vector_make(scale, scale);
swirl.sprite.color._tint[3] = alpha;
return EFFECT_UPDATE_FINISH;
@@ -439,7 +439,7 @@ constexpr ColorMod BLACKHOLE_RING_COLOR = color_make({1, 1, 1, 0});
// is eaten: shots and tears burst (unless just fired, low or Ludovico), bombs and rerollable pickups go, players hurt.
constexpr float BLACKHOLE_PULL = 4;
constexpr float BLACKHOLE_STRONG_PULL = 6;
constexpr float BLACKHOLE_NEAR = 8;
constexpr float BLACKHOLE_NEAR = 64;
constexpr float BLACKHOLE_NEAR_SHARE = 4096;
constexpr float BLACKHOLE_FALLOFF = 0.05f;
constexpr float BLACKHOLE_SHOT_WARMUP = 30;
@@ -694,14 +694,14 @@ static EffectUpdateEnd dogma_hole_update(Entity_Effect& hole)
hole.Remove();
return EFFECT_UPDATE_RETURN;
}
hole.sprite.rotation = angle_wrapped(hole.sprite.rotation + hole.speedMultiplier * BLACKHOLE_SWIRL_SPIN);
hole.sprite.rotation = normalize_angle_degrees(hole.sprite.rotation + hole.speedMultiplier * BLACKHOLE_SWIRL_SPIN);
hole.sprite.scale = vector_make(scale, scale);
hole.sprite.color._tint[3] = alpha;
}
else if (hole.subtype == BLACKHOLE_SPARK)
{
hole.renderDepthOffset = BLACKHOLE_DEPTH;
hole.sprite.rotation = angle_wrapped(hole.sprite.rotation + hole.rotation * hole.speedMultiplier);
hole.sprite.rotation = normalize_angle_degrees(hole.sprite.rotation + hole.rotation * hole.speedMultiplier);
if (hole.sprite.IsFinished()) hole.Remove();
}
else dogma_hole_body_update(hole);
+2 -1
View File
@@ -383,7 +383,8 @@ static void hand_water_splash(Vector place, int count)
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;
Vector velocity = vector_make(offset.x * speed / HAND_SPLASH_SPREAD_X, offset.y * speed / HAND_SPLASH_SPREAD_Y);
// 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<Entity_Effect*>(g_game->Spawn({.position = vector_add(place, offset),
.velocity = velocity,
.subType = SPLASH_DROP,
+10 -3
View File
@@ -296,7 +296,7 @@ static void crackwave_rocks_throw(Entity_Effect& wave)
}
// A crackwave's step: it crawls on from its last crack, gone once it leaves the room or meets a pit, a wall or a
// solid cell, cracking and crushing where it lands.
// solid cell, cracking where it lands. It crushes there even when a solid cell stops it.
static void crackwave_step(Entity_Effect& wave, int frame)
{
bool isBeast = wave.subtype == CRACKWAVE_BEAST;
@@ -323,8 +323,8 @@ static void crackwave_step(Entity_Effect& wave, int frame)
}
else
{
Entity* rock = floor_crack(wave.targetPosition, wave.spawnerEntity, CRACK_DAMAGE,
wave.sprite.scale.x * CRACK_RADIUS);
Entity* rock = g_game->Spawn(
{.position = wave.targetPosition, .type = ENTITY_EFFECT, .variant = EFFECT_ROCK_EXPLOSION, .seed = Random()});
rock->sprite.scale = wave.sprite.scale;
}
if (isBeast)
@@ -334,6 +334,13 @@ static void crackwave_step(Entity_Effect& wave, int frame)
.playerDamageThreshold = CRACKWAVE_BEAST_STRONG,
.radius = CRACKWAVE_BEAST_RADIUS,
.isHitAll = true});
else
explosion_damage({.position = wave.targetPosition,
.source = wave.spawnerEntity,
.damageFlags = DAMAGE_CRUSH,
.damage = CRACK_DAMAGE,
.radius = wave.sprite.scale.x * CRACK_RADIUS,
.isLineCheck = false});
if (wave.HasEntityFlags(FLAG_SPAWN_STICKY_SPIDERS) && random_below(CRACKWAVE_ROCK_ODDS) == 0)
crackwave_rocks_throw(wave);
+3 -1
View File
@@ -266,7 +266,9 @@ static MrMeJob mr_me_grid_job(Room& room, int index, GridEntity& grid)
// two spared kinds) and not its own ancestor.
static bool is_mr_me_foe(Entity_Effect& helper, Entity& entity)
{
if (!Entity::is_enemy_type(entity.type) || entity.entityCollisionClass == ENTCOLL_NONE || entity.entityCollisionClass == ENTCOLL_PLAYERONLY)
bool isVersusPlayer = entity.type == ENTITY_PLAYER && g_game->deathmatchManager.is_active();
if (!(Entity::is_enemy_type(entity.type) || isVersusPlayer) || entity.entityCollisionClass == ENTCOLL_NONE ||
entity.entityCollisionClass == ENTCOLL_PLAYERONLY)
return false;
if (entity.isInvincible || entity.isDead) return false;
if (entity.HasEntityFlags(FLAG_NO_TARGET) && entity.type != ENTITY_BLOOD_PUPPY && entity.type != ENTITY_DARK_ESAU)
+2 -2
View File
@@ -1355,8 +1355,8 @@ static void halo_push(Entity_Effect& halo, Entity& enemy)
static void telekinesis_halo_update(Entity_Effect& halo)
{
std::string_view animation = halo.sprite.GetAnimation();
if (halo.state >= 1 && animation != "Blink") halo.sprite.SetAnimation("Blink", SWITCH_KEEP_FRAME);
else if (halo.state == 0 && halo.sprite.IsPlaying("Idle")) halo.sprite.SetAnimation("Idle", SWITCH_KEEP_FRAME);
if (halo.state >= 1 && animation != "Blink") halo.sprite.SetAnimation("Blink");
else if (halo.state == 0 && halo.sprite.IsPlaying("Idle")) halo.sprite.SetAnimation("Idle");
if (!halo.sprite.IsEventTriggered("Push")) return;
for (Entity* enemy : entity_query_radius(halo.pos, HALO_PUSH_RANGE, QUERY_ENEMIES))
+4 -3
View File
@@ -220,11 +220,12 @@ static void lava_spawner_init(Entity_Effect& lava)
layer_additive_set(*lava.sprite.GetLayer(0));
}
// An eruption at the spawner's column: a lava ball thrown up from the lava's line, a blast and a shake.
// An eruption at the spawner's column: a lava ball thrown up from the lava's line, a blast and a shake. Only subtype 2
// rises with its sound.
static void lava_erupt(Entity_Effect& lava)
{
Vector line = vector_make(lava.pos.x, g_game->room->get_lava_line_y());
effect_sound_play(SOUND_BEAST_LAVABALL_RISE);
if (lava.subtype == 2) effect_sound_play(SOUND_BEAST_LAVABALL_RISE);
uint32_t seed = Random();
auto* ball = static_cast<Entity_Projectile*>(g_game->Spawn({.position = line,
.velocity = vector_make(0, LAVA_BALL_SPEED),
@@ -512,7 +513,7 @@ static void big_knife_update(Entity_Effect& knife)
game_shake_screen(KNIFE_SHAKE);
knife.friction *= KNIFE_SPEEDUP;
}
if (knife.state == 0 && room_grid_collision_at(vector_add(knife.pos, vector_make(0, KNIFE_WALL_PROBE))) == GRIDCOLL_WALLS)
if (knife.state == 0 && room_grid_collision_at(vector_add(knife.pos, vector_make(0, KNIFE_WALL_PROBE))) == COLLISION_WALL)
knife_wall_burst(knife, room);
if (knife.state <= 0) return;
+1 -1
View File
@@ -165,7 +165,7 @@ static int portal_room_find(Entity_Effect& portal)
static void portal_enter(Entity_Effect& portal, Entity_Player& player, bool isLinkedHere)
{
Game& game = *g_game;
game.leaveDoor = -1;
if (portal.variant == EFFECT_PORTAL_TELEPORT || !isLinkedHere) game.leaveDoor = -1;
if (portal.variant == EFFECT_PORTAL_TELEPORT)
{
int roomIndex = portal_room_find(portal);
+7 -5
View File
@@ -47,12 +47,12 @@ constexpr int SHOT_POOF_TURNS = 4;
constexpr std::array<std::string_view, 4> EVIL_EYE_SHOOTS = {"ShootSide", "ShootUp", "ShootSide", "ShootDown"};
constexpr std::array<std::string_view, 4> EVIL_EYE_IDLES = {"IdleSide", "IdleUp", "IdleSide", "IdleDown"};
// Whether the eye bursts: off the room, over a wall or pit, or (after its first frames) on an enemy.
// Whether the eye bursts: off the room, over anything more solid than a pit, or (after its first frames) on an enemy.
static bool is_evil_eye_bursting(Entity_Effect& eye)
{
uint32_t collision = room_grid_collision_at(eye.pos);
Vector clamped = g_game->room->GetClampedPosition(eye.pos, eye.size);
if (clamped.x != eye.pos.x || clamped.y != eye.pos.y || collision > GRIDCOLL_WALLS_X) return true;
if (clamped.x != eye.pos.x || clamped.y != eye.pos.y || collision > COLLISION_PIT) return true;
return eye.FrameCount() > EVIL_EYE_SAFE_FRAMES && !entity_query_radius(eye.pos, eye.size, QUERY_ENEMIES).empty();
}
@@ -249,15 +249,17 @@ static void tech_dot_render(Entity_Effect& dot, const Vector& offset)
g_beamRenderer.End();
}
// 005f9b88 (Update's case 71 and 126) The swirl keeps its shadow under it. A tech dot pops when it shoots or dies (a
// Dogma dot firing its laser once). Live, it pulls with Strange Attractor and hurts what it touches every third
// frame, then goes once its animation ends with no child.
// 005f9b88 (Update's case 71 and 126) The swirl keeps its shadow under it. A tech dot dies once its player stops
// firing, and pops when it shoots or dies (a Dogma dot firing its laser once). Live, it pulls with Strange
// Attractor and hurts what it touches every third frame, then goes once its animation ends with no child.
static void swirl_update(Entity_Effect& swirl)
{
Entity* spawner = swirl.spawnerEntity;
Entity_Player* player = spawner ? spawner->ToPlayer() : nullptr;
if (!player && spawner) player = spawner->GetLastSpawner()->ToPlayer();
swirl.shadowOffset.x = swirl.posOffset.x;
if (player && swirl.variant == EFFECT_TECH_DOT && !swirl.isDead && player->fireDirection == DIRECTION_NONE)
swirl.isDead = true;
if (swirl.sprite.IsEventTriggered("Shoot") || swirl.isDead)
{
+3 -3
View File
@@ -101,7 +101,7 @@ static float shooter_turn_share(Entity_Effect& shooter)
// The side the thrower faces at an angle: down or up within 20 of the vertical, else left or right.
static std::string_view shooter_side(float angle)
{
angle = angle_wrapped(angle);
angle = normalize_angle_degrees(angle);
if (angle >= SHOOTER_SIDE_SPAN && angle <= SHOOTER_SIDE_FAR) return "Down";
if (angle >= -SHOOTER_SIDE_FAR && angle <= -SHOOTER_SIDE_SPAN) return "Up";
if (angle > SHOOTER_SIDE_FAR || angle < -SHOOTER_SIDE_FAR) return "Left";
@@ -134,13 +134,13 @@ void Entity_Effect::update_variant178_shooter(bool isPositionOnly)
if (!isPositionOnly)
{
float delta = angle_wrapped(rotation - sprite.rotation);
float delta = normalize_angle_degrees(rotation - sprite.rotation);
sprite.rotation = angle_approach(sprite.rotation, rotation, std::fabs(delta * shooter_turn_share(*this)));
}
float angle = sprite.rotation;
if (isPositionOnly)
angle = angle_approach(angle, rotation,
std::fabs(angle_wrapped(rotation - angle) * shooter_turn_share(*this)) * 0.5f);
std::fabs(normalize_angle_degrees(rotation - angle) * shooter_turn_share(*this)) * 0.5f);
pos = vector_add(parent->pos, vector_scale(vector_from_angle(angle), SHOOTER_REACH));
velocity = {};
if (isPositionOnly) return;
+4 -13
View File
@@ -240,15 +240,6 @@ void familiar_sound_play(int sound, SoundPlay play)
g_manager->sfxManager.Play(sound, play);
}
// normalize_angle_degrees 00682740: an angle brought into -180 to 180.
float angle_wrap(float angle)
{
if (std::fabs(angle) > 360) angle = std::fmod(angle, 360.0f);
if (angle > 180) return angle - 360;
if (angle < -180) return angle + 360;
return angle;
}
// Whether My Little Unicorn or Unicorn Stump spins the player's wisps.
bool familiar_unicorn_active(Entity_Player& owner)
{
@@ -990,12 +981,12 @@ void Entity_Familiar::update_tail()
{
if (HasEntityFlags(FLAG_SPIN))
{
orbitAngleOffset = angle_wrap(orbitAngleOffset - orbitSpeed * SPIN_ORBIT_STEP);
orbitAngleOffset = normalize_angle_degrees(orbitAngleOffset - orbitSpeed * SPIN_ORBIT_STEP);
if (orbitLayer >= 0 && IsFrame(SPIN_FLASH_INTERVAL, 0))
SetColor(SPIN_FLASH, SPIN_FLASH_INTERVAL, COLOR_PRIORITY_DEFAULT, true, true);
}
if (orbitLayer == ORBIT_LAYER_WISPS && familiar_unicorn_active(*player))
orbitAngleOffset = angle_wrap(orbitAngleOffset - orbitSpeed * UNICORN_ORBIT_STEP);
orbitAngleOffset = normalize_angle_degrees(orbitAngleOffset - orbitSpeed * UNICORN_ORBIT_STEP);
}
lua_engine_get().FamiliarUpdate(this);
@@ -1056,11 +1047,11 @@ void Entity_Familiar::Interpolate()
float angle = savedAngle;
if (HasEntityFlags(FLAG_SPIN))
{
angle = angle_wrap(angle - orbitSpeed * SPIN_INTERPOLATE_STEP);
angle = normalize_angle_degrees(angle - orbitSpeed * SPIN_INTERPOLATE_STEP);
orbitAngleOffset = angle;
}
if (orbitLayer == ORBIT_LAYER_WISPS && familiar_unicorn_active(*player))
orbitAngleOffset = angle_wrap(angle - orbitSpeed * UNICORN_INTERPOLATE_STEP);
orbitAngleOffset = normalize_angle_degrees(angle - orbitSpeed * UNICORN_INTERPOLATE_STEP);
}
Entity::Interpolate();
if (variant == DECAP_ATTACK) posOffset.y += targetPosition.y * 0.5f * speedMultiplier;
-1
View File
@@ -561,7 +561,6 @@ void familiar_chase_limit(Entity_Familiar& familiar, int chaseFrames);
void familiar_sound_play(int sound, SoundPlay play = {});
bool familiar_unicorn_active(Entity_Player& owner);
Entity* spawn_dip_at(int subType, const Vector* position, Entity* spawner, const Vector* targetPosition);
float angle_wrap(float angle);
float orbit_layer_angle_offset(int layer);
Vector direction_unit(int direction);
+9 -9
View File
@@ -561,7 +561,7 @@ void Entity_Knife::copy_parent_state(Entity_Knife& source)
SetColor(source.color, -1, COLOR_PRIORITY_DEFAULT, false, true);
tearFlags = source.tearFlags;
SetCollisionDamage(source.collisionDamage);
rotationOffset = angle_wrap(source.rotationOffset);
rotationOffset = normalize_angle_degrees(source.rotationOffset);
sprite.scale = source.sprite.scale;
isMultidimensionalApplied = source.isMultidimensionalApplied;
isPrismApplied = source.isPrismApplied;
@@ -1093,7 +1093,7 @@ bool Entity_Knife::held_update(Entity_Player* player)
pos = vector_add(anchorPosition, vector_scale(vector_from_angle(displayRotation), knifeDistance + holdDistance));
else
{
float skew = angle_wrap(rotationOffset);
float skew = normalize_angle_degrees(rotationOffset);
float turn = knifeDistance * PI_F * 2 * (skew * KNIFE_ORBIT_TURN_SKEW + 1) + displayRotation;
float radius = (1 - skew * KNIFE_ORBIT_RADIUS_SKEW) * knifeDistance * KNIFE_ORBIT_RADIUS_SHARE + holdDistance;
pos = vector_add(anchorPosition, vector_scale(vector_from_angle(turn), radius));
@@ -1203,16 +1203,16 @@ bool Entity_Knife::held_update(Entity_Player* player)
if (kind == KNIFE_KIND_THROWN)
{
sprite.rotation = angle_wrap(angle - KNIFE_TURN_QUARTER);
sprite.rotation = normalize_angle_degrees(angle - KNIFE_TURN_QUARTER);
sprite.GetLayer(0)->isFlipX = sprite.rotation > 0;
}
else if (isFlying)
{
if (kind == KNIFE_KIND_SWORD) sprite.rotation = angle_wrap(angle - KNIFE_TURN_QUARTER);
if (kind == KNIFE_KIND_SWORD) sprite.rotation = normalize_angle_degrees(angle - KNIFE_TURN_QUARTER);
}
else
{
sprite.rotation = angle_wrap(vector_angle(vector_sub(tip, owner->pos)) - KNIFE_TURN_QUARTER);
sprite.rotation = normalize_angle_degrees(vector_angle(vector_sub(tip, owner->pos)) - KNIFE_TURN_QUARTER);
if (const AnimationFrame* frame = sprite.animState.GetLayerFrame(0))
{
Vector facing = vector_from_angle(sprite.rotation);
@@ -1294,7 +1294,7 @@ void Entity_Knife::ludovico_update()
if (tearFlags[TEAR_PULSE])
radius *= (std::sin(time * LUDOVICO_PULSE_RATE) + 1) * 0.5f * LUDOVICO_PULSE_SHARE + 1;
knife.pos = vector_add(pos, vector_scale(vector_from_angle(angle), radius));
knife.sprite.rotation = angle_wrap(angle - KNIFE_TURN_QUARTER);
knife.sprite.rotation = normalize_angle_degrees(angle - KNIFE_TURN_QUARTER);
knife.SetColor(sprite.color, -1, COLOR_PRIORITY_DEFAULT, false, true);
knife.tearFlags = tearFlags;
knife.SetCollisionDamage(collisionDamage);
@@ -1437,7 +1437,7 @@ void Entity_Knife::path_update()
Vector along = vector_normalized(vector_sub(next, at));
Vector goal = vector_make(along.y * pathOffset + next.x, -along.x * pathOffset + next.y);
AddVelocity_divided(vector_resized(vector_sub(goal, pos), KNIFE_PATH_STEER), false);
sprite.rotation = angle_wrap(std::atan2(fallingSpeed + velocity.y, velocity.x) * RADIANS_TO_DEGREES -
sprite.rotation = normalize_angle_degrees(std::atan2(fallingSpeed + velocity.y, velocity.x) * RADIANS_TO_DEGREES -
KNIFE_TURN_QUARTER);
sprite.GetLayer(0)->isFlipX = sprite.rotation > 0;
pathSegment = bestSegment;
@@ -1469,7 +1469,7 @@ void Entity_Knife::chained_update()
Vector toParent = vector_sub(parent->pos, pos);
if (vector_length_squared(toParent) > KNIFE_CHAIN_LENGTH * KNIFE_CHAIN_LENGTH)
pos = vector_sub(parent->pos, vector_resized(toParent, KNIFE_CHAIN_LENGTH));
sprite.rotation = angle_wrap(vector_angle(toParent) + KNIFE_TURN_QUARTER);
sprite.rotation = normalize_angle_degrees(vector_angle(toParent) + KNIFE_TURN_QUARTER);
sprite.GetLayer(0)->isFlipX = sprite.rotation > 0;
}
@@ -1584,7 +1584,7 @@ void Entity_Knife::render_orbit_trail(const Vector& offset)
if (owner)
for (int i = ORBIT_TRAIL_COUNT - 1; i >= 0; i--)
{
float skew = angle_wrap(rotationOffset);
float skew = normalize_angle_degrees(rotationOffset);
float distance = knifeDistance - (float)(i + 1) * knifeVelocity * ORBIT_TRAIL_SPACING;
float turn = distance * PI_F * 2 * (skew * KNIFE_ORBIT_TURN_SKEW + 1) + displayRotation;
float radius = (1 - skew * KNIFE_ORBIT_RADIUS_SKEW) * distance * KNIFE_ORBIT_RADIUS_SHARE + reach;
+2 -2
View File
@@ -243,7 +243,7 @@ void Entity_Knife::SetAttackAnimation()
{
pos = vector_add(parent->pos, vector_scale(vector_from_angle(displayRotation), SWING_START_DISTANCE));
anchorPosition = parent->pos;
sprite.rotation = angle_wrap(vector_angle(vector_sub(pos, parent->pos)) - 90);
sprite.rotation = normalize_angle_degrees(vector_angle(vector_sub(pos, parent->pos)) - 90);
}
isDeadEyeHit = false;
isSwinging = true;
@@ -698,7 +698,7 @@ static bool swing_effect_spawn(Entity_Knife& knife, Entity_Player* player, const
if (player->HasCollectible(COLLECTIBLE_TECHNOLOGY))
{
float laserReach = (angle_wrap(knife.rotationOffset) * SWING_LASER_REACH / 180 + reach.tipRadius + reach.tipDistance) *
float laserReach = (normalize_angle_degrees(knife.rotationOffset) * SWING_LASER_REACH / 180 + reach.tipRadius + reach.tipDistance) *
knife.sprite.scale.y;
Entity_Laser& laser = *static_cast<Entity_Laser*>(g_game->Spawn({.position = swing.pos,
.spawner = player,
+7 -7
View File
@@ -200,8 +200,8 @@ static void laser_sound_play(int sound, SoundPlay play)
// 006827a0 The shortest signed turn from one angle to another, in degrees.
float angle_difference(float from, float to)
{
from = angle_wrap(from);
to = angle_wrap(to);
from = normalize_angle_degrees(from);
to = normalize_angle_degrees(to);
if (std::abs(to - from) > ANGLE_HALF_TURN)
{
if (from < to) return to - (from + ANGLE_FULL_TURN);
@@ -910,7 +910,7 @@ void Entity_Laser::update_impact_effect(bool isHidden)
float rotation = 0;
if (effect->subtype == IMPACT_SUBTYPE_THIN)
rotation =
isPath ? angle_wrap(vector_angle(back) + SPRITE_ROTATION_OFFSET) : angleDegrees - SPRITE_ROTATION_OFFSET;
isPath ? normalize_angle_degrees(vector_angle(back) + SPRITE_ROTATION_OFFSET) : angleDegrees - SPRITE_ROTATION_OFFSET;
else
{
float scaleX = sprite.scale.x;
@@ -935,12 +935,12 @@ void Entity_Laser::update_impact_effect(bool isHidden)
effect->pos = bounce->pos;
effect->posOffset = posOffset;
effect->renderDepthOffset = bounce->renderDepthOffset + IMPACT_DEPTH;
effect->sprite.rotation = isPath ? angle_wrap(vector_angle(back) - SPRITE_ROTATION_OFFSET)
effect->sprite.rotation = isPath ? normalize_angle_degrees(vector_angle(back) - SPRITE_ROTATION_OFFSET)
: angleDegrees + SPRITE_ROTATION_OFFSET;
return;
}
rotation =
isPath ? angle_wrap(vector_angle(back) - SPRITE_ROTATION_OFFSET) : angleDegrees + SPRITE_ROTATION_OFFSET;
isPath ? normalize_angle_degrees(vector_angle(back) - SPRITE_ROTATION_OFFSET) : angleDegrees + SPRITE_ROTATION_OFFSET;
}
effect->pos = end;
effect->posOffset = posOffset;
@@ -1181,7 +1181,7 @@ void Entity_Laser::update_laser()
{
angleDegrees += turn;
rotationDegrees -= turn;
sprite.rotation = angle_wrap(angleDegrees - SPRITE_ROTATION_OFFSET);
sprite.rotation = normalize_angle_degrees(angleDegrees - SPRITE_ROTATION_OFFSET);
}
if (rotationDegrees == 0 || (rotationDegrees > 0) != (turn > 0)) isActiveRotating = false;
}
@@ -1420,7 +1420,7 @@ void Entity_Laser::blood_drop_spawn()
if (!isDropping || samples.size() < 2) return;
float back = vector_angle(vector_sub(samples[samples.size() - 2], samples.back()));
float angle = angle_wrap(random_fraction() * ANGLE_HALF_TURN + back - SPRITE_ROTATION_OFFSET);
float angle = normalize_angle_degrees(random_fraction() * ANGLE_HALF_TURN + back - SPRITE_ROTATION_OFFSET);
uint32_t seed = Random();
Vector velocity = vector_scale(vector_from_angle(angle), random_fraction() * 10 + 1);
Vector spray = random_direction();
+9 -10
View File
@@ -46,7 +46,6 @@ constexpr int ENTITY_FEAR_IMMUNE = 205;
constexpr int ENTITY_NO_DECOY_TYPE = 213;
constexpr uint32_t DOPLE_PICK_SHIFT = 11;
constexpr int ENTITY_UNREACHABLE_EXEMPT = 886;
constexpr int ENTITY_DAMAGE_NUMBERS_TYPE = 964;
constexpr float DAMAGE_NUMBER_MAX = 9999;
constexpr float DAMAGE_NUMBER_MIN = 0.1f;
constexpr float DAMAGE_NUMBER_PRECISION = 10;
@@ -169,7 +168,6 @@ constexpr int STATUS_SPREAD_FRAMES = 90;
constexpr float MARK_SPREAD_DAMAGE = 10;
constexpr int MARK_SPREAD_COUNTDOWN = 30;
constexpr ColorMod SPREAD_SLOW_COLOR = {{1, 1, 1.3f, 1}, {0, 0, 0, 0}, {40 / 255.0f, 40 / 255.0f, 40 / 255.0f}};
constexpr int SOUND_POOP_DEATH = 237;
constexpr float POOP_DEATH_VOLUME = 0.9f;
// The burst effects a dead NPC leaves besides blood (Lua's EffectVariant).
@@ -446,7 +444,8 @@ bool entity_is_prey(Entity& prey)
// 007069a0 What an enemy at a position goes after: the nearest visible player within reach (Dark Esau only Jacob),
// else a Punching Bag, then a baited enemy, or for the Blood Puppy its nearest prey. An enemy forced onto a target keeps
// it. Isaac's Heart stands in for its player.
// The stand-in target a player keeps at Entity_Player 0x144c waits for Entity_Player to name it.
// The original also reads a stand-in target at Entity_Player 0x144c, which nothing in the executable ever sets (only
// Init and the weapon release clear it), so it is always none and left out.
Entity* game_nearest_target_player(const Vector& position, Entity* source, bool isPlayersOnly, bool isTargetDecoys,
float maxDistance, TargetDistance measure)
{
@@ -832,7 +831,7 @@ void Entity_NPC::LoadEntityConfig()
load_graphics(true);
sprite.scale = vector_make(1, 1);
if (sprite.SetAnimation(sprite.GetDefaultAnimationName(), SWITCH_KEEP_FRAME) && sprite.animState.animData)
if (sprite.SetAnimation(sprite.GetDefaultAnimationName()) && sprite.animState.animData)
{
sprite.animState.SetFrameFloat(0);
sprite.animState.isPlaying = false;
@@ -983,7 +982,7 @@ void Entity_NPC::SetBossColorIdx(int bossColorIdx, int)
{
bosscoloridx = bossColorIdx;
load_graphics(true);
if (sprite.SetAnimation(sprite.GetDefaultAnimationName(), SWITCH_KEEP_FRAME) && sprite.animState.animData)
if (sprite.SetAnimation(sprite.GetDefaultAnimationName()) && sprite.animState.animData)
{
sprite.animState.SetFrameFloat(0);
sprite.animState.isPlaying = false;
@@ -2382,7 +2381,7 @@ void Entity_NPC::PlayDeathEffects()
}
else
{
if (config->gibFlags & GIB_FLAG_POOP) npc_sound_play(SOUND_POOP_DEATH, POOP_DEATH_VOLUME, 2, 1);
if (config->gibFlags & GIB_FLAG_POOP) npc_sound_play(SOUND_PLOP, POOP_DEATH_VOLUME, 2, 1);
Entity* burstEffect = spawn_at(ENTITY_EFFECT, burst, 0, vector_add(pos, offset), nullptr);
burstEffect->SetColor(splatColor, -1, COLOR_PRIORITY_DEFAULT, false, true);
}
@@ -2547,7 +2546,7 @@ void Entity_NPC::AnimWalkFrame(std::string_view horizontalAnim, std::string_view
if (isChampion && championSpeed < 1) speedThreshold *= HALF;
if (vector_length_squared(velocity) < speedThreshold * speedThreshold)
{
if (sprite.SetAnimation(verticalAnim, SWITCH_KEEP_FRAME) && sprite.animState.animData)
if (sprite.SetAnimation(verticalAnim) && sprite.animState.animData)
{
sprite.animState.SetFrameFloat(0);
sprite.animState.isPlaying = false;
@@ -2560,7 +2559,7 @@ void Entity_NPC::AnimWalkFrame(std::string_view horizontalAnim, std::string_view
std::string_view walk = isHorizontal ? horizontalAnim : verticalAnim;
const AnimationData* current = sprite.animState.animData;
bool isWalking = current && current->name == walk && (!current->isLooping || sprite.animState.isPlaying);
if (!isWalking && sprite.SetAnimation(walk, SWITCH_KEEP_FRAME))
if (!isWalking && sprite.SetAnimation(walk))
{
sprite.animState.Rewind();
sprite.animState.isPlaying = true;
@@ -2801,7 +2800,7 @@ void Entity_NPC::UpdateChildEffectPosition(bool isPredictMovement)
// 006d7010 With Spider Mod, shows the damage each hit of this frame dealt it as a rising number.
void Entity_NPC::spawn_damage_numbers()
{
bool isShown = type == ENTITY_DAMAGE_NUMBERS_TYPE ||
bool isShown = type == ENTITY_DUMMY ||
(g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_SPIDER_MOD_ID, LAZARUS_SHARE_CHECK) &&
IsActiveEnemy(DEAD_EXCLUDED));
if (!isShown || !isVisible || sprite.color._tint[3] <= 0 || health <= 0) return;
@@ -3442,7 +3441,7 @@ void Entity_NPC::UpdateChargeBar(float start, float end, float value, bool isHid
int frame = (int)(std::clamp((value - start) / (end - start), 0.0f, 1.0f) * CHARGE_BAR_FRAMES);
if (!isHideWhenFull || frame < CHARGE_BAR_FRAMES)
{
if (chargeBarSprite.SetAnimation("Charging", SWITCH_KEEP_FRAME) && chargeBarSprite.animState.animData)
if (chargeBarSprite.SetAnimation("Charging") && chargeBarSprite.animState.animData)
{
chargeBarSprite.animState.SetFrameFloat((float)frame);
chargeBarSprite.animState.isPlaying = false;
+3 -1
View File
@@ -89,6 +89,8 @@ constexpr float CONTROL_STEER_DRAG = 1.25f;
constexpr float CONTROL_STEER_DRAG_FALL = 0.20000005f;
constexpr float CONTROL_STEER_SPEED = 30;
constexpr float CONTROLLED_ATTACK_RANGE = 1000;
// How often an NPC looks for its target in attack range, as nearly every caller of IsTargetInAttackRange asks.
constexpr int ATTACK_RANGE_FRAMES = 7;
constexpr ColorMod CONTROL_TARGET_COLOR = {{155 / 255.0f, 0, 0, 1}, {0, 0, 0, 0}, {0, 0, 0}};
// Lua's ChampionColor values the NPC code tests.
@@ -344,7 +346,7 @@ struct Entity_NPC : Entity
Vector CalcTargetPosition(float distanceLimit);
bool TryForceTarget(Entity* target, int duration);
void ResetPathFinderTarget();
bool IsTargetInAttackRange(float range, int frameInterval, bool isPredictVelocity);
bool IsTargetInAttackRange(float range, int frameInterval = ATTACK_RANGE_FRAMES, bool isPredictVelocity = false);
int GetAliveEnemyCount();
void AnimWalkFrame(std::string_view horizontalAnim, std::string_view verticalAnim, float speedThreshold);
void PlaySound(int id, float volume, int frameDelay, bool isLoop, float pitch);
+4 -2
View File
@@ -22,7 +22,8 @@ constexpr float BOSS_SHOT_SCATTER = 3.5f;
constexpr float BOSS_SHOT_FALL_ACCEL = 0.32f;
constexpr float BOSS_SHOT_FALL_ACCEL_PER_TRAJECTORY = 0.1f;
constexpr float BOSS_SHOT_FALL_SPEED = 5;
constexpr float BOSS_SHOT_FALL_SPEED_SPREAD = 24;
constexpr float BOSS_SHOT_FALL_SPEED_SPREAD = 30;
constexpr float BOSS_SHOT_FALL_SPEED_SHARE = 0.8f;
constexpr float BOSS_SHOT_SCALE = 0.9f;
constexpr float BOSS_SHOT_SCALE_LARGE = 0.4f;
constexpr float BOSS_SHOT_SCALE_SPREAD = 0.05f;
@@ -129,7 +130,8 @@ Entity_Projectile* Entity_NPC::FireBossProjectiles(int count, const Vector& targ
.seed = Random()}));
projectile->fallingAccel = fallingAccel;
projectile->fallingSpeed = BOSS_SHOT_FALL_SPEED - random_unit() * BOSS_SHOT_FALL_SPEED_SPREAD - trajectoryModifier;
projectile->fallingSpeed =
BOSS_SHOT_FALL_SPEED - random_unit() * BOSS_SHOT_FALL_SPEED_SPREAD * BOSS_SHOT_FALL_SPEED_SHARE - trajectoryModifier;
float size = (float)(Random() & 1) * BOSS_SHOT_SCALE_LARGE + BOSS_SHOT_SCALE;
size += random_unit() * BOSS_SHOT_SCALE_SPREAD;
projectile->scale = size * params.scale * shotScale;
+6 -9
View File
@@ -2,6 +2,7 @@
#include "entity_effect.h"
#include "entity_familiar.h"
#include "entity_pickup.h"
#include "boss_ai.h"
#include "entity_player.h"
#include "game.h"
#include "grid_entity_spikes.h"
@@ -342,15 +343,11 @@ void Entity_Pickup::TriggerShopPurchase(Entity_Player& player, int spentMoney)
priceANM2.Reset();
if (spentMoney > 0)
{
int wisps = 0;
for (Entity* wisp : g_game->room->entityList.wispEL)
{
if (wisp->type != ENTITY_FAMILIAR || wisp->variant != Entity_Familiar::WISP ||
wisp->subtype != COLLECTIBLE_COUPON)
continue;
if (wisps++ < spentMoney) wisp->Kill(EntityRef());
}
spentMoney = std::max(spentMoney - wisps, 0);
std::vector<Entity*> wisps;
for (Entity* wisp : entity_query(ENTITY_FAMILIAR, Entity_Familiar::WISP))
if (wisp->subtype == COLLECTIBLE_COUPON) wisps.push_back(wisp);
for (int i = 0; i < spentMoney && i < (int)wisps.size(); i++) wisps[i]->Kill(EntityRef());
spentMoney = std::max(spentMoney - (int)wisps.size(), 0);
player.AddCoins(-spentMoney);
coins_spent_count(player, spentMoney);
Player_stats_add(g_game->onlinePlayerStats, ONLINE_STAT_COINS_SPENT, &player, spentMoney);
+2
View File
@@ -652,6 +652,7 @@ enum PlayerItemId : int
COLLECTIBLE_DREAM_CATCHER = 566,
COLLECTIBLE_PLAYDOUGH_COOKIE = 570,
COLLECTIBLE_SOCKS = 571,
COLLECTIBLE_SOUL = 335,
COLLECTIBLE_EYE_OF_THE_OCCULT = 572,
COLLECTIBLE_DIRTY_MIND = 576,
COLLECTIBLE_DAMOCLES = 577,
@@ -1896,6 +1897,7 @@ public:
Vector GetLaserOffset(int laserOffsetId, const Vector& direction);
Entity_Laser* FireTechLaser(const TechLaserShot& shot);
Entity_Laser* FireBrimstone(const Vector& direction, Entity* source, float damageMultiplier);
Entity_Effect* FireBrimstoneBall(const PosVel& shot, const Vector& offset);
Entity_Laser* FireTechXLaser(const TechXShot& shot);
Entity_Knife* FireKnife(const KnifeShot& shot);
Vector delayed_shoot_direction();
+1 -2
View File
@@ -43,7 +43,6 @@ constexpr int BLOOD_EXPLOSION_LARGE = 3;
constexpr float QUARTER_TURN_DEGREES = 90;
constexpr float BELIAL_DAMAGE_SCALE = 1.4f;
constexpr float BELIAL_TEAR_SCALE_BONUS = 0.5f;
constexpr ColorMod FLUSH_POOP_COLOR = {{0, 0, 0, 1}, {0, 0, 0, 0}, {39 / 255.0f, 25 / 255.0f, 22 / 255.0f}};
constexpr int VERSUS_EFFECT_FRAMES = 450;
constexpr float HOURGLASS_VERSUS_SLOW = 0.9f;
@@ -979,7 +978,7 @@ static void flush_npc(ItemUse& use, Entity_NPC& npc)
npc.Remove();
Entity* poop = g_game->Spawn({.position = npc.pos, .type = ENTITY_POOP, .seed = Random()});
poop->splatColor = FLUSH_POOP_COLOR;
poop->splatColor = DARK_POOP_SPLAT_COLOR;
if (is_wisp_use(use)) player.AddWisp(use.id, player.pos, false, false);
if (npc.minecart) static_cast<Entity_NPC*>(npc.minecart.get())->MinecartUpdateChild(poop);
}
+16 -9
View File
@@ -47,6 +47,7 @@ constexpr int SHORT_FUSE = 22;
constexpr std::array<float, 3> SHORT_FUSE_DAMAGE = {15.000001f, 30.000002f, 50};
constexpr int SOUND_GLITTER_FUSE = 867;
constexpr int PLACE_SOUND_DELAY = 4;
constexpr float GIGA_ROCKET_PITCH = 0.8f;
// Dr. Fetus' bombs: their fuse (longer with Tiny Planet, shorter with Short Fuse, a rocket's after its flight), the
// throw Tiny Planet and Cricket's Body speed up, their size and damage by the tear's, and Tech X's ring around them.
@@ -141,7 +142,7 @@ TearFlags Entity_Player::GetBombFlags(bool isRollChances)
for (const BombItem& item : BOMB_ITEMS)
if (HasCollectible(item.collectible) && is_rolled(*this, item, isRollChances)) flags.set(item.flag);
if (HasCollectible(COLLECTIBLE_STICKY_BOMBS)) flags.set(TEAR_EGG_FLAG);
if (GetTrinketMultiplier(TRINKET_BOBS_BLADDER) > 0) flags.set(TEAR_CREEP_TRAIL);
if (HasTrinket(TRINKET_BOBS_BLADDER)) flags.set(TEAR_CREEP_TRAIL);
if (hasGoldenBomb && !isRollChances) flags.set(TEAR_GOLDEN_BOMB);
if (HasCollectible(COLLECTIBLE_FAST_BOMBS) && !isRollChances) flags.set(TEAR_FAST_BOMB);
if (HasCollectible(COLLECTIBLE_BLOOD_BOMBS)) flags.set(TEAR_BLOOD_BOMB);
@@ -172,10 +173,10 @@ static void hud_refresh_players()
}
// Plays a sound through the fart seeds.
static void bomb_sound_play(int sound, int frameDelay)
static void bomb_sound_play(int sound, int frameDelay, float pitch = 1)
{
seed_fart_sound_override(&sound);
g_manager->sfxManager.Play(sound, {.frameDelay = frameDelay});
g_manager->sfxManager.Play(sound, {.frameDelay = frameDelay, .pitch = pitch});
}
// Dresses a placed bomb: its size, effects and costumes, a big bomb's extra damage, a giga bomb lit at its end, Short
@@ -194,11 +195,12 @@ static void placed_bomb_setup(Entity_Player& player, Entity_Bomb& bomb, const Te
if (const AnimationData* data = bomb.sprite.animState.animData) bomb.sprite.animState.AdvancePosition(data->length - 1);
bomb.SetExplosionCountdown(BOMB_FUSE);
}
int shortFuse = player.GetTrinketMultiplier(TRINKET_SHORT_FUSE);
if (shortFuse > 0)
if (player.HasTrinket(TRINKET_SHORT_FUSE))
{
int shortFuse = player.GetTrinketMultiplier(TRINKET_SHORT_FUSE);
bomb.SetExplosionCountdown(SHORT_FUSE);
if (shortFuse <= (int)SHORT_FUSE_DAMAGE.size()) bomb.explosionDamage += SHORT_FUSE_DAMAGE[shortFuse - 1];
if (shortFuse >= 1 && shortFuse <= (int)SHORT_FUSE_DAMAGE.size())
bomb.explosionDamage += SHORT_FUSE_DAMAGE[shortFuse - 1];
}
if (flags[TEAR_FAST_BOMB]) bomb.AddEntityFlags(FLAG_NO_KNOCKBACK);
}
@@ -330,7 +332,13 @@ void Entity_Player::update_bomb_input()
if (i == 0)
{
bomb_count_take(*this, isFree);
bomb_sound_play(SOUND_FETUS_LAND, PLACE_SOUND_DELAY);
if (!rocket.isRocket) bomb_sound_play(SOUND_FETUS_LAND, PLACE_SOUND_DELAY);
else if (bombVariant != BOMB_ROCKET_GIGA) bomb_sound_play(SOUND_ROCKET_LAUNCH, PLACE_SOUND_DELAY);
else
{
bomb_sound_play(SOUND_BULLET_SHOT, PLACE_SOUND_DELAY);
bomb_sound_play(SOUND_ROCKET_LAUNCH, PLACE_SOUND_DELAY, GIGA_ROCKET_PITCH);
}
}
bomb.Update();
}
@@ -375,8 +383,7 @@ Entity_Bomb* Entity_Player::FireBomb(Vector position, Vector throwVelocity, Enti
bomb.AddEntityFlags(FLAG_NO_KNOCKBACK);
bomb.entityGridCollisionClass = GRIDCOLL_NOPITS;
// The original also counts a Short Fuse the online item queue is adding or taking away, which offline is none.
if (GetTrinketMultiplier(TRINKET_SHORT_FUSE) > 0) fuse -= FETUS_FUSE_SHORT;
if (HasTrinket(TRINKET_SHORT_FUSE)) fuse -= FETUS_FUSE_SHORT;
bomb.tearFlags = params.tearFlags;
bomb.isLoadCostumes = true;
bomb.SetExplosionCountdown(fuse);
+9 -8
View File
@@ -5,6 +5,7 @@
#include "entity_knife.h"
#include "entity_pickup.h"
#include "entity_player_tainted.h"
#include "entity_player_trinkets.h"
#include "game.h"
#include "hud.h"
#include "item_overlay.h"
@@ -61,8 +62,6 @@ constexpr float SAFE_SPAWN_NEAREST_START = 1e8f;
constexpr int SAFE_SPAWN_RADIUS_MIN = 30;
constexpr int SAFE_SPAWN_RADIUS_STEP = 3;
constexpr int SAFE_SPAWN_TRIES = 150;
constexpr int NPC_TYPE_FIRST = 10;
constexpr int NPC_TYPE_LAST = 999;
constexpr int ROOM_IDX_DEBUG = -16;
constexpr float FORGOTTEN_CHAIN_SCALE = 120;
constexpr int MAGDALENE_PILL_TRIES = 10;
@@ -385,7 +384,7 @@ Vector PlayerManager::find_safe_spawn_position(Vector position)
for (Entity* entity : room.entityList.updateEL)
{
bool isPlayer = game.deathmatchManager.is_active() && entity->type == ENTITY_PLAYER;
bool isEnemy = entity->type >= NPC_TYPE_FIRST && entity->type <= NPC_TYPE_LAST;
bool isEnemy = entity->type >= ENTITY_FIRST_ENEMY && entity->type <= ENTITY_LAST_ENEMY;
if (!isPlayer && !isEnemy && entity->type != ENTITY_PROJECTILE) continue;
dangers.push_back(entity->pos);
dangers.push_back(vector_make(entity->velocity.x * SAFE_SPAWN_LOOKAHEAD + entity->pos.x,
@@ -1050,15 +1049,15 @@ void Entity_Player::ChangePlayerType(int newType, bool isKeepState)
UpdateCostumes();
}
// The TakeDamage part (007729d0) for the items Eve and Samson start with: Dead Bird's effect wakes (and its costume
// goes), and Bloody Lust, Bloody Gust and Blood Rights count the hit, Bloody Lust's and Bloody Gust's effects waking
// (Samson's Bloody Lust without its costume). A versus match wakes Dead Bird for 15 seconds at most every 30.
void character_items_hit(Entity_Player& player)
// The TakeDamage steps (007729d0) for the items Eve and Samson start with: Dead Bird's effect wakes (and its costume
// goes), and later Bloody Lust, Bloody Gust and Blood Rights count the hit, Bloody Lust's and Bloody Gust's effects
// waking (Samson's Bloody Lust without its costume). A versus match wakes Dead Bird for 15 seconds at most every 30.
void character_items_hit(Entity_Player& player, HitStep step)
{
TemporaryEffects& effects = player.temporaryEffects;
bool isVersus = g_game->deathmatchManager.is_active();
if (player.HasCollectible(COLLECTIBLE_DEAD_BIRD) &&
if (step == HIT_STEP_DEAD_BIRD && player.HasCollectible(COLLECTIBLE_DEAD_BIRD) &&
(!isVersus || versus_cooldown_is_over(player.versus.deadBirdMs, DEAD_BIRD_VERSUS_MS)))
{
ItemConfig_Item* deadBird = g_manager->itemConfig.GetCollectible(COLLECTIBLE_DEAD_BIRD);
@@ -1071,6 +1070,8 @@ void character_items_hit(Entity_Player& player)
effects.AddEffect(birds, true, 1);
player.RemoveCostume(deadBird);
}
if (step != HIT_STEP_BLOODY_LUST) return;
bool isLust = player.HasCollectible(COLLECTIBLE_BLOODY_LUST);
bool isGust = player.HasCollectible(COLLECTIBLE_BLOODY_GUST);
if (!isLust && !isGust && !player.HasCollectible(COLLECTIBLE_BLOOD_RIGHTS)) return;
+2 -1
View File
@@ -25,6 +25,7 @@ enum PoopSpell : char
};
struct ItemUse;
enum HitStep : int;
// The buttons Jacob and Esau share: the item button and the pocket button.
enum TwinButton
@@ -63,7 +64,7 @@ void birthright_gain(Entity_Player& player, RNG& rng, bool isFirstTime);
void cambion_conception_hit(Entity_Player& player);
// Eve's Dead Bird and Samson's Bloody Lust answering a hit (007729d0).
void character_items_hit(Entity_Player& player);
void character_items_hit(Entity_Player& player, HitStep step);
// Tainted Magdalene's lasting red hearts (007d4320) and whether health above them is draining away.
int maggy_heart_limit(Entity_Player& player);
+4 -3
View File
@@ -197,7 +197,7 @@ static void collectible_last_removed(Entity_Player& player, int collectibleId)
player.update_greeds_gullet();
return;
case COLLECTIBLE_ROCK_BOTTOM:
player.rock_bottom_reset();
if (player.previewCollectible == 0 && player.previewTrinket == 0) player.rock_bottom_reset();
return;
case COLLECTIBLE_RED_KEY:
g_game->room->UpdateRedKey();
@@ -309,7 +309,7 @@ static void spin_to_win_end(Entity_Player& player)
for (Entity* entity : g_game->room->entityList.updateEL)
{
if (entity->type != ENTITY_FAMILIAR || static_cast<Entity_Familiar*>(entity)->player != &player) continue;
entity->ClearEntityFlags(FLAG_CONFUSION);
entity->ClearEntityFlags(FLAG_SPIN);
entity->size = entity->config->collisionRadius;
}
if (player.HasCollectible(COLLECTIBLE_BOOK_OF_VIRTUES))
@@ -517,7 +517,7 @@ void Entity_Player::trigger_collectible_effect_removed(ItemConfig_Item* item, in
}
// 0078f840 Takes a collectible from the player: a voided active leaves the Void, a helper's item goes from its
// backup, an active only from a slot (the first slot empties into the second). The count, the costumes, the
// backup, an active only from its first slot (the first slot empties into the second). The count, the costumes, the
// transformations and the history follow, and the stats are evaluated again.
void Entity_Player::RemoveCollectible(int type, bool isIgnoreModifiers, int activeSlot, bool isRemoveFromForm)
{
@@ -566,6 +566,7 @@ void Entity_Player::RemoveCollectible(int type, bool isIgnoreModifiers, int acti
activeItems[slot].batteryCharge = 0;
activeItems[slot].item = 0;
if (slot == ACTIVE_SLOT_PRIMARY) SwapActiveItems();
break;
}
TriggerCollectibleRemoved(type);
+6 -4
View File
@@ -57,6 +57,7 @@ constexpr float BABY_DEATH_THROW_STEP = 100;
constexpr float BABY_DEATH_THROW_HEIGHT = -30;
constexpr int HEART_HALF_SUBTYPE = 2;
constexpr uint32_t BABY_DEATH_TEAR_FLAGS = 3;
constexpr ColorMod LOST_BABY_CREEP_COLOR = {{0.9f, 0, 0, 1}, {0, 0, 0, 0}, {0, 0, 0}};
// The chain a Bound Baby keeps to its player, and its reach.
constexpr float BOUND_CHAIN_REACH = 120;
@@ -364,7 +365,7 @@ void Entity_Player::coop_baby_death_effect()
{
Entity* creep = game.Spawn({.position = pos, .spawner = this, .type = ENTITY_EFFECT,
.variant = EFFECT_PLAYER_CREEP_HOLYWATER, .seed = Random()});
creep->SetColor(ColorMod(), -1, COLOR_PRIORITY_DEFAULT, false, true);
creep->SetColor(LOST_BABY_CREEP_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
creep->Update();
break;
}
@@ -400,7 +401,8 @@ void Entity_Player::coop_baby_death_effect()
}
}
// 007bf040 Dresses a co-op baby in its skin's sheet (a basic baby in its subtype's), on every layer.
// 007bf040 Dresses a co-op baby in its skin's sheet (a basic baby in its subtype's), on every layer. A skin past the
// basic one keeps its sheets.
void Entity_Player::InitBabySkin()
{
std::vector<EntityConfig_Baby>& babies = g_manager->entityConfig.babies;
@@ -411,8 +413,8 @@ void Entity_Player::InitBabySkin()
if (skin < BABY_BASIC || skin >= babies.size()) log_printf(LOG_ASSERT, "Bad baby basic id %d", subtype);
if (skin < BABY_BASIC) skin = UINT32_MAX;
}
else if (skin < BABY_BASIC && skin >= babies.size())
log_printf(LOG_ASSERT, "Baby list is smaller than requested baby %d!", babySkin);
else if (skin > BABY_BASIC) skin = UINT32_MAX;
else if (skin >= babies.size()) log_printf(LOG_ASSERT, "Baby list is smaller than requested baby %d!", babySkin);
// The original reads past the baby list for a skin it lacks, so such a skin keeps the sheets here.
if (skin < babies.size())
+15 -15
View File
@@ -39,7 +39,6 @@ constexpr int TRINKET_SWALLOWED_M80 = 178;
constexpr int TRINKET_WALNUT = 108;
constexpr int NULLITEM_DOUBLE_DAMAGE = 29;
constexpr int SAMSON_B_HIT_CHARGE = 10000;
constexpr int BLEED_OUT_HEALTH = 600;
constexpr int SIREN_CHARM_SPARE_FRAMES = 29;
constexpr int WHITE_FIRE_VARIANT = 4;
@@ -60,8 +59,6 @@ constexpr int COIN_SHOOTER_TYPES[] = {50, 86, 90};
constexpr int ULTRA_GREED = 406;
constexpr int ULTRA_GREED_DOOR = 294;
constexpr int SOUND_NAIL_HURT_1 = 104;
constexpr int SOUND_NAIL_HURT_2 = 106;
constexpr int SOUND_BOSS_DELAY_RANDOM = 130;
constexpr int SOUND_BOSS_DELAY_MIN = 50;
constexpr int SOUND_FRAME_DELAY = 2;
@@ -746,19 +743,22 @@ static bool holy_mantle_block(Entity_Player& player)
return false;
}
// The items a landed hit sets off: collectibles 1 to 366, then the trinkets and later collectibles
// (entity_player_hits.cpp), Eve's Dead Bird and Samson's Bloody Lust, then Tainted Samson's rage. Bleeding out
// restarts its timer. The amount is the hit's hearts, not yet taken. Whether the hurt animation still plays.
// The items a landed hit sets off, step by step in the original's order (HitStep): the passives, the characters'
// items, the trinkets and later collectibles (entity_player_hits.cpp, which also restarts a self-inflicted bleed), and
// Tainted Samson's rage. The amount is the hit's hearts, not yet taken. Whether the hurt animation still plays.
static bool hit_items_check(Entity_Player& player, int amount, const ItemsHit& hit)
{
passives_hit_trigger(player, amount);
bool isHurtShown = late_items_hit_trigger(player, hit);
character_items_hit(player);
if (player.playerType == PLAYER_SAMSON_B && (player.redHearts > 0 || player.soulHearts > 0 || player.boneHearts > 0))
player.add_samson_berserk_charge(SAMSON_B_HIT_CHARGE);
if (player.HasEntityFlags(FLAG_BLEED_OUT) && player.bleedSource.entity == &player && player.bleedOutHealth > 0)
player.bleedOutHealth = BLEED_OUT_HEALTH;
bool isHurtShown = true;
for (int i = 0; i < HIT_STEP_COUNT; i++)
{
HitStep step = (HitStep)i;
passives_hit_trigger(player, amount, step);
character_items_hit(player, step);
if (!late_items_hit_trigger(player, hit, step)) isHurtShown = false;
bool isSamsonRaging = player.playerType == PLAYER_SAMSON_B &&
(player.redHearts > 0 || player.soulHearts > 0 || player.boneHearts > 0);
if (step == HIT_STEP_SAMSON && isSamsonRaging) player.add_samson_berserk_charge(SAMSON_B_HIT_CHARGE);
}
return isHurtShown;
}
@@ -1055,7 +1055,7 @@ bool Entity_Player::TakeDamage(float damage, uint64_t damageFlags, const EntityR
float pitch = get_voice_pitch();
int grunt = SOUND_ISAAC_HURT_GRUNT;
if (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_THE_NAIL)) grunt = random_below(2) ? SOUND_NAIL_HURT_1 : SOUND_NAIL_HURT_2;
if (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_THE_NAIL)) grunt = random_below(2) ? SOUND_MONSTER_GRUNT_0 : SOUND_MONSTER_GRUNT_1;
voice_play(grunt, volume, SOUND_FRAME_DELAY, pitch);
if (source.type == ENTITY_MOM || source.type == ENTITY_MOMS_HEART)
voice_play(source.type == ENTITY_MOM ? SOUND_MOM_VOX_EVILLAUGH : SOUND_MOM_VOX_FILTERED_EVILLAUGH, 1,
+1 -1
View File
@@ -1565,7 +1565,7 @@ static void spear_of_destiny_update(Entity_Player& player, const PassiveShot& sh
if (shot.isShootHeld)
{
Vector aim = is_zero(shot.direction) ? vector_from_direction(player.headDirection) : shot.direction;
float angle = angle_wrapped(vector_angle(aim) - RIGHT_ANGLE_DEGREES);
float angle = normalize_angle_degrees(vector_angle(aim) - RIGHT_ANGLE_DEGREES);
spear->rotation = angle;
player.spearOfDestinyAngle = angle;
rate = SPEAR_SWING_RATE;
+1 -2
View File
@@ -872,7 +872,6 @@ void Entity_Player::SyncConsumables(Entity_Player* target, uint32_t mask)
// Tainted Bethany's blood charges, given as now and before.
void Entity_Player::charge_store_changed(int effectiveCharge, int oldCharge)
{
constexpr int SOUND_BATTERY_CHARGE = 171;
constexpr int POCKET_SLOT = 3;
constexpr int RED_KEY_SLOT = 2;
@@ -890,7 +889,7 @@ void Entity_Player::charge_store_changed(int effectiveCharge, int oldCharge)
int before = total - effectiveCharge + oldCharge;
if (before >= total || before >= maxCharge) continue;
g_game->hud.FlashChargeBar(this, slot);
sound_play(total < maxCharge ? SOUND_BATTERY_CHARGE : SOUND_ITEMRECHARGE);
sound_play(total < maxCharge ? SOUND_BEEP : SOUND_ITEMRECHARGE);
}
if (!HasTrinket(TRINKET_VIBRANT_BULB) && !HasTrinket(TRINKET_DIM_BULB)) return;
cacheFlags |= CACHE_DAMAGE | CACHE_FIREDELAY | CACHE_SHOTSPEED | CACHE_RANGE | CACHE_LUCK;
+67 -49
View File
@@ -391,64 +391,80 @@ static void butter_hit(Entity_Player& player)
sound_play(SOUND_BUTTER_DROP);
}
// The hit part of 007729d0 for the trinkets and collectibles 367 on, in their order there (the collectibles 1 to 366
// run first, in passives_hit_trigger): Red Patch, Missing Page, Fish Head, Leprosy, Giant Cell, Salvation, Perfection,
// Stompy, the Bird Cage, Larynx, Swallowed Penny, Cartridge, Curse of the Tower, Cracked Dice, Purity, the Crown of
// Light, the Shard of Glass, Varicose Veins, It Hurts, the Cracked Orb, the Vengeful Spirit, Torn Pocket,
// Hypercoagulation, Large Zit, Tonsil, Bag Lunch, Umbilical Cord, Wish Bone, Bozo and Butter. Whether the hurt
// animation still plays (Cartridge's Gamekid stops it).
bool late_items_hit_trigger(Entity_Player& player, const ItemsHit& hit)
// The hit steps of 007729d0 for the trinkets and collectibles 367 on, in their order there (the passives and the
// characters' items run between them, see HitStep): Red Patch, Missing Page, Fish Head, then Leprosy, Giant Cell,
// Salvation, Perfection, Stompy, then the Bird Cage and Larynx, then Swallowed Penny, then Cartridge, then Curse of the
// Tower, Cracked Dice, Purity, the Crown of Light, Cambion Conception, a self-inflicted bleed's restart, the Shard of
// Glass, Varicose Veins, It Hurts, the Cracked Orb, the Vengeful Spirit, Torn Pocket, Hypercoagulation, Large Zit,
// Tonsil, Bag Lunch, Umbilical Cord, Wish Bone, Bozo and Butter. Whether the hurt animation still plays (Cartridge's
// Gamekid stops it).
bool late_items_hit_trigger(Entity_Player& player, const ItemsHit& hit, HitStep step)
{
Game& game = *g_game;
TemporaryEffects& effects = player.temporaryEffects;
bool isVersus = game.deathmatchManager.is_active();
bool isHurtShown = true;
if (player.HasTrinket(TRINKET_RED_PATCH)) red_patch_hit(player);
if (player.HasTrinket(TRINKET_MISSING_PAGE)) missing_page_hit(player);
if (player.HasTrinket(TRINKET_FISH_HEAD) && (!isVersus || random_below(FISH_HEAD_VERSUS_ODDS) == 0))
switch (step)
{
int multiplier = player.GetTrinketMultiplier(TRINKET_FISH_HEAD);
player.AddBlueFlies(multiplier * (random_below(2) + 1), player.pos, nullptr);
}
if (player.HasCollectible(COLLECTIBLE_LEPROSY))
{
if (!isVersus || ++player.versus.leprosyHits % LEPROSY_VERSUS_HITS == 0) player.AddLeprosy();
}
if (player.HasCollectible(COLLECTIBLE_GIANT_CELL)) giant_cell_hit(player, hit.damage);
if (player.HasCollectible(COLLECTIBLE_SALVATION) && effects.GetCollectibleEffectNum(COLLECTIBLE_SALVATION) < SALVATION_HITS_MAX)
effects.AddCollectibleEffect(COLLECTIBLE_SALVATION, true, 1);
if (hit.isPenalized && player.HasTrinket(TRINKET_PERFECTION) && player.TryRemoveTrinket(TRINKET_PERFECTION))
perfection_break(player);
if (player.HasPlayerForm(PLAYER_FORM_STOMPY) && random_below(STOMPY_ODDS) == 0)
{
uint32_t seed = Random();
auto* wave = static_cast<Entity_Effect*>(game.Spawn({.position = player.pos, .spawner = &player,
.type = ENTITY_EFFECT, .variant = EFFECT_SHOCKWAVE,
.seed = seed}));
wave->parent = &player;
wave->SetRadii(player.size, STOMPY_RADIUS_MAX);
wave->SetTimeout(STOMPY_TIMEOUT);
}
if (player.HasCollectible(COLLECTIBLE_BIRD_CAGE))
{
effects.AddCollectibleEffect(COLLECTIBLE_BIRD_CAGE, true, 1);
player.RemoveCostume(g_manager->itemConfig.GetCollectible(COLLECTIBLE_BIRD_CAGE));
}
for (int slot = 0; slot < ACTIVE_SLOT_COUNT; slot++)
if (player.activeItems[slot].item == COLLECTIBLE_LARYNX) player.AddActiveCharge(1, slot, false, false, false);
if (player.HasTrinket(TRINKET_SWALLOWED_PENNY)) swallowed_penny_hit(player);
if (player.HasTrinket(TRINKET_CARTRIDGE))
{
int odds = std::max(1, CARTRIDGE_ODDS - (int)(player.luck * CARTRIDGE_LUCK));
int roll = (int)player.GetTrinketRNG(TRINKET_CARTRIDGE).RandomInt((uint32_t)odds);
if (roll < player.GetTrinketMultiplier(TRINKET_CARTRIDGE) && !effects.HasCollectibleEffect(COLLECTIBLE_GAMEKID))
case HIT_STEP_RED_PATCH:
if (player.HasTrinket(TRINKET_RED_PATCH)) red_patch_hit(player);
if (player.HasTrinket(TRINKET_MISSING_PAGE)) missing_page_hit(player);
if (player.HasTrinket(TRINKET_FISH_HEAD) && (!isVersus || random_below(FISH_HEAD_VERSUS_ODDS) == 0))
{
int multiplier = player.GetTrinketMultiplier(TRINKET_FISH_HEAD);
player.AddBlueFlies(multiplier * (random_below(2) + 1), player.pos, nullptr);
}
return true;
case HIT_STEP_LEPROSY:
if (player.HasCollectible(COLLECTIBLE_LEPROSY))
{
if (!isVersus || ++player.versus.leprosyHits % LEPROSY_VERSUS_HITS == 0) player.AddLeprosy();
}
if (player.HasCollectible(COLLECTIBLE_GIANT_CELL)) giant_cell_hit(player, hit.damage);
if (player.HasCollectible(COLLECTIBLE_SALVATION) &&
effects.GetCollectibleEffectNum(COLLECTIBLE_SALVATION) < SALVATION_HITS_MAX)
effects.AddCollectibleEffect(COLLECTIBLE_SALVATION, true, 1);
if (hit.isPenalized && player.HasTrinket(TRINKET_PERFECTION) && player.TryRemoveTrinket(TRINKET_PERFECTION))
perfection_break(player);
if (player.HasPlayerForm(PLAYER_FORM_STOMPY) && random_below(STOMPY_ODDS) == 0)
{
uint32_t seed = Random();
auto* wave = static_cast<Entity_Effect*>(game.Spawn({.position = player.pos, .spawner = &player,
.type = ENTITY_EFFECT, .variant = EFFECT_SHOCKWAVE,
.seed = seed}));
wave->parent = &player;
wave->SetRadii(player.size, STOMPY_RADIUS_MAX);
wave->SetTimeout(STOMPY_TIMEOUT);
}
return true;
case HIT_STEP_BIRD_CAGE:
if (player.HasCollectible(COLLECTIBLE_BIRD_CAGE))
{
effects.AddCollectibleEffect(COLLECTIBLE_BIRD_CAGE, true, 1);
player.RemoveCostume(g_manager->itemConfig.GetCollectible(COLLECTIBLE_BIRD_CAGE));
}
for (int slot = 0; slot < ACTIVE_SLOT_COUNT; slot++)
if (player.activeItems[slot].item == COLLECTIBLE_LARYNX) player.AddActiveCharge(1, slot, false, false, false);
return true;
case HIT_STEP_SWALLOWED_PENNY:
if (player.HasTrinket(TRINKET_SWALLOWED_PENNY)) swallowed_penny_hit(player);
return true;
case HIT_STEP_CARTRIDGE:
{
if (!player.HasTrinket(TRINKET_CARTRIDGE)) return true;
int odds = std::max(1, CARTRIDGE_ODDS - (int)(player.luck * CARTRIDGE_LUCK));
int roll = (int)player.GetTrinketRNG(TRINKET_CARTRIDGE).RandomInt((uint32_t)odds);
if (roll >= player.GetTrinketMultiplier(TRINKET_CARTRIDGE) || effects.HasCollectibleEffect(COLLECTIBLE_GAMEKID))
return true;
player.UseActiveItem({.item = COLLECTIBLE_GAMEKID, .flags = USE_NOANIM});
isHurtShown = false;
return false;
}
case HIT_STEP_TOWER:
break;
default:
return true;
}
if (player.HasCollectible(COLLECTIBLE_CURSE_OF_THE_TOWER) && hit.source.type != ENTITY_BOMB && hit.source.type != ENTITY_SLOT)
effects.AddEffect(TemporaryEffect(g_manager->itemConfig.GetCollectible(COLLECTIBLE_ANARCHIST_COOKBOOK)), true, 1);
if (player.HasTrinket(TRINKET_CRACKED_DICE))
@@ -466,6 +482,8 @@ bool late_items_hit_trigger(Entity_Player& player, const ItemsHit& hit)
player.crownOfLightSprite.Play("FloatNoGlow");
}
if (player.HasCollectible(COLLECTIBLE_CAMBION_CONCEPTION)) cambion_conception_hit(player);
if (player.HasEntityFlags(FLAG_BLEED_OUT) && player.bleedSource.entity == &player && player.bleedOutHealth > 0)
player.bleedOutHealth = BLEED_OUT_FRAMES;
if (player.HasCollectible(COLLECTIBLE_SHARD_OF_GLASS))
{
@@ -510,7 +528,7 @@ bool late_items_hit_trigger(Entity_Player& player, const ItemsHit& hit)
}
if (player.HasCollectible(COLLECTIBLE_BOZO)) bozo_hit(player);
if (player.HasTrinket(TRINKET_BUTTER)) butter_hit(player);
return isHurtShown;
return true;
}
// The rooms a stronger Cursed Skull sends the player to.
+18 -14
View File
@@ -574,7 +574,6 @@ void Entity_Player::TriggerNewRoom_TemporaryEffects()
temporaryEffects.AddCollectibleEffect(COLLECTIBLE_EMPTY_VESSEL, true, 1);
AddCostume(vessel, false);
}
if (vessel) temporaryEffects.AddEffect(TemporaryEffect(vessel), true, 1);
}
if (ItemConfig_Item* scapular = items.GetCollectible(COLLECTIBLE_SCAPULAR); scapular && HasCollectible(COLLECTIBLE_SCAPULAR))
temporaryEffects.AddEffect(TemporaryEffect(scapular), true, 1);
@@ -631,7 +630,6 @@ constexpr TagUnlock STARS_UNLOCK = {TAG_STARS, 2, 406};
// The pickups, sounds and stand-ins the collectibles' own pickup effects (in 0075f0e0) use.
constexpr int COIN_LUCKY_PENNY = 5;
constexpr int SOUND_KISS_LIPS = 219;
constexpr int SOUND_PEEPER_POP = 237;
constexpr int ROSARY_BIBLE_UPGRADE = 5;
constexpr int RED_STEW_FRAMES = 5400;
constexpr int RED_STEW_DEATHMATCH_FRAMES = 600;
@@ -1374,8 +1372,7 @@ static bool collectible_drops_apply(Entity_Player& p, const CollectibleGain& gai
}
// The part of 0075f0e0 a main player's collectible runs for itself: maps, transformation counters, heals, charges,
// curses lifted, effects started, and on the first pickup the pickups it drops. The items not written yet stop the
// game until reached. An active slot past the four reads past them in the original, here it is ignored.
// curses lifted, effects started, and on the first pickup the pickups it drops.
static void collectible_effect_apply(Entity_Player& p, const CollectibleGain& gain)
{
Game& game = *g_game;
@@ -1422,7 +1419,7 @@ static void collectible_effect_apply(Entity_Player& p, const CollectibleGain& ga
p.temporaryEffects.AddCollectibleEffect(142, true, 1);
return;
case 155:
sound_play(SOUND_PEEPER_POP);
sound_play(SOUND_PLOP);
return;
case 179:
case 601:
@@ -1485,8 +1482,7 @@ static void collectible_effect_apply(Entity_Player& p, const CollectibleGain& ga
if (isFirst) dogma_gain(p);
return;
case 685:
if (gain.slot >= 0 && gain.slot < ACTIVE_SLOT_COUNT)
p.activeItems[gain.slot].varData = std::max(p.activeItems[gain.slot].varData, 2);
p.activeItems[gain.slot].varData = std::max(p.activeItems[gain.slot].varData, 2);
return;
case 692:
game.room->spawn_sanguine_bond_spikes(false);
@@ -1594,7 +1590,7 @@ static void collectible_late_effect_apply(Entity_Player& p, const CollectibleGai
}
}
// 0075f0e0 Gives the player a collectible: Tainted Jacob's ghost passes it to Jacob, it joins the collection, the
// 0075f0e0 Gives the player a collectible: Tainted Forgotten's soul passes it to its body, it joins the collection, the
// counts and the history, its first pickup gives its pickups and hearts, the unlocks for many items are checked, its
// own pickup effect runs, its cache flags are evaluated, transformations count it, and its costume goes on. An active
// takes its slot, and Book of Virtues an empty first one. The history keeps the pool the item came from. Nothing is
@@ -1612,11 +1608,15 @@ void Entity_Player::AddCollectible(int type, int charge, bool isFirstTime, int a
transition != STAGE_TRANSITION_IN && transition != STAGE_TRANSITION_LANDING)
return;
Entity_Player* twin = twin_get();
if (playerType == PLAYER_JACOB2_B && twin && item->type != ITEM_ACTIVE)
return twin->AddCollectible(type, charge, isFirstTime, slot, varData, poolType);
if (playerType == PLAYER_THESOUL_B && twin && item->type != ITEM_ACTIVE)
return twin->AddCollectible(type, charge, isFirstTime, slot, varData, 0);
if (charge < 0) charge = item->initCharge;
if (charge < 0) charge = GetCollectibleMaxCharge(type, varData);
std::string_view poolName = poolType >= 0 && poolType < POOL_COUNT ? POOL_NAMES[poolType] : "";
log_printf(LOG_INFO, "Adding collectible %d (%s) to player %d (%s) from pool %s\n", type,
item->GetLocalizedName(LANGUAGE_CURRENT).c_str(), playerIndex, name.c_str(), "");
item->GetLocalizedName(LANGUAGE_CURRENT).c_str(), playerIndex, name.c_str(),
std::string(poolName).c_str());
DeathmatchManager& versus = game.deathmatchManager;
if (!versus.is_active() && g_manager->netplayManager.is_online() && !versus.type->is_collectible_banned(type))
versus.type->collectiblePool[type] = true;
@@ -1649,10 +1649,10 @@ void Entity_Player::AddCollectible(int type, int charge, bool isFirstTime, int a
else cacheFlags |= item->cacheFlags;
if (HasCollectible(COLLECTIBLE_BINGE_EATER) && item->HasTags(TAG_FOOD))
cacheFlags |= g_manager->itemConfig.GetCollectible(COLLECTIBLE_BINGE_EATER)->cacheFlags;
CollectibleGain gain{type, charge, activeSlot, isFirstTime};
CollectibleGain gain{type, charge, slot, isFirstTime};
if (variant == PLAYER_VARIANT_PLAYER) collectible_effect_apply(*this, gain);
if (variant == PLAYER_VARIANT_PLAYER && HasCollectible(COLLECTIBLE_BINGE_EATER) && item->HasTags(TAG_FOOD) &&
isFirstTime)
if (type >= 0 && variant == PLAYER_VARIANT_PLAYER && HasCollectible(COLLECTIBLE_BINGE_EATER) &&
item->HasTags(TAG_FOOD) && isFirstTime)
{
redStewBonusDuration = std::max(redStewBonusDuration, BINGE_EATER_STEW_FRAMES);
AddHearts(2, false, false);
@@ -1667,7 +1667,11 @@ void Entity_Player::AddCollectible(int type, int charge, bool isFirstTime, int a
IncrementPlayerFormCounter(form, 1);
}
EvaluateItems();
bool isHurting = item->addMaxHearts < 0 || item->addHearts < 0 || item->addSoulHearts < 0 || item->addBlackHearts < 0;
if (type < 0 && isHurting) TryPreventDeath();
// The original takes off Spoon Bender's costume (collectible 3) for an active picked up mid-use, not the active's.
if (item->isAddCostumeOnPickup) AddCostume(item, false);
else if (item->type == ITEM_ACTIVE && itemState != 0) TryRemoveCollectibleCostume(COLLECTIBLE_SPOON_BENDER, false);
int owned = 0;
for (int count : collectibleCounts) owned += count;
+9 -10
View File
@@ -10,7 +10,6 @@
#include "room_grid.h"
#include <algorithm>
constexpr int COLLECTIBLE_CHARM_OF_THE_VAMPIRE = 62;
// Charm of the Vampire heals every 13 kills, every 8 in a versus match. The heart rises 24 above the player.
constexpr int VAMPIRE_KILLS = 13;
@@ -78,17 +77,17 @@ static bool is_luck_roll_won(Entity_Player& player, int odds, float luckScale, i
// Samson's Lock and Eve's Bird Foot: a chance at their temporary effect.
static void luck_trinkets_update(Entity_Player& player)
{
int lock = player.GetTrinketMultiplier(TRINKET_SAMSONS_LOCK);
if (lock > 0)
if (player.HasTrinket(TRINKET_SAMSONS_LOCK))
{
int lock = player.GetTrinketMultiplier(TRINKET_SAMSONS_LOCK);
int odds = lock == 2 ? SAMSONS_LOCK_ODDS_DOUBLE : lock >= 3 ? SAMSONS_LOCK_ODDS_TRIPLE : SAMSONS_LOCK_ODDS;
if (is_luck_roll_won(player, odds, SAMSONS_LOCK_LUCK_SCALE, SAMSONS_LOCK_ROLL))
player.temporaryEffects.AddTrinketEffect(TRINKET_SAMSONS_LOCK, true, 1);
}
int foot = player.GetTrinketMultiplier(TRINKET_EVES_BIRD_FOOT);
if (foot <= 0) return;
if (!player.HasTrinket(TRINKET_EVES_BIRD_FOOT)) return;
int foot = player.GetTrinketMultiplier(TRINKET_EVES_BIRD_FOOT);
int odds = foot == 2 ? EVES_BIRD_FOOT_ODDS_DOUBLE : foot >= 3 ? EVES_BIRD_FOOT_ODDS_TRIPLE : EVES_BIRD_FOOT_ODDS;
if (is_luck_roll_won(player, odds, EVES_BIRD_FOOT_LUCK_SCALE, EVES_BIRD_FOOT_ROLL))
player.temporaryEffects.AddTrinketEffect(TRINKET_EVES_BIRD_FOOT, true, 1);
@@ -97,9 +96,9 @@ static void luck_trinkets_update(Entity_Player& player)
// Bat Wing: while it is not flying, one kill in 20 (10 doubled, 7 tripled) gives its flight and wings.
static void bat_wing_update(Entity_Player& player)
{
int multiplier = player.GetTrinketMultiplier(TRINKET_BAT_WING);
if (multiplier <= 0 || player.temporaryEffects.HasTrinketEffect(TRINKET_BAT_WING)) return;
if (!player.HasTrinket(TRINKET_BAT_WING) || player.temporaryEffects.HasTrinketEffect(TRINKET_BAT_WING)) return;
int multiplier = player.GetTrinketMultiplier(TRINKET_BAT_WING);
int odds = multiplier == 2 ? BAT_WING_ODDS_DOUBLE : multiplier == 3 ? BAT_WING_ODDS_TRIPLE : BAT_WING_ODDS;
if (player.trinketRNGs[TRINKET_BAT_WING].RandomInt(odds) != 0) return;
@@ -142,9 +141,9 @@ static void berserk_update(Entity_Player& player, Entity& npc)
// Sigil of Baphomet: each kill grants Book of Shadows for a while, up to a cap. A fresh shield plays its sound.
static void sigil_update(Entity_Player& player)
{
int multiplier = player.GetTrinketMultiplier(TRINKET_SIGIL_OF_BAPHOMET);
if (multiplier <= 0) return;
if (!player.HasTrinket(TRINKET_SIGIL_OF_BAPHOMET)) return;
int multiplier = player.GetTrinketMultiplier(TRINKET_SIGIL_OF_BAPHOMET);
int frames = multiplier == 2 ? SIGIL_FRAMES_DOUBLE : multiplier == 3 ? SIGIL_FRAMES_TRIPLE : SIGIL_FRAMES;
int maxFrames = multiplier == 2 ? SIGIL_MAX_FRAMES_DOUBLE
: multiplier == 3 ? SIGIL_MAX_FRAMES_TRIPLE
@@ -224,7 +223,7 @@ void Entity_Player::trigger_npc_death(Entity* npc)
void Entity_Player::trigger_vampire_charm_kill()
{
int kills = g_game->deathmatchManager.is_active() ? VAMPIRE_KILLS_VERSUS : VAMPIRE_KILLS;
if (!HasCollectible(COLLECTIBLE_CHARM_OF_THE_VAMPIRE)) return;
if (!HasCollectible(COLLECTIBLE_CHARM_VAMPIRE)) return;
if ((int)++vampireCharmKills < kills || isDead) return;
sound_play(playerType == PLAYER_MAGDALENE_B ? SOUND_VAMP_DOUBLE : SOUND_VAMP_GULP);
+61 -41
View File
@@ -6,6 +6,7 @@
#include "entity_laser.h"
#include "entity_pickup.h"
#include "entity_player.h"
#include "entity_player_trinkets.h"
#include "game.h"
#include "grid_entity_door.h"
#include "grid_entity_rock.h"
@@ -435,55 +436,18 @@ static void missing_page_hit(Entity_Player& player, int amount)
player.UseActiveItem({.item = COLLECTIBLE_NECRONOMICON, .flags = USE_NOANIM});
}
// The collectibles 1 to 366 a landed hit sets off (part of 007729d0), in their order there: Infestation's flies,
// Celtic Cross's shield, Best Bud, Habit's charge, the Black Bean, Anemic, the pickups of Fanny Pack, Old Bandage,
// Gimpy and Piggy Bank, Spiderbaby's spiders, Missing Page 2, Cancer's and Virgo's protection. The amount is the hit's
// hearts, not yet taken.
void passives_hit_trigger(Entity_Player& player, int amount)
// The last passives of a hit, after the Cartridge: Spiderbaby's spiders, Missing Page 2, Cancer's and Virgo's
// protection.
static void late_passives_hit(Entity_Player& player, int amount)
{
bool isVersus = g_game->deathmatchManager.is_active();
auto has = [&](int id) { return player.HasCollectible(id); };
auto zodiac = [&](int id) { return has(id) || player.GetZodiacEffect() == id; };
VersusPacing& pacing = player.versus;
auto is_ready = [isVersus](uint64_t stampMs, uint64_t cooldownMs) {
return !isVersus || versus_cooldown_is_over(stampMs, cooldownMs);
};
if (has(COLLECTIBLE_INFESTATION) && is_ready(pacing.infestationMs, INFESTATION_VERSUS_MS))
{
player.AddBlueFlies(random_below(INFESTATION_FLIES_RANGE) + INFESTATION_FLIES_MIN, player.pos, nullptr);
pacing.infestationMs = versus_time_get();
}
if (has(COLLECTIBLE_CELTIC_CROSS) &&
random_below(std::max(1, CELTIC_CROSS_ODDS - (int)(player.luck * CELTIC_CROSS_LUCK))) == 0)
effect_lend(player, COLLECTIBLE_BOOK_OF_SHADOWS, COLLECTIBLE_CELTIC_CROSS);
if (has(COLLECTIBLE_BEST_BUD)) player.temporaryEffects.AddCollectibleEffect(COLLECTIBLE_BEST_BUD, true, 1);
if (has(COLLECTIBLE_HABIT))
{
bool isCharged = !isVersus;
if (isVersus)
{
pacing.habitDamage = (uint8_t)(pacing.habitDamage + amount);
isCharged = pacing.habitDamage >= HABIT_VERSUS_DAMAGE;
if (isCharged) pacing.habitDamage -= HABIT_VERSUS_DAMAGE;
}
if (isCharged) player.AddActiveCharge(1, ACTIVE_SLOT_NONE, false, false, false);
}
if (has(COLLECTIBLE_BLACK_BEAN) && is_ready(pacing.blackBeanMs, BLACK_BEAN_VERSUS_MS))
{
player.temporaryEffects.AddCollectibleEffect(COLLECTIBLE_BLACK_BEAN, true, 1);
pacing.blackBeanMs = versus_time_get();
}
if (has(COLLECTIBLE_ANEMIC))
{
TemporaryEffect anemic(g_manager->itemConfig.GetCollectible(COLLECTIBLE_ANEMIC));
if (isVersus) anemic.cooldown = ANEMIC_VERSUS_FRAMES;
player.temporaryEffects.AddEffect(anemic, true, 1);
}
if (has(COLLECTIBLE_FANNY_PACK)) fanny_pack_hit(player);
heart_items_hit(player);
if (has(COLLECTIBLE_PIGGY_BANK)) piggy_bank_hit(player);
if (has(COLLECTIBLE_SPIDERBABY) && is_ready(pacing.spiderbabyMs, SPIDERBABY_VERSUS_MS))
{
RNG& rng = player.GetCollectibleRNG(COLLECTIBLE_SPIDERBABY);
@@ -509,6 +473,62 @@ void passives_hit_trigger(Entity_Player& player, int amount)
}
}
// The collectibles 1 to 366 a landed hit sets off (TakeDamage 007729d0's steps), in their order there: Infestation's
// flies, Celtic Cross's shield, Best Bud, Habit's charge, the Black Bean, Anemic, the pickups of Fanny Pack, Old
// Bandage, Gimpy and Piggy Bank, Spiderbaby's spiders, Missing Page 2, Cancer's and Virgo's protection. The amount is
// the hit's hearts, not yet taken.
void passives_hit_trigger(Entity_Player& player, int amount, HitStep step)
{
bool isVersus = g_game->deathmatchManager.is_active();
auto has = [&](int id) { return player.HasCollectible(id); };
VersusPacing& pacing = player.versus;
auto is_ready = [isVersus](uint64_t stampMs, uint64_t cooldownMs) {
return !isVersus || versus_cooldown_is_over(stampMs, cooldownMs);
};
if (step == HIT_STEP_INFESTATION && has(COLLECTIBLE_INFESTATION) && is_ready(pacing.infestationMs, INFESTATION_VERSUS_MS))
{
player.AddBlueFlies(random_below(INFESTATION_FLIES_RANGE) + INFESTATION_FLIES_MIN, player.pos, nullptr);
pacing.infestationMs = versus_time_get();
}
if (step == HIT_STEP_CELTIC_CROSS && has(COLLECTIBLE_CELTIC_CROSS) &&
random_below(std::max(1, CELTIC_CROSS_ODDS - (int)(player.luck * CELTIC_CROSS_LUCK))) == 0)
effect_lend(player, COLLECTIBLE_BOOK_OF_SHADOWS, COLLECTIBLE_CELTIC_CROSS);
if (step == HIT_STEP_FANNY_PACK)
{
if (has(COLLECTIBLE_FANNY_PACK)) fanny_pack_hit(player);
heart_items_hit(player);
if (has(COLLECTIBLE_PIGGY_BANK)) piggy_bank_hit(player);
}
if (step == HIT_STEP_SPIDERBABY) late_passives_hit(player, amount);
if (step != HIT_STEP_BEST_BUD) return;
if (has(COLLECTIBLE_BEST_BUD)) player.temporaryEffects.AddCollectibleEffect(COLLECTIBLE_BEST_BUD, true, 1);
if (has(COLLECTIBLE_HABIT))
{
bool isCharged = !isVersus;
if (isVersus)
{
pacing.habitDamage = (uint8_t)(pacing.habitDamage + amount);
isCharged = pacing.habitDamage >= HABIT_VERSUS_DAMAGE;
if (isCharged) pacing.habitDamage -= HABIT_VERSUS_DAMAGE;
}
if (isCharged) player.AddActiveCharge(1, ACTIVE_SLOT_NONE, false, false, false);
}
if (has(COLLECTIBLE_BLACK_BEAN) && is_ready(pacing.blackBeanMs, BLACK_BEAN_VERSUS_MS))
{
player.temporaryEffects.AddCollectibleEffect(COLLECTIBLE_BLACK_BEAN, true, 1);
pacing.blackBeanMs = versus_time_get();
}
if (has(COLLECTIBLE_ANEMIC))
{
TemporaryEffect anemic(g_manager->itemConfig.GetCollectible(COLLECTIBLE_ANEMIC));
if (isVersus) anemic.cooldown = ANEMIC_VERSUS_FRAMES;
player.temporaryEffects.AddEffect(anemic, true, 1);
}
}
// Cursed Eye, without the Black Candle: a hit while the weapon charges teleports the player to a random room. Whether
// it did, which keeps the hit from animating.
bool cursed_eye_teleport(Entity_Player& player)
@@ -660,7 +680,7 @@ void trinity_shield_update(Entity_Player& player, const PassiveShot& shot)
Vector aim = isFacing && player.headDirection >= DIRECTION_LEFT && player.headDirection <= DIRECTION_DOWN
? vector_make(FACED_X[player.headDirection], FACED_Y[player.headDirection])
: shot.direction;
shield.rotation = angle_wrap(vector_angle(aim) - SHIELD_SIDE);
shield.rotation = normalize_angle_degrees(vector_angle(aim) - SHIELD_SIDE);
player.trinityShieldAngle = shield.rotation;
turn = SHIELD_TURN_SHOOTING;
}
+2 -1
View File
@@ -6,6 +6,7 @@
struct EffectBehaviour;
struct Entity_Player;
struct TemporaryEffect;
enum HitStep : int;
// Toxic Shock's green poop clouds, and how fast Unicorn Stump's music changes volume.
constexpr ColorMod TOXIC_SHOCK_COLOR = {{1, 1, 1, 1}, {0, 1, 0, 1}, {0, 0, 0}};
@@ -32,6 +33,6 @@ struct PassiveShot
void trinity_shield_update(Entity_Player& player, const PassiveShot& shot);
void tech_five_update(Entity_Player& player, const PassiveShot& shot);
std::span<const EffectBehaviour> passive_effect_behaviours();
void passives_hit_trigger(Entity_Player& player, int amount);
void passives_hit_trigger(Entity_Player& player, int amount, HitStep step);
bool cursed_eye_teleport(Entity_Player& player);
void last_heart_items_trigger(Entity_Player& player, uint64_t damageFlags);
+13 -8
View File
@@ -23,12 +23,10 @@ constexpr int NULL_ITEM_BELIAL = 123;
constexpr int NULL_ITEM_FORGOTTEN_CHALLENGE = 106;
constexpr int BELIAL_NULL_COUNT = 4;
constexpr int VERSUS_EFFECT_COOLDOWN = 300;
constexpr int PLAYER_NO_DOGMA = 40;
constexpr int CHALLENGE_FORGOTTEN_COSTUME = 42;
constexpr int BETHS_ESSENCE_WISPS = 5;
constexpr int BETHS_ESSENCE_CHANCE_DOUBLE = 50;
constexpr int BETHS_ESSENCE_CHANCE_TRIPLE = 100;
constexpr int SOUND_BETHS_ESSENCE = 471;
constexpr int SOUND_DOG_TOOTH_SECRET = 442;
constexpr int SOUND_DOG_TOOTH_ROCK = 441;
constexpr int DOG_TOOTH_SECRET_DELAY = 30;
@@ -116,7 +114,7 @@ static void beths_essence_wisps_add(Entity_Player& player)
}
player.AddWisp(actives[rng.RandomInt((uint32_t)actives.size())], player.pos, true, false);
}
sound_play(SOUND_BETHS_ESSENCE);
sound_play(SOUND_CANDLE_LIGHT);
}
// Door Stop: the door the player came in by (or, entering without one, the first within reach, if any) opens, and with
@@ -311,8 +309,8 @@ static void friendly_followers_place(Entity_Player& player)
// 007a6c50 Sets the player up in the room just entered (after the floor's start): the cursed mist, Beth's Essence,
// Dogma in the living room, the Twins and Judas's Belial, then the player stands at its entry with its motion, held
// throw and pit fall reset, and its items react to the room. Friendly enemies follow it in, and Used Diaper, Lil Clot,
// the Forgotten's body and the item sounds come last.
// throw, pit fall and Mom's Hand's carry reset, and its items react to the room. Friendly enemies follow it in, and
// Used Diaper, Lil Clot, the Forgotten's body and the item sounds come last.
// The room's trail starts over and the hallucination's replays from its start.
void Entity_Player::room_enter()
{
@@ -325,7 +323,7 @@ void Entity_Player::room_enter()
if (room.roomType == ROOM_ANGEL && room.descriptor->visitedCount == 1 && HasTrinket(TRINKET_BETHS_ESSENCE))
beths_essence_wisps_add(*this);
bool isDogmaRoom = data && data->type == ROOM_DUNGEON && data->stageId == STAGE_ID_HOME;
if (isDogmaRoom && collectibleCounts[COLLECTIBLE_DOGMA] < 1 && playerType != PLAYER_NO_DOGMA)
if (isDogmaRoom && collectibleCounts[COLLECTIBLE_DOGMA] < 1 && playerType != PLAYER_THESOUL_B)
AddCollectible(COLLECTIBLE_DOGMA, 0, true, 0, 0);
if (playerType == PLAYER_THEFORGOTTEN_B && game.challenge == CHALLENGE_FORGOTTEN_COSTUME)
{
@@ -394,6 +392,13 @@ void Entity_Player::room_enter()
isControlsEnabled = true;
entityCollisionClass = ENTCOLL_ALL;
}
if (momsHandTimer > 0)
{
isControlsEnabled = true;
entityCollisionClass = ENTCOLL_ALL;
momsHandTimer = 0;
isVisible = true;
}
if (!(flags & FLAG_HELD)) entityCollisionClass = ENTCOLL_ALL;
if (HasTrinket(TRINKET_ERROR) || HasTrinket(TRINKET_MODELING_CLAY))
{
@@ -441,7 +446,7 @@ static void teleport_poof_spawn(Entity_Player& player)
const AnimationData* shown = poof->sprite.animState.animData;
bool isShowing = shown && shown->name == "TeleportUp" && (!shown->isLooping || poof->sprite.animState.isPlaying);
if (!isShowing && poof->sprite.SetAnimation("TeleportUp", SWITCH_KEEP_FRAME))
if (!isShowing && poof->sprite.SetAnimation("TeleportUp"))
{
poof->sprite.animState.Rewind();
poof->sprite.animState.isPlaying = true;
@@ -490,7 +495,7 @@ void Entity_Player::Teleport(const Vector& position, bool isDoEffects, bool isTe
bodySprite.Reset();
sprite.playbackSpeed = 1;
sprite.overlayAnimState.SetAnimationData(nullptr);
if (sprite.SetAnimation("TeleportDown", SWITCH_KEEP_FRAME))
if (sprite.SetAnimation("TeleportDown"))
{
sprite.animState.Rewind();
sprite.animState.isPlaying = true;
+14 -29
View File
@@ -437,8 +437,8 @@ bool Entity_Player::TryRemoveTrinket(uint32_t trinketId)
// direction from a poof of blood with a squish.
void Entity_Player::spawn_lil_clot_familiars()
{
if (!HasTrinket(TRINKET_LIL_CLOT)) return;
int multiplier = GetTrinketMultiplier(TRINKET_LIL_CLOT);
if (multiplier == 0) return;
int clots = (int)std::ranges::count_if(g_game->room->entityList.updateEL, [this](Entity* entity)
{
@@ -785,15 +785,6 @@ void dice_bag_room_enter(Entity_Player& player)
sound_play(SOUND_SHELLGAME);
}
// A pickup a collectible's first pickup drops on a free spot near the player.
static void gain_pickup_drop(Entity_Player& player, const EntitySpawn& spawn)
{
EntitySpawn drop = spawn;
drop.position = room_free_pickup_position_find({.position = player.pos, .step = GAIN_PICKUP_STEP});
drop.type = ENTITY_PICKUP;
g_game->Spawn(drop);
}
// Divorce Papers' first pickup: a bone heart, and Mysterious Paper from the trinket pool once it is unlocked (or in a
// daily or debug run).
static void divorce_papers_gain(Entity_Player& player, RNG& rng)
@@ -805,16 +796,16 @@ static void divorce_papers_gain(Entity_Player& player, RNG& rng)
(g_manager->state == MANAGER_STATE_GAME && (game.dailyChallenge.id != 0 || game.isDebug));
if (!isAllowed || !game.itemPool.RemoveTrinket(TRINKET_MYSTERIOUS_PAPER)) return;
Vector position = room_free_pickup_position_find({.position = player.pos, .step = GAIN_PICKUP_STEP});
game.Spawn({.position = position, .subType = TRINKET_MYSTERIOUS_PAPER, .type = ENTITY_PICKUP,
game.Spawn({.position = position, .spawner = &player, .subType = TRINKET_MYSTERIOUS_PAPER, .type = ENTITY_PICKUP,
.variant = PICKUP_TRINKET, .seed = rng.Next()});
}
// Brittle Bones' first pickup: six bone hearts for the red hearts (and the Soul's) it takes, or a tears up for
// a coin or soul health player.
// Brittle Bones' first pickup: six bone hearts for the red hearts (and the Soul's) it takes, or a tears up (and the
// bone hearts anyway) for a coin or no health player.
static void brittle_bones_gain(Entity_Player& player)
{
HealthType health = player.GetHealthType();
if (health == HEALTH_COIN || health == HEALTH_SOUL)
if (health == HEALTH_COIN || health == HEALTH_NO_HEALTH)
{
player.brittleBonesUpgrades++;
player.cacheFlags |= CACHE_FIREDELAY;
@@ -863,13 +854,6 @@ static void booster_pack_gain(Entity_Player& player, RNG& rng)
}
}
// False PHD's first pickup: a pill, and every pill colour identified.
static void false_phd_gain(Entity_Player& player, RNG& rng)
{
gain_pickup_drop(player, {.spawner = &player, .variant = PICKUP_PILL, .seed = rng.Next()});
for (uint32_t color = 1; color < PILL_COLOR_SLOTS; color++) g_game->itemPool.IdentifyPill(color);
}
// TMTRAINER's first pickup: the music fades and every enemy (and versus player) still alive burns and freezes for a
// hundred seconds.
static void tmtrainer_gain(Entity_Player& player)
@@ -881,8 +865,9 @@ static void tmtrainer_gain(Entity_Player& player)
bool isVersus = g_game->deathmatchManager.is_active();
for (Entity* entity : entities)
{
bool isTarget = (isVersus && entity->type == ENTITY_PLAYER) || entity->IsEnemy();
if (!isTarget || entity->isDead || entity->type == ENTITY_FIREPLACE || entity->type == ENTITY_PITFALL)
bool isTarget = (isVersus && entity->type == ENTITY_PLAYER) ||
(entity->type >= ENTITY_FIRST_ENEMY && entity->type < ENTITY_EFFECT);
if (!isTarget || entity->isDead || entity->type == ENTITY_FIREPLACE || entity->type == ENTITY_SHOPKEEPER)
continue;
entity->bossStatusEffectCooldown = 0;
entity->CopyStatusEffects();
@@ -901,7 +886,7 @@ static bool is_pre_ascent_mom_room()
// The pickup effects of 0075f0e0 for Clear Rune's rune and the collectibles 367 on that do more than drop pickups:
// Mom's Box's Wooden Cross and Duct Tape, Tarot Cloth's card, Divorce Papers, Brittle Bones, the Broken Shovel, Luna's secret room,
// Saturnus' tears, the Booster Pack, False PHD, Dad's Note's ascent and TMTRAINER. Camo Undies only acts in versus.
// Saturnus' tears, the Booster Pack, Dad's Note's ascent and TMTRAINER. Camo Undies only acts in versus.
void late_collectible_gain(Entity_Player& player, int type, bool isFirstTime)
{
RNG& rng = player.GetCollectibleRNG(type);
@@ -951,9 +936,6 @@ void late_collectible_gain(Entity_Player& player, int type, bool isFirstTime)
case COLLECTIBLE_BOOSTER_PACK:
if (isFirstTime) booster_pack_gain(player, rng);
return;
case COLLECTIBLE_FALSE_PHD:
if (isFirstTime) false_phd_gain(player, rng);
return;
case COLLECTIBLE_DADS_NOTE:
if (is_pre_ascent_mom_room() && !g_game->IsAscent() && g_game->ascentTimer < 1) g_game->ascentTimer = 1;
return;
@@ -970,6 +952,7 @@ void purity_gain(Entity_Player& player)
player.temporaryEffects.AddCollectibleEffect(COLLECTIBLE_PURITY, true, 1);
player.AddCostume(g_manager->itemConfig.GetNullItem(NULLITEM_PURITY_GLOW), false);
player.update_purity_glow();
player.versus.purityHits = 0;
}
// A crown's glow following its condition: the effect and the glowing float come on together, or go together.
@@ -1287,8 +1270,8 @@ void Entity_Player::GetGlyphOfBalanceDrop(int* variant, int* subType)
drop.soul_heart_set();
}
// 00772530 Turns a golden Store Credit back into a plain one: the one held over the head, else each held (its costume
// and effects swapped), else each smelted one in the history. True when the held over one was changed.
// 00772530 Turns a golden Store Credit back into a plain one: the one held over the head, else the first held (its
// costume and effects swapped), else the first smelted one in the history. Whether one was changed.
bool Entity_Player::replace_trinket()
{
bool isMainPlayer = variant == PLAYER_VARIANT_PLAYER && !isCoopGhost;
@@ -1314,6 +1297,7 @@ bool Entity_Player::replace_trinket()
if (storeCredit->isAddCostumeOnPickup || !temporaryEffects.HasTrinketEffect(golden)) RemoveCostume(storeCredit);
TriggerTrinketAdded(TRINKET_STORE_CREDIT, false);
if (storeCredit->isAddCostumeOnPickup) AddCostume(storeCredit, false);
return true;
}
if (!isMainPlayer) return false;
@@ -1335,6 +1319,7 @@ bool Entity_Player::replace_trinket()
storeCredit->GetLocalizedName().c_str(), playerIndex, name.c_str(), TRINKET_STORE_CREDIT,
storeCredit->GetLocalizedName().c_str());
g_game->hud.mark_all_slots_dirty(HISTORY_KEEP_ICONS, HISTORY_KEEP_ITEMS);
return true;
}
return false;
}
+23 -1
View File
@@ -11,6 +11,28 @@ constexpr int PURITY_STATES = 4;
constexpr int RAINBOW_WORM_FRAMES = 90;
constexpr int HISTORY_POOL_NONE = -1;
// The steps 007729d0 runs a landed hit's items in, interleaving the passives (entity_player_passives.cpp), the
// characters' items (entity_player_characters.cpp), the trinkets and late collectibles (entity_player_hits.cpp) and
// Tainted Samson's rage, so that their draws come in the original's order.
enum HitStep : int
{
HIT_STEP_RED_PATCH,
HIT_STEP_INFESTATION,
HIT_STEP_LEPROSY,
HIT_STEP_CELTIC_CROSS,
HIT_STEP_DEAD_BIRD,
HIT_STEP_BIRD_CAGE,
HIT_STEP_SAMSON,
HIT_STEP_BEST_BUD,
HIT_STEP_SWALLOWED_PENNY,
HIT_STEP_FANNY_PACK,
HIT_STEP_CARTRIDGE,
HIT_STEP_SPIDERBABY,
HIT_STEP_BLOODY_LUST,
HIT_STEP_TOWER,
HIT_STEP_COUNT
};
// What a landed hit tells the items it sets off.
struct ItemsHit
{
@@ -39,7 +61,7 @@ void crowns_room_enter(Entity_Player& player);
void dice_bag_room_enter(Entity_Player& player);
void crowns_update(Entity_Player& player);
bool is_dark_prince_lit(Entity_Player& player);
bool late_items_hit_trigger(Entity_Player& player, const ItemsHit& hit);
bool late_items_hit_trigger(Entity_Player& player, const ItemsHit& hit, HitStep step);
void cursed_skull_teleport(Entity_Player& player);
// A collectible taken.
+3 -2
View File
@@ -653,7 +653,7 @@ Entity_Knife* Entity_Player::FireKnife(const KnifeShot& shot)
knife->SetColor(tearColor, -1, COLOR_PRIORITY_DEFAULT, false, true);
static_cast<Entity_Knife*>(knife)->tearFlags = tearFlags;
knife->SetCollisionDamage(damage);
static_cast<Entity_Knife*>(knife)->rotationOffset = angle_wrap(shot.rotationOffset);
static_cast<Entity_Knife*>(knife)->rotationOffset = normalize_angle_degrees(shot.rotationOffset);
if (shot.isCantOverwrite) knife->AddEntityFlags(FLAG_DONT_OVERWRITE);
return static_cast<Entity_Knife*>(knife);
}
@@ -751,7 +751,8 @@ void Entity_Player::fire_saturnus_tears()
Vector offset = vector_from_angle(angle);
Vector velocity = vector_scale(vector_from_angle(angle + RIGHT_ANGLE_DEGREES), shotSpeed * SATURNUS_SPEED);
PosVel shot = {vector_add(pos, vector_scale(offset, SATURNUS_SPREAD)), velocity};
Entity_Tear* tear = FireTear(shot, TEAR_FIRE_NO_EVIL_EYE | TEAR_FIRE_EXTRA_SHOT, nullptr, SATURNUS_DAMAGE_SCALE);
Entity_Tear* tear = FireTear(shot, TEAR_FIRE_NO_EVIL_EYE | TEAR_FIRE_EXTRA_SHOT | TEAR_FIRE_ORBITAL, nullptr,
SATURNUS_DAMAGE_SCALE);
tear->SetCollisionDamage(tear->collisionDamage + SATURNUS_DAMAGE_BONUS);
tear->tearIdx = 1;
+4 -7
View File
@@ -362,12 +362,9 @@ constexpr float ROTGUT_SPLIT_SCALE_RANGE = 0.6f;
constexpr int FIRE_POOF_SUBTYPE = 1;
constexpr int BONE_PARTICLE_SUBTYPE = 1;
constexpr int SOUND_BLOOD_SPLASH = 30;
constexpr int SOUND_COIN_IMPACT = 138;
constexpr int SOUND_INFAMY_BLOCK = 863;
constexpr int SOUND_PIN_GOO = 934;
constexpr int COLLECTIBLE_SOUL = 335;
constexpr int COLLECTIBLE_BETRAYAL = 391;
constexpr uint32_t CHALLENGE_BROKEN_WATCH = 22;
@@ -1632,7 +1629,7 @@ void Entity_Projectile::death_poof_spawn()
.speed = speed,
.count = random_below(2) + COIN_PARTICLES,
.variant = EFFECT_COIN_PARTICLE});
sound_play(SOUND_COIN_IMPACT, random_unit() * COIN_SOUND_PITCH_SPREAD + COIN_SOUND_PITCH, COIN_SOUND_VOLUME);
sound_play(SOUND_POT_BREAK, random_unit() * COIN_SOUND_PITCH_SPREAD + COIN_SOUND_PITCH, COIN_SOUND_VOLUME);
}
else if (variant == PROJECTILE_GRID) grid_splash();
else if (variant == PROJECTILE_ROCK) rock_splash();
@@ -1798,7 +1795,7 @@ void Entity_Projectile::death_bursts_spawn()
if (projectileFlags & PROJECTILE_BURST8)
{
pos = vector_sub(pos, vector_scale(gridCollisionVelocity, 2));
sound_play(SOUND_BLOOD_SPLASH, 1, 1);
sound_play(SOUND_DEATH_BURST_SMALL, 1, 1);
effect_spawn(EFFECT_BLOOD_EXPLOSION, pos, nullptr, BLOOD_EXPLOSION_SPLASH);
bool isBloodfly = spawnerType == ENTITY_SUCKER && spawnerVariant == SUCKER_BLOODFLY;
int count = isBloodfly ? BURST8_BLOODFLY_COUNT : BURST8_COUNT;
@@ -1842,7 +1839,7 @@ void Entity_Projectile::death_bursts_spawn()
if (!(projectileFlags & PROJECTILE_BURSTSPLIT)) return;
sound_play(SOUND_BLOOD_SPLASH, 1, 1);
sound_play(SOUND_DEATH_BURST_SMALL, 1, 1);
Entity_Effect* splash = effect_spawn(EFFECT_BLOOD_EXPLOSION, pos, nullptr, BLOOD_EXPLOSION_SPLASH);
if (splash) splash->SetColor(BURSTSPLIT_SPLASH_COLOR, COLOR_PRIORITY_NONE, COLOR_PRIORITY, false, true);
if (isRotgutHeart) return rotgut_split_spawn(*this);
@@ -2167,7 +2164,7 @@ void Entity_Projectile::fall_update()
fallingSpeed = speedMultiplier * fallingAccel + speedMultiplier * GRAVITY_PULL +
timescale_factor(FALL_DRAG, speedMultiplier) * fallingSpeed;
height = fallingSpeed * speedMultiplier + height;
if (variant == PROJECTILE_HEAD) sprite.rotation = angle_wrap(sprite.rotation + fallingSpeed * HEAD_SPIN);
if (variant == PROJECTILE_HEAD) sprite.rotation = normalize_angle_degrees(sprite.rotation + fallingSpeed * HEAD_SPIN);
if (!is_crawlspace()) return;
if (fallingAccel >= CRAWLSPACE_MIN_ACCEL) velocity.y = fallingAccel * speedMultiplier + velocity.y;
+3 -4
View File
@@ -130,7 +130,6 @@ constexpr float VERSUS_BLOOD_DAMAGE = 8;
constexpr int COIN_FRAMES = 15;
constexpr int COUNTER_DONE_FRAMES = 20;
constexpr int TOUCH_FRAMES = 4;
constexpr int ENEMY_TYPE_FIRST = 10;
constexpr int TOUCH_SLOWDOWN = 10;
constexpr int COIN_INSERT2_TOUCHES = 61;
constexpr int COIN_INSERT3_TOUCHES = 121;
@@ -247,7 +246,7 @@ constexpr std::array<std::array<int, 2>, 5> BREAK_DROP_TRINKETS = {{{TRINKET_ACE
// Restarts an overlay animation from its first frame.
static void overlay_restart(ANM2& sprite, std::string_view name)
{
if (!sprite.SetOverlayAnimation(name, SWITCH_KEEP_FRAME)) return;
if (!sprite.SetOverlayAnimation(name)) return;
sprite.overlayAnimState.Rewind();
sprite.overlayAnimState.isPlaying = true;
@@ -1876,7 +1875,7 @@ bool Entity_Slot::is_payment_taken(Entity_Player& player)
void Entity_Slot::shell_game_start(Entity_Player& player)
{
sprite.Play("PayShuffle");
if (prizeAnm2.SetAnimation("Prizes", SWITCH_KEEP_FRAME))
if (prizeAnm2.SetAnimation("Prizes"))
{
prizeAnm2.animState.Rewind();
prizeAnm2.animState.isPlaying = true;
@@ -2175,7 +2174,7 @@ bool Entity_Slot::HandleCollision(Entity* collider, bool)
if (isPlayer && collider->variant == PLAYER_VARIANT_PLAYER && state != SLOT_STATE_BROKEN) unkShort1 = TOUCH_FRAMES;
bool isVersus = g_game->deathmatchManager.is_active() && isPlayer;
bool isPassing =
(collider->type >= ENEMY_TYPE_FIRST && collider->type < ENTITY_EFFECT) || collider->type == ENTITY_BOMB;
(collider->type >= ENTITY_FIRST_ENEMY && collider->type < ENTITY_EFFECT) || collider->type == ENTITY_BOMB;
return !isVersus && isPassing;
}
+16 -11
View File
@@ -240,7 +240,6 @@ constexpr int EGG_FLY_DELAY = 20;
constexpr uint32_t EGG_FLY_DELAY_SPREAD = 10;
constexpr float HOLY_LIGHT_HIT_SCALE = 3;
constexpr float HOLY_LIGHT_REACH = 100;
constexpr int ENTITY_TYPE_NPC_FIRST = 10;
constexpr float HIT_DIRECTION_MIN_SPEED = 0.02f;
// A knocked out coin flies back off the hit, turned 160 to 200 degrees, at 2 to 6, or drops within 40 of it.
constexpr float KNOCKED_COIN_TURN_MIN = 160;
@@ -263,8 +262,6 @@ constexpr float BACKSTAB_VOLUME = 0.7f;
constexpr int BACKSTAB_SOUND_DELAY = 8;
constexpr float BACKSTAB_SPRAY_SPEED = -4;
constexpr float BACKSTAB_SPRAY_LIFT = -15;
constexpr int SOUND_TEAR_FIRE = 153;
constexpr int SOUND_FETUS_FIRE = 237;
constexpr float FETUS_FIRE_PITCH = 1.2f;
constexpr int SOUND_LITTLE_HORN = 868;
constexpr int HORN_HAND_HOLD = 50;
@@ -946,7 +943,7 @@ void Entity_Tear::ludovico_ring_update()
orbiter.SetTearFlags(flags);
orbiter.entityGridCollisionClass = GRIDCOLL_NONE;
orbiter.SetCollisionDamage(collisionDamage);
orbiter.rotation = angle_wrap(angle + TEAR_RIGHT_ANGLE);
orbiter.rotation = normalize_angle_degrees(angle + TEAR_RIGHT_ANGLE);
}
if (parent && parent->IsFamiliar())
@@ -1344,10 +1341,14 @@ void Entity_Tear::fall_update()
}
// 00679400 Moves the tear half a step for the frame between updates, sways the worms' tears, and places its sprite at
// the height it will fall to. A held tear stays at its parent.
// the height it will fall to. A held tear only stays at its parent.
void Entity_Tear::Interpolate()
{
if (holdTimer > 0 && parent) pos = vector_add(parent->pos, holdOffset);
if (holdTimer > 0)
{
if (parent) pos = vector_add(parent->pos, holdOffset);
return;
}
tractor_beam_follow();
if (tearFlags[TEAR_LASER] && techZeroLaser && techZeroTarget) tech_zero_aim();
if (tearFlags[TEAR_LUDOVICO]) return ludovico_interpolate();
@@ -1502,7 +1503,7 @@ void Entity_Tear::play_fire_sound()
bool isSilent = variant == TEAR_CHAOS_CARD || variant == TEAR_FIRE || variant == TEAR_GRIDENT || isFireSoundMuted;
bool isFetus = variant == TEAR_FETUS;
if (!isSilent && !is_gfuel_nail(variant))
npc_sound_play(isFetus ? SOUND_FETUS_FIRE : SOUND_TEAR_FIRE, 1, TEAR_SOUND_DELAY, isFetus ? FETUS_FIRE_PITCH : 1);
npc_sound_play(isFetus ? SOUND_PLOP : SOUND_TEARS_FIRE, 1, TEAR_SOUND_DELAY, isFetus ? FETUS_FIRE_PITCH : 1);
if (tearFlags[TEAR_HORN]) npc_sound_play(SOUND_LITTLE_HORN, 1, TEAR_SOUND_DELAY, 1);
if (tearFlags[TEAR_ORBIT])
{
@@ -1834,8 +1835,10 @@ bool Entity_Tear::try_make_bridges(const Vector& position)
isHitSolid = true;
if (isRockBroken) continue;
bool isBreaking = tearFlags[TEAR_ACID] || (tearFlags[TEAR_ROCK_FLAG] && random_unit() < collisionDamage * ROCK_BREAK_CHANCE);
if (grid->CanTakeDamageFromTearEffects() && isBreaking && grid->Destroy(false, EntityRef(this)))
bool isBreaking = grid->CanTakeDamageFromTearEffects() &&
(tearFlags[TEAR_ACID] ||
(tearFlags[TEAR_ROCK_FLAG] && random_unit() < collisionDamage * ROCK_BREAK_CHANCE));
if (isBreaking && grid->Destroy(false, EntityRef(this)))
{
isRockBroken = true;
bridge_beyond(*grid);
@@ -1902,6 +1905,7 @@ static void needle_burst(Entity& entity, Entity* source)
needle.SetTearFlags(flags);
needle.SetCollisionDamage(params.tearDamage);
needle.SetColor(NEEDLE_COLOR, -1, TEAR_COLOR_PRIORITY, false, true);
needle.isCanTriggerStreakEnd = false;
if (!needle.tearFlags[TEAR_HYDROBOUNCE]) continue;
needle.fallingAccel = NEEDLE_HYDRO_ACCEL;
needle.fallingSpeed = NEEDLE_HYDRO_FALL - needle.fallingSpeed;
@@ -2025,13 +2029,14 @@ static Entity_Player* wisp_owner_get(Entity* source)
// Mom's foot down on it. The original asks a missing source for its spawner. Here no wisp comes of it.
static void rerollable_flags_apply(Entity& entity, const TearFlags& flags, Entity* source)
{
bool isRerollable = entity.type >= ENTITY_TYPE_NPC_FIRST && static_cast<Entity_NPC&>(entity).CanReroll() &&
bool isRerollable = entity.type >= ENTITY_FIRST_ENEMY && static_cast<Entity_NPC&>(entity).CanReroll() &&
entity.type != ENTITY_POOP && entity.type != ENTITY_CHUB && entity.type != ENTITY_MOMS_HAND;
if (!isRerollable) return;
if (flags[TEAR_ECOLI] && entity.IsVulnerableEnemy(nullptr) && entity.type != ENTITY_PLAYER)
{
entity.Remove();
Entity* poop = g_game->Spawn({.position = entity.pos, .type = ENTITY_POOP, .seed = Random()});
poop->splatColor = DARK_POOP_SPLAT_COLOR;
if (entity.minecart) static_cast<Entity_NPC*>(entity.minecart.get())->MinecartUpdateChild(poop);
}
if (flags[TEAR_ENEMY_TO_WISP] && entity.IsVulnerableEnemy(nullptr))
@@ -2143,7 +2148,7 @@ static void horn_hand_grab(Entity& entity, Entity* source)
bool isFlipped = Random() & 1;
if (hands.size() == 1) isFlipped = !hands[0]->sprite.isFlipX;
if (!isHeavy)
if (!entity.IsBoss() && entity.type != ENTITY_PLAYER)
{
static_cast<Entity_NPC&>(entity).hold_set(HORN_HAND_HOLD, at);
entity.AddFear(EntityRef(source), -HORN_HAND_HOLD, false);
+7
View File
@@ -6,6 +6,9 @@
#include <array>
#include <vector>
struct Entity_Knife;
struct FetusKnife;
// The scale each RegularTear%d animation (1 to 13) draws at, the one a tear plays being the first at least its scale
// less the margin. A grown tear scales its layers by its scale over its animation's.
constexpr std::array<float, 13> TEAR_ANIMATION_SCALES = {0.25f, 0.5f, 0.625f, 0.75f, 0.875f, 1.0f, 1.125f,
@@ -389,6 +392,10 @@ private:
void orbit_plain_update(Entity* center);
void orbit_steady_update(Entity* center);
void fetus_update();
void fetus_ring_update(Entity_Player* player);
Entity_Knife* fetus_knife_spawn(const FetusKnife& kind, Entity_Player* player);
bool fetus_knife_update(Entity_Player* player, float facing);
void fetus_beam_fire(Entity_Player* player, float facing, float luck);
void fetus_spin();
void homing_update();
float size_flags_update();
+276 -11
View File
@@ -3,6 +3,7 @@
#include "entity_bomb.h"
#include "entity_config.h"
#include "entity_effect.h"
#include "entity_factory.h"
#include "entity_familiar.h"
#include "entity_knife.h"
#include "entity_laser.h"
@@ -72,6 +73,47 @@ constexpr float FETUS_TURN = 2;
constexpr float FETUS_TURN_HOMING = 12;
constexpr float FETUS_SPIN = 2;
// The way a fetus faces: its spin frame over a turn of fifteen frames, a quarter turn on. A club fetus turns its sprite
// toward its target by the pull over this many frames.
constexpr float FETUS_SPIN_FRAMES = 15;
constexpr float FETUS_FACING_OFFSET = 90;
// A fetus' Tech X ring: its size, reach (a bigger one each frame after the first) and how long it lasts.
constexpr float FETUS_LASER_SCALE = 0.75f;
constexpr float FETUS_RING_RADIUS_BASE = 14;
constexpr float FETUS_RING_RADIUS_SHARE = 25;
constexpr float FETUS_RING_HELD_RADIUS_BASE = 6;
constexpr float FETUS_RING_HELD_RADIUS_SHARE = 50;
constexpr int FETUS_RING_TIMEOUT = 300;
// A fetus' Technology beam: fired every eighth frame at most at the enemy within reach most in front of it, keeping
// its stickiness and its popping only one time in twenty less its luck.
constexpr float FETUS_TECH_RANGE = 140;
constexpr float FETUS_TECH_AIM = 0.85f;
constexpr int FETUS_TECH_COOLDOWN = 8;
constexpr float FETUS_TECH_LUCK_ODDS = 20;
// A fetus' sword spins once charged, charging while it attacks. A club swings at a target ahead within reach.
constexpr float FETUS_SWORD_SPIN_CHARGE = 1.1f;
constexpr float FETUS_SWORD_CHARGE_RATE = 0.04f;
constexpr float FETUS_CLUB_AIM = 0.1f;
constexpr float FETUS_CLUB_REACH = 50;
constexpr float FETUS_SWING_PITCH = 0.9f;
constexpr float FETUS_SWING_PITCH_SPREAD = 0.2f;
// A fetus' knife: its variant, the share of the fetus' damage and size it takes, and how far below the fetus it rides.
struct FetusKnife
{
int variant = KNIFE_MOMS_KNIFE;
float damageShare = 1;
float lift = 0;
float scaleShare = 1;
};
constexpr FetusKnife FETUS_SWORD = {.variant = KNIFE_SPIRIT_SWORD, .damageShare = HALF, .lift = 6, .scaleShare = 0.6f};
constexpr FetusKnife FETUS_MOMS_KNIFE = {.variant = KNIFE_MOMS_KNIFE, .damageShare = HALF, .lift = 4, .scaleShare = HALF};
constexpr FetusKnife FETUS_CLUB = {.variant = KNIFE_BONE_CLUB, .damageShare = 1, .lift = 6, .scaleShare = 0.6f};
// Homing's search: every fourth frame, ahead of the tear, within 128, a random part, a target already hit last.
constexpr float HOMING_LOOK_AHEAD = 5;
constexpr float HOMING_RADIUS = 128;
@@ -89,8 +131,6 @@ constexpr float ATTRACT_NEAR = 10;
constexpr float ATTRACT_NEAR_DRAG = 0.9f;
constexpr float ATTRACT_NEAR_SHARE = 100;
constexpr float ATTRACT_ENEMY_SCALE = 4;
constexpr int ENTITY_TYPE_ENEMY_FIRST = 10;
constexpr int ENTITY_TYPE_ENEMY_END = 1000;
// The trails some tears leave every other frame: the balloons' smoke and blood, and the G-Fuel missiles' dust.
constexpr float TRAIL_SPEED_SHARE = 0.3f;
@@ -259,7 +299,7 @@ void entities_attract(const Attraction& attraction)
for (Entity* entity : g_game->room->entityList.updateEL)
{
bool isVersusPlayer = isVersus && entity->type == ENTITY_PLAYER;
bool isEnemy = isVersusPlayer || (entity->type >= ENTITY_TYPE_ENEMY_FIRST && entity->type < ENTITY_TYPE_ENEMY_END);
bool isEnemy = isVersusPlayer || (entity->type >= ENTITY_FIRST_ENEMY && entity->type < ENTITY_EFFECT);
bool isTargetable = entity->entityCollisionClass > ENTCOLL_PLAYERONLY && !entity->isInvincible &&
!entity->isDead && !entity->HasEntityFlags(FLAG_FRIENDLY) &&
(!entity->HasEntityFlags(FLAG_NO_TARGET) || entity->type == ENTITY_HUSH ||
@@ -425,7 +465,7 @@ void Entity_Tear::orbit_plain_update(Entity* center)
float pull = (radius - distance) * pullScale;
float weight = std::clamp(distance / radius, 0.0f, 1.0f);
float flightAngle = vector_angle(velocity);
float turn = angle_wrap(vector_angle(away) + side * TEAR_RIGHT_ANGLE - flightAngle) * weight * weight;
float turn = normalize_angle_degrees(vector_angle(away) + side * TEAR_RIGHT_ANGLE - flightAngle) * weight * weight;
float speed = vector_length(velocity);
Vector turned = vector_add(vector_scale(vector_from_angle(flightAngle + turn), speed), vector_scale(away, pull));
velocity = vector_add(vector_scale(vector_normalized(turned), speed), centerVelocity);
@@ -467,7 +507,7 @@ void Entity_Tear::orbit_steady_update(Entity* center)
float stepMax = std::max(ORBIT_STEP_MIN, std::fabs(orbitRadius));
if (vector_length(step) > stepMax) step = vector_resized(step, stepMax);
velocity = vector_scale(vector_add(lead, step), 1 / friction);
orbitAngle = angle_wrap(orbitRadius / distance * TEAR_HALF_TURN / PI_F * speedMultiplier + orbitAngle);
orbitAngle = normalize_angle_degrees(orbitRadius / distance * TEAR_HALF_TURN / PI_F * speedMultiplier + orbitAngle);
if (waitFrames > 1) continueVelocity = vector_scale(vector_from_angle(orbitAngle), std::fabs(orbitRadius));
}
@@ -540,13 +580,18 @@ Entity* homing_target_find(Entity_Tear& tear, bool isFetus)
return best;
}
// (006670f0's fetus) C Section's fetus: it drags hard over its first frames, forgets its hits every eighth frame,
// searches a target every fourth, and pulls and turns toward it, harder over its first 45 frames (and homing).
// The weapons it carries (a Tech X ring, a sword, a knife, a club, a Technology laser) are not written yet.
// (006670f0's fetus) C Section's fetus: it carries its weapons (a Tech X ring, a sword, a knife or a club, Technology's
// beam), drags hard over its first frames, forgets its hits every eighth frame, searches a target every fourth, and
// pulls and turns toward it, harder over its first 45 frames (and homing). A club fetus turns its sprite toward it.
void Entity_Tear::fetus_update()
{
for (int weapon : {TEAR_FETUS_TECHX, TEAR_FETUS_SWORD, TEAR_FETUS_KNIFE, TEAR_FETUS_BONE, TEAR_FETUS_TECH})
if (tearFlags[weapon]) reconstruction_missing("Entity_Tear::Update 006670f0: a fetus' weapon");
Entity_Player* player = GetRootPlayer();
float frame = sprite.animState.animData ? sprite.animState.animFrame : -1;
float facing = frame * TEAR_FULL_TURN / FETUS_SPIN_FRAMES + FETUS_FACING_OFFSET;
float luck = player ? player->luck : 0;
fetus_ring_update(player);
bool isClubHeld = fetus_knife_update(player, facing);
if (tearFlags[TEAR_FETUS_TECH]) fetus_beam_fire(player, facing, luck);
float drag = 1 - std::clamp(updateTime / FETUS_DRAG_FRAMES, 0.0f, FETUS_DRAG_SPAN);
friction = drag * drag * FETUS_FRICTION_SHARE + FETUS_FRICTION_BASE;
@@ -566,6 +611,226 @@ void Entity_Tear::fetus_update()
float turn = (tearFlags[TEAR_HOMING] ? FETUS_TURN_HOMING : FETUS_TURN) * speedMultiplier;
float angle = angle_approach(vector_angle(velocity), vector_angle(vector_scale(fromTarget, -1)), turn);
velocity = vector_scale(vector_from_angle(angle), vector_length(velocity));
if (!isClubHeld || vector_is_zero(fromTarget)) return;
float step = TEAR_FULL_TURN / (float)sprite.animState.GetAnimationLength();
float spriteFrame = sprite.animState.animData ? sprite.animState.animFrame : -1;
Vector turned = vector_scale(fromTarget, speedMultiplier * FETUS_SPIN_FRAMES / vector_length_squared(fromTarget));
float spriteAngle = normalize_angle_degrees(vector_angle(vector_add(vector_from_angle(spriteFrame * step), turned)));
if (spriteAngle < 0) spriteAngle += TEAR_FULL_TURN;
sprite.SetFrame(spriteAngle / step);
}
// (006670f0's fetus Tech X) A Tech X fetus keeps a ring around it: a player's laser colour, half its damage, flags but
// not its growth, lasting 300 frames. Without a ring to spawn the fetus loses the flag. The ring is sized every frame.
void Entity_Tear::fetus_ring_update(Entity_Player* player)
{
if (!tearFlags[TEAR_FETUS_TECHX]) return;
if (!fetusLaser && !isDead)
{
uint32_t seed = Random();
Entity* spawned = game_spawn({.position = pos,
.spawner = player,
.subType = LASER_SUBTYPE_RING_FOLLOW_PARENT,
.type = ENTITY_LASER,
.variant = LASER_THIN_RED,
.seed = seed},
POOL_KEEP);
if (!spawned) tearFlags.reset(TEAR_FETUS_TECHX);
else
{
Entity_Laser& ring = *static_cast<Entity_Laser*>(spawned);
if (player) ring.SetColor(player->get_laser_color_copy(), -1, COLOR_PRIORITY_DEFAULT, false, true);
ring.posOffset = posOffset;
ring.parent = this;
ring.renderDepthOffset = TECH_LASER_FRONT_DEPTH;
ring.tearFlags = tearFlags;
for (int dropped : {TEAR_GROW, TEAR_SHRINK, TEAR_FETUS_FLAG}) ring.tearFlags.reset(dropped);
ring.SetCollisionDamage(collisionDamage * HALF);
ring.timeout = FETUS_RING_TIMEOUT;
ring.set_scale(fScale * FETUS_LASER_SCALE);
ring.radius = fScale * FETUS_RING_RADIUS_SHARE + FETUS_RING_RADIUS_BASE;
ring.spawnerEntity = player;
ring.Update();
fetusLaser = &ring;
}
}
if (!fetusLaser) return;
Entity_Laser& ring = *static_cast<Entity_Laser*>(fetusLaser.get());
ring.set_scale(fScale * FETUS_LASER_SCALE);
ring.radius = fScale * FETUS_RING_HELD_RADIUS_SHARE + FETUS_RING_HELD_RADIUS_BASE;
}
// Spawns a fetus' knife: parented to it, tinted like it, with its flags but not its growth, its share of the damage
// and size, updated once and held as its attached effect.
Entity_Knife* Entity_Tear::fetus_knife_spawn(const FetusKnife& kind, Entity_Player* player)
{
uint32_t seed = Random();
Entity* spawned = g_game->Spawn(
{.position = pos, .spawner = player, .type = ENTITY_KNIFE, .variant = kind.variant, .seed = seed});
if (!spawned) return nullptr;
Entity_Knife& knife = *static_cast<Entity_Knife*>(spawned);
knife.parent = this;
knife.SetColor(sprite.color, -1, COLOR_PRIORITY_DEFAULT, false, true);
knife.tearFlags = tearFlags;
for (int dropped : {TEAR_GROW, TEAR_SHRINK}) knife.tearFlags.reset(dropped);
knife.SetCollisionDamage(collisionDamage * kind.damageShare);
knife.rotationOffset = 0;
knife.sprite.scale = vector_make(fScale * kind.scaleShare, fScale * kind.scaleShare);
knife.Update();
attachedEffect = &knife;
return &knife;
}
// A fetus' sword or club swings: its swing sound (lower for a bigger one) and its attack animation.
static void fetus_swing(Entity_Knife& knife)
{
float pitch = std::max(HALF, 1 / (knife.sprite.scale.x * HALF + HALF));
effect_sound_play(SOUND_SHELLGAME,
{.frameDelay = 1, .pitch = (random_unit() * FETUS_SWING_PITCH_SPREAD + FETUS_SWING_PITCH) * pitch});
knife.swingEffects = 1;
knife.swingTick = 0;
knife.SetAttackAnimation();
}
// (006670f0's fetus weapons) A fetus holds one blade, below it and turned its way: Spirit Sword's (Technology's with
// it) swings when idle, charges while attacking and spins once charged, then goes once still. A spinning sword turns
// the fetus' sprite with its hit point. Mom's Knife only follows. A club swings at a target ahead within reach. True
// while the fetus holds a club.
bool Entity_Tear::fetus_knife_update(Entity_Player* player, float facing)
{
auto held = [this] { return static_cast<Entity_Knife*>(attachedEffect.get()); };
if (tearFlags[TEAR_FETUS_SWORD])
{
FetusKnife sword = FETUS_SWORD;
if (tearFlags[TEAR_FETUS_TECH]) sword.variant = KNIFE_TECH_SWORD;
if (!attachedEffect && !isDead)
{
if (Entity_Knife* spawned = fetus_knife_spawn(sword, player)) spawned->rotation = facing;
else KAGE_LogMessage(LOG_ERROR, (uint8_t*)"BAD THINGS! \n");
}
if (!attachedEffect) return false;
Entity_Knife& knife = *held();
knife.SetCollisionDamage(collisionDamage * sword.damageShare);
knife.sprite.scale = vector_make(fScale * sword.scaleShare, fScale * sword.scaleShare);
knife.posOffset = vector_add(posOffset, vector_scale(vector_make(0, sword.lift), fScale));
if (knife.charge > FETUS_SWORD_SPIN_CHARGE)
{
knife.SpinAttack(1, 0);
if (Entity_Knife* spun = held())
{
spun->charge = 0;
spun->isSwingCharged = false;
}
}
else if (knife.isAttacking)
{
knife.charge += FETUS_SWORD_CHARGE_RATE;
knife.isSwingCharged = knife.charge >= 1;
}
else if (!knife.isSwinging) fetus_swing(knife);
Entity_Knife* still = held();
if (still && !still->isFlying && !still->isSwinging && !still->isAttacking) still->Remove();
Entity_Knife* shown = held();
if (!shown || !shown->isExists) return false;
if (!shown->sprite.GetAnimation().starts_with("Spin"))
{
shown->rotation = facing;
return false;
}
float step = TEAR_FULL_TURN / (float)sprite.animState.GetAnimationLength();
float spriteAngle = normalize_angle_degrees(vector_angle(shown->GetNullOffset("Hit")));
if (spriteAngle < 0) spriteAngle += TEAR_FULL_TURN;
sprite.SetFrame(spriteAngle / step);
return false;
}
const FetusKnife& kind = tearFlags[TEAR_FETUS_KNIFE] ? FETUS_MOMS_KNIFE : FETUS_CLUB;
if (!tearFlags[TEAR_FETUS_KNIFE] && !tearFlags[TEAR_FETUS_BONE]) return false;
if (!attachedEffect && !isDead) fetus_knife_spawn(kind, player);
if (!attachedEffect) return false;
Entity_Knife& knife = *held();
if (&kind == &FETUS_MOMS_KNIFE)
{
knife.SetCollisionDamage(collisionDamage * kind.damageShare);
knife.sprite.scale = vector_make(fScale * kind.scaleShare, fScale * kind.scaleShare);
}
knife.posOffset = vector_add(posOffset, vector_scale(vector_make(0, kind.lift), fScale));
knife.rotation = facing;
if (&kind == &FETUS_MOMS_KNIFE) return false;
if (knife.isSwinging || !target) return true;
Vector ahead = vector_from_angle(facing);
bool isAhead = vector_dot(vector_normalized(vector_sub(target->pos, pos)), ahead) > FETUS_CLUB_AIM;
if (isAhead && vector_distance(target->pos, pos) < fScale * FETUS_CLUB_REACH) fetus_swing(knife);
return true;
}
// (006670f0's fetus Technology) A Technology fetus fires a short one-hit beam at the enemy within reach most in front
// of it (in sight for a grid-bound fetus), then waits eight frames. The beam keeps the fetus' flags but its growth,
// keeps stickiness and popping only with luck, takes its full damage and a player's laser colour at the fetus' alpha.
void Entity_Tear::fetus_beam_fire(Entity_Player* player, float facing, float luck)
{
if (fetusTechCooldown > 0)
{
fetusTechCooldown--;
return;
}
Vector ahead = vector_from_angle(facing);
Entity* best = nullptr;
float bestDot = -1;
for (Entity* enemy : entity_query_radius(pos, FETUS_TECH_RANGE, QUERY_ENEMIES))
{
if (!enemy->IsVulnerableEnemy(nullptr) || enemy->HasEntityFlags(FLAG_FRIENDLY | FLAG_NO_TARGET)) continue;
if (entityGridCollisionClass == GRIDCOLL_BULLET &&
!room_check_line(pos, enemy->pos, LINE_MODE_PROJECTILE, 0))
continue;
float dot = vector_dot(vector_normalized(vector_sub(enemy->pos, pos)), ahead);
if (dot <= bestDot) continue;
bestDot = dot;
best = enemy;
}
if (bestDot <= FETUS_TECH_AIM || !best) return;
fetusTechCooldown = FETUS_TECH_COOLDOWN;
Vector aim = vector_normalized(vector_sub(best->pos, pos));
Entity_Laser* laser = Entity_Laser::ShootAngle({.position = pos,
.posOffset = posOffset,
.source = player,
.angleDegrees = vector_angle(aim),
.timeout = TECH_LASER_TIMEOUT,
.variant = LASER_THIN_RED,
.isPoolKept = true});
if (!laser) return;
laser->isOneHit = true;
laser->isDisableFollowParent = true;
laser->tearFlags = tearFlags;
for (int dropped : {TEAR_GROW, TEAR_SHRINK}) laser->tearFlags.reset(dropped);
int odds = std::max((int)(FETUS_TECH_LUCK_ODDS - luck), 1);
if (random_below(odds) != 0)
for (int dropped : {TEAR_STICKY, TEAR_BOOGER_FLAG, TEAR_SPORE_FLAG}) laser->tearFlags.reset(dropped);
if (random_below(odds) != 0)
for (int dropped : {TEAR_POP, TEAR_ABSORB}) laser->tearFlags.reset(dropped);
laser->SetCollisionDamage(collisionDamage);
bool isBehind = aim.y < -TECH_LASER_FACING || aim.x < -TECH_LASER_FACING;
laser->renderDepthOffset = isBehind ? TECH_LASER_BACK_DEPTH : TECH_LASER_FRONT_DEPTH;
if (player)
{
ColorMod color = player->get_laser_color_copy();
color._tint[3] = sprite.color._tint[3];
laser->SetColor(color, -1, COLOR_PRIORITY_DEFAULT, false, true);
}
laser->maxDistance = FETUS_TECH_RANGE;
laser->set_scale(fScale * FETUS_LASER_SCALE);
laser->Update();
}
// (006670f0's fetus sprite) The fetus spins its frames with its speed, backwards flying left.
@@ -576,7 +841,7 @@ void Entity_Tear::fetus_spin()
float spin = vector_length(velocity) * FETUS_SPIN;
if (velocity.x < 0) spin = -spin;
float step = TEAR_FULL_TURN / (float)state.GetAnimationLength();
float angle = angle_wrap(state.animFrame * step + spin * speedMultiplier);
float angle = normalize_angle_degrees(state.animFrame * step + spin * speedMultiplier);
if (angle < 0) angle += TEAR_FULL_TURN;
sprite.SetFrame(angle / step);
}
+3 -1
View File
@@ -424,7 +424,9 @@ void bumbo_update(Entity_Familiar& bumbo)
}
Vector toLead = vector_sub(lead, bumbo.pos);
float leadDistance = vector_length(toLead);
if (leadDistance > leadReach) bumbo.velocity = vector_add(bumbo.velocity, vector_scale(toLead, BUM_FOLLOW_PULL / leadDistance));
if (leadDistance > leadReach)
bumbo.velocity = vector_make(toLead.x / leadDistance * BUM_FOLLOW_PULL + bumbo.velocity.x,
toLead.y / leadDistance * BUM_FOLLOW_PULL + bumbo.velocity.y);
if (bumbo.state == 2)
{
bumbo.Shoot();
+28 -14
View File
@@ -308,10 +308,18 @@ static void clot_walk(Entity_Familiar& clot, bool isPostMove)
if (!isPostMove) clot_size(clot);
}
// What a clot home with its player does: gives its heart, is refused, or is held back by its other kind being out.
enum ClotAbsorb
{
CLOT_REFUSED,
CLOT_ABSORBED,
CLOT_HELD
};
// Part of 0064e0c0: a clot home with its player gives its heart when the player can take it, a soul clot waiting
// while a black clot is out (unless a soul half is open) and a black clot while a soul clot is out and a soul half is
// open. Whether it was absorbed.
static bool clot_absorb(Entity_Familiar& clot)
// open.
static ClotAbsorb clot_absorb(Entity_Familiar& clot)
{
Entity_Player& player = *clot.player;
bool isSoulHalf = (player.soulHearts & 1) && !player.IsBlackHeart(player.soulHearts);
@@ -326,17 +334,19 @@ static bool clot_absorb(Entity_Familiar& clot)
switch (clot.subtype)
{
case CLOT_RED:
if (!player.CanPickRedHearts()) return false;
if (!player.CanPickRedHearts()) return CLOT_REFUSED;
sound = SOUND_BOSS2_BUBBLES;
player.AddHearts(1, true, false);
break;
case CLOT_SOUL:
if (!player.CanPickSoulHearts() || (!isSoulHalf && isOtherOut(CLOT_BLACK))) return false;
if (!player.CanPickSoulHearts()) return CLOT_REFUSED;
if (!isSoulHalf && isOtherOut(CLOT_BLACK)) return CLOT_HELD;
sound = SOUND_HOLY;
player.AddSoulHearts(1, false);
break;
case CLOT_BLACK:
if (!player.CanPickBlackHearts() || (isSoulHalf && isOtherOut(CLOT_SOUL))) return false;
if (!player.CanPickBlackHearts()) return CLOT_REFUSED;
if (isSoulHalf && isOtherOut(CLOT_SOUL)) return CLOT_HELD;
sound = SOUND_UNHOLY;
player.AddBlackHearts(1);
break;
@@ -345,25 +355,25 @@ static bool clot_absorb(Entity_Familiar& clot)
player.AddEternalHearts(1);
break;
case CLOT_GOLD:
if (!player.CanPickGoldenHearts()) return false;
if (!player.CanPickGoldenHearts()) return CLOT_REFUSED;
sound = SOUND_GOLD_HEART;
player.AddGoldenHearts(1, false);
break;
case CLOT_BONE:
if (!player.CanPickBoneHearts()) return false;
if (!player.CanPickBoneHearts()) return CLOT_REFUSED;
sound = SOUND_BONE_HEART;
player.AddBoneHearts(1);
break;
case CLOT_ROTTEN:
if (!player.CanPickRottenHearts()) return false;
if (!player.CanPickRottenHearts()) return CLOT_REFUSED;
sound = SOUND_ROTTEN_HEART;
player.AddRottenHearts(2, false);
break;
default: return false;
default: return CLOT_REFUSED;
}
familiar_sound_play(sound);
clot.Remove();
return true;
return CLOT_ABSORBED;
}
// Part of 0064e0c0: a launched clot's glowing trail, in its kind's colour.
@@ -389,8 +399,9 @@ static void clot_trail_spawn(Entity_Familiar& clot)
}
// Part of 0064e0c0: a launched clot drips blood, hits each enemy it passes once (three times the player's damage) and
// flies home faster and faster. Home, it gives its heart or, a few frames on, walks again.
static void clot_fly(Entity_Familiar& clot)
// flies home faster and faster. Home, it gives its heart or, a few frames on, walks again. False when its other kind
// holds it back, which ends its frame there.
static bool clot_fly(Entity_Familiar& clot)
{
if (clot.IsFrame(CLOT_DRIP_INTERVAL, 0))
{
@@ -426,7 +437,9 @@ static void clot_fly(Entity_Familiar& clot)
if (vector_distance(clot.pos, clot.player->pos) <= reach)
{
clot.state = std::max(clot.state, CLOT_ARRIVED);
if (!clot_absorb(clot) && clot.state > CLOT_ARRIVED_LIMIT)
ClotAbsorb absorb = clot_absorb(clot);
if (absorb == CLOT_HELD) return false;
if (absorb == CLOT_REFUSED && clot.state > CLOT_ARRIVED_LIMIT)
{
clot.state = CLOT_RETURNED;
if (clot.child) clot.child->Remove();
@@ -437,6 +450,7 @@ static void clot_fly(Entity_Familiar& clot)
}
}
if (!clot.child && clot.state > CLOT_LANDING) clot_trail_spawn(clot);
return true;
}
// 0064e0c0 The clots of Sumptorium and Lil Clot, run on each update and again after each move: they walk with the
@@ -453,7 +467,7 @@ void Entity_Familiar::ai_blood_clot(bool isPostMove)
}
if (state < CLOT_LAUNCHED) return clot_walk(*this, isPostMove);
if (!isPostMove) clot_fly(*this);
if (!isPostMove && !clot_fly(*this)) return;
if (!child) return;
child->sprite.color._tint[3] = CLOT_TRAIL_ALPHA;
+2 -2
View File
@@ -227,7 +227,7 @@ static void dip_scoot(Entity_Familiar& dip, float speedScale)
else if (dip.subtype == DIP_SUBTYPE_RED) speedScale = DIP_RED_CHARGE;
Vector heading = vector_is_zero(vector_sub(destination, dip.pos))
? vector_from_angle(random_unit() * PI_ROUGH * 2 * RADIANS_TO_DEGREES)
? random_direction()
: vector_normalized(vector_sub(destination, dip.pos));
float speed = random_unit() * DIP_SCOOT_SPEED + DIP_SCOOT_SPEED;
dip.velocity = vector_add(dip.velocity, vector_scale(heading, speed * speedScale / dip.friction));
@@ -373,9 +373,9 @@ void Entity_Familiar::zhl_misfit_006414c0()
if (Random() % DIP_SPLAT_ODDS == 0 && subtype != DIP_SUBTYPE_STONE)
{
float size = random_unit() * DIP_SPLAT_RANGE + DIP_SPLAT_MIN;
Entity* splat = g_game->Spawn(
{.position = pos, .spawner = this, .type = ENTITY_EFFECT, .variant = EFFECT_BLOOD_SPLAT, .seed = Random()});
float size = random_unit() * DIP_SPLAT_RANGE + DIP_SPLAT_MIN;
splat->sprite.scale = vector_make(size, size);
splat->Update();
splat->SetColor(splatColor, -1, COLOR_PRIORITY_DEFAULT, false, true);
+1 -2
View File
@@ -91,7 +91,6 @@ constexpr int GIANTBOOK_SUPER_BUM = 38;
constexpr std::pair<int, int> SUPER_BUM_PARTS[] = {{COLLECTIBLE_KEY_BUM, Entity_Familiar::KEY_BUM},
{COLLECTIBLE_DARK_BUM, Entity_Familiar::DARK_BUM},
{COLLECTIBLE_BUM_FRIEND, Entity_Familiar::BUM_FRIEND}};
constexpr int COLLECTIBLE_PEEPER_2 = 605;
constexpr int TRINKET_ISAACS_HEAD = 54;
constexpr int TRINKET_SOUL = 57;
constexpr int SOUL_TRINKET_CAP = 3;
@@ -537,7 +536,7 @@ void familiars_evaluate(Entity_Player& p)
.rng = &p.GetCollectibleRNG(COLLECTIBLE_BIRD_CAGE),
.count = p.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_BIRD_CAGE) ? 1 : 0,
.variant = Entity_Familiar::BIRD_CAGE});
effect_check(p, COLLECTIBLE_PEEPER_2, Entity_Familiar::PEEPER_2);
effect_check(p, COLLECTIBLE_SCOOPER, Entity_Familiar::PEEPER_2);
source_check(p, {COLLECTIBLE_DAMOCLES_PASSIVE, Entity_Familiar::DAMOCLES, COUNT_OWNED_ONE});
companions_check(p);
+3 -3
View File
@@ -657,14 +657,14 @@ Vector Entity_Familiar::UpdateFollowPosition()
if (formationMode != FORMATION_FREE && vector_length_squared(aim) > FORMATION_AIM_THRESHOLD)
aimAngle = std::atan2(aim.y, aim.x) * RADIANS_TO_DEGREES - 90;
float from = angle_wrap(formationAngle);
float to = angle_wrap(aimAngle);
float from = normalize_angle_degrees(formationAngle);
float to = normalize_angle_degrees(aimAngle);
if (std::fabs(to - from) > 180)
{
if (to <= from) to += 360;
else from += 360;
}
formationAngle = angle_wrap((to - from) * FORMATION_LERP + from);
formationAngle = normalize_angle_degrees((to - from) * FORMATION_LERP + from);
float radians = formationAngle * DEGREES_TO_RADIANS;
float cosine = std::cos(radians);
+2 -2
View File
@@ -622,7 +622,7 @@ void finger_update(Entity_Familiar& finger)
finger.friction *= FINGER_FRICTION;
Vector outward = vector_sub(finger.pos, player.pos);
finger.sprite.rotation = angle_wrap(vector_angle(outward) - 90);
finger.sprite.rotation = normalize_angle_degrees(vector_angle(outward) - 90);
finger.sprite.GetLayer(0)->isFlipX = finger.sprite.rotation > FINGER_FLIP_ROTATION;
int interval = g_game->deathmatchManager.is_active() ? FINGER_POKE_FRAMES_VERSUS : FINGER_POKE_FRAMES;
@@ -692,7 +692,7 @@ void succubus_update(Entity_Familiar& succubus)
void bloodshot_eye_update(Entity_Familiar& eye)
{
Vector outward = vector_sub(eye.pos, eye.player->pos);
float look = angle_wrap(vector_angle(outward) + BLOODSHOT_LOOK_TURN);
float look = normalize_angle_degrees(vector_angle(outward) + BLOODSHOT_LOOK_TURN);
int frame = (int)((1 - (look + 180) / 360) * BLOODSHOT_FRAMES);
if (eye.fireCooldown > 0) eye.fireCooldown--;
int interval = familiar_lullaby_delay(eye, BLOODSHOT_SHOT_INTERVAL);
+1 -1
View File
@@ -1005,7 +1005,7 @@ void plum_flute_wisp_target(Entity_Familiar& wisp)
wisp.state = 0;
wisp.fireCooldown = 0;
wisp.entityGridCollisionClass = GRIDCOLL_NONE;
wisp_anim_play(wisp, "Idle", SWITCH_RESET);
wisp_anim_play(wisp, "Idle");
}
else if (isSpraying && wisp.state == 0)
{
Loaded 100 of 215 files, more files were not shown because too many files have changed in this diff. Show more