Curation round 11: effects, room clears, items, Continue, bombs, active items, the boss and Basement II
This commit is contained in:
1 parent
d8385e6c64
commit
698eeb74e9
74 files changed
+13965
-2078
No files matched your search
+51
-337
@@ -1,106 +1,46 @@
|
||||
#include "entity_effect.h"
|
||||
#include "entity_effect_ambient.h"
|
||||
#include "entity_effect_combat.h"
|
||||
#include "entity_list.h"
|
||||
#include "entity_player.h"
|
||||
#include "entity_tear.h"
|
||||
#include "game.h"
|
||||
#include "log.h"
|
||||
#include "lua_engine.h"
|
||||
#include "manager.h"
|
||||
#include "room.h"
|
||||
#include "room_config.h"
|
||||
#include "sfx_manager.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
|
||||
// The creep variants the players leave (holy water trail, black, red, white, holy water, green, Lemon Mishap, Lemon
|
||||
// Party, 204, Black Powder, milk, Black Powder's pentagram).
|
||||
constexpr std::array<int, 12> PLAYER_CREEPS = {54, 45, 46, 44, 37, 53, 32, 78, 204, 92, 90, 93};
|
||||
|
||||
constexpr int EFFECT_BLOOD_SPLAT = 7;
|
||||
constexpr int EFFECT_BULLET_POOF = 11;
|
||||
constexpr int EFFECT_TEAR_POOF_A = 12;
|
||||
constexpr int EFFECT_TEAR_POOF_B = 13;
|
||||
constexpr int EFFECT_RIPPLE_POOF = 14;
|
||||
constexpr int EFFECT_TEAR_POOF_SMALL = 79;
|
||||
constexpr int EFFECT_TEAR_POOF_VERYSMALL = 80;
|
||||
constexpr int EFFECT_IMPACT = 97;
|
||||
// The floor stains a crawlspace never shows: blood, craters, creep of every kind, footprints and puddles.
|
||||
constexpr std::array<int, 26> CRAWLSPACE_HIDDEN_EFFECTS = {7, 18, 22, 23, 24, 25, 26, 32, 37, 44, 45, 46, 53,
|
||||
54, 56, 77, 78, 89, 90, 92, 93, 94, 100, 169, 195, 204};
|
||||
|
||||
// The creep a familiar's wave of creep (familiar variant 125) leaves, which keeps its chain going.
|
||||
constexpr std::array<int, 6> WAVE_CHAIN_CREEPS = {53, 44, 46, 45, 32, 204};
|
||||
constexpr int FAMILIAR_CREEP_WAVE = 125;
|
||||
|
||||
constexpr int EFFECT_BLOOD_PARTICLE = 5;
|
||||
constexpr int EFFECT_HUSH_LASER = 96;
|
||||
constexpr int EFFECT_HUSH_LASER_UP = 101;
|
||||
constexpr int EFFECT_BLACK_POWDER = 92;
|
||||
constexpr int EFFECT_BOOMERANG = 60;
|
||||
constexpr int EFFECT_PORTAL_TELEPORT = 161;
|
||||
constexpr int EFFECT_TIMER = 119;
|
||||
constexpr int EFFECT_ENEMY_SOUL = 179;
|
||||
constexpr int EFFECT_ANIMA_CHAIN = 193;
|
||||
constexpr int EFFECT_REDEMPTION = 185;
|
||||
constexpr int EFFECT_BLOOD_EXPLOSION = 2;
|
||||
constexpr int EFFECT_POOF01 = 15;
|
||||
constexpr int EFFECT_POOF02 = 16;
|
||||
constexpr int EFFECT_TINY_FLY = 33;
|
||||
constexpr int EFFECT_LIGHT = 121;
|
||||
|
||||
// The variants whose Init, Update and Render are reconstructed: the tear poofs, the blood stains, the poofs and the
|
||||
// ambient tiny fly.
|
||||
constexpr std::array<int, 11> EFFECT_RECONSTRUCTED_VARIANTS = {
|
||||
EFFECT_BLOOD_SPLAT, EFFECT_BULLET_POOF, EFFECT_TEAR_POOF_A, EFFECT_TEAR_POOF_B,
|
||||
EFFECT_RIPPLE_POOF, EFFECT_TEAR_POOF_SMALL, EFFECT_TEAR_POOF_VERYSMALL, EFFECT_IMPACT,
|
||||
EFFECT_POOF01, EFFECT_POOF02, EFFECT_TINY_FLY};
|
||||
|
||||
// The animations a poof plays by its subtype: POOF01 from 1 to 3, POOF02's lava splash at random.
|
||||
constexpr std::array<const char*, 4> POOF01_ANIMATIONS = {"Poof2", "Poof_Small", "Poof", "Poof_Large"};
|
||||
constexpr std::array<const char*, 3> LAVA_SPLASH_ANIMATIONS = {"Poof0", "Poof1", "Poof2"};
|
||||
constexpr int POOF01_SUBTYPE_LAST = 3;
|
||||
constexpr int POOF02_LAVA_SPLASH = 66;
|
||||
constexpr int POOF02_LAVA_SPLASH_LARGE = 67;
|
||||
constexpr int POOF_RENDER_Z = 8000;
|
||||
constexpr uint32_t LAVA_SPLASH_SHIFT = 4;
|
||||
|
||||
// The tiny fly: white in the Cathedral, its own color in Dross, how it wanders, flees the nearest player within
|
||||
// range, dies to tears, knives and fires, and drops down in circles when dead.
|
||||
constexpr int STAGE_ID_CATHEDRAL = 15;
|
||||
constexpr int BACKDROP_DROSS = 45;
|
||||
constexpr int ENTITY_KNIFE_TYPE = 8;
|
||||
constexpr int FLY_WANDER_ODDS = 5;
|
||||
constexpr int FLY_JITTER_FRAMES = 5;
|
||||
constexpr float FLY_MASS = 1;
|
||||
constexpr float FLY_FRICTION = 0.98f;
|
||||
constexpr float FLY_DEAD_FRICTION = 0.8f;
|
||||
constexpr float FLY_PULL = 0.5f;
|
||||
constexpr float FLY_JITTER = 0.9f;
|
||||
constexpr float FLY_FLEE_RANGE = 60;
|
||||
constexpr float FLY_FLEE_PUSH = -0.2f;
|
||||
constexpr float FLY_HIT_RADIUS = 0.5f;
|
||||
constexpr float FLY_KNIFE_REACH = 1.5f;
|
||||
constexpr float FLY_FIRE_REACH = 2;
|
||||
constexpr float FLY_FALL_STEP = 0.25f;
|
||||
constexpr float FLY_FALL_HEIGHT = 16;
|
||||
constexpr float FLY_CIRCLE_SPEED = 15;
|
||||
constexpr float FLY_CIRCLE_RADIUS = 3;
|
||||
constexpr float FLY_CLAMP_MARGIN = 2;
|
||||
constexpr float FLY_SPLAT_SCALE = 0.1f;
|
||||
constexpr float FLY_BURST_SCALE = 0.3f;
|
||||
constexpr float FLY_BURST_RISE = -16;
|
||||
constexpr float MIN_DISTANCE = 0.01f;
|
||||
constexpr float RANDOM_UNIT = 2.3283064e-10f;
|
||||
constexpr float RANDOM_HALF_TURN = 3.14f;
|
||||
constexpr float DEGREES_TO_RADIANS = 0.017453292f;
|
||||
// The poofs that turn with their rotation.
|
||||
constexpr std::array<int, 5> EFFECT_TURNED_POOFS = {EFFECT_TEAR_POOF_A, EFFECT_TEAR_POOF_B, EFFECT_TEAR_POOF_SMALL,
|
||||
EFFECT_TEAR_POOF_VERYSMALL, EFFECT_IMPACT};
|
||||
|
||||
// The blood stain animations by the scale it was spawned at: the first whose limit is above it, the last past all.
|
||||
constexpr std::array<float, 5> STAIN_SCALE_LIMITS = {0.4f, 0.6f, 0.8f, 1.2f, 2.0f};
|
||||
constexpr std::array<const char*, 6> STAIN_ANIMATIONS = {"Size1BloodStains", "Size2BloodStains", "Size3BloodStains",
|
||||
"Size4BloodStains", "Size5BloodStains", "Size6BloodStains"};
|
||||
constexpr float STAIN_ALPHA_MIN = 0.5f;
|
||||
constexpr float STAIN_ALPHA_STEP = 0.1f;
|
||||
constexpr int STAIN_ALPHA_STEPS = 6;
|
||||
|
||||
// The ripple poof's animations for small spawn scales, which it draws larger.
|
||||
constexpr float RIPPLE_TINY_SCALE = 0.5f;
|
||||
constexpr float RIPPLE_SMALL_SCALE = 0.75f;
|
||||
constexpr float RIPPLE_TINY_GROWTH = 2;
|
||||
constexpr float RIPPLE_SMALL_GROWTH = 1.33333f;
|
||||
// The Hourglass slows Hush's lasers from full speed to half as its effect's cooldown runs from 0 to 30.
|
||||
constexpr int COLLECTIBLE_HOURGLASS = 66;
|
||||
constexpr float HOURGLASS_COOLDOWN_SPAN = 30;
|
||||
constexpr float HOURGLASS_SLOWEST = 0.5f;
|
||||
|
||||
constexpr float PAUSE_VELOCITY_DECAY = 0.6f;
|
||||
constexpr float RIGHT_ANGLE = 90;
|
||||
constexpr int SOUND_BOOMERANG_LOOP = 837;
|
||||
constexpr int SOUND_PORTAL_ENTITY_LOOP = 846;
|
||||
constexpr int SOUND_CHAIN_LOOP = 503;
|
||||
@@ -149,9 +89,9 @@ bool Entity_Effect::IsPlayerCreep(int effectVariant)
|
||||
return std::find(PLAYER_CREEPS.begin(), PLAYER_CREEPS.end(), effectVariant) != PLAYER_CREEPS.end();
|
||||
}
|
||||
|
||||
// 005cdb20 Starts the effect from its config's sprite with no timeout, rotation or extra data. A crawlspace removes
|
||||
// its blood stains at once. The tear poofs face a random quarter turn and the ripple a random side.
|
||||
// Only the tear poofs and the blood stains are reconstructed yet.
|
||||
// 005cdb20 Starts the effect from its config's sprite with no timeout, rotation or extra data, then hands it to its
|
||||
// variant. A crawlspace removes its floor stains at once, and a variant that removes itself skips its graphics and
|
||||
// Lua's callback.
|
||||
void Entity_Effect::Init(int entityType, int entityVariant, int entitySubType, uint32_t seed)
|
||||
{
|
||||
extraData.reset();
|
||||
@@ -175,30 +115,18 @@ void Entity_Effect::Init(int entityType, int entityVariant, int entitySubType, u
|
||||
maxRadius = 0;
|
||||
damageSource = 0;
|
||||
varData = {};
|
||||
if (!is_listed(EFFECT_RECONSTRUCTED_VARIANTS, variant))
|
||||
reconstruction_missing("Entity_Effect::Init 005cdb20: this effect variant");
|
||||
if (g_game->room->roomType == ROOM_DUNGEON && variant == EFFECT_BLOOD_SPLAT)
|
||||
if (g_game->room->roomType == ROOM_DUNGEON && is_listed(CRAWLSPACE_HIDDEN_EFFECTS, variant))
|
||||
{
|
||||
isVisible = false;
|
||||
return Remove();
|
||||
}
|
||||
|
||||
if (variant == EFFECT_BLOOD_SPLAT) sortingLayer = SORTING_BACKGROUND;
|
||||
if (variant == EFFECT_RIPPLE_POOF)
|
||||
{
|
||||
sortingLayer = SORTING_BACKGROUND;
|
||||
sprite.isFlipX = Random() & 1;
|
||||
}
|
||||
entityGridCollisionClass = GRIDCOLL_NONE;
|
||||
entityGridCollisionClass = variant == EFFECT_BLOOD_PARTICLE ? GRIDCOLL_WALLS : GRIDCOLL_NONE;
|
||||
entityCollisionClass = ENTCOLL_NONE;
|
||||
if (is_listed(EFFECT_TURNED_POOFS, variant))
|
||||
{
|
||||
rotation = (float)(Random() & 3) * RIGHT_ANGLE;
|
||||
isUnknown176 = true;
|
||||
}
|
||||
if (variant == EFFECT_IMPACT) sprite.isFlipX = !(Random() & 1);
|
||||
if (variant == EFFECT_POOF01 || variant == EFFECT_POOF02) poof_init();
|
||||
if (variant == EFFECT_TINY_FLY) tiny_fly_init();
|
||||
if (is_ambient_effect(variant)) ambient_effect_init(*this);
|
||||
else if (is_combat_effect(variant)) combat_effect_init(*this);
|
||||
else reconstruction_missing("Entity_Effect::Init 005cdb20: this effect variant");
|
||||
if (!isExists) return;
|
||||
|
||||
sprite.LoadGraphics();
|
||||
if (g_game->deathmatchManager.is_active())
|
||||
@@ -207,10 +135,19 @@ void Entity_Effect::Init(int entityType, int entityVariant, int entitySubType, u
|
||||
}
|
||||
|
||||
// 005d4380 Runs the effect for a frame at the room's time scale, held in place while paused and kept on its parent
|
||||
// while following it, then counts its timeout down to its death.
|
||||
// while following it, then runs its variant and counts its timeout down to its death.
|
||||
void Entity_Effect::Update()
|
||||
{
|
||||
speedMultiplier = g_game->room->GetTimeScale(this);
|
||||
if (variant == EFFECT_HUSH_LASER || variant == EFFECT_HUSH_LASER_UP)
|
||||
{
|
||||
if (TemporaryEffect* hourglass = g_game->room->temporaryEffects.GetCollectibleEffect(COLLECTIBLE_HOURGLASS))
|
||||
{
|
||||
float t = std::clamp((float)hourglass->cooldown / HOURGLASS_COOLDOWN_SPAN, 0.0f, 1.0f);
|
||||
speedMultiplier *= (HOURGLASS_SLOWEST - 1) * t + 1;
|
||||
}
|
||||
}
|
||||
if (variant == EFFECT_BLACK_POWDER) pauseTimer = 0;
|
||||
if (pauseTimer != 0)
|
||||
{
|
||||
uint64_t savedFlags = flags;
|
||||
@@ -237,246 +174,22 @@ void Entity_Effect::Update()
|
||||
{
|
||||
velocity = {};
|
||||
isFollowing = false;
|
||||
if (variant == EFFECT_LIGHT && timeout < 0) SetTimeout(state);
|
||||
}
|
||||
|
||||
if (variant == EFFECT_BLOOD_SPLAT) stain_update();
|
||||
else if (variant == EFFECT_TINY_FLY) tiny_fly_update();
|
||||
else poof_update();
|
||||
EffectUpdateEnd end = EFFECT_UPDATE_FINISH;
|
||||
if (is_ambient_effect(variant)) end = ambient_effect_update(*this);
|
||||
else if (is_combat_effect(variant)) end = combat_effect_update(*this);
|
||||
else reconstruction_missing("Entity_Effect::Update 005d4380: this effect variant");
|
||||
if (end == EFFECT_UPDATE_RETURN) return;
|
||||
|
||||
if (timeout > 0 && --timeout < 1) isDead = true;
|
||||
pausePosition = pos;
|
||||
if (spawnerType == ENTITY_FAMILIAR && spawnerVariant == FAMILIAR_CREEP_WAVE && is_listed(WAVE_CHAIN_CREEPS, variant))
|
||||
update_wave_chain();
|
||||
lua_engine_get().PostEffectUpdate(this);
|
||||
}
|
||||
|
||||
// A poof's animation by its subtype. POOF01 and POOF02's large kinds draw over everything, POOF02's small kinds lie
|
||||
// on the floor outside the crawl space, and its lava splashes face a seeded side.
|
||||
void Entity_Effect::poof_init()
|
||||
{
|
||||
if (variant == EFFECT_POOF01)
|
||||
{
|
||||
if (subtype >= 1 && subtype <= POOF01_SUBTYPE_LAST) sprite.Play(POOF01_ANIMATIONS[subtype]);
|
||||
renderZOffset = POOF_RENDER_Z;
|
||||
return;
|
||||
}
|
||||
|
||||
if (subtype == 1 || subtype == 3)
|
||||
{
|
||||
if (g_game->room->roomType != ROOM_DUNGEON) sortingLayer = SORTING_BACKGROUND;
|
||||
sprite.Play("Poof");
|
||||
}
|
||||
else if (subtype == 2 || subtype == 4 || subtype == 5)
|
||||
{
|
||||
renderZOffset = POOF_RENDER_Z;
|
||||
sprite.Play("Poof");
|
||||
}
|
||||
else if (subtype == POOF02_LAVA_SPLASH || subtype == POOF02_LAVA_SPLASH_LARGE)
|
||||
{
|
||||
RNG rng = rng_make(initSeed, LAVA_SPLASH_SHIFT);
|
||||
uint32_t roll = subtype == POOF02_LAVA_SPLASH ? rng.Next() % LAVA_SPLASH_ANIMATIONS.size() : 0;
|
||||
sprite.Play(subtype == POOF02_LAVA_SPLASH ? LAVA_SPLASH_ANIMATIONS[roll] : "PoofLarge");
|
||||
sprite.isFlipX = !(initSeed & 1);
|
||||
}
|
||||
}
|
||||
|
||||
// A tiny fly: white in the Cathedral, uncolored in Dross, light and colliding with everything.
|
||||
void Entity_Effect::tiny_fly_init()
|
||||
{
|
||||
if (RoomConfig::GetStageID((int)g_game->stage, (int)g_game->stageType, (RoomMode)-1) == STAGE_ID_CATHEDRAL)
|
||||
sprite.Play("White");
|
||||
mass = FLY_MASS;
|
||||
entityCollisionClass = ENTCOLL_ALL;
|
||||
isUnknown176 = true;
|
||||
if (g_game->room->backdropType == BACKDROP_DROSS) sprite.color = COLOR_DEFAULT;
|
||||
}
|
||||
|
||||
// The player nearest a position, the first one on a tie (Game::GetNearestPlayer 00703950, which Game does not
|
||||
// declare yet).
|
||||
static Entity_Player* nearest_player_get(const Vector& position)
|
||||
{
|
||||
Entity_Player* nearest = nullptr;
|
||||
float nearestDistance = 0;
|
||||
|
||||
for (Entity_Player* player : g_game->playerManager.playerList)
|
||||
{
|
||||
float dx = position.x - player->pos.x;
|
||||
float dy = position.y - player->pos.y;
|
||||
float distance = dy * dy + dx * dx;
|
||||
if (nearest && distance >= nearestDistance) continue;
|
||||
nearest = player;
|
||||
nearestDistance = distance;
|
||||
}
|
||||
return nearest;
|
||||
}
|
||||
|
||||
static float random_unit()
|
||||
{
|
||||
return (float)Random() * RANDOM_UNIT;
|
||||
}
|
||||
|
||||
static Vector vector_scaled(Vector v, float scale)
|
||||
{
|
||||
return vector_make(v.x * scale, v.y * scale);
|
||||
}
|
||||
|
||||
static float vector_length(Vector v)
|
||||
{
|
||||
return std::sqrt(v.x * v.x + v.y * v.y);
|
||||
}
|
||||
|
||||
// Whether an entity of the list stands within reach of a position, reach scaled from its size.
|
||||
static bool is_within_reach(Entity& entity, const Vector& position, float reach)
|
||||
{
|
||||
float dx = entity.pos.x - position.x;
|
||||
float dy = entity.pos.y - position.y;
|
||||
return dx * dx + dy * dy < reach * reach;
|
||||
}
|
||||
|
||||
// Bursts the fly into a small splash of its blood color.
|
||||
void Entity_Effect::tiny_fly_burst()
|
||||
{
|
||||
isDead = true;
|
||||
Entity* burst = g_game->Spawn({vector_make(pos.x, pos.y + FLY_BURST_RISE), {}, nullptr, 0, ENTITY_EFFECT,
|
||||
EFFECT_BLOOD_EXPLOSION, Random()});
|
||||
burst->SetColor(splatColor, -1, 255, false, true);
|
||||
burst->sprite.scale = vector_make(FLY_BURST_SCALE, FLY_BURST_SCALE);
|
||||
burst->Update();
|
||||
sprite.Stop();
|
||||
}
|
||||
|
||||
// A tiny fly's frame: alive it drifts at random, now and then toward its parent or the nearest player, and away
|
||||
// from a player close by, and bursts on a tear, knife or fire. Dead, it spirals down and splats. It faces its motion
|
||||
// and stays in the room.
|
||||
void Entity_Effect::tiny_fly_update()
|
||||
{
|
||||
Entity_Player* player = nearest_player_get(pos);
|
||||
Vector toPlayer = vector_make(player->pos.x - pos.x, player->pos.y - pos.y);
|
||||
float distance = vector_length(toPlayer);
|
||||
Vector direction = vector_scaled(toPlayer, 1 / (distance == 0 ? MIN_DISTANCE : distance));
|
||||
EntityList& entities = g_game->room->entityList;
|
||||
|
||||
friction *= FLY_FRICTION;
|
||||
if (isDead)
|
||||
{
|
||||
LayerState& layer = *sprite.GetLayer(0);
|
||||
if (layer.pos.y <= FLY_FALL_HEIGHT)
|
||||
{
|
||||
layer.pos.y += FLY_FALL_STEP;
|
||||
float side = (float)(index % 2) * 2 - 1;
|
||||
float angle = (float)g_game->frameCount * FLY_CIRCLE_SPEED * side * DEGREES_TO_RADIANS;
|
||||
Vector circle = vector_make(std::cos(angle), std::sin(angle));
|
||||
circle = vector_scaled(vector_scaled(circle, std::abs(layer.pos.y) / FLY_FALL_HEIGHT), FLY_CIRCLE_RADIUS);
|
||||
pos = vector_make(pos.x + circle.x, pos.y + circle.y);
|
||||
friction *= FLY_DEAD_FRICTION;
|
||||
}
|
||||
else
|
||||
{
|
||||
Entity* splat = g_game->Spawn({pos, {}, nullptr, 0, ENTITY_EFFECT, EFFECT_BLOOD_SPLAT, Random()});
|
||||
splat->SetColor(splatColor, -1, 255, false, true);
|
||||
splat->sprite.scale = vector_make(FLY_SPLAT_SCALE, FLY_SPLAT_SCALE);
|
||||
splat->Update();
|
||||
Remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (!isDead)
|
||||
{
|
||||
if (Random() % FLY_WANDER_ODDS == 0)
|
||||
{
|
||||
Vector pull = direction;
|
||||
if (parent)
|
||||
{
|
||||
Vector toParent = vector_make(parent->pos.x - pos.x, parent->pos.y - pos.y);
|
||||
float length = vector_length(toParent);
|
||||
if (length > 0) toParent = vector_scaled(toParent, (length - parent->size) / length);
|
||||
float resized = vector_length(toParent);
|
||||
pull = resized > 0 ? vector_scaled(toParent, 1 / resized) : toParent;
|
||||
}
|
||||
AddVelocity_divided(vector_scaled(pull, random_unit() * FLY_PULL), false);
|
||||
}
|
||||
if (IsFrame(FLY_JITTER_FRAMES, (int)index))
|
||||
{
|
||||
float angle = random_unit() * RANDOM_HALF_TURN * 2;
|
||||
Vector jitter = vector_make(std::cos(angle), std::sin(angle));
|
||||
AddVelocity_divided(vector_scaled(jitter, random_unit() * FLY_JITTER), false);
|
||||
}
|
||||
if (distance < FLY_FLEE_RANGE)
|
||||
{
|
||||
float push = (1 - distance * distance / (FLY_FLEE_RANGE * FLY_FLEE_RANGE)) * FLY_FLEE_PUSH;
|
||||
AddVelocity_divided(vector_scaled(direction, push), false);
|
||||
}
|
||||
|
||||
EntityList_EL shots;
|
||||
entities.partitions[PARTITION_SHOTS].query_box(shots, pos, vector_make(FLY_HIT_RADIUS, FLY_HIT_RADIUS));
|
||||
bool isShot = std::any_of(shots.begin(), shots.end(), [this](Entity* shot) {
|
||||
return !shot->HasEntityFlags(FLAG_INTERPOLATION_UPDATE) && shot->type == ENTITY_TEAR &&
|
||||
is_within_reach(*shot, pos, FLY_HIT_RADIUS + shot->size);
|
||||
});
|
||||
if (isShot) tiny_fly_burst();
|
||||
|
||||
std::vector<Entity*> hazards(entities.updateEL);
|
||||
for (Entity* hazard : hazards)
|
||||
{
|
||||
bool isKnife =
|
||||
hazard->type == ENTITY_KNIFE_TYPE && is_within_reach(*hazard, pos, hazard->size * FLY_KNIFE_REACH);
|
||||
bool isFire =
|
||||
hazard->type == ENTITY_FIREPLACE && is_within_reach(*hazard, pos, hazard->size + FLY_FIRE_REACH);
|
||||
if (isKnife || isFire) tiny_fly_burst();
|
||||
}
|
||||
}
|
||||
|
||||
sprite.isFlipX = pos.x - targetPosition.x < 0;
|
||||
pos = g_game->room->GetClampedPosition(pos, FLY_CLAMP_MARGIN);
|
||||
targetPosition = pos;
|
||||
}
|
||||
|
||||
// Turns a poof by its rotation, mirrored unless flipped, and removes it once its animation ends. A ripple first
|
||||
// draws its small sizes larger with their own animations.
|
||||
void Entity_Effect::poof_update()
|
||||
{
|
||||
if (variant == EFFECT_RIPPLE_POOF && state == 0)
|
||||
{
|
||||
float spawnScale = sprite.scale.x;
|
||||
if (spawnScale <= RIPPLE_TINY_SCALE)
|
||||
{
|
||||
sprite.scale = vector_make(sprite.scale.x * RIPPLE_TINY_GROWTH, sprite.scale.y * RIPPLE_TINY_GROWTH);
|
||||
sprite.Play("Poof_Tiny");
|
||||
}
|
||||
else if (spawnScale <= RIPPLE_SMALL_SCALE)
|
||||
{
|
||||
sprite.scale = vector_make(sprite.scale.x * RIPPLE_SMALL_GROWTH, sprite.scale.y * RIPPLE_SMALL_GROWTH);
|
||||
sprite.Play("Poof_Small");
|
||||
}
|
||||
state = 1;
|
||||
}
|
||||
sprite.rotation = sprite.isFlipX ? rotation : -rotation;
|
||||
if (sprite.IsFinished()) Remove();
|
||||
}
|
||||
|
||||
// Settles a blood stain on its first update: the stain animation for the scale it was spawned at on a random frame,
|
||||
// its own scale, random flips, a random strength for an opaque color, and the floor to be drawn into.
|
||||
// A glowing stain, whose color is brighter than white, fades with a light instead, which is not reconstructed yet.
|
||||
void Entity_Effect::stain_update()
|
||||
{
|
||||
if (state != 0) reconstruction_missing("Entity_Effect::Update 005d4380: a glowing blood stain's fade");
|
||||
float spawnScale = sprite.scale.x;
|
||||
sprite.scale = vector_make(scale, scale);
|
||||
|
||||
auto limit = std::find_if(STAIN_SCALE_LIMITS.begin(), STAIN_SCALE_LIMITS.end(),
|
||||
[spawnScale](float scaleLimit) { return spawnScale < scaleLimit; });
|
||||
const char* animation = STAIN_ANIMATIONS[limit - STAIN_SCALE_LIMITS.begin()];
|
||||
if (const AnimationData* data = sprite.GetAnimationData(animation))
|
||||
sprite.SetFrame(animation, (int)(data->length == 0 ? 0 : Random() % (uint32_t)data->length));
|
||||
sprite.isFlipX = Random() % 2 == 0;
|
||||
sprite.isFlipY = Random() % 2 == 0;
|
||||
|
||||
ColorMod stainColor = sprite.color;
|
||||
bool isGlowing = color._tint[3] > 1;
|
||||
if (stainColor._tint[3] >= 1)
|
||||
stainColor._tint[3] = (float)(Random() % STAIN_ALPHA_STEPS) * STAIN_ALPHA_STEP + STAIN_ALPHA_MIN;
|
||||
sprite.color = stainColor;
|
||||
if (isGlowing) reconstruction_missing("Entity_Effect::Update 005d4380: a glowing blood stain");
|
||||
AddEntityFlags(FLAG_RENDER_FLOOR);
|
||||
}
|
||||
|
||||
// 005d2520 Moves the effect half a step between updates, keeping a following effect on its parent.
|
||||
void Entity_Effect::Interpolate()
|
||||
{
|
||||
@@ -488,14 +201,15 @@ void Entity_Effect::Interpolate()
|
||||
posOffset = parent->posOffset;
|
||||
}
|
||||
|
||||
// 00607620 Draws the effect's sprite at its place on screen.
|
||||
// 00607620 Draws the effect at its place on screen through its variant, or its sprite. A light only lights the room.
|
||||
void Entity_Effect::Render(const Vector& offset)
|
||||
{
|
||||
if (!isVisible) return;
|
||||
if (variant == EFFECT_LIGHT || !isVisible) return;
|
||||
|
||||
Vector screen = render_position_get(vector_make(pos.x + posOffset.x, pos.y + posOffset.y), RENDER_SNAPPED);
|
||||
renderPosition = vector_make(screen.x + offset.x, screen.y + offset.y);
|
||||
sprite.Render(SpriteDraw{renderPosition, {}, {}});
|
||||
if (is_ambient_effect(variant)) ambient_effect_render(*this, offset);
|
||||
else sprite.Render(SpriteDraw{renderPosition, {}, {}});
|
||||
lua_engine_get().PostEffectRender(this, offset);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user