Curation round 17: Theora and Vorbis cutscene videos, Ludovico, Epic and Dr. Fetus, Tractor Beam and Eye of the Occult, familiars and blue spiders, fortune teller and restock, the Bag of Crafting and four tainted characters, ten enemies, water and the ultra secret door, Isaac, ???, the Lamb and Hush
This commit is contained in:
1 parent
e9de039d0f
commit
024cb12016
133 files changed
+13325
-2520
No files matched your search
+205
-4
@@ -1,5 +1,6 @@
|
||||
#include "entity_projectile.h"
|
||||
#include "entity_bomb.h"
|
||||
#include "entity_combat.h"
|
||||
#include "entity_effect.h"
|
||||
#include "entity_effect_combat.h"
|
||||
#include "entity_familiar.h"
|
||||
@@ -11,6 +12,7 @@
|
||||
#include "lua_engine.h"
|
||||
#include "manager.h"
|
||||
#include "npc_ai.h"
|
||||
#include "npc_basement.h"
|
||||
#include "room.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -86,6 +88,44 @@ constexpr int ANIM_KEY_CORN = 300;
|
||||
constexpr int ANIM_KEY_COIN = 400;
|
||||
constexpr int ANIM_KEY_MEAT = 600;
|
||||
constexpr int ANIM_KEY_FCUK = 700;
|
||||
constexpr int ANIM_KEY_ROCK = 500;
|
||||
constexpr int ANIM_KEY_WING = 800;
|
||||
constexpr int ANIM_KEY_LAVA = 900;
|
||||
constexpr int ANIM_KEY_HEAD = 1000;
|
||||
constexpr int ANIM_KEY_PEEP = 1100;
|
||||
|
||||
// The rock's spin by size, the heads' strip of faces and tilt, and the Peeper's red trail.
|
||||
constexpr float ROCK_STEP_SCALE = 2;
|
||||
constexpr int ROCK_STEP_MAX = 6;
|
||||
constexpr float PEEP_HALF_TURN = 180;
|
||||
constexpr float PEEP_QUARTER_TURN = 90;
|
||||
constexpr uint32_t HEAD_FACES = 4;
|
||||
constexpr float HEAD_FACE_WIDTH = 48;
|
||||
constexpr float HEAD_TILT = 10;
|
||||
constexpr float HEAD_SPIN = 2;
|
||||
constexpr ColorMod PEEP_TRAIL_COLOR = {{0.9f, 0, 0, 0.8f}, {0, 0, 0, 0}, {0, 0, 0}};
|
||||
constexpr float PEEP_TRAIL_RADIUS = 0.15f;
|
||||
constexpr float PEEP_TRAIL_ALPHA = 0.5f;
|
||||
|
||||
// The splashes: a thrown grid entity's packed subtype, the rock's poof tint and chips, the meat ball's Globin and the
|
||||
// head's gibs.
|
||||
constexpr int GRID_TYPE_SHIFT = 16;
|
||||
constexpr int GRID_VARIANT_MASK = 0xffff;
|
||||
constexpr ColorMod ROCK_POOF_COLOR = {{140 / 255.0f, 123 / 255.0f, 123 / 255.0f, 1}, {0, 0, 0, 0}, {0, 0, 0}};
|
||||
constexpr float ROCK_SOUND_MARGIN = -20;
|
||||
constexpr float ROCK_CHIPS_SCALE = 4;
|
||||
constexpr int ROCK_CHIPS_MAX = 16;
|
||||
constexpr float ROCK_CHIP_SPEED = 2;
|
||||
constexpr int ROCK_CHIP_SUBTYPE = 1;
|
||||
constexpr float ROCK_CHIP_TURN = 360;
|
||||
constexpr int MEAT_BURST_SUBTYPE = 2;
|
||||
constexpr uint32_t MEAT_GAZING_ODDS = 10;
|
||||
constexpr float MEAT_GLOBIN_PUSH = 0.1f;
|
||||
constexpr float MEAT_GLOBIN_HEALTH = 24;
|
||||
constexpr int MEAT_GLOBIN_SHRINK = -150;
|
||||
constexpr int HEAD_GIBS = 8;
|
||||
constexpr float HEAD_GIB_SPREAD = 40;
|
||||
constexpr uint32_t HEAD_GIB_FLAGS = GIB_FLAG_BLOOD | GIB_FLAG_BONE | GIB_FLAG_GUT | GIB_FLAG_EYE;
|
||||
constexpr float DOGMA_DEPTH_OFFSET = 300;
|
||||
constexpr uint64_t DOGMA_ELECTRIC_FLAGS = PROJECTILE_SHIELDED | PROJECTILE_BLUE_FIRE_SPAWN;
|
||||
|
||||
@@ -236,7 +276,6 @@ constexpr int COLOR_PRIORITY_NONE = -1;
|
||||
|
||||
constexpr int ENTITY_MR_FRED = 270;
|
||||
constexpr int ENTITY_MEGA_SATAN_2 = 275;
|
||||
constexpr int ENTITY_RED_GHOST = 285;
|
||||
constexpr int ENTITY_TARBOY = 307;
|
||||
constexpr int ENTITY_NECRO = 828;
|
||||
constexpr int ENTITY_SHADY = 888;
|
||||
@@ -340,6 +379,19 @@ static void layer_additive_set(ANM2& sprite, int layerId)
|
||||
layer->blendMode[BLEND_ALPHA_DEST] = BLEND_FACTOR_ONE;
|
||||
}
|
||||
|
||||
// Makes a sprite layer cover what is under it by its alpha (BlendMode::SetMode's normal mode).
|
||||
static void layer_normal_set(ANM2& sprite, int layerId)
|
||||
{
|
||||
LayerState* layer = sprite.GetLayer(layerId);
|
||||
bool isPremultiplied = KAGE::Graphics::manager.isPremultipliedAlpha;
|
||||
|
||||
layer->blendMode[BLEND_EQUATION] = BLEND_EQUATION_ADD;
|
||||
layer->blendMode[BLEND_RGB_SOURCE] = isPremultiplied ? BLEND_FACTOR_ONE : BLEND_FACTOR_SRC_ALPHA;
|
||||
layer->blendMode[BLEND_RGB_DEST] = BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
layer->blendMode[BLEND_ALPHA_SOURCE] = BLEND_FACTOR_ONE;
|
||||
layer->blendMode[BLEND_ALPHA_DEST] = BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
|
||||
// Spawns an effect at a position. Game::Spawn returning nothing crashes the original. Callers skip what it sets.
|
||||
static Entity_Effect* effect_spawn(int variant, const Vector& position, Entity* spawner, int subType = 0)
|
||||
{
|
||||
@@ -576,11 +628,49 @@ void Entity_Projectile::animation_update()
|
||||
animKey = ANIM_KEY_FCUK;
|
||||
break;
|
||||
case PROJECTILE_ROCK:
|
||||
if (animKey == ANIM_KEY_ROCK) break;
|
||||
std::snprintf(name, sizeof(name), "Rotate%d",
|
||||
std::min((int)(scale * ROCK_STEP_SCALE + 1), ROCK_STEP_MAX));
|
||||
sprite.Play(name);
|
||||
animKey = ANIM_KEY_ROCK;
|
||||
break;
|
||||
case PROJECTILE_WING:
|
||||
case PROJECTILE_LAVA:
|
||||
{
|
||||
int key = variant == PROJECTILE_WING ? ANIM_KEY_WING : ANIM_KEY_LAVA;
|
||||
if (animKey != key)
|
||||
{
|
||||
sprite.Play("Move");
|
||||
sprite.isFlipY = dropRNG._seed & 1;
|
||||
frame_randomize();
|
||||
animKey = key;
|
||||
if (variant == PROJECTILE_WING) sprite.bitflags |= ANIM_RENDER_STATIC;
|
||||
sprite.scale = vector_make(scale, scale);
|
||||
}
|
||||
sprite.rotation = (vector_angle(velocity) + PEEP_HALF_TURN) * (sprite.isFlipY ? -1 : 1);
|
||||
break;
|
||||
}
|
||||
case PROJECTILE_HEAD:
|
||||
if (animKey == ANIM_KEY_HEAD) break;
|
||||
sprite.Play("Idle");
|
||||
sprite.isFlipX = dropRNG._seed & 1;
|
||||
sprite.GetLayer(0)->cropOffset.x = (float)dropRNG.RandomInt(HEAD_FACES) * HEAD_FACE_WIDTH;
|
||||
sprite.rotation = random_unit() * HEAD_TILT * 2 - HEAD_TILT;
|
||||
animKey = ANIM_KEY_HEAD;
|
||||
sprite.scale = vector_make(scale, scale);
|
||||
break;
|
||||
case PROJECTILE_PEEP:
|
||||
reconstruction_missing("Entity_Projectile::Update 00653070: this projectile variant's animation");
|
||||
{
|
||||
int key = sizeStep + ANIM_KEY_PEEP;
|
||||
if (animKey != key)
|
||||
{
|
||||
std::snprintf(name, sizeof(name), "RegularTear%d", sizeStep);
|
||||
sprite.Play(name);
|
||||
animKey = key;
|
||||
}
|
||||
peep_update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// A shot without a config crashes the original here. This leaves its shadow.
|
||||
@@ -611,6 +701,114 @@ void Entity_Projectile::first_frame_update()
|
||||
aura->Update();
|
||||
}
|
||||
|
||||
// The Peeper's eye: it faces along its flight, upright either way, and drags a red trail at half its alpha.
|
||||
void Entity_Projectile::peep_update()
|
||||
{
|
||||
float angle = vector_angle(velocity);
|
||||
bool isBackward = angle < -PEEP_QUARTER_TURN || angle > PEEP_QUARTER_TURN;
|
||||
sprite.isFlipX = isBackward;
|
||||
sprite.rotation = isBackward ? PEEP_HALF_TURN - angle : angle;
|
||||
|
||||
if (!child)
|
||||
{
|
||||
auto* trail = static_cast<Entity_Effect*>(g_game->Spawn({.position = pos, .spawner = this,
|
||||
.type = ENTITY_EFFECT,
|
||||
.variant = EFFECT_SPRITE_TRAIL, .seed = Random()}));
|
||||
trail->sprite.color = PEEP_TRAIL_COLOR;
|
||||
layer_normal_set(trail->sprite, 0);
|
||||
trail->sprite.scale = vector_make(scale + scale, scale + scale);
|
||||
trail->SetRadii(PEEP_TRAIL_RADIUS, PEEP_TRAIL_RADIUS);
|
||||
trail->parent = this;
|
||||
trail->Update();
|
||||
child = trail;
|
||||
}
|
||||
|
||||
Entity* trail = child.get();
|
||||
if (!isVisible)
|
||||
{
|
||||
trail->sprite.color._tint[3] = 0;
|
||||
return;
|
||||
}
|
||||
trail->sprite.color._tint[3] = sprite.color._tint[3] * PEEP_TRAIL_ALPHA;
|
||||
trail->pos = vector_add(pos, posOffset);
|
||||
trail->velocity = velocity;
|
||||
}
|
||||
|
||||
// The splash of a thrown grid entity: it breaks where it lands as the rock its subtype packs (type high, variant
|
||||
// low), keeping the shot's health and seed.
|
||||
void Entity_Projectile::grid_splash()
|
||||
{
|
||||
sprite.color = COLOR_DEFAULT;
|
||||
GridEntityDesc desc{};
|
||||
desc._type = (int)((uint32_t)subtype >> GRID_TYPE_SHIFT);
|
||||
desc._variant = subtype & GRID_VARIANT_MASK;
|
||||
desc._state = (int)health;
|
||||
desc._spawnSeed = initSeed;
|
||||
desc._varData = HasEntityFlags(FLAG_NO_DEATH_TRIGGER);
|
||||
DestroyRockGridAt(pos, &desc, this, wiggleFrameOffset);
|
||||
}
|
||||
|
||||
// A rock's splash: a poof its size in its own color, and, in the room, a crumble and a handful of rock-tinted chips.
|
||||
void Entity_Projectile::rock_splash()
|
||||
{
|
||||
ColorMod color = ROCK_POOF_COLOR;
|
||||
color_multiply(color, sprite.color);
|
||||
Entity* poof = effect_spawn(EFFECT_ROCK_POOF, pos, this);
|
||||
poof->posOffset = posOffset;
|
||||
poof->SetColor(this->color, COLOR_PRIORITY_NONE, COLOR_PRIORITY, false, true);
|
||||
poof->Update();
|
||||
poof->sprite.scale = vector_make(scale, scale);
|
||||
poof->sprite.rotation = 0;
|
||||
if (!g_game->room->IsPositionInRoom(pos, ROCK_SOUND_MARGIN)) return;
|
||||
|
||||
sound_play(SOUND_ROCK_CRUMBLE, 1, 1);
|
||||
int chips = std::min(std::max((int)(scale * ROCK_CHIPS_SCALE * (random_unit() * HALF + 1)), 1), ROCK_CHIPS_MAX);
|
||||
for (int i = 0; i < chips; i++)
|
||||
{
|
||||
Vector direction = vector_from_angle(random_unit() * ROCK_CHIP_TURN);
|
||||
float speed = random_unit() * ROCK_CHIP_SPEED + 1;
|
||||
Vector spot = vector_add(pos, vector_scale(direction, random_unit() * size));
|
||||
Entity* chip = g_game->Spawn({.position = spot, .velocity = vector_scale(direction, speed),
|
||||
.subType = ROCK_CHIP_SUBTYPE, .type = ENTITY_EFFECT,
|
||||
.variant = EFFECT_TOOTH_PARTICLE, .seed = Random()});
|
||||
chip->posOffset = posOffset;
|
||||
chip->SetColor(color, COLOR_PRIORITY_NONE, COLOR_PRIORITY, false, true);
|
||||
chip->Update();
|
||||
}
|
||||
}
|
||||
|
||||
// A meat ball's splash: a blood burst, then, off the grid, a Globin (one in ten a Gazing one) pulling itself back
|
||||
// together, shrunk if the shot was.
|
||||
void Entity_Projectile::meat_splash()
|
||||
{
|
||||
Entity* burst = effect_spawn(EFFECT_BLOOD_EXPLOSION, pos, nullptr, MEAT_BURST_SUBTYPE);
|
||||
burst->posOffset = posOffset;
|
||||
sound_play(SOUND_SPLATTER, 1, 1);
|
||||
if (room_grid_collision_at(pos) != 0) return;
|
||||
|
||||
int globinVariant = initSeed % MEAT_GAZING_ODDS == 0;
|
||||
auto* globin = static_cast<Entity_NPC*>(g_game->Spawn({.position = pos,
|
||||
.velocity = vector_scale(velocity, MEAT_GLOBIN_PUSH),
|
||||
.spawner = spawnerEntity, .type = ENTITY_GLOBIN,
|
||||
.variant = globinVariant, .seed = Random()}));
|
||||
globin->ClearEntityFlags(FLAG_APPEAR);
|
||||
globin->health = MEAT_GLOBIN_HEALTH;
|
||||
globin->sprite.Play("ReGenProjectile");
|
||||
globin->state = NPC_STATE_IDLE;
|
||||
if (HasEntityFlags(FLAG_SHRINK)) globin->AddShrink(EntityRef(this), MEAT_GLOBIN_SHRINK, false);
|
||||
}
|
||||
|
||||
// A head's splash: a green burst, a small death burst's sound and green gibs.
|
||||
void Entity_Projectile::head_splash()
|
||||
{
|
||||
Entity* burst = effect_spawn(EFFECT_BLOOD_EXPLOSION, pos, nullptr, BLOOD_EXPLOSION_SPLASH);
|
||||
burst->SetColor(COLOR_GREEN_SPLAT, COLOR_PRIORITY_NONE, COLOR_PRIORITY, false, true);
|
||||
burst->Update();
|
||||
npc_sound_play(SOUND_DEATH_BURST_SMALL, 1, 2, 1);
|
||||
gibs_spawn({.color = COLOR_GREEN_SPLAT, .position = pos, .spawner = this, .spread = HEAD_GIB_SPREAD,
|
||||
.amount = HEAD_GIBS, .gibFlags = HEAD_GIB_FLAGS});
|
||||
}
|
||||
|
||||
// The trails the late bosses' shots leave, which are not reconstructed.
|
||||
void Entity_Projectile::trails_update()
|
||||
{
|
||||
@@ -631,6 +829,7 @@ void Entity_Projectile::death_update()
|
||||
death_poof_spawn();
|
||||
death_flags_apply();
|
||||
death_bursts_spawn();
|
||||
if (variant == PROJECTILE_HEAD) head_splash();
|
||||
Remove();
|
||||
if (variant == PROJECTILE_FIRE && spawnerType == ENTITY_BEAST) npc_sound_play(SOUND_BEAST_FIRE, 1, 2, 1);
|
||||
}
|
||||
@@ -721,8 +920,9 @@ void Entity_Projectile::death_poof_spawn()
|
||||
.variant = EFFECT_COIN_PARTICLE});
|
||||
sound_play(SOUND_COIN_IMPACT, random_unit() * COIN_SOUND_PITCH_SPREAD + COIN_SOUND_PITCH, COIN_SOUND_VOLUME);
|
||||
}
|
||||
else if (variant == PROJECTILE_GRID || variant == PROJECTILE_ROCK || variant == PROJECTILE_MEAT)
|
||||
reconstruction_missing("Entity_Projectile::Update 00653070: this projectile variant's splash");
|
||||
else if (variant == PROJECTILE_GRID) grid_splash();
|
||||
else if (variant == PROJECTILE_ROCK) rock_splash();
|
||||
else if (variant == PROJECTILE_MEAT) meat_splash();
|
||||
|
||||
if (!(projectileFlags & PROJECTILE_EXPLODE) && (projectileFlags & PROJECTILE_CREEP_BROWN))
|
||||
{
|
||||
@@ -1184,6 +1384,7 @@ void Entity_Projectile::fall_update()
|
||||
fallingSpeed = speedMultiplier * fallingAccel + speedMultiplier * GRAVITY_PULL +
|
||||
timescale_factor(FALL_DRAG, speedMultiplier) * fallingSpeed;
|
||||
height = fallingSpeed * speedMultiplier + height;
|
||||
if (variant == PROJECTILE_HEAD) sprite.rotation = angle_wrap(sprite.rotation + fallingSpeed * HEAD_SPIN);
|
||||
if (!is_crawlspace()) return;
|
||||
|
||||
if (fallingAccel >= CRAWLSPACE_MIN_ACCEL) velocity.y = fallingAccel * speedMultiplier + velocity.y;
|
||||
|
||||
Reference in new issue
Block a user