228 lines
7.5 KiB
C++
228 lines
7.5 KiB
C++
#pragma once
|
|
|
|
#include "entity.h"
|
|
|
|
// Lua's ProjectileVariant: the look of a shot, which also picks its splash.
|
|
enum ProjectileVariant : int
|
|
{
|
|
PROJECTILE_NORMAL,
|
|
PROJECTILE_BONE,
|
|
PROJECTILE_FIRE,
|
|
PROJECTILE_PUKE,
|
|
PROJECTILE_TEAR,
|
|
PROJECTILE_CORN,
|
|
PROJECTILE_HUSH,
|
|
PROJECTILE_COIN,
|
|
PROJECTILE_GRID,
|
|
PROJECTILE_ROCK,
|
|
PROJECTILE_RING,
|
|
PROJECTILE_MEAT,
|
|
PROJECTILE_FCUK,
|
|
PROJECTILE_WING,
|
|
PROJECTILE_LAVA,
|
|
PROJECTILE_HEAD,
|
|
PROJECTILE_PEEP
|
|
};
|
|
|
|
// The tints the late bosses' shots take: sickly green, its paler glow, the rotten orange and the fiery one.
|
|
constexpr ColorMod SHOT_COLOR_SICK = {{1, 1, 1, 1}, {1.5f, 2, 1, 1}, {0, 0, 0}};
|
|
constexpr ColorMod SHOT_COLOR_SICK_PALE = {{1, 1, 1, 1}, {2.7f, 3, 2, 1}, {0, 0, 0}};
|
|
constexpr ColorMod SHOT_COLOR_ROTTEN = {{1, 1, 1, 1}, {3, 2, 1, 1}, {0, 0, 0}};
|
|
constexpr ColorMod SHOT_COLOR_FIERY = {{1, 1, 1, 1}, {3.5f, 2.5f, 1, 1}, {0, 0, 0}};
|
|
|
|
// Lua's ProjectileFlags: how a shot flies and what it does when it lands.
|
|
// FIRE is PROJECTILE_FIRE_FLAG, the variant taking the plain name.
|
|
enum ProjectileFlag : uint64_t
|
|
{
|
|
PROJECTILE_SMART = 1ull << 0,
|
|
PROJECTILE_EXPLODE = 1ull << 1,
|
|
PROJECTILE_ACID_GREEN = 1ull << 2,
|
|
PROJECTILE_GOO = 1ull << 3,
|
|
PROJECTILE_GHOST = 1ull << 4,
|
|
PROJECTILE_WIGGLE = 1ull << 5,
|
|
PROJECTILE_BOOMERANG = 1ull << 6,
|
|
PROJECTILE_HIT_ENEMIES = 1ull << 7,
|
|
PROJECTILE_ACID_RED = 1ull << 8,
|
|
PROJECTILE_GREED = 1ull << 9,
|
|
PROJECTILE_RED_CREEP = 1ull << 10,
|
|
PROJECTILE_ORBIT_CW = 1ull << 11,
|
|
PROJECTILE_ORBIT_CCW = 1ull << 12,
|
|
PROJECTILE_NO_WALL_COLLIDE = 1ull << 13,
|
|
PROJECTILE_CREEP_BROWN = 1ull << 14,
|
|
PROJECTILE_FIRE_FLAG = 1ull << 15,
|
|
PROJECTILE_BURST = 1ull << 16,
|
|
PROJECTILE_ANY_HEIGHT_ENTITY_HIT = 1ull << 17,
|
|
PROJECTILE_CURVE_LEFT = 1ull << 18,
|
|
PROJECTILE_CURVE_RIGHT = 1ull << 19,
|
|
PROJECTILE_TURN_HORIZONTAL = 1ull << 20,
|
|
PROJECTILE_SINE_VELOCITY = 1ull << 21,
|
|
PROJECTILE_MEGA_WIGGLE = 1ull << 22,
|
|
PROJECTILE_SAWTOOTH_WIGGLE = 1ull << 23,
|
|
PROJECTILE_SLOWED = 1ull << 24,
|
|
PROJECTILE_TRIANGLE = 1ull << 25,
|
|
PROJECTILE_MOVE_TO_PARENT = 1ull << 26,
|
|
PROJECTILE_ACCELERATE = 1ull << 27,
|
|
PROJECTILE_DECELERATE = 1ull << 28,
|
|
PROJECTILE_BURST3 = 1ull << 29,
|
|
PROJECTILE_CONTINUUM = 1ull << 30,
|
|
PROJECTILE_CANT_HIT_PLAYER = 1ull << 31,
|
|
PROJECTILE_CHANGE_FLAGS_AFTER_TIMEOUT = 1ull << 32,
|
|
PROJECTILE_CHANGE_VELOCITY_AFTER_TIMEOUT = 1ull << 33,
|
|
PROJECTILE_STASIS = 1ull << 34,
|
|
PROJECTILE_FIRE_WAVE = 1ull << 35,
|
|
PROJECTILE_FIRE_WAVE_X = 1ull << 36,
|
|
PROJECTILE_ACCELERATE_EX = 1ull << 37,
|
|
PROJECTILE_BURST8 = 1ull << 38,
|
|
PROJECTILE_FIRE_SPAWN = 1ull << 39,
|
|
PROJECTILE_ANTI_GRAVITY = 1ull << 40,
|
|
PROJECTILE_TRACTOR_BEAM = 1ull << 41,
|
|
PROJECTILE_BOUNCE = 1ull << 42,
|
|
PROJECTILE_BOUNCE_FLOOR = 1ull << 43,
|
|
PROJECTILE_SHIELDED = 1ull << 44,
|
|
PROJECTILE_BLUE_FIRE_SPAWN = 1ull << 45,
|
|
PROJECTILE_LASER_SHOT = 1ull << 46,
|
|
PROJECTILE_GODHEAD = 1ull << 47,
|
|
PROJECTILE_SMART_PERFECT = 1ull << 48,
|
|
PROJECTILE_BURSTSPLIT = 1ull << 49,
|
|
PROJECTILE_WIGGLE_ROTGUT = 1ull << 50,
|
|
PROJECTILE_FREEZE = 1ull << 51,
|
|
PROJECTILE_ACCELERATE_TO_POSITION = 1ull << 52,
|
|
PROJECTILE_BROCCOLI = 1ull << 53,
|
|
PROJECTILE_BACK_SPLIT = 1ull << 54,
|
|
PROJECTILE_SIDE_WAVE = 1ull << 55,
|
|
PROJECTILE_ORBIT_PARENT = 1ull << 56,
|
|
PROJECTILE_FADEOUT = 1ull << 57
|
|
};
|
|
|
|
// The four fire waves a fire wave shot leaves: along the axes, or the diagonals.
|
|
enum FireWaveShape : int
|
|
{
|
|
FIRE_WAVE_PLUS,
|
|
FIRE_WAVE_CROSS
|
|
};
|
|
|
|
// A fire a shot leaves in the room: a share of a moving fireplace's health (or a flame's size) above a random
|
|
// fifth, and for a friendly shot the flame, its damage and timeout (a random range above its least).
|
|
struct LeftFire
|
|
{
|
|
float flameDamage = 0;
|
|
float share = 0;
|
|
int fireplaceVariant = 0;
|
|
int flameVariant = 0;
|
|
int timeoutMin = 0;
|
|
int timeoutRange = 0;
|
|
};
|
|
|
|
ColorMod continuum_tint_get(int step);
|
|
|
|
// When a shot's motion hook runs: on its update, or on the interpolation between two.
|
|
enum ProjectileStep : int
|
|
{
|
|
PROJECTILE_STEP_UPDATE,
|
|
PROJECTILE_STEP_INTERPOLATE
|
|
};
|
|
|
|
struct Entity_Projectile;
|
|
|
|
// A function some shooters give their shots (ProjectileParams 0xa0), run on every update and interpolation.
|
|
using ProjectileHook = void (*)(Entity_Projectile& projectile, ProjectileStep step);
|
|
|
|
// What a shot takes from what fired it: the shooter (none for a timer or effect), its entity flags, its scale and its
|
|
// champion color (-1 for none).
|
|
struct ProjectileShooter
|
|
{
|
|
Entity* entity = nullptr;
|
|
uint64_t flags = 0;
|
|
float scale = 1;
|
|
int championColor = -1;
|
|
};
|
|
|
|
// Construction and destruction (00652b00, 00652b50) are the defaults.
|
|
// Field accessors (00417830, 00444c90, 00447740, 004b70a0, 004d3060, 004d3070, 0085e300, 0085e310, 0085e360) are the
|
|
// public fields.
|
|
// An enemy shot (Lua's EntityProjectile): its height and fall, damage, homing and curving, and the projectile flags
|
|
// that change how it flies and what it does when it lands.
|
|
// The flags and variants of the late bosses (Mother, Dogma, the Beast, Rotgut) and a few rare items stop the game.
|
|
struct Entity_Projectile : Entity
|
|
{
|
|
ProjectileHook motionHook = nullptr;
|
|
uint64_t changeFlags = 0;
|
|
uint64_t projectileFlags = 0;
|
|
Vector modemPosition{};
|
|
Vector orbitParentVelocity{};
|
|
float acceleration = 0;
|
|
float changeVelocity = 0;
|
|
float curvingStrength = 0;
|
|
float damage = 0;
|
|
float fallingAccel = 0;
|
|
float fallingSpeed = 0;
|
|
float height = 0;
|
|
float homingStrength = 0;
|
|
float orbitDistance = 0;
|
|
float scale = 0;
|
|
int animKey = 0;
|
|
int changeTimeout = 0;
|
|
int wiggleFrameOffset = 0;
|
|
bool isRenderedAtGround = false;
|
|
|
|
void Init(int type, int variant, int subType, uint32_t initSeed) override;
|
|
void Update() override;
|
|
void Interpolate() override;
|
|
void Render(const Vector& offset) override;
|
|
bool CanShutDoors() override;
|
|
bool HandleCollision(Entity* collider, bool isLow) override;
|
|
|
|
void AddHeight(float amount);
|
|
void AddFallingSpeed(float amount);
|
|
void AddFallingAccel(float amount);
|
|
void AddProjectileFlags(uint64_t added);
|
|
void AddChangeFlags(uint64_t added);
|
|
void AddScale(float amount);
|
|
void Reflect(const Vector& newVelocity);
|
|
void die_without_flags();
|
|
void apply_spawn_flags(const ProjectileShooter& shooter);
|
|
void update_height_collision();
|
|
|
|
private:
|
|
float time_scale_get();
|
|
bool modem_freeze_update();
|
|
void animation_update();
|
|
void first_frame_update();
|
|
void peep_update();
|
|
void trails_update();
|
|
void death_update();
|
|
void death_poof_spawn();
|
|
void heretic_burst_spawn();
|
|
void death_flags_apply();
|
|
void death_bursts_spawn();
|
|
void grid_splash();
|
|
void rock_splash();
|
|
void meat_splash();
|
|
void head_splash();
|
|
void homing_update();
|
|
void continuum_update();
|
|
void glow_trail_spawn(bool isPurple);
|
|
bool is_friendly_fire();
|
|
void fire_waves_spawn(FireWaveShape shape);
|
|
void fire_leave(const LeftFire& fire);
|
|
void blue_fire_spawn();
|
|
void fire_spawn();
|
|
void orbit_update();
|
|
void steering_update();
|
|
bool wiggles_update();
|
|
void speed_update();
|
|
void fall_update();
|
|
void lava_sink();
|
|
void circle_reflect();
|
|
void beast_fire_ball_burst();
|
|
void target_find(float range);
|
|
void laser_shot_dot_spawn();
|
|
void side_wave_burst();
|
|
bool stasis_update();
|
|
void ground_update();
|
|
void late_update();
|
|
bool player_hit(Entity_Player& player);
|
|
bool enemy_hit(Entity* collider);
|
|
bool familiar_hit(Entity* collider);
|
|
};
|