Curation round 8: the first room plays: Isaac walks and shoots tears
Eight agents took over Room::Init's pieces, RailManager, Room::Render/render_lighting/Update, the GridEntity hierarchy (walls, doors, rocks, pits, poop ...), Game::Update and interpolate_update, the run's save, update_ingame_input, Game::Spawn with the entity factory and grid collision, the player's movement and tears through Weapon/Weapon_Tears, PlayerManager's positions, the camera focus, MinimapConfig, PlayerHUD, mod shader rendering, Entity_Tear and Entity_Effect. Integration wrote Level::get_secret_exit_kind, shared the secret-exit enum (four copies merged) and fixed the generator's vtable-stub check (word boundary and namespace, not a substring). Under gdb a run reaches the first room: doors, HUD with hearts and minimap, WASD movement with acceleration, arrow-key tears that fly and splash. Floor and walls (Backdrop::RenderFloor/RenderWalls) and room transitions are next. The official build/isaac reaches the start room and stops at Entity_NPC::Redirect. 2770 functions taken over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b85591bdf4
commit
69a354f843
140 files changed
+23561
-20206
No files matched your search
@@ -0,0 +1,483 @@
|
||||
#include "entity_effect.h"
|
||||
#include "entity_player.h"
|
||||
#include "entity_tear.h"
|
||||
#include "game.h"
|
||||
#include "log.h"
|
||||
#include "lua_engine.h"
|
||||
#include "manager.h"
|
||||
#include "menu_manager.h"
|
||||
#include "room.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
constexpr float CROSS_EYED_ANGLE = 0.7853982f;
|
||||
constexpr float DEAD_EYE_STEP = 0.125f;
|
||||
constexpr float DEGREES_TO_RADIANS = 0.017453292f;
|
||||
constexpr float DEGREES_PER_RADIAN = 57.295776f;
|
||||
constexpr float DUNGEON_TEAR_HEIGHT_MAX = -5.1f;
|
||||
constexpr float DUNGEON_TEAR_OFFSET_Y = -18;
|
||||
constexpr float EXPLOSIVE_TEAR_SCALE = 0.5f;
|
||||
constexpr float INHERIT_SCALE = 0.6f;
|
||||
constexpr float LANE_HALF_ARC = 90;
|
||||
constexpr float LANE_SPREAD_X = 1.15f;
|
||||
constexpr float LANE_SPREAD_Y = 0.8f;
|
||||
constexpr float QUADSPLIT_TEAR_SCALE = 1.2f;
|
||||
constexpr float RANDOM_UNIT = 2.3283064e-10f;
|
||||
constexpr float SPREAD_CLAMP = 90;
|
||||
constexpr float TEAR_FALL_SPREAD = 0.2f;
|
||||
constexpr float TEAR_SCALE_DAMAGE = 0.01f;
|
||||
constexpr float TEAR_SCALE_MIN = 0.01f;
|
||||
constexpr float TEAR_SCALE_ROOT = 0.23f;
|
||||
constexpr float TEAR_SCALE_SIZE = 0.55f;
|
||||
constexpr float HOLOGRAM_TEAR_ALPHA = 0.2f;
|
||||
constexpr int TINT_ALPHA = 3;
|
||||
constexpr float WIZ_EYE_ANGLE = 45;
|
||||
// How much each extra tear widens a volley's tears and lasers, by what adds it, and how the other weapons follow.
|
||||
constexpr float SPREAD_ITEM_LASER = 2.333f;
|
||||
constexpr float SPREAD_ITEM_TEARS = 2.167f;
|
||||
constexpr float SPREAD_LUNG_LASER = 2.7f;
|
||||
constexpr float SPREAD_LUNG_TEARS = 2.4f;
|
||||
constexpr float SPREAD_MULTIPLIER_LASER = 2.33f;
|
||||
constexpr float SPREAD_MULTIPLIER_TEARS = 2.17f;
|
||||
constexpr float SPREAD_TWINS_TEARS = 0.4f;
|
||||
constexpr float SPREAD_WIZ_LASER = 3;
|
||||
constexpr float SPREAD_KNIFE_SCALE = 2.14f;
|
||||
constexpr float SPREAD_TECH_X_SCALE = 2.4f;
|
||||
constexpr float SPREAD_BONE_SCALE = 3;
|
||||
constexpr float MOMS_EYE_CHANCE = 0.5f;
|
||||
constexpr float MOMS_EYE_LUCK = 0.1f;
|
||||
constexpr float LOKIS_HORNS_CHANCE = 0.25f;
|
||||
constexpr float LOKIS_HORNS_LUCK = 0.05f;
|
||||
constexpr int LUNG_TEARS_PER_COPY = 5;
|
||||
constexpr int LUNG_RANDOM_ROCKETS = 2;
|
||||
constexpr int LUNG_RANDOM_LASERS = 3;
|
||||
constexpr int LUNG_RANDOM_RANGE = 3;
|
||||
constexpr int EYE_SORE_ROLL_MASK = 3;
|
||||
constexpr int BOOKWORM_ROLL_MASK = 3;
|
||||
constexpr int CONJOINED_EXTRA_TEARS = 2;
|
||||
constexpr float WIZ_EYE_ANGLE_MAX = 55;
|
||||
constexpr int DEAD_EYE_STEPS = 8;
|
||||
constexpr int DARK_ARTS_STEPS = 16;
|
||||
constexpr float DARK_ARTS_STEP = 0.0625f;
|
||||
constexpr int MAX_TEARS = 16;
|
||||
constexpr int MAX_EYES = 8;
|
||||
constexpr int RED_STEW_BLOOD_FRAMES = 90;
|
||||
constexpr int BABY_TECHNOLOGY = 16;
|
||||
constexpr int BABY_TWENTY_TWENTY = 65;
|
||||
constexpr int PLAYERFORM_CONJOINED = 7;
|
||||
constexpr int PLAYERFORM_BOOKWORM = 10;
|
||||
constexpr int TRANSFORMATION_COUNT = 3;
|
||||
constexpr int LUA_CALLBACK_POST_FIRE_TEAR = 61;
|
||||
constexpr int TEAR_COLOR_PRIORITY = 255;
|
||||
|
||||
constexpr int COLLECTIBLE_20_20 = 245;
|
||||
constexpr int COLLECTIBLE_ALMOND_MILK = 561;
|
||||
constexpr int COLLECTIBLE_ANTI_GRAVITY = 222;
|
||||
constexpr int COLLECTIBLE_BRIMSTONE_WEAPON = 118;
|
||||
constexpr int COLLECTIBLE_C_SECTION = 678;
|
||||
constexpr int COLLECTIBLE_CHOCOLATE_MILK = 69;
|
||||
constexpr int COLLECTIBLE_CURSED_EYE_WEAPON = 316;
|
||||
constexpr int COLLECTIBLE_DEAD_TOOTH = 446;
|
||||
constexpr int COLLECTIBLE_DR_FETUS = 52;
|
||||
constexpr int COLLECTIBLE_EPIC_FETUS = 168;
|
||||
constexpr int COLLECTIBLE_EVIL_EYE = 410;
|
||||
constexpr int COLLECTIBLE_EYE_SORE = 558;
|
||||
constexpr int COLLECTIBLE_INNER_EYE = 2;
|
||||
constexpr int COLLECTIBLE_LARGE_ZIT = 502;
|
||||
constexpr int COLLECTIBLE_LEAD_PENCIL = 444;
|
||||
constexpr int COLLECTIBLE_LOKIS_HORNS = 87;
|
||||
constexpr int COLLECTIBLE_LUDOVICO = 329;
|
||||
constexpr int COLLECTIBLE_MARKED = 394;
|
||||
constexpr int COLLECTIBLE_MOMS_EYE = 55;
|
||||
constexpr int COLLECTIBLE_MOMS_KNIFE = 114;
|
||||
constexpr int COLLECTIBLE_MONSTROS_LUNG = 229;
|
||||
constexpr int COLLECTIBLE_NEPTUNUS = 597;
|
||||
constexpr int COLLECTIBLE_STAPLER = 708;
|
||||
constexpr int COLLECTIBLE_STYE = 731;
|
||||
constexpr int COLLECTIBLE_TECH_X = 395;
|
||||
constexpr int COLLECTIBLE_TECHNOLOGY = 68;
|
||||
constexpr int COLLECTIBLE_THE_WIZ = 358;
|
||||
constexpr int COLLECTIBLE_TRACTOR_BEAM = 397;
|
||||
constexpr int NULLITEM_REVERSE_HANGED_MAN = 65;
|
||||
constexpr int NULLITEM_DARK_ARTS = 111;
|
||||
|
||||
// The items GetWeaponModifiers turns into modifier bits, in the order it asks.
|
||||
constexpr std::pair<int, uint32_t> MODIFIER_ITEMS[] = {
|
||||
{COLLECTIBLE_CHOCOLATE_MILK, WEAPON_MOD_CHOCOLATE_MILK}, {COLLECTIBLE_CURSED_EYE_WEAPON, WEAPON_MOD_CURSED_EYE},
|
||||
{COLLECTIBLE_BRIMSTONE_WEAPON, WEAPON_MOD_BRIMSTONE}, {COLLECTIBLE_MONSTROS_LUNG, WEAPON_MOD_MONSTROS_LUNG},
|
||||
{COLLECTIBLE_LUDOVICO, WEAPON_MOD_LUDOVICO_TECHNIQUE}, {COLLECTIBLE_ANTI_GRAVITY, WEAPON_MOD_ANTI_GRAVITY},
|
||||
{COLLECTIBLE_TRACTOR_BEAM, WEAPON_MOD_TRACTOR_BEAM}, {COLLECTIBLE_NEPTUNUS, WEAPON_MOD_NEPTUNUS}};
|
||||
// The items whose copies past the first each add a tear to the volley.
|
||||
constexpr int SPREAD_ITEMS[] = {COLLECTIBLE_TECHNOLOGY, COLLECTIBLE_MOMS_KNIFE, COLLECTIBLE_DR_FETUS,
|
||||
COLLECTIBLE_EPIC_FETUS, COLLECTIBLE_LUDOVICO, COLLECTIBLE_TECH_X};
|
||||
|
||||
// A vector turned by an angle in radians.
|
||||
static Vector vector_rotate(Vector v, float radians)
|
||||
{
|
||||
float cosine = std::cos(radians);
|
||||
float sine = std::sin(radians);
|
||||
return vector_make(v.x * cosine - v.y * sine, v.y * cosine + v.x * sine);
|
||||
}
|
||||
|
||||
static Vector vector_scale(Vector v, float scale) { return vector_make(v.x * scale, v.y * scale); }
|
||||
|
||||
// The weapon in charge: the one overriding the rest, or the main one.
|
||||
static Weapon* weapon_main(std::array<WeaponPtr, WEAPON_SLOT_COUNT>& weapons)
|
||||
{
|
||||
return weapons[0] ? weapons[0].get() : weapons[1].get();
|
||||
}
|
||||
|
||||
// 005b1780 Whether the player has a weapon type.
|
||||
bool Entity_Player::HasWeaponType(int weaponType)
|
||||
{
|
||||
return weaponType >= 0 && weaponType < WEAPON_TYPE_COUNT && weaponTypes[weaponType];
|
||||
}
|
||||
|
||||
// 00753980 Gives or takes a weapon type, which EvaluateItems makes weapons of. Out of range types write past the array
|
||||
// in the original: here they are ignored.
|
||||
void Entity_Player::EnableWeaponType(int weaponType, bool isSet)
|
||||
{
|
||||
if (weaponType >= 0 && weaponType < WEAPON_TYPE_COUNT) weaponTypes[weaponType] = isSet;
|
||||
}
|
||||
|
||||
// 00779320 What the camera and the head follow: the Marked target, or what a weapon (past the overriding slot) aims.
|
||||
Entity* Entity_Player::GetFocusEntity()
|
||||
{
|
||||
if (markedTarget) return markedTarget;
|
||||
for (int slot = 1; slot < WEAPON_SLOT_COUNT; slot++)
|
||||
if (Entity* focus = weapons[slot] ? weapons[slot]->GetFocusEntity() : nullptr) return focus;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 00779a20 The modifier bits the player's items, Tainted Azazel's sneeze and C Section give its weapons.
|
||||
int Entity_Player::GetWeaponModifiers()
|
||||
{
|
||||
uint32_t modifiers = 0;
|
||||
|
||||
for (auto [item, modifier] : MODIFIER_ITEMS)
|
||||
if (HasCollectible(item)) modifiers |= modifier;
|
||||
if (HasCollectible(COLLECTIBLE_SOY_MILK) || HasCollectible(COLLECTIBLE_ALMOND_MILK))
|
||||
modifiers |= WEAPON_MOD_SOY_MILK;
|
||||
if (playerType == PLAYER_AZAZEL_B) modifiers |= WEAPON_MOD_AZAZELS_SNEEZE;
|
||||
if (HasCollectible(COLLECTIBLE_C_SECTION)) modifiers |= WEAPON_MOD_C_SECTION;
|
||||
return (int)modifiers;
|
||||
}
|
||||
|
||||
// 00782a40 The entity the weapon in charge fires as, if any.
|
||||
Entity* Entity_Player::GetActiveWeaponEntity()
|
||||
{
|
||||
Weapon* weapon = weapon_main(weapons);
|
||||
return weapon ? weapon->GetMainEntity() : nullptr;
|
||||
}
|
||||
|
||||
// 00782a70 The fire delay of the weapon in charge.
|
||||
float Entity_Player::FireDelay()
|
||||
{
|
||||
Weapon* weapon = weapon_main(weapons);
|
||||
return weapon ? weapon->fireDelay : 0;
|
||||
}
|
||||
|
||||
// 00753940 The shot direction of a few frames ago, as weapons aim with it: the oldest kept, or the last one.
|
||||
Vector Entity_Player::delayed_shoot_direction()
|
||||
{
|
||||
return shootDirectionHistory.empty() ? lastDirection : shootDirectionHistory.front();
|
||||
}
|
||||
|
||||
// 007ad4e0 Stops the item animations of the costumes the player wears, unless it is a co-op ghost.
|
||||
void Entity_Player::stop_costume_item_anims()
|
||||
{
|
||||
if (isCoopGhost) return;
|
||||
for (PlayerCostumeMap& map : playerCostumeMap)
|
||||
if (map.index >= 0) costumeSpriteDescs[map.index].isItemAnimPlay = false;
|
||||
}
|
||||
|
||||
// 007826d0 What firing does each frame: the items that react to shots (not written yet), then the weapon in charge
|
||||
// fires, or every weapon does. Offline every player is local, so the deathmatch's check is not written yet.
|
||||
void Entity_Player::trigger_fire_item_effects(Vector direction, bool isShotFired)
|
||||
{
|
||||
if (g_game->deathmatchManager.is_active())
|
||||
reconstruction_missing("Entity_Player::trigger_fire_item_effects 007826d0 (deathmatch)");
|
||||
if (HasCollectible(COLLECTIBLE_DEAD_TOOTH) || HasCollectible(COLLECTIBLE_LARGE_ZIT))
|
||||
reconstruction_missing("Entity_Player::trigger_fire_item_effects 007826d0 (Dead Tooth and Large Zit)");
|
||||
|
||||
bool isInterpolated = HasEntityFlags(FLAG_INTERPOLATION_UPDATE);
|
||||
if (weapons[0])
|
||||
{
|
||||
weapons[0]->Fire(direction, isShotFired, isInterpolated);
|
||||
return;
|
||||
}
|
||||
for (int slot = 1; slot < WEAPON_SLOT_COUNT; slot++)
|
||||
if (weapons[slot]) weapons[slot]->Fire(direction, isShotFired, isInterpolated);
|
||||
}
|
||||
|
||||
// 007aaea0 The share of the player's movement its shots carry: twice six tenths of its last velocity, without the part
|
||||
// against the shot. None while Marked aims or tears leave from a shifted head, unless always asked.
|
||||
Vector Entity_Player::GetTearMovementInheritance(const Vector& shotDirection, InheritMode mode)
|
||||
{
|
||||
bool isShifted =
|
||||
(tearsOffset.x != 0 || tearsOffset.y != 0) && (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_SCISSORS) ||
|
||||
temporaryEffects.HasCollectibleEffect(COLLECTIBLE_DECAP_ATTACK));
|
||||
if (mode == INHERIT_CHECKED && ((HasCollectible(COLLECTIBLE_MARKED) && markedTarget) || isShifted)) return {};
|
||||
|
||||
Vector inherited = vector_make(lastVelocity.x * INHERIT_SCALE, lastVelocity.y * INHERIT_SCALE);
|
||||
inherited = vector_make(inherited.x + inherited.x, inherited.y + inherited.y);
|
||||
if (shotDirection.x == 0 && shotDirection.y == 0) return inherited;
|
||||
|
||||
float length = std::sqrt(shotDirection.x * shotDirection.x + shotDirection.y * shotDirection.y);
|
||||
Vector normal = length > 0 ? vector_scale(shotDirection, 1 / length) : shotDirection;
|
||||
float along = inherited.x * normal.x + inherited.y * normal.y;
|
||||
Vector projection = vector_scale(normal, along);
|
||||
if (projection.y * shotDirection.y + projection.x * shotDirection.x < 0)
|
||||
inherited = vector_make(inherited.x - projection.x, inherited.y - projection.y);
|
||||
return inherited;
|
||||
}
|
||||
|
||||
// 00781b90 How the player's volleys spread: extra tears for each copy of the weapon items past the first, Monstro's
|
||||
// Lung, Mutant Spider, Inner Eye, 20/20 and Bookworm's chance, The Wiz's eyes, Conjoined's cross-eyed pair, Mom's Eye
|
||||
// and Loki's Horns' backward and sideways shots, and Eye Sore's and the Lung's random ones.
|
||||
Weapon_MultiShotParams Entity_Player::GetMultiShotParams(WeaponType weaponType)
|
||||
{
|
||||
Weapon_MultiShotParams params;
|
||||
int extraTears = 0;
|
||||
|
||||
for (int item : SPREAD_ITEMS) extraTears += std::max(0, GetCollectibleNum(item) - 1);
|
||||
if (extraTears != 0)
|
||||
{
|
||||
params.numTears = (short)(params.numTears + extraTears);
|
||||
params.spreadAngleLaser += (float)extraTears * SPREAD_ITEM_LASER;
|
||||
params.spreadAngleTears += (float)extraTears * SPREAD_ITEM_TEARS;
|
||||
}
|
||||
int lungTears = std::max(0, GetCollectibleNum(COLLECTIBLE_MONSTROS_LUNG) - 1);
|
||||
if (lungTears != 0)
|
||||
{
|
||||
params.numTears = (short)(params.numTears + lungTears * LUNG_TEARS_PER_COPY);
|
||||
params.spreadAngleLaser += (float)lungTears * SPREAD_LUNG_LASER;
|
||||
params.spreadAngleTears += (float)lungTears * SPREAD_LUNG_TEARS;
|
||||
}
|
||||
|
||||
int spiders = GetCollectibleNum(COLLECTIBLE_MUTANT_SPIDER) + (playerType == PLAYER_KEEPER_B);
|
||||
int innerEyes = temporaryEffects.HasNullEffect(NULLITEM_REVERSE_HANGED_MAN) + (playerType == PLAYER_KEEPER) +
|
||||
GetCollectibleNum(COLLECTIBLE_INNER_EYE) +
|
||||
temporaryEffects.HasCollectibleEffect(COLLECTIBLE_INNER_EYE);
|
||||
int twins = temporaryEffects.HasCollectibleEffect(COLLECTIBLE_20_20) + GetCollectibleNum(COLLECTIBLE_20_20) +
|
||||
(babySkin == BABY_TWENTY_TWENTY);
|
||||
bool isMultiplied = spiders != 0 || innerEyes != 0;
|
||||
if (isMultiplied)
|
||||
{
|
||||
int extra = spiders * 2 + 1 + innerEyes;
|
||||
params.numTears = (short)(params.numTears + extra);
|
||||
params.spreadAngleLaser += (float)extra * SPREAD_MULTIPLIER_LASER;
|
||||
params.spreadAngleTears += (float)extra * SPREAD_MULTIPLIER_TEARS;
|
||||
}
|
||||
if (twins != 0) params.numTears = (short)(params.numTears + twins - (isMultiplied ? 1 : 0));
|
||||
|
||||
bool isBookwormShot = weaponType != WEAPON_LUDOVICO_TECHNIQUE && !hasCurseMistEffect && !isCoopGhost &&
|
||||
playerForms[PLAYERFORM_BOOKWORM] >= TRANSFORMATION_COUNT &&
|
||||
(Random() & BOOKWORM_ROLL_MASK) == 0;
|
||||
if (isBookwormShot) params.numTears++;
|
||||
if (isBookwormShot || twins != 0)
|
||||
{
|
||||
params.spreadAngleTears *= SPREAD_TWINS_TEARS;
|
||||
params.spreadAngleLaser += (float)twins + (float)twins;
|
||||
}
|
||||
|
||||
int wizards = temporaryEffects.HasCollectibleEffect(COLLECTIBLE_THE_WIZ) + GetCollectibleNum(COLLECTIBLE_THE_WIZ);
|
||||
int tears = params.numTears;
|
||||
if (wizards != 0)
|
||||
{
|
||||
params.numEyesActive = std::min(params.numEyesActive + wizards, MAX_EYES);
|
||||
params.spreadAngleLaser += (float)wizards * SPREAD_WIZ_LASER;
|
||||
tears = (short)(params.numTears + wizards);
|
||||
if (tears % params.numEyesActive != 0)
|
||||
tears = (short)(tears + params.numEyesActive - tears % params.numEyesActive);
|
||||
params.multiEyeAngle = std::min((float)wizards * WIZ_EYE_ANGLE, WIZ_EYE_ANGLE_MAX);
|
||||
}
|
||||
if (!hasCurseMistEffect && !isCoopGhost && playerForms[PLAYERFORM_CONJOINED] >= TRANSFORMATION_COUNT)
|
||||
{
|
||||
params.isCrossEyed = wizards == 0;
|
||||
tears = (short)(tears + CONJOINED_EXTRA_TEARS);
|
||||
}
|
||||
|
||||
tears = std::min(tears, MAX_TEARS);
|
||||
params.numLanesPerEye = (short)(tears / params.numEyesActive);
|
||||
params.spreadAngleKnife = params.spreadAngleLaser * SPREAD_KNIFE_SCALE;
|
||||
params.numTears = (short)(params.numLanesPerEye * params.numEyesActive);
|
||||
params.spreadAngleTechX = std::min(params.spreadAngleTears * SPREAD_TECH_X_SCALE, SPREAD_CLAMP);
|
||||
params.spreadAngleTears = std::min(params.spreadAngleTears, SPREAD_CLAMP);
|
||||
params.spreadAngleLaser = std::min(params.spreadAngleLaser, SPREAD_CLAMP);
|
||||
|
||||
bool isMomsEye = HasCollectible(COLLECTIBLE_MOMS_EYE);
|
||||
bool isLokisHorns = HasCollectible(COLLECTIBLE_LOKIS_HORNS);
|
||||
bool isLung = HasCollectible(COLLECTIBLE_MONSTROS_LUNG);
|
||||
if (weaponType == WEAPON_LUDOVICO_TECHNIQUE)
|
||||
{
|
||||
params.isShootingBackwards = isMomsEye || isLokisHorns;
|
||||
params.isShootingSideways = isLokisHorns;
|
||||
}
|
||||
else if ((isMomsEye && (float)Random() * RANDOM_UNIT < luck * MOMS_EYE_LUCK + MOMS_EYE_CHANCE) ||
|
||||
(isLokisHorns && (float)Random() * RANDOM_UNIT < luck * LOKIS_HORNS_LUCK + LOKIS_HORNS_CHANCE))
|
||||
{
|
||||
params.isShootingBackwards = true;
|
||||
params.isShootingSideways = isLokisHorns;
|
||||
}
|
||||
|
||||
if (HasCollectible(COLLECTIBLE_EYE_SORE))
|
||||
{
|
||||
uint32_t first = Random();
|
||||
uint32_t second = Random();
|
||||
params.numRandomDirTears = (short)std::max(0, (int)(first & EYE_SORE_ROLL_MASK) - EYE_SORE_ROLL_MASK +
|
||||
(int)(second & EYE_SORE_ROLL_MASK));
|
||||
}
|
||||
else if (isLung && weaponType == WEAPON_ROCKETS)
|
||||
params.numRandomDirTears = (short)(Random() % LUNG_RANDOM_RANGE + LUNG_RANDOM_ROCKETS);
|
||||
else if (isLung && (weaponType == WEAPON_BRIMSTONE || weaponType == WEAPON_TECH_X))
|
||||
params.numRandomDirTears = (short)(Random() % LUNG_RANDOM_RANGE + LUNG_RANDOM_LASERS);
|
||||
return params;
|
||||
}
|
||||
|
||||
// 00782160 Where shot loopIndex of a volley starts and how fast it goes: the eyes fan out over The Wiz's angle, the
|
||||
// lanes of an eye spread over the weapon's angle (tears, Tech X and bombs also start along an arc), and Conjoined's
|
||||
// last two shots go off at 45 degrees.
|
||||
PosVel Entity_Player::GetMultiShotPositionVelocity(int loopIndex, WeaponType weaponType, const Vector& shotDirection,
|
||||
float shotSpeed, const Weapon_MultiShotParams& params)
|
||||
{
|
||||
float spreadAngle = params.spreadAngleTears;
|
||||
if (weaponType == WEAPON_LASER || weaponType == WEAPON_BRIMSTONE) spreadAngle = params.spreadAngleLaser;
|
||||
else if (weaponType == WEAPON_TECH_X) spreadAngle = params.spreadAngleTechX;
|
||||
else if (weaponType == WEAPON_KNIFE) spreadAngle = params.spreadAngleKnife;
|
||||
else if (weaponType == WEAPON_BONE) spreadAngle = params.spreadAngleKnife * SPREAD_BONE_SCALE;
|
||||
|
||||
PosVel shot;
|
||||
if (params.isCrossEyed && loopIndex >= params.numTears - 2)
|
||||
{
|
||||
float angle = loopIndex == params.numTears - 1 ? CROSS_EYED_ANGLE : -CROSS_EYED_ANGLE;
|
||||
shot.velocity = vector_scale(vector_rotate(shotDirection, angle), shotSpeed);
|
||||
return shot;
|
||||
}
|
||||
|
||||
float eyeAngle = 0;
|
||||
if (params.numEyesActive > 1)
|
||||
{
|
||||
float t = std::clamp((float)(loopIndex % params.numEyesActive) / ((float)params.numEyesActive - 1), 0.0f, 1.0f);
|
||||
eyeAngle = (params.multiEyeAngle + params.multiEyeAngle) * t - params.multiEyeAngle;
|
||||
}
|
||||
Vector aimed = vector_rotate(shotDirection, eyeAngle * DEGREES_TO_RADIANS);
|
||||
shot.velocity = vector_scale(aimed, shotSpeed);
|
||||
if (params.numLanesPerEye <= 1) return shot;
|
||||
|
||||
float lane = std::clamp((float)(loopIndex / params.numEyesActive) / ((float)params.numLanesPerEye - 1), 0.0f, 1.0f);
|
||||
if (weaponType == WEAPON_TEARS || weaponType == WEAPON_TECH_X || weaponType == WEAPON_BOMBS)
|
||||
{
|
||||
float arc = (lane * (LANE_HALF_ARC + LANE_HALF_ARC) - LANE_HALF_ARC) * DEGREES_TO_RADIANS;
|
||||
float length = std::sqrt(aimed.y * aimed.y + aimed.x * aimed.x);
|
||||
Vector offset = vector_make(std::cos(arc) * LANE_SPREAD_X * length, std::sin(arc) * LANE_SPREAD_Y * length);
|
||||
shot.position = vector_rotate(offset, std::atan2(aimed.y, aimed.x) * DEGREES_PER_RADIAN * DEGREES_TO_RADIANS);
|
||||
}
|
||||
shot.velocity =
|
||||
vector_rotate(shot.velocity, ((spreadAngle + spreadAngle) * lane - spreadAngle) * DEGREES_TO_RADIANS);
|
||||
return shot;
|
||||
}
|
||||
|
||||
// 007bf6c0 What a tear from the player is fired with: its stats, flags and color, the eye it leaves from, and a scale
|
||||
// from its damage. Only a plain player's tears are written yet: items, effects, familiars and other characters stop the
|
||||
// game until reached.
|
||||
TearParams Entity_Player::GetTearHitParams(WeaponType weaponType, float damageScale, int displacement, Entity* source)
|
||||
{
|
||||
if ((source && source->IsFamiliar()) || !is_evaluation_plain() || redStewBonusDuration > RED_STEW_BLOOD_FRAMES)
|
||||
reconstruction_missing("Entity_Player::GetTearHitParams 007bf6c0 (items, effects and familiars)");
|
||||
|
||||
TearParams params;
|
||||
params.tearDamage = damageScale * damage;
|
||||
params.tearHeight = tearHeight;
|
||||
params.tearFlags = tearFlags;
|
||||
params.tearColor = tearColor;
|
||||
float baseDamage = params.tearDamage;
|
||||
float scaleMultiplier = 1;
|
||||
|
||||
bool isOneEyed = playerType == PLAYER_CAIN || HasCollectible(COLLECTIBLE_LEAD_PENCIL) ||
|
||||
!weaponTypes[WEAPON_TEARS] || HasCollectible(COLLECTIBLE_CURSED_EYE_WEAPON) ||
|
||||
HasCollectible(COLLECTIBLE_STAPLER) || playerType == PLAYER_CAIN_B;
|
||||
bool isLeftEye = displacement < 0 || (isOneEyed && (Random() & 1) == 0);
|
||||
params.tearDisplacement = isLeftEye ? -1 : (displacement >= 1 ? 1 : 0);
|
||||
|
||||
if (weaponType == WEAPON_TEARS || weaponType == WEAPON_FETUS)
|
||||
{
|
||||
bool isLudovico = params.tearFlags.test(TEAR_LUDOVICO);
|
||||
if (params.tearFlags.test(TEAR_EXPLOSIVE) && !isLudovico) scaleMultiplier = EXPLOSIVE_TEAR_SCALE;
|
||||
if (params.tearFlags.test(TEAR_QUADSPLIT) && !isLudovico) params.tearScale *= QUADSPLIT_TEAR_SCALE;
|
||||
if ((playerType == PLAYER_THEFORGOTTEN || playerType == PLAYER_THEFORGOTTEN_B) &&
|
||||
params.tearVariant != TEAR_SCHYTHE)
|
||||
params.tearVariant = TEAR_BONE;
|
||||
if (weaponType == WEAPON_FETUS) params.tearVariant = TEAR_FETUS;
|
||||
}
|
||||
|
||||
float size = params.tearScale > 1 ? std::log(params.tearScale) + 1 : params.tearScale;
|
||||
params.tearScale =
|
||||
(std::sqrt(baseDamage) * TEAR_SCALE_ROOT + size * TEAR_SCALE_SIZE + baseDamage * TEAR_SCALE_DAMAGE) *
|
||||
scaleMultiplier;
|
||||
if (IsHologram()) params.tearColor._tint[TINT_ALPHA] = HOLOGRAM_TEAR_ALPHA;
|
||||
return params;
|
||||
}
|
||||
|
||||
// 00790af0 Fires a tear with the player's hit params from a shot (from the player's tear offset when it shoots it
|
||||
// itself): its height, fall, scale, color, range, Dead Eye's (or Dark Arts') glow and an index, updated once and moved
|
||||
// back a frame.
|
||||
// The Marked target holds no tear back, and extra shots drop the Tractor Beam and end no streak. The co-op baby's
|
||||
// lasers, Stye, Evil Eye and the Lua callback are not written yet.
|
||||
Entity_Tear* Entity_Player::FireTear(const PosVel& shot, uint32_t fireFlags, Entity* source, float damageMultiplier)
|
||||
{
|
||||
if (variant == PLAYER_VARIANT_COOP_BABY && babySkin == BABY_TECHNOLOGY)
|
||||
reconstruction_missing("Entity_Player::FireTear 00790af0 (the laser baby)");
|
||||
|
||||
Vector position = shot.position;
|
||||
if (source && source == this) position = vector_add(position, tearsOffset);
|
||||
TearParams params = GetTearHitParams(WEAPON_TEARS, damageMultiplier, tearDisplacement, source);
|
||||
if (HasCollectible(COLLECTIBLE_MARKED)) params.tearFlags.reset(TEAR_WAIT);
|
||||
if (fireFlags & TEAR_FIRE_NO_TRACTOR_BEAM) params.tearFlags.reset(TEAR_TRACTOR_BEAM);
|
||||
|
||||
EntitySpawn spawn{.position = vector_add(shot.velocity, position),
|
||||
.velocity = shot.velocity,
|
||||
.spawner = this,
|
||||
.type = ENTITY_TEAR,
|
||||
.variant = params.tearVariant};
|
||||
spawn.seed = Random();
|
||||
Entity_Tear* tear = g_game->Spawn(spawn)->ToTear();
|
||||
tear->velocity = vector_scale(tear->velocity, params.speedMultiplier);
|
||||
tear->height = params.tearHeight;
|
||||
tear->posOffset.y = tear->get_height_offset_y(params.tearHeight);
|
||||
if (g_game->room->roomType == ROOM_DUNGEON)
|
||||
{
|
||||
tear->posOffset.y = DUNGEON_TEAR_OFFSET_Y;
|
||||
if (params.tearHeight > DUNGEON_TEAR_HEIGHT_MAX) tear->height = DUNGEON_TEAR_HEIGHT_MAX;
|
||||
}
|
||||
float fallSpread = params.tearFlags.test(TEAR_POP) ? 0 : (float)Random() * RANDOM_UNIT * TEAR_FALL_SPREAD;
|
||||
tear->fallingSpeed = fallSpread - tearFallingSpeed;
|
||||
tear->SetCollisionDamage(params.tearDamage);
|
||||
tear->SetTearFlags(params.tearFlags);
|
||||
tear->baseScale = std::max(params.tearScale, TEAR_SCALE_MIN);
|
||||
tear->fScale = tear->baseScale;
|
||||
tear->ResetSpriteScale();
|
||||
tear->fallingAccel = tearFallingAcceleration;
|
||||
tear->SetColor(params.tearColor, -1, TEAR_COLOR_PRIORITY, false, true);
|
||||
tear->tearRange = tearRange;
|
||||
tear->parent = this;
|
||||
if (fireFlags & TEAR_FIRE_NO_STREAK_END) tear->isCanTriggerStreakEnd = false;
|
||||
|
||||
float deadEye = deadEyeCharges > 0 ? (float)std::min((int)deadEyeCharges, DEAD_EYE_STEPS) * DEAD_EYE_STEP : 0;
|
||||
float intensity = deadEye;
|
||||
if (int darkArts = temporaryEffects.GetNullEffectNum(NULLITEM_DARK_ARTS); darkArts > 0)
|
||||
intensity = std::max((float)std::min(darkArts, DARK_ARTS_STEPS) * DARK_ARTS_STEP, deadEye);
|
||||
if (HasCollectible(COLLECTIBLE_STYE)) reconstruction_missing("Entity_Player::FireTear 00790af0 (Stye)");
|
||||
if (intensity > 0) tear->SetDeadEyeIntensity(intensity);
|
||||
tear->mass *= params.massMultiplier;
|
||||
tear->knockbackMultiplier = params.knockbackMultiplier;
|
||||
tear->tearIdx = firedTearCount++;
|
||||
tear->Update();
|
||||
tear->pos = vector_make(tear->pos.x - tear->velocity.x, tear->pos.y - tear->velocity.y);
|
||||
|
||||
if (static_cast<LuaEngine*>(g_luaEngine)->enabledCallbacks.test(LUA_CALLBACK_POST_FIRE_TEAR))
|
||||
reconstruction_missing("lua_callback_run_post_fire_tear 00863f70");
|
||||
if (HasCollectible(COLLECTIBLE_EVIL_EYE) && !(fireFlags & TEAR_FIRE_NO_EVIL_EYE))
|
||||
reconstruction_missing("Entity_Player::FireTear 00790af0 (Evil Eye)");
|
||||
return tear;
|
||||
}
|
||||
Reference in new issue
Block a user