#pragma once #include "entity.h" #include "anm2.h" #include // Lua's TearFlags bits the game reads. Bits 84 and 101 to 103 have no Lua name: It Hurts' creep on death, flags // swapped in on an interval, a speed reset on an interval, and steering back toward the parent. enum TearFlagBit : int { TEAR_SPECTRAL = 0, TEAR_PIERCING = 1, TEAR_HOMING = 2, TEAR_SLOW = 3, TEAR_POISON = 4, TEAR_FREEZE = 5, TEAR_SPLIT = 6, TEAR_GROW = 7, TEAR_BOOMERANG = 8, TEAR_PERSISTENT = 9, TEAR_WIGGLE = 10, TEAR_MULLIGAN = 11, TEAR_EXPLOSIVE = 12, TEAR_CHARM = 13, TEAR_CONFUSION = 14, TEAR_HP_DROP = 15, TEAR_ORBIT = 16, TEAR_WAIT = 17, TEAR_QUADSPLIT = 18, TEAR_BOUNCE = 19, TEAR_FEAR = 20, TEAR_SHRINK = 21, TEAR_BURN = 22, TEAR_ATTRACTOR = 23, TEAR_KNOCKBACK = 24, TEAR_PULSE = 25, TEAR_SPIRAL = 26, TEAR_FLAT = 27, TEAR_SAD_BOMB = 28, TEAR_BUTT_BOMB = 29, TEAR_SQUARE = 30, TEAR_GLOW = 31, TEAR_GISH = 32, TEAR_MYSTERIOUS_LIQUID_CREEP = 33, TEAR_SHIELDED = 34, TEAR_GLITTER_BOMB = 35, TEAR_SCATTER_BOMB = 36, TEAR_STICKY = 37, TEAR_CONTINUUM = 38, TEAR_LIGHT_FROM_HEAVEN = 39, TEAR_COIN_DROP = 40, TEAR_BLACK_HP_DROP = 41, TEAR_TRACTOR_BEAM = 42, TEAR_GODS_FLESH_FLAG = 43, TEAR_GREED_COIN = 44, TEAR_CROSS_BOMB = 45, TEAR_BIG_SPIRAL = 46, TEAR_PERMANENT_CONFUSION = 47, TEAR_BOOGER_FLAG = 48, TEAR_EGG_FLAG = 49, TEAR_ACID = 50, TEAR_BONE_FLAG = 51, TEAR_BELIAL_FLAG = 52, TEAR_MIDAS = 53, TEAR_NEEDLE_FLAG = 54, TEAR_JACOBS = 55, TEAR_HORN = 56, TEAR_LASER = 57, TEAR_POP = 58, TEAR_ABSORB = 59, TEAR_LASERSHOT = 60, TEAR_HYDROBOUNCE = 61, TEAR_BURSTSPLIT = 62, TEAR_CREEP_TRAIL = 63, TEAR_PUNCH = 64, TEAR_ICE_FLAG = 65, TEAR_MAGNETIZE = 66, TEAR_BAIT = 67, TEAR_OCCULT = 68, TEAR_ORBIT_ADVANCED = 69, TEAR_ROCK_FLAG = 70, TEAR_TURN_HORIZONTAL = 71, TEAR_BLOOD_BOMB = 72, TEAR_ECOLI = 73, TEAR_COIN_DROP_DEATH = 74, TEAR_BRIMSTONE_BOMB = 75, TEAR_RIFT = 76, TEAR_SPORE_FLAG = 77, TEAR_GHOST_BOMB = 78, TEAR_CARD_DROP_DEATH = 79, TEAR_RUNE_DROP_DEATH = 80, TEAR_TELEPORT = 81, TEAR_DECELERATE = 82, TEAR_ACCELERATE = 83, TEAR_BLOOD_CREEP = 84, TEAR_THROUGH_COOLDOWN = 100, TEAR_INTERVAL_FLAGS = 101, TEAR_INTERVAL_SPEED = 102, TEAR_PARENT_STEER = 103, TEAR_BOUNCE_WALLSONLY = 104, TEAR_NO_GRID_DAMAGE = 105, TEAR_BACKSTAB = 106, TEAR_FETUS_SWORD = 107, TEAR_FETUS_BONE = 108, TEAR_FETUS_KNIFE = 109, TEAR_FETUS_TECHX = 110, TEAR_FETUS_TECH = 111, TEAR_FETUS_BRIMSTONE = 112, TEAR_FETUS_BOMBER = 113, TEAR_FETUS_FLAG = 114, TEAR_REROLL_ROCK_WISP = 115, TEAR_MOM_STOMP_WISP = 116, TEAR_ENEMY_TO_WISP = 117, TEAR_REROLL_ENEMY = 118, TEAR_GIGA_BOMB = 119, TEAR_EXTRA_GORE = 120, TEAR_RAINBOW = 121, TEAR_DETONATE = 122, TEAR_CHAIN = 123, TEAR_DARK_MATTER_FLAG = 124, TEAR_GOLDEN_BOMB = 125, TEAR_FAST_BOMB = 126, TEAR_LUDOVICO = 127 }; // Lua's TearVariant: the look of a tear, which also picks its splash. enum TearVariant : int { TEAR_BLUE = 0, TEAR_BLOOD = 1, TEAR_TOOTH = 2, TEAR_METALLIC = 3, TEAR_BOBS_HEAD = 4, TEAR_FIRE_MIND = 5, TEAR_DARK_MATTER = 6, TEAR_MYSTERIOUS = 7, TEAR_SCHYTHE = 8, TEAR_CHAOS_CARD = 9, TEAR_LOST_CONTACT = 10, TEAR_CUPID_BLUE = 11, TEAR_CUPID_BLOOD = 12, TEAR_NAIL = 13, TEAR_PUPULA = 14, TEAR_PUPULA_BLOOD = 15, TEAR_GODS_FLESH = 16, TEAR_GODS_FLESH_BLOOD = 17, TEAR_DIAMOND = 18, TEAR_EXPLOSIVO = 19, TEAR_COIN = 20, TEAR_MULTIDIMENSIONAL = 21, TEAR_STONE = 22, TEAR_NAIL_BLOOD = 23, TEAR_GLAUCOMA = 24, TEAR_GLAUCOMA_BLOOD = 25, TEAR_BOOGER = 26, TEAR_EGG = 27, TEAR_RAZOR = 28, TEAR_BONE = 29, TEAR_BLACK_TOOTH = 30, TEAR_NEEDLE = 31, TEAR_BELIAL = 32, TEAR_EYE = 33, TEAR_EYE_BLOOD = 34, TEAR_BALLOON = 35, TEAR_HUNGRY = 36, TEAR_BALLOON_BRIMSTONE = 37, TEAR_BALLOON_BOMB = 38, TEAR_FIST = 39, TEAR_GRIDENT = 40, TEAR_ICE = 41, TEAR_ROCK = 42, TEAR_KEY = 43, TEAR_KEY_BLOOD = 44, TEAR_ERASER = 45, TEAR_FIRE = 46, TEAR_SWORD_BEAM = 47, TEAR_SPORE = 48, TEAR_TECH_SWORD_BEAM = 49, TEAR_FETUS = 50 }; // Why a tear died, as deathFlags collects them. enum TearDeath : uint32_t { TEAR_DEATH_GRID = 1 << 0, TEAR_DEATH_WALL = 1 << 1, TEAR_DEATH_FLOOR = 1 << 2, TEAR_DEATH_ENTITY = 1 << 3, TEAR_DEATH_SHRUNK = 1 << 4, TEAR_DEATH_EXPLOSION = 1 << 5, TEAR_DEATH_FORCED = 1 << 6 }; // What tears and projectiles share: the crawlspace sink, the hover over the floor and the poofs' volumes. constexpr float CRAWLSPACE_HEIGHT_MAX = -5.1f; constexpr float CRAWLSPACE_SINK_HEIGHT = -10; constexpr float CRAWLSPACE_SINK_SPEED = 0.5f; constexpr float HOVER_FLOOR_DISTANCE = 8.5f; constexpr float HOVER_OFFSET_LIFT = -15; constexpr float POOF_VOLUME_SMALL = 0.85f; constexpr float POOF_VOLUME_TINY = 0.7f; // Construction and destruction (00665ea0, 00665cf0) are the defaults. // Field accessors (004177c0, 00431750, 00435e50, 00456440, 004aade0, 00557cd0, 0060ccb0, 0060ccc0, 0060ccd0, // 0060cd00, 0085dd60, 0085dd70, 0085dd90) are the public fields. // A player's tear (Lua's EntityTear): its height and fall, scale and damage, the tear flags that change how it flies // and hits, the entity it sticks to, and the tears and lasers it links to. // The flags of the common items fly and hit. The rest of the flags and the special variants stop the game in Update, // Interpolate and ApplyTearFlagEffects until reconstructed. struct Entity_Tear : Entity { ANM2 deadEyeANM2; ANM2 tearEffectANM2; ANM2 tearHaloANM2; std::vector hitList; TearFlags intervalFlags; TearFlags tearFlags; EntityPtr attachedEffect; EntityPtr laserShotLaser; EntityPtr linkNext; EntityPtr linkPrev; EntityPtr stickTarget; EntityPtr techZeroLaser; EntityPtr techZeroTarget; Vector continueVelocity{}; Vector holdOffset{}; Vector holdVelocity{}; Vector orbitVelocity{}; Vector parentOffset{}; Vector posDisplacement{}; Vector stickDiff{}; float baseDamage = 0; float baseScale = 0; float deadEyeIntensity = 0; float fScale = 0; float fallingAccel = 0; float fallingSpeed = 0; float height = 0; float homingFriction = 0; float knockbackMultiplier = 0; float orbitAngle = 0; float orbitRadius = 0; float rotation = 0; float tearRange = 0; int hitCount = 0; int holdTimer = 0; int scaleAnimNum = 0; int stickTimer = 0; int tearIdx = 0; int waitFrames = 0; uint32_t deathFlags = 0; short popBounceCount = 0; bool isCanTriggerStreakEnd = false; bool isFireSoundMuted = false; bool isFireSoundPending = false; bool isGridTouched = false; bool isHovering = false; bool isMultidimensionalTouched = false; bool isPrismTouched = 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; void SetCollisionDamage(float damage) override; void ClearReferences() override; bool HandleCollision(Entity* collider, bool isLow) override; Entity_Player* GetRootPlayer(); void wiggle_apply(float strength); void spiral_apply(float strength); void big_spiral_apply(float strength); void play_fire_sound(); float get_height_offset_y(float tearHeight); void SetHeight(float tearHeight); void SetScale(float scale); void SetTearFlags(TearFlags flags); void Deflect(Entity* newSpawner, const Vector& newVelocity); void apply_death_flag_effects(Entity* target); void ResetSpriteScale(); bool is_not_familiar_spawned(); void fire_split_projectiles(bool isHalved); void SetDeadEyeIntensity(float intensity); Entity_Tear* MakeMultidimensionalCopy(Entity* spawner); void ChangeVariant(int newVariant); int find_nearest_linkable_tear(); Entity_Tear* find_link_partner(); void apply_link_spring_forces(); bool try_make_bridges(const Vector& position); void reroll_hit_entity(int unused); static void ApplyTearFlagEffects(Entity* entity, const Vector& position, const TearFlags& flags, Entity* source, float damage); private: float animation_update(); bool hold_update(); void wait_update(); void death_creep_spawn(); void death_update(); void quadsplit_fire(); void blood_stains_spawn(); void flight_update(); void square_turn(); void homing_update(); float size_flags_update(); void spectral_update(); void boomerang_pull(); void rotation_update(Entity_Player* player); void floor_hit(); void grid_hit(); void bounce_hit(); void turn_horizontal_update(Vector previous); void fall_update(); void split_fire(bool isRising); void bone_shards_fire(bool isRising); void child_setup(Entity_Tear& child, TearFlags flags, float alpha); }; float worm_multiplier_get(Entity_Player* player, int flag);