#include "weapon_lasers.h" #include "boss_ai.h" #include "entity_familiar.h" #include "entity_laser.h" #include "entity_player.h" #include "entity_tear.h" #include "game.h" #include "log.h" #include "manager.h" #include "npc_ai.h" #include "npc_basement.h" #include "sfx_manager.h" #include constexpr float LASER_INHERIT_SCALE = 0.4f; constexpr float LASER_AIM_SPEED = 10; constexpr float LASER_BLINK_SCALE = -0.45f; constexpr int LASER_BLINK_BASE = 7; constexpr int LASER_SHOTS_PER_FRAME = 8; constexpr float SPRAY_REACH = 70; constexpr float SPRAY_SCATTER = 50; constexpr float LUNG_SPRAY_SCALE_STEP = 0.4f; constexpr float SPRAY_SCALE_MIN = 0.9f; constexpr float SPRAY_SCALE_RANGE = 0.05f; constexpr int SPRAY_CHAIN_MIN = 3; constexpr int SPRAY_QUIET_COUNT = 5; constexpr float LUNG_CHARGE = 4.3f; constexpr float LASER_CHOCOLATE_CHARGE = 2.5f; constexpr float CHARGE_MINIMUM = 0.001f; constexpr float TECH_X_CHARGE = 3; constexpr int MARKED_TARGET_VARIANT = 30; constexpr int OCCULT_TARGET_VARIANT = 153; constexpr float BRIMSTONE_WEAK_SCALE = 0.75f; constexpr float BRIMSTONE_THICKER_SCALE = 1.5f; constexpr int BRIMSTONE_TIMEOUT = 9; constexpr int BRIMSTONE_BURST_TIMEOUT = 3; constexpr float BRIMSTONE_SHORT_REACH = 30; constexpr float BRIMSTONE_RANGE_SCALE = 0.25f; constexpr float BRIMSTONE_RANGE_BASE = 32; constexpr float BRIMSTONE_RANGE_MINIMUM = 60; constexpr float FAMILIAR_BRIMSTONE_REACH = 10; constexpr float FAMILIAR_BRIMSTONE_LIFT = 4; constexpr float FAMILIAR_BRIMSTONE_HEIGHT = 23; constexpr const char* NULL_MOUTH = "Mouth"; constexpr float RAPID_BEAM_DAMAGE = 0.2f; constexpr float RAPID_CHOCOLATE_DAMAGE = 1.25f; constexpr float CHOCOLATE_DAMAGE_MIN = 0.1f; constexpr float CHOCOLATE_DAMAGE_MAX = 2.5f; constexpr float CHOCOLATE_RELEASE_SHARE = 0.25f; constexpr float CHOCOLATE_AIM_NEAR = 50; constexpr float CHOCOLATE_AIM_RANGE = 250; constexpr float TEAR_EFFECT_INTERVAL = 4; constexpr float BEAM_SWEEP_SPEED = 8; constexpr float HEAD_FRAME_KEEP = -2; constexpr float HELD_BEAM_LOOP_START = 8; constexpr int HELD_BEAM_LOOP_FRAME = 15; constexpr int HELD_BEAM_TIMEOUT = 8; constexpr int HELD_BEAM_MIN_TIMEOUT = 4; constexpr int FAMILIAR_BEAM_BLINK = 10; constexpr float LUDOVICO_RING_LIFT = -20; constexpr float TRACTOR_BEAM_REACH = 12; constexpr float TRACTOR_BEAM_UP = -0.5f; constexpr float TRACTOR_BEAM_DEPTH_UP = -10; constexpr float TRACTOR_BEAM_DEPTH = 3000; constexpr int TRACTOR_BEAM_BLINK = 5; constexpr float LUDOVICO_RETURN_PUSH = 0.15f; constexpr float LUDOVICO_RETURN_DISTANCE_SQUARED = 10000; constexpr float NO_RELEASE_CHARGE = -1000; constexpr float TECH_X_RADIUS_MIN = 15; constexpr float TECH_X_RADIUS_RANGE = 45; constexpr float TECH_X_DAMAGE_MIN = 0.25f; constexpr float TECH_X_DAMAGE_RANGE = 0.75f; constexpr float TECH_X_RANDOM_SPREAD = 50; constexpr int TECH_X_BLINK_MIN = 11; // 009f9020's makers for the laser weapons (009f94c0, 009f9640, 009f91f0): a fresh weapon of the type, or none for the // other types. Weapon* weapon_laser_make(WeaponType type) { switch (type) { case WEAPON_LASER: return new Weapon_Laser(); case WEAPON_BRIMSTONE: return new Weapon_Brimstone(); case WEAPON_TECH_X: return new Weapon_TechX(); default: return nullptr; } } // The player a weapon's owner fires for: the owner, or its familiar's player. static Entity_Player* weapon_player(Entity* owner) { if (!owner) return nullptr; if (owner->type == ENTITY_PLAYER) return owner->ToPlayer(); return owner->type == ENTITY_FAMILIAR ? static_cast(owner)->player : nullptr; } // Marked's target, or Eye of the Occult's with it, or none. static int marked_variant_get(Entity_Player* player) { if (!player || !player->HasCollectible(COLLECTIBLE_MARKED)) return 0; return player->HasCollectible(COLLECTIBLE_EYE_OF_THE_OCCULT) ? OCCULT_TARGET_VARIANT : MARKED_TARGET_VARIANT; } // 009f3f60 The color the owner's lasers take: its player's laser color. A familiar's lasers are recolored by // Baby-Bender, which is not reconstructed yet. Online, another player's lasers fade with the opacity option, which // this offline build has no use for. ColorMod Weapon::get_laser_color() { Entity_Player* player = weapon_player(owner); if (!player) return COLOR_DEFAULT; if (owner->type == ENTITY_FAMILIAR) reconstruction_missing("Weapon::get_laser_color 009f3f60 (a familiar's lasers)"); return player->laserColor; } // 009f5a30 Where the owner's laser of an offset leaves from: its player's eye or mouth. A familiar's are not // reconstructed yet. Vector Weapon::GetOwnerLaserOffset(int laserOffsetId, const Vector& shootDirection) { if (!owner) return {}; if (owner->type == ENTITY_PLAYER) return owner->ToPlayer()->GetLaserOffset(laserOffsetId, shootDirection); if (owner->type == ENTITY_FAMILIAR) reconstruction_missing("Weapon::GetOwnerLaserOffset 009f5a30 (00631a00)"); return {}; } // 009f5f40 Fires a Brimstone beam: thicker with the damage, Technology's red-blue beam with it, doubled by a second // Brimstone and by Azazel's Birthright or Stump, halved for a familiar or a burst (without Brimstone), the thicker // variant past one and a half. It leaves the player's mouth (or a familiar's front) and takes the player's hit // params. Azazel's short beam reaches by range. Entity_Laser* Weapon::FireBrimstone(const BrimstoneShot& shot) { Entity* entity = shot.entity; Entity_Familiar* familiar = entity && entity->type == ENTITY_FAMILIAR ? static_cast(entity) : nullptr; Entity_Player* player = familiar ? familiar->player : (entity && entity->type == ENTITY_PLAYER ? entity->ToPlayer() : nullptr); bool isBurst = shot.fireFlags & BRIMSTONE_FIRE_BURST; bool hasBrimstone = player && player->HasCollectible(COLLECTIBLE_BRIMSTONE); float scale = std::sqrt(shot.damageMultiplier); if (shot.fireFlags & BRIMSTONE_FIRE_WEAK) scale *= BRIMSTONE_WEAK_SCALE; if (familiar) scale *= 0.5f; int variant = LASER_THICK_RED; if (player) { if (player->HasCollectible(COLLECTIBLE_TECHNOLOGY)) variant = LASER_BRIM_TECH; if (player->GetCollectibleNum(COLLECTIBLE_BRIMSTONE) > 1) scale += scale; } if (!isBurst || hasBrimstone) { if (shot.fireFlags & BRIMSTONE_FIRE_SHORT) scale += scale; } else scale *= 0.5f; bool isAzazelBeam = player && (player->playerType == PLAYER_AZAZEL || player->temporaryEffects.HasTrinketEffect(TRINKET_AZAZELS_STUMP)); if (player && player->playerType == PLAYER_AZAZEL && (player->HasCollectible(COLLECTIBLE_BIRTHRIGHT) || player->temporaryEffects.HasTrinketEffect(TRINKET_AZAZELS_STUMP))) scale += scale; if (scale > BRIMSTONE_THICKER_SCALE) { variant = variant == LASER_BRIM_TECH ? LASER_THICKER_BRIM_TECH : LASER_THICKER_RED; scale *= 0.5f; } Vector offset{}; if (familiar) offset = vector_make(shot.direction.x * FAMILIAR_BRIMSTONE_REACH, FAMILIAR_BRIMSTONE_LIFT - std::abs(shot.direction.x) * FAMILIAR_BRIMSTONE_LIFT - FAMILIAR_BRIMSTONE_HEIGHT); else if (player && player->HasCollectible(COLLECTIBLE_C_SECTION)) offset = vector_make(0, player->sprite.scale.y * C_SECTION_LASER_LIFT); else if (player) { offset = vector_scale(player->GetCostumeNullPos(NULL_MOUTH, true, Vector{}), 1 / LASER_SCREEN_SCALE); if (player->canFly) offset = vector_add(offset, vector_scale(player->GetFlyingOffset(), 1 / LASER_SCREEN_SCALE)); } bool isBurstBeam = (shot.fireFlags & (BRIMSTONE_FIRE_BURST | BRIMSTONE_FIRE_WEAK)) == BRIMSTONE_FIRE_BURST && !hasBrimstone; Entity_Laser* laser = Entity_Laser::ShootAngle({.position = shot.position, .posOffset = offset, .source = entity, .angleDegrees = vector_angle(shot.direction), .timeout = isBurstBeam ? BRIMSTONE_BURST_TIMEOUT : BRIMSTONE_TIMEOUT, .variant = variant}); laser->damageMultiplier = shot.damageMultiplier; laser->set_scale(scale); TearParams params; if (player) { int displacement = (int)(Random() & 1) * 2 - 1; params = player->GetTearHitParams(WEAPON_BRIMSTONE, shot.damageMultiplier, displacement, entity); } laser->SetCollisionDamage(params.tearDamage); laser->renderDepthOffset = shot.direction.y <= -TECH_LASER_FACING ? TECH_LASER_BACK_DEPTH : TECH_LASER_FRONT_DEPTH; if (isAzazelBeam && !hasBrimstone) laser->maxDistance = std::max(player->tearRange * BRIMSTONE_RANGE_SCALE + BRIMSTONE_RANGE_BASE, BRIMSTONE_RANGE_MINIMUM); else if (shot.fireFlags & BRIMSTONE_FIRE_SHORT) laser->maxDistance = BRIMSTONE_SHORT_REACH; float massMultiplier = params.massMultiplier; if (isBurst && !hasBrimstone) massMultiplier *= 0.5f; laser->isPlayerParams = true; laser->mass *= massMultiplier; laser->tearFlags = params.tearFlags; return laser; } // 009f6570 Fires a Brimstone beam from the owner in the owner's laser color. Entity_Laser* Weapon::fire_brimstone_with_color(const Vector& shootDirection, float damageMultiplier, uint32_t fireFlags) { Entity_Laser* laser = FireBrimstone({.direction = shootDirection, .position = get_owner_position(), .entity = owner, .damageMultiplier = damageMultiplier, .fireFlags = fireFlags}); laser->SetColor(get_laser_color(), -1, COLOR_PRIORITY_DEFAULT, false, true); return laser; } // 009f6610 Fires a Technology laser: the player's own, a familiar's (not reconstructed yet), or a plain one from the // owner. Entity_Laser* Weapon::fire_laser(const TechLaserShot& shot) { if (owner && owner->type == ENTITY_PLAYER) return owner->ToPlayer()->FireTechLaser(shot); if (owner && owner->type == ENTITY_FAMILIAR) reconstruction_missing("Weapon::fire_laser 009f6610 (a familiar's laser)"); return Entity_Laser::ShootAngle({.position = get_owner_position(), .source = owner, .angleDegrees = vector_angle(shot.direction), .timeout = TECH_LASER_TIMEOUT, .variant = LASER_THIN_RED}); } // 00a052a0 Forgets the charges. The base's reset does not run. void Weapon_Laser::Reset() { cursedEyeCharges = 0; chargeAtRelease = 0; } // 00a063b0 Removes Technology 2's laser and Ludovico's ring, and forgets them. void Weapon_Laser::ClearReferences() { for (EntityPtr* laser : {&technology2Laser, &ludovicoLaser}) { if (!*laser) continue; (*laser)->Remove(); *laser = nullptr; } } // 00a06870 The charge a full shot takes: Monstro's Lung's, Chocolate Milk's and Cursed Eye's, none without them. float Weapon_Laser::GetMaxCharge() { float multiplier = 1; if (modifiers & WEAPON_MOD_MONSTROS_LUNG) multiplier = LUNG_CHARGE; if (modifiers & WEAPON_MOD_CHOCOLATE_MILK) multiplier *= LASER_CHOCOLATE_CHARGE; if (modifiers & WEAPON_MOD_CURSED_EYE) multiplier += multiplier; return multiplier > 1 ? (maxFireDelay + 1) * multiplier - 1 : 0; } // Ludovico's ring is what the camera follows (Weapon_Bombs::GetFocusEntity, which lasers share). Entity* Weapon_Laser::GetFocusEntity() { return (modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) ? ludovicoLaser.get() : nullptr; } // Marked's target, as Brimstone's (Weapon_Brimstone::GetMarkedTargetVariant, which lasers share). int Weapon_Laser::GetMarkedTargetVariant() { return (modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) ? 0 : marked_variant_get(weapon_player(owner)); } // 00a068e0 Whether a half charged shot lets Cursed Eye teleport the player: not while Marked aims. bool Weapon_Laser::CanTriggerCursedEyeTeleport() { if (!owner || owner->type != ENTITY_PLAYER) return false; if (owner->ToPlayer()->markedTarget && GetMarkedTargetVariant()) return false; return charge > 0 && charge < GetMaxCharge(); } // Lasers ride a Tractor Beam unless Ludovico holds them (Weapon_Knife::SupportsTractorBeam, which lasers share). bool Weapon_Laser::SupportsTractorBeam() { return !(modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE); } // 00a06330 Gives a laser the owner's tear flags, laser color and damage (Weapon_Brimstone::init_laser 00a00f90 is the // same). void Weapon_Laser::init_laser(Weapon& weapon, Entity_Laser& laser) { laser.tearFlags = weapon.get_owner_tear_flags(); laser.SetColor(weapon.get_laser_color(), -1, COLOR_PRIORITY_DEFAULT, false, true); laser.SetCollisionDamage(weapon.get_damage()); } // 00a06420 Fires a volley: one laser per shot of the volley, offset and turned by it, or a spray of shorter lasers // around the direction, each scaled at random and chaining three or four more (the spray's sound plays for a big // one). std::vector Weapon_Laser::fire_lasers(const LaserVolley& volley) { std::vector fired; int shots = volley.params ? volley.params->numTears : 1; Entity_Player* player = weapon_player(owner); float shotSpeed = player ? player->shotSpeed : 1; for (int i = 0; i < shots; i++) { Vector position = volley.position; Vector direction = volley.direction; if (volley.params) { PosVel shot = Entity_Player::GetMultiShotPositionVelocity(i, WEAPON_LASER, volley.direction, shotSpeed, *volley.params); position = vector_add(position, shot.position); direction = shot.velocity; } TechLaserShot laserShot = {.direction = direction, .position = position, .damageScale = volley.damageScale, .offsetId = volley.offsetId, .isLeftEye = true, .isOneHit = true}; if (volley.sprayCount < 1) { fired.push_back(fire_laser(laserShot)); continue; } Vector reach = vector_scale(direction, SPRAY_REACH); for (int spray = 0; spray < volley.sprayCount; spray++) { float angle = random_unit() * RANDOM_HALF_TURN * 2; float scatter = random_unit(); Vector aim = vector_add(reach, vector_make(std::cos(angle) * SPRAY_SCATTER * scatter, std::sin(angle) * SPRAY_SCATTER * scatter)); laserShot.direction = vector_normalized(aim); Entity_Laser* laser = fire_laser(laserShot); laser->maxDistance = vector_length(aim); float growth = (float)(Random() & 1) * LUNG_SPRAY_SCALE_STEP + SPRAY_SCALE_MIN; laser->scale *= growth + random_unit() * SPRAY_SCALE_RANGE; laser->ResetSpriteScale(); laser->chainedLasers = (int)(Random() & 1) + SPRAY_CHAIN_MIN; laser->isDisableInitSound = volley.sprayCount > SPRAY_QUIET_COUNT; fired.push_back(laser); } if (volley.sprayCount > SPRAY_QUIET_COUNT) npc_sound_play(SOUND_BLOOD_LASER_LARGE, 1, 2, 1); } return fired; } // 00a052b0 Fires Technology's lasers: one volley per fire delay passed this frame (at most eight), from the eye with // the volley's extra backward, sideways and random lasers, carrying a share of the owner's movement unless a // Tractor Beam holds them. Ludovico's ring and the charged shots (Monstro's Lung, Chocolate Milk, Cursed Eye) are // not reconstructed yet. void Weapon_Laser::Fire(const Vector& shootDirection, bool isShooting, bool isInterpolated) { Weapon::Fire(shootDirection, isShooting, isInterpolated); if (modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) reconstruction_missing("Weapon_Laser::Fire 00a052b0 (Ludovico's ring)"); if (modifiers & (WEAPON_MOD_MONSTROS_LUNG | WEAPON_MOD_CHOCOLATE_MILK | WEAPON_MOD_CURSED_EYE)) reconstruction_missing("Weapon_Laser::Fire 00a052b0 (charged lasers)"); int shots = 0; if (isShooting) { if (isInterpolated) return; while (fireDelay < 0 && shots < LASER_SHOTS_PER_FRAME) { shots++; fireDelay += maxFireDelay + 1; } chargeAtRelease = 0; } Vector aim = isShooting ? shootDirection : direction; aim = IsAxisAligned() ? vector_cardinal(aim) : vector_normalized(aim); if (shots > 0) { bool isTractorBeam = modifiers & WEAPON_MOD_TRACTOR_BEAM; Vector velocity = vector_scale(aim, LASER_AIM_SPEED); if (!isTractorBeam) velocity = vector_add(velocity, vector_scale(get_tear_movement_inheritance(aim), LASER_INHERIT_SCALE)); aim = vector_normalized(velocity); SetBlinkTime(LASER_BLINK_BASE - (int)(maxFireDelay * LASER_BLINK_SCALE)); TriggerTearEffects(aim, 1); Weapon_MultiShotParams params = GetMultiShotParams(); LaserVolley volley = {.direction = aim, .position = get_owner_position(), .params = ¶ms}; std::vector fired = fire_lasers(volley); volley.params = nullptr; volley.offsetId = LASER_OFFSET_MOMS_EYE; auto fire_more = [&](Vector extra) { volley.direction = extra; std::vector more = fire_lasers(volley); fired.insert(fired.end(), more.begin(), more.end()); }; if (params.isShootingBackwards) fire_more(vector_make(-aim.x, -aim.y)); if (params.isShootingSideways) { fire_more(vector_make(aim.y, -aim.x)); fire_more(vector_make(-aim.y, aim.x)); } for (int i = 0; i < params.numRandomDirTears; i++) fire_more(random_direction()); for (Entity_Laser* laser : fired) { laser->isDisableFollowParent = !isTractorBeam; laser->Update(); } } if (isShooting) direction = IsAxisAligned() ? aim : get_aim_direction(aim); } // 00a00f30 The charge a full beam takes: the fire delay (Chocolate Milk's two and a half of it), none under Ludovico. float Weapon_Brimstone::GetMaxCharge() { if (modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) return 0; float multiplier = (modifiers & WEAPON_MOD_CHOCOLATE_MILK) ? LASER_CHOCOLATE_CHARGE : 1; return std::max(maxFireDelay, CHARGE_MINIMUM) * multiplier; } // 00a02790 Removes Technology 2's laser and the main beam, and forgets them. void Weapon_Brimstone::ClearReferences() { for (EntityPtr* laser : {&technology2Laser, &mainLaser}) { if (!*laser) continue; (*laser)->Remove(); *laser = nullptr; } } // 00a02870 The camera follows Ludovico's beam. Entity* Weapon_Brimstone::GetFocusEntity() { return (modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) ? mainLaser.get() : nullptr; } // 009f3160 The beam it fires as. Entity* Weapon_Brimstone::GetMainEntity() { return mainLaser; } // 00a02800 Marked's target, Eye of the Occult's with it, none under Ludovico. int Weapon_Brimstone::GetMarkedTargetVariant() { return (modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) ? 0 : marked_variant_get(weapon_player(owner)); } // What Brimstone's Fire works out about the owner before it decides to charge or fire. struct BrimstoneAim { Vector target{}; Entity_Player* player = nullptr; float maxCharge = 0; float shotSpeed = 1; bool isAimFixed = false; bool isFullyCharged = false; bool isHasBrimstone = false; bool isHasMarked = false; bool isRapid = false; bool isRapidBeam = false; }; // The charge part of Brimstone's Fire: a beam left on its parent goes, the head charges toward a full beam (unless // the costume shoots its other shot) as the charge grows by the owner's speed, and the aim follows the input. void Weapon_Brimstone::charge_update(const Vector& shootDirection, bool isCharging, bool isInterpolated) { Entity* beam = mainLaser; if (beam && beam->parent && beam->parent->type != ENTITY_EFFECT) beam->Remove(); bool isShootAlt = false; ItemConfig_Item* item = g_manager->itemConfig.GetCollectible(COLLECTIBLE_BRIMSTONE); if (owner && owner->is_player()) for (PlayerCostumeMap& map : owner->ToPlayer()->playerCostumeMap) { if (map.index < 0 || map.isBodyLayer) continue; CostumeSpriteDesc& costume = owner->ToPlayer()->costumeSpriteDescs[map.index]; if (!is_held_item(costume, "", item) || !costume.sprite.IsPlaying()) continue; isShootAlt = costume.sprite.GetAnimation().ends_with("ShootAlt"); break; } bool isCSection = modifiers & WEAPON_MOD_C_SECTION; if (isCharging) { float maxCharge = GetMaxCharge(); if (charge < maxCharge) { float frame = charge / maxCharge * HEAD_CHARGE_FRAMES; if (!isCSection && !isShootAlt) UpdateHeadChargeAnimation(COLLECTIBLE_BRIMSTONE, HEAD_CHARGE_CHARGING, shootDirection, frame); else if (isCSection && is_c_section_anim_finished()) update_c_section_charge_anim(HEAD_CHARGE_CHARGING, shootDirection, frame); if (!isInterpolated) charge += owner ? owner->speedMultiplier : 1; } else if (isCSection) update_c_section_charge_anim(HEAD_CHARGE_CHARGED, shootDirection, -1); else if (!isShootAlt) UpdateHeadChargeAnimation(COLLECTIBLE_BRIMSTONE, HEAD_CHARGE_CHARGED, shootDirection, -1); } direction = IsAxisAligned() ? shootDirection : get_aim_direction(shootDirection); SetBlinkTime(1); } // Fires one beam of a volley along a direction and links it to the main beam, or makes it the main beam. Entity_Laser* Weapon_Brimstone::fire_beam(const Vector& beamDirection, float damageScale, uint32_t fireFlags) { Entity_Laser* laser = fire_brimstone_with_color(beamDirection, damageScale, fireFlags); laser->parent = mainLaser; laser->Update(); return laser; } // The release part of Brimstone's Fire: without enough charge the costume stops, otherwise the volley's beams fire // (weak for a rapid fire, scaled by Chocolate Milk) along the aim, with the extra backward, sideways and random ones. // A beam out triggers the tear effects, and under Marked or a rapid fire it sweeps the beams toward the aim. void Weapon_Brimstone::release(const Vector& shootDirection, const BrimstoneAim& aim, bool isInterpolated) { bool isChocolateMilk = modifiers & WEAPON_MOD_CHOCOLATE_MILK; bool isCSection = modifiers & WEAPON_MOD_C_SECTION; bool isAntiGravity = modifiers & WEAPON_MOD_ANTI_GRAVITY; float threshold = isChocolateMilk ? std::max(aim.maxCharge * CHOCOLATE_RELEASE_SHARE, CHARGE_MINIMUM) : aim.maxCharge; if (charge < threshold) { int blink = 0; if (owner && owner->is_player()) blink = owner->ToPlayer()->blinkTime; else if (owner && owner->IsFamiliar()) blink = static_cast(owner)->headFrameDelay; if (mainLaser || blink > 1) { if (owner && owner->is_player() && IsItemAnimFinished(COLLECTIBLE_BRIMSTONE)) stop_costume_item_anim(COLLECTIBLE_BRIMSTONE); } else stop_costume_item_anim(COLLECTIBLE_BRIMSTONE); if (!mainLaser && owner && owner->is_player() && isCSection && is_c_section_anim_finished()) update_c_section_charge_anim(HEAD_CHARGE_CHARGING, shootDirection, 0); } else { uint32_t fireFlags = (aim.isRapid ? BRIMSTONE_FIRE_WEAK : 0) | (isCSection ? BRIMSTONE_FIRE_C_SECTION : 0); Vector beamDirection = aim.isAimFixed ? shootDirection : direction; beamDirection = IsAxisAligned() ? vector_cardinal(beamDirection) : vector_normalized(beamDirection); float damageScale = 1; if (aim.isRapidBeam) { damageScale = SHOTS_PER_SECOND / (maxFireDelay + 1) * RAPID_BEAM_DAMAGE; if (isChocolateMilk) damageScale *= RAPID_CHOCOLATE_DAMAGE; } else if (isChocolateMilk) damageScale = std::clamp(charge / aim.maxCharge, CHOCOLATE_DAMAGE_MIN, CHOCOLATE_DAMAGE_MAX); if (modifiers & WEAPON_MOD_AZAZELS_SNEEZE) { fireFlags |= BRIMSTONE_FIRE_BURST; if (!aim.isHasBrimstone) damageScale *= 0.5f; } Weapon_MultiShotParams params = GetMultiShotParams(); aimAngle = vector_angle(beamDirection); if (isCSection) update_c_section_charge_anim(HEAD_CHARGE_SHOOT, beamDirection, -1); else UpdateHeadChargeAnimation(COLLECTIBLE_BRIMSTONE, HEAD_CHARGE_SHOOT, beamDirection, -1); Entity_Laser* first = nullptr; for (int i = 0; i < params.numTears; i++) { PosVel shot = Entity_Player::GetMultiShotPositionVelocity(i, WEAPON_BRIMSTONE, beamDirection, aim.shotSpeed, params); Entity_Laser* laser = fire_brimstone_with_color(shot.velocity, damageScale, fireFlags); laser->Update(); if (first) laser->parent = first; else mainLaser = first = laser; } for (int i = 0; i < params.numRandomDirTears; i++) fire_beam(random_direction(), damageScale, fireFlags); if (params.isShootingBackwards) fire_beam(vector_scale(beamDirection, -1), damageScale, fireFlags); if (params.isShootingSideways) { fire_beam(vector_make(-beamDirection.y, beamDirection.x), damageScale, fireFlags); fire_beam(vector_make(beamDirection.y, -beamDirection.x), damageScale, fireFlags); } if (isAntiGravity && isCSection) fire_c_section_fetuses(); } Entity* beam = mainLaser; if (beam && !isInterpolated) { TriggerTearEffects(shootDirection, beam->GetIntervalTicks(TEAR_EFFECT_INTERVAL, 0)); if (!isAntiGravity && beam->GetIntervalTicks(TEAR_EFFECT_INTERVAL, 0) && isCSection) fire_c_section_fetuses(); if (aim.isHasMarked || (aim.isRapidBeam && aim.isFullyCharged)) sweep(shootDirection, aim); else { SetHeadLockTime(2); if (owner && owner->IsFamiliar()) SetBlinkTime(FAMILIAR_BEAM_BLINK); } } charge = 0; } // Turns the main beam and the beams on it toward the aim, by at most eight degrees a frame, facing them behind the // head when aimed up. A rapid beam at full charge also follows the mouth and keeps going. The head shows the shot. void Weapon_Brimstone::sweep(const Vector& shootDirection, const BrimstoneAim& aim) { float targetAngle = vector_angle(shootDirection); bool isHeld = aim.isRapidBeam && aim.isFullyCharged; for (Entity* entity : entity_query(ENTITY_LASER, -1)) { if (entity != mainLaser && entity->parent != mainLaser) continue; Entity_Laser& laser = *static_cast(entity); laser.isActiveRotating = true; laser.rotationDelay = 0; laser.rotationDegrees = angle_difference(laser.angleDegrees, laser.angleDegrees - aimAngle + targetAngle); laser.rotationSpd = laser.rotationDegrees >= 0 ? BEAM_SWEEP_SPEED : -BEAM_SWEEP_SPEED; bool isFacingUp = std::sin(laser.angleDegrees * DEGREES_TO_RADIANS) <= -TECH_LASER_FACING; laser.renderDepthOffset = isFacingUp ? TECH_LASER_BACK_DEPTH : TECH_LASER_FRONT_DEPTH; if (!isHeld) continue; laser.posOffset = GetOwnerLaserOffset(LASER_OFFSET_BRIMSTONE, shootDirection); laser.timeout = std::max(laser.timeout, HELD_BEAM_TIMEOUT); } float step = std::clamp(angle_difference(aimAngle, targetAngle), -BEAM_SWEEP_SPEED, BEAM_SWEEP_SPEED); aimAngle = angle_wrap(aimAngle + step); if (IsItemAnimFinished(COLLECTIBLE_BRIMSTONE)) return; if (modifiers & WEAPON_MOD_C_SECTION) { update_c_section_charge_anim(HEAD_CHARGE_SHOOT, shootDirection, 0); return; } UpdateHeadChargeAnimation(COLLECTIBLE_BRIMSTONE, HEAD_CHARGE_SHOOT, shootDirection, HEAD_FRAME_KEEP); Entity_Player* player = owner && owner->is_player() ? owner->ToPlayer() : nullptr; ItemConfig_Item* item = g_manager->itemConfig.GetCollectible(COLLECTIBLE_BRIMSTONE); if (isHeld && player && costume_item_frame_get(*player, item) > HELD_BEAM_LOOP_FRAME) play_brimstone_costume_shoot(shootDirection, HELD_BEAM_LOOP_START); } // Ludovico's part of Brimstone's Fire: one ring beam that the input steers (or that drifts back to an owner in a // clear room), remade when its variant changes, thicker with a second Brimstone, triggering tear effects as it // moves. void Weapon_Brimstone::ludovico_update(const Vector& shootDirection, const BrimstoneAim& aim, bool isShooting, bool isInterpolated) { Vector ownerPosition = get_owner_position(); Entity* ring = mainLaser; Vector ringPosition = ring ? ring->pos : ownerPosition; float ringScale = 1; if (!isInterpolated) { bool isTechnology = aim.player && aim.player->HasCollectible(COLLECTIBLE_TECHNOLOGY); int variant = isTechnology ? LASER_BRIM_TECH : LASER_THICK_RED; if ((modifiers & WEAPON_MOD_AZAZELS_SNEEZE) && !aim.isHasBrimstone) ringScale = 0.5f; if (aim.player && aim.player->GetCollectibleNum(COLLECTIBLE_BRIMSTONE) > 1) ringScale += ringScale; if (owner && owner->IsFamiliar()) ringScale *= 0.5f; if (ringScale > BRIMSTONE_THICKER_SCALE) { variant = variant == LASER_BRIM_TECH ? LASER_THICKER_BRIM_TECH : LASER_THICKER_RED; ringScale *= 0.5f; } if (ring && (ring->subtype != LASER_SUBTYPE_RING_LUDOVICO || ring->variant != variant)) { ring->Remove(); mainLaser = ring = nullptr; } if (!ring) { Entity_Laser* laser = static_cast(g_game->Spawn({.position = ringPosition, .spawner = owner, .subType = LASER_SUBTYPE_RING_LUDOVICO, .type = ENTITY_LASER, .variant = variant, .seed = Random()})); laser->posOffset = vector_make(0, LUDOVICO_RING_LIFT); laser->parent = owner; laser->renderDepthOffset = TECH_LASER_FRONT_DEPTH; laser->scale = ringScale; laser->ResetSpriteScale(); Weapon_Laser::init_laser(*this, *laser); laser->Update(); mainLaser = ring = laser; } } if (!ring) return; if (isShooting) { Vector push = shootDirection; if (vector_length_squared(push) > 1) push = vector_normalized(push); ring->AddVelocity_divided(vector_scale(push, aim.shotSpeed), false); } else if (g_game->room->GetAliveEnemiesCount() < 1) { Vector away = vector_sub(ownerPosition, ring->pos); if (vector_length_squared(away) > LUDOVICO_RETURN_DISTANCE_SQUARED) ring->AddVelocity_divided(vector_scale(vector_normalized(away), LUDOVICO_RETURN_PUSH), false); } if (isInterpolated) return; Entity_Laser& laser = *static_cast(ring); Weapon_Laser::init_laser(*this, laser); laser.scale = ringScale; laser.ResetSpriteScale(); Entity* shooter = owner && owner->is_player() ? owner : nullptr; if (!shooter || !shooter->GetIntervalTicks(aim.maxCharge, 0)) return; bool isApart = laser.pos.x != owner->pos.x || laser.pos.y != owner->pos.y; TriggerTearEffects(isApart ? vector_normalized(vector_sub(laser.pos, owner->pos)) : random_direction(), 1); } // What Brimstone's Fire decides from the owner: its player, shot speed and charge, the aim Marked's target or a // fixed aim gives, and whether a rapid fire (Soy Milk or a fast fire delay) is already at full charge. BrimstoneAim Weapon_Brimstone::aim_get(bool isShooting) { BrimstoneAim aim; aim.player = weapon_player(owner); aim.shotSpeed = aim.player ? aim.player->shotSpeed : 1; aim.maxCharge = std::max(maxFireDelay, CHARGE_MINIMUM); aim.isHasBrimstone = aim.player && aim.player->HasCollectible(COLLECTIBLE_BRIMSTONE); aim.isRapid = (modifiers & WEAPON_MOD_SOY_MILK) || maxFireDelay <= 1; aim.isRapidBeam = aim.isRapid && !(modifiers & WEAPON_MOD_ANTI_GRAVITY); aim.isHasMarked = aim.player && aim.player->HasCollectible(COLLECTIBLE_MARKED); bool isMarking = aim.player && (aim.isHasMarked || aim.player->HasCollectible(COLLECTIBLE_EYE_OF_THE_OCCULT)); Entity* markedTarget = aim.player ? aim.player->markedTarget : nullptr; aim.target = isMarking && markedTarget ? markedTarget->pos : fixedDirection; aim.isAimFixed = !vector_is_zero(aim.target); Entity* beam = mainLaser; bool isBeamHeld = beam && static_cast(beam)->timeout > HELD_BEAM_MIN_TIMEOUT; aim.isFullyCharged = aim.isRapid && (aim.maxCharge <= charge || (isShooting && aim.isRapidBeam && isBeamHeld)); return aim; } // 009ff360 Charges and fires Brimstone: while shooting the head charges, on release (or once a fixed aim or Marked's // charge is enough) the beams fire. A rapid fire keeps one beam going and sweeps it, Ludovico steers a ring beam. // C Section's fetuses and Hemoptysis' sneeze are not reconstructed yet. With C Section, the body faces the beam. void Weapon_Brimstone::Fire(const Vector& shootDirection, bool isShooting, bool isInterpolated) { Weapon::Fire(shootDirection, isShooting, isInterpolated); BrimstoneAim aim = aim_get(isShooting); bool isShootingNow = isShooting; if (modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) ludovico_update(shootDirection, aim, isShooting, isInterpolated); else { bool isCharging = fireDelay < 0 || charge > 0; if (!aim.isFullyCharged) { if (!isInterpolated && isShooting && aim.isAimFixed) { float threshold = aim.maxCharge; if (modifiers & WEAPON_MOD_CHOCOLATE_MILK) { float distance = vector_length(vector_sub(aim.target, get_owner_position())); float share = std::clamp((distance - CHOCOLATE_AIM_NEAR) / CHOCOLATE_AIM_RANGE, 0.0f, 1.0f); threshold = (aim.maxCharge * CHOCOLATE_DAMAGE_MAX - aim.maxCharge * CHOCOLATE_RELEASE_SHARE) * share + aim.maxCharge * CHOCOLATE_RELEASE_SHARE; } if (threshold <= charge) isShootingNow = false; } Entity* beam = mainLaser; if (beam && beam->parent && beam->parent->type != ENTITY_EFFECT && (!aim.player || aim.isAimFixed || aim.player->twinPlayer)) isShootingNow = false; } bool isSneezing = modifiers & WEAPON_MOD_AZAZELS_SNEEZE; bool isHeldCharge = isInterpolated || charge > 0 || fireDelay >= 0; if (isSneezing && isShootingNow && !isHeldCharge && !aim.isFullyCharged) reconstruction_missing("Weapon_Brimstone::Fire 009ff360 (Hemoptysis' sneeze, fire_hitscan 00a01020)"); if (isShootingNow && !aim.isFullyCharged) charge_update(shootDirection, isCharging, isInterpolated); else release(shootDirection, aim, isInterpolated); } if (!(modifiers & WEAPON_MOD_C_SECTION)) return; if (Entity* beam = mainLaser) bodyDirection = vector_from_angle(static_cast(beam)->angleDegrees); else if (isShootingNow || is_c_section_anim_finished()) bodyDirection = shootDirection; } // 00a00d10 void Weapon_Brimstone::fire_c_section_fetuses() { reconstruction_missing("Weapon_Brimstone::fire_c_section_fetuses 00a00d10"); } // 00a01020 void Weapon_Brimstone::fire_hitscan() { reconstruction_missing("Weapon_Brimstone::fire_hitscan 00a01020"); } // 00a02890 void Weapon_Brimstone::fire(float, bool) { reconstruction_missing("Weapon_Brimstone::fire 00a02890"); } // 00a0e260 The charge a full ring takes: three fire delays. float Weapon_TechX::GetMaxCharge() { return maxFireDelay * TECH_X_CHARGE; } // Marked's target, as Monstro's Lung picks it, which Tech X shares. int Weapon_TechX::GetMarkedTargetVariant() { return marked_variant_get(weapon_player(owner)); } // 00a0d9c0 Charges and fires Tech X's rings: the charge grows while shooting, and on release (or once a rapid fire, // Marked's aim or a pee burst has charged enough) a volley of rings flies off, bigger and stronger the longer it // charged, with the extra backward, mirrored and random ones. void Weapon_TechX::Fire(const Vector& shootDirection, bool isShooting, bool isInterpolated) { Weapon::Fire(shootDirection, isShooting, isInterpolated); if (isInterpolated) return; Entity_Player* player = weapon_player(owner); float shotSpeed = player ? player->shotSpeed : 1; bool isHasMarked = player && player->HasCollectible(COLLECTIBLE_MARKED); bool isRapid = (modifiers & WEAPON_MOD_SOY_MILK) || maxFireDelay <= 0; Entity* markedTarget = player ? player->markedTarget : nullptr; Vector target = markedTarget && isHasMarked ? markedTarget->pos : fixedDirection; float releaseCharge = NO_RELEASE_CHARGE; if (isShooting && isRapid) releaseCharge = maxFireDelay * TECH_X_CHARGE; else if (isShooting && !vector_is_zero(target)) { float distance = vector_length(vector_sub(target, get_owner_position())); float share = std::clamp((distance - CHOCOLATE_AIM_NEAR) / CHOCOLATE_AIM_RANGE, 0.0f, 1.0f); releaseCharge = (maxFireDelay * TECH_X_CHARGE - maxFireDelay) * share + maxFireDelay; } if (owner && owner->is_player() && owner->ToPlayer()->peeBurstCooldown > 0) releaseCharge = std::max(maxFireDelay, 1.0f); bool isReleaseCharged = releaseCharge > NO_RELEASE_CHARGE && releaseCharge <= charge; Vector aim = isShooting ? shootDirection : direction; aim = IsAxisAligned() ? vector_cardinal(aim) : vector_normalized(aim); if (isShooting && !isReleaseCharged) { if (maxFireDelay * TECH_X_CHARGE <= charge) UpdateHeadChargeAnimation(COLLECTIBLE_TECH_X, HEAD_CHARGE_CHARGED, shootDirection, -1); else charge += owner ? owner->speedMultiplier : 1; SetBlinkTime(1); } else { if (std::max(maxFireDelay, 1.0f) <= charge || isReleaseCharged) fire_rings(aim, shotSpeed); charge = 0; } if (isShooting) direction = IsAxisAligned() ? shootDirection : get_aim_direction(shootDirection); } // Fires the charged volley of Tech X rings along an aim: their radius and damage grow from a quarter at one fire // delay to full at three. void Weapon_TechX::fire_rings(const Vector& aim, float shotSpeed) { fireDelay = maxFireDelay; SetBlinkTime(std::max(TECH_X_BLINK_MIN, LASER_BLINK_BASE - (int)(maxFireDelay * LASER_BLINK_SCALE))); TriggerTearEffects(aim, 1); Vector position = get_owner_position(); Vector velocity = vector_add(vector_scale(aim, LASER_AIM_SPEED), get_tear_movement_inheritance(aim)); float fullDelay = maxFireDelay + 1; float share = (std::min(charge + 1, fullDelay * TECH_X_CHARGE) - fullDelay) / (fullDelay + fullDelay); float radius = share * TECH_X_RADIUS_RANGE + TECH_X_RADIUS_MIN; float damageScale = share * TECH_X_DAMAGE_RANGE + TECH_X_DAMAGE_MIN; Weapon_MultiShotParams params = GetMultiShotParams(); auto fire_ring = [&](Vector ringPosition, Vector ringVelocity, float scale) { fire_tech_x_laser({.position = ringPosition, .velocity = ringVelocity, .damageMultiplier = damageScale * scale, .radius = radius * scale}) ->Update(); }; if (params.isShootingBackwards) fire_ring(position, vector_scale(velocity, -shotSpeed), 1); if (params.isShootingSideways) { fire_ring(position, vector_make(velocity.x * shotSpeed, -velocity.y * shotSpeed), 1); fire_ring(position, vector_make(-velocity.x * shotSpeed, velocity.y * shotSpeed), 1); } for (int i = 0; i < params.numRandomDirTears; i++) { float scale = random_unit() * 0.5f + 0.5f; float angle = (random_unit() * TECH_X_RANDOM_SPREAD - TECH_X_RANDOM_SPREAD / 2) * DEGREES_TO_RADIANS; Vector turned = vector_make(velocity.x * std::cos(angle) - velocity.y * std::sin(angle), velocity.y * std::cos(angle) + velocity.x * std::sin(angle)); fire_ring(position, vector_scale(turned, shotSpeed), scale); } for (int i = 0; i < params.numTears; i++) { PosVel shot = Entity_Player::GetMultiShotPositionVelocity(i, WEAPON_TECH_X, velocity, shotSpeed, params); fire_ring(vector_add(position, shot.position), shot.velocity, 1); } if (owner && owner->IsFamiliar()) static_cast(owner)->fireCooldown = 0; else if (owner && owner->is_player()) owner->ToPlayer()->stop_costume_item_anims(); } // The Tractor Beam part of 00782af0: a plain player holding it with a weapon that rides it keeps a beam from its // Tractor Beam spot along its aim (or the way its head faces), drawn under it when aiming up and hidden while an // item animation plays or an item is held, and keeps its eyes open. Otherwise the beam goes. void tractor_beam_update(Entity_Player& player) { if (player.variant != PLAYER_VARIANT_PLAYER || player.isCoopGhost) return; Weapon* weapon = player.weapons[1].get(); if (!player.HasCollectible(COLLECTIBLE_TRACTOR_BEAM) || !weapon || !weapon->SupportsTractorBeam()) { if (Entity* beam = player.tractorBeam) beam->Remove(); return; } Vector aim = player.aimDirection; bool isFreeAim = !vector_is_zero(aim) && player.HasCollectible(COLLECTIBLE_ANALOG_STICK); aim = player.markedTarget || isFreeAim ? vector_normalized(aim) : vector_from_direction(player.headDirection); if (!player.tractorBeam) { Entity* spawned = g_game->Spawn({.position = player.pos, .spawner = &player, .type = ENTITY_LASER, .variant = LASER_TRACTOR_BEAM, .seed = Random()}); spawned->parent = &player; spawned->Update(); player.tractorBeam = spawned; } auto& beam = *static_cast(player.tractorBeam.get()); beam.posOffset = player.GetLaserOffset(LASER_OFFSET_TRACTOR_BEAM, vector_scale(aim, TRACTOR_BEAM_REACH)); beam.set_aim_angle(angle_wrap(vector_angle(aim))); beam.renderDepthOffset = aim.y <= TRACTOR_BEAM_UP ? TRACTOR_BEAM_DEPTH_UP : TRACTOR_BEAM_DEPTH; beam.isVisible = player.IsExtraAnimationFinished() && !player.IsHoldingItem(); player.blinkTime = std::max(player.blinkTime, TRACTOR_BEAM_BLINK); } // 009f6980 Fires a Tech X ring: the owning player's, or a plain one from the owner. Entity_Laser* Weapon::fire_tech_x_laser(const TechXShot& shot) { if (Entity_Player* player = weapon_player(owner)) { TechXShot playerShot = shot; playerShot.source = owner; if (Entity_Laser* laser = player->FireTechXLaser(playerShot)) return laser; } Entity_Laser* laser = static_cast(g_game->Spawn({.position = shot.position, .velocity = shot.velocity, .spawner = owner, .subType = LASER_SUBTYPE_RING_PROJECTILE, .type = ENTITY_LASER, .variant = LASER_THIN_RED, .seed = Random()})); laser->posOffset = vector_make(0, LUDOVICO_RING_LIFT); laser->parent = owner; laser->renderDepthOffset = TECH_LASER_FRONT_DEPTH; laser->radius = shot.radius; return laser; }