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
@@ -0,0 +1,241 @@
|
||||
#include "entity_effect.h"
|
||||
#include "entity_npc.h"
|
||||
#include "entity_player.h"
|
||||
#include "entity_projectile.h"
|
||||
#include "game.h"
|
||||
#include "item_config.h"
|
||||
#include "manager.h"
|
||||
#include "npc_ai.h"
|
||||
#include "room.h"
|
||||
#include "room_grid.h"
|
||||
#include <algorithm>
|
||||
|
||||
constexpr int COLLECTIBLE_CHARM_OF_THE_VAMPIRE = 62;
|
||||
constexpr int COLLECTIBLE_LUSTY_BLOOD = 411;
|
||||
constexpr int COLLECTIBLE_JUMPER_CABLES = 520;
|
||||
constexpr int COLLECTIBLE_DEATHS_LIST = 530;
|
||||
constexpr int COLLECTIBLE_BERSERK_KILLS = 704;
|
||||
constexpr int TRINKET_SAMSONS_LOCK = 58;
|
||||
constexpr int TRINKET_EVES_BIRD_FOOT = 60;
|
||||
constexpr int TRINKET_BAT_WING_KILLS = 118;
|
||||
constexpr int TRINKET_SIGIL_OF_BAPHOMET = 189;
|
||||
constexpr int NULLITEM_BAT_WING = 40;
|
||||
constexpr int EFFECT_HEART = 49;
|
||||
constexpr int SOUND_VAMP_GULP = 157;
|
||||
constexpr int SOUND_VAMP_DOUBLE = 614;
|
||||
constexpr int SOUND_BOOK_SHADOWS_SIGIL = 1028;
|
||||
|
||||
// Charm of the Vampire heals every 13 kills, every 8 in a versus match. The heart rises 24 above the player.
|
||||
constexpr int VAMPIRE_KILLS = 13;
|
||||
constexpr int VAMPIRE_KILLS_VERSUS = 8;
|
||||
constexpr float HEART_EFFECT_RISE = -24;
|
||||
constexpr int VERSUS_LUSTY_BLOOD_EXTRA = 4;
|
||||
|
||||
// Samson's Lock rolls out of 10000 and Eve's Bird Foot out of 1000, by trinket multiplier, plus luck scaled up.
|
||||
constexpr int SAMSONS_LOCK_ROLL = 10000;
|
||||
constexpr int SAMSONS_LOCK_ODDS = 666;
|
||||
constexpr int SAMSONS_LOCK_ODDS_DOUBLE = 1300;
|
||||
constexpr int SAMSONS_LOCK_ODDS_TRIPLE = 2500;
|
||||
constexpr float SAMSONS_LOCK_LUCK_SCALE = 1000;
|
||||
constexpr int EVES_BIRD_FOOT_ROLL = 1000;
|
||||
constexpr int EVES_BIRD_FOOT_ODDS = 50;
|
||||
constexpr int EVES_BIRD_FOOT_ODDS_DOUBLE = 100;
|
||||
constexpr int EVES_BIRD_FOOT_ODDS_TRIPLE = 150;
|
||||
constexpr float EVES_BIRD_FOOT_LUCK_SCALE = 125;
|
||||
|
||||
// Bat Wing flies one kill in 20 (10 doubled, 7 tripled).
|
||||
constexpr int BAT_WING_ODDS = 20;
|
||||
constexpr int BAT_WING_ODDS_DOUBLE = 10;
|
||||
constexpr int BAT_WING_ODDS_TRIPLE = 7;
|
||||
|
||||
// Red Stew's bonus lasts 30 frames more each kill, up to 9000.
|
||||
constexpr int RED_STEW_KILL_FRAMES = 30;
|
||||
constexpr int RED_STEW_MAX_FRAMES = 9000;
|
||||
|
||||
// Berserk lasts up to 30 frames more each gory kill (90 for Tainted Samson with his Birthright), and the kill
|
||||
// destroys enemy shots within 60.
|
||||
constexpr int BERSERK_KILL_FRAMES = 30;
|
||||
constexpr int BERSERK_KILL_FRAMES_BIRTHRIGHT = 90;
|
||||
constexpr float BERSERK_SHOT_RADIUS = 60;
|
||||
|
||||
// Sigil of Baphomet grants Book of Shadows for 30 frames a kill up to 150, more for golden or stacked sigils.
|
||||
constexpr int SIGIL_FRAMES = 30;
|
||||
constexpr int SIGIL_FRAMES_DOUBLE = 45;
|
||||
constexpr int SIGIL_FRAMES_TRIPLE = 60;
|
||||
constexpr int SIGIL_MAX_FRAMES = 150;
|
||||
constexpr int SIGIL_MAX_FRAMES_DOUBLE = 225;
|
||||
constexpr int SIGIL_MAX_FRAMES_TRIPLE = 300;
|
||||
|
||||
// The heart that rises above a player healed by a kill.
|
||||
static void heart_effect_spawn(Entity_Player& player)
|
||||
{
|
||||
Entity* heart = g_game->Spawn({.position = player.pos, .type = ENTITY_EFFECT, .variant = EFFECT_HEART,
|
||||
.seed = Random()});
|
||||
heart->sprite.offset = vector_make(0, HEART_EFFECT_RISE);
|
||||
heart->renderDepthOffset = 1;
|
||||
}
|
||||
|
||||
// One chance in roll that a luck-scaled trinket procs.
|
||||
// A sum below zero compares as a huge unsigned number, so the original procs every time at negative luck. Kept.
|
||||
static bool is_luck_roll_won(Entity_Player& player, int odds, float luckScale, int roll)
|
||||
{
|
||||
uint32_t chance = (uint32_t)(odds + (int)(player.luck * luckScale));
|
||||
return Random() % (uint32_t)roll < chance;
|
||||
}
|
||||
|
||||
// Samson's Lock and Eve's Bird Foot: a chance at their temporary effect.
|
||||
static void luck_trinkets_update(Entity_Player& player)
|
||||
{
|
||||
int lock = player.GetTrinketMultiplier(TRINKET_SAMSONS_LOCK);
|
||||
if (lock > 0)
|
||||
{
|
||||
int odds = lock == 2 ? SAMSONS_LOCK_ODDS_DOUBLE : lock >= 3 ? SAMSONS_LOCK_ODDS_TRIPLE : SAMSONS_LOCK_ODDS;
|
||||
if (is_luck_roll_won(player, odds, SAMSONS_LOCK_LUCK_SCALE, SAMSONS_LOCK_ROLL))
|
||||
player.temporaryEffects.AddTrinketEffect(TRINKET_SAMSONS_LOCK, true, 1);
|
||||
}
|
||||
|
||||
int foot = player.GetTrinketMultiplier(TRINKET_EVES_BIRD_FOOT);
|
||||
if (foot <= 0) return;
|
||||
|
||||
int odds = foot == 2 ? EVES_BIRD_FOOT_ODDS_DOUBLE : foot >= 3 ? EVES_BIRD_FOOT_ODDS_TRIPLE : EVES_BIRD_FOOT_ODDS;
|
||||
if (is_luck_roll_won(player, odds, EVES_BIRD_FOOT_LUCK_SCALE, EVES_BIRD_FOOT_ROLL))
|
||||
player.temporaryEffects.AddTrinketEffect(TRINKET_EVES_BIRD_FOOT, true, 1);
|
||||
}
|
||||
|
||||
// Bat Wing: while it is not flying, one kill in 20 (10 doubled, 7 tripled) gives its flight and wings.
|
||||
static void bat_wing_update(Entity_Player& player)
|
||||
{
|
||||
int multiplier = player.GetTrinketMultiplier(TRINKET_BAT_WING_KILLS);
|
||||
if (multiplier <= 0 || player.temporaryEffects.HasTrinketEffect(TRINKET_BAT_WING_KILLS)) return;
|
||||
|
||||
int odds = multiplier == 2 ? BAT_WING_ODDS_DOUBLE : multiplier == 3 ? BAT_WING_ODDS_TRIPLE : BAT_WING_ODDS;
|
||||
if (player.trinketRNGs[TRINKET_BAT_WING_KILLS].RandomInt(odds) != 0) return;
|
||||
|
||||
player.temporaryEffects.AddTrinketEffect(TRINKET_BAT_WING_KILLS, true, 1);
|
||||
player.AddCostume(g_manager->itemConfig.GetNullItem(NULLITEM_BAT_WING), false);
|
||||
}
|
||||
|
||||
// Death's List: killing the marked enemy moves the mark to where it died, killing another fails the list.
|
||||
static void deaths_list_update(Entity_Player& player, Entity& npc)
|
||||
{
|
||||
Room& room = *g_game->room;
|
||||
if (!player.HasCollectible(COLLECTIBLE_DEATHS_LIST) || room.isDeathsListDone || !room.deathsListTarget) return;
|
||||
|
||||
if (&npc != room.deathsListTarget && !npc.HasEntityFlags(FLAG_FRIENDLY)) room.isDeathsListDone = true;
|
||||
room.deathsListTarget = nullptr;
|
||||
if (!room.isDeathsListDone) room.deathsListOffset = npc.pos;
|
||||
}
|
||||
|
||||
// Berserk: a gory kill lengthens it and destroys the enemy shots around the player.
|
||||
static void berserk_update(Entity_Player& player, Entity& npc)
|
||||
{
|
||||
TemporaryEffect* berserk = player.temporaryEffects.GetCollectibleEffect(COLLECTIBLE_BERSERK_KILLS);
|
||||
if (!npc.HasEntityFlags(FLAG_EXTRA_GORE) || !berserk) return;
|
||||
|
||||
ItemConfig_Item* item = g_manager->itemConfig.GetCollectible(COLLECTIBLE_BERSERK_KILLS);
|
||||
bool isLong = player.playerType == PLAYER_SAMSON_B && player.HasCollectible(COLLECTIBLE_BIRTHRIGHT);
|
||||
TemporaryEffect added;
|
||||
added.item = item;
|
||||
added.cooldown = std::min(item->maxCooldown - berserk->cooldown,
|
||||
isLong ? BERSERK_KILL_FRAMES_BIRTHRIGHT : BERSERK_KILL_FRAMES);
|
||||
player.temporaryEffects.AddEffect(added, false, 1);
|
||||
|
||||
for (Entity* shot : entity_query_radius(player.pos, BERSERK_SHOT_RADIUS, QUERY_PROJECTILES))
|
||||
{
|
||||
bool isStoppable = !(static_cast<Entity_Projectile*>(shot)->projectileFlags & PROJECTILE_CANT_BE_STOPPED);
|
||||
if (shot->type == ENTITY_PROJECTILE && !shot->isDead && isStoppable) shot->isDead = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sigil of Baphomet: each kill grants Book of Shadows for a while, up to a cap. A fresh shield plays its sound.
|
||||
static void sigil_update(Entity_Player& player)
|
||||
{
|
||||
int multiplier = player.GetTrinketMultiplier(TRINKET_SIGIL_OF_BAPHOMET);
|
||||
if (multiplier <= 0) return;
|
||||
|
||||
int frames = multiplier == 2 ? SIGIL_FRAMES_DOUBLE : multiplier == 3 ? SIGIL_FRAMES_TRIPLE : SIGIL_FRAMES;
|
||||
int maxFrames = multiplier == 2 ? SIGIL_MAX_FRAMES_DOUBLE
|
||||
: multiplier == 3 ? SIGIL_MAX_FRAMES_TRIPLE
|
||||
: SIGIL_MAX_FRAMES;
|
||||
TemporaryEffect* shadows = player.temporaryEffects.GetCollectibleEffect(COLLECTIBLE_BOOK_OF_SHADOWS);
|
||||
if (shadows && shadows->cooldown >= maxFrames) return;
|
||||
|
||||
TemporaryEffect added;
|
||||
added.item = g_manager->itemConfig.GetCollectible(COLLECTIBLE_BOOK_OF_SHADOWS);
|
||||
added.cooldown = shadows ? std::min(frames, maxFrames - shadows->cooldown) : frames;
|
||||
if (!shadows)
|
||||
{
|
||||
sound_play(SOUND_BOOK_SHADOWS_SIGIL);
|
||||
added.unknown = 1;
|
||||
}
|
||||
player.temporaryEffects.AddEffect(added, true, 1);
|
||||
}
|
||||
|
||||
// The kill rewards that need a rewarded kill: Gamekid's healing, Lusty Blood, the luck trinkets, Charm of the Vampire,
|
||||
// Jumper Cables, Bat Wing, the score of a room's first visit, and Death's List.
|
||||
static void kill_rewards_trigger(Entity_Player& player, Entity& npc, Entity_NPC* killedNpc)
|
||||
{
|
||||
Game& game = *g_game;
|
||||
TemporaryEffects& effects = player.temporaryEffects;
|
||||
|
||||
bool isGamekidFrame = !game.IsPaused() && (game.frameCount & 1) == 0;
|
||||
if (effects.HasCollectibleEffect(COLLECTIBLE_GAMEKID) && !player.HasEntityFlags(FLAG_INTERPOLATION_UPDATE) &&
|
||||
isGamekidFrame)
|
||||
player.AddHearts(1, false, false);
|
||||
|
||||
if (player.HasCollectible(COLLECTIBLE_LUSTY_BLOOD))
|
||||
{
|
||||
effects.AddCollectibleEffect(COLLECTIBLE_LUSTY_BLOOD, false, 1);
|
||||
if (npc.type == ENTITY_PLAYER && game.deathmatchManager.is_active())
|
||||
for (int i = 0; i < VERSUS_LUSTY_BLOOD_EXTRA; i++)
|
||||
effects.AddCollectibleEffect(COLLECTIBLE_LUSTY_BLOOD, false, 1);
|
||||
}
|
||||
|
||||
luck_trinkets_update(player);
|
||||
player.trigger_vampire_charm_kill();
|
||||
if (player.HasCollectible(COLLECTIBLE_JUMPER_CABLES))
|
||||
reconstruction_missing("Entity_Player::trigger_npc_death 007a0080: Jumper Cables' kill counter (+0x160c, which "
|
||||
"Entity_Player has no field for)");
|
||||
bat_wing_update(player);
|
||||
|
||||
if (game.room->isFirstVisit && killedNpc && killedNpc->spawnGridIndex >= 0 && &player == game.GetPlayer(0))
|
||||
game.scoreSheet.AddKilledEnemy(*killedNpc);
|
||||
deaths_list_update(player, npc);
|
||||
}
|
||||
|
||||
// 007a0080 Reacts to an NPC's death: the kill's item rewards (unless the kill gives none), Red Stew and Berserk, the
|
||||
// TMTRAINER kill triggers, Sigil of Baphomet, and the bestiary's kill count.
|
||||
void Entity_Player::trigger_npc_death(Entity* npc)
|
||||
{
|
||||
Entity_NPC* killedNpc = dynamic_cast<Entity_NPC*>(npc);
|
||||
|
||||
if (!npc->HasEntityFlags(FLAG_NO_REWARD)) kill_rewards_trigger(*this, *npc, killedNpc);
|
||||
if (redStewBonusDuration > 0)
|
||||
{
|
||||
temporaryEffects.isEvaluateCachePending = true;
|
||||
temporaryEffects.cacheFlags |= CACHE_DAMAGE;
|
||||
redStewBonusDuration = std::min(redStewBonusDuration + RED_STEW_KILL_FRAMES, RED_STEW_MAX_FRAMES);
|
||||
}
|
||||
berserk_update(*this, *npc);
|
||||
|
||||
if (!proceduralItems.empty())
|
||||
reconstruction_missing("Entity_Player::trigger_npc_death 007a0080: the TMTRAINER kill triggers "
|
||||
"(trigger_set_dispatch 009e0680)");
|
||||
sigil_update(*this);
|
||||
|
||||
if (killedNpc) g_manager->persistentGameData.AddBestiaryKill(killedNpc->type, killedNpc->variant);
|
||||
}
|
||||
|
||||
// 007d3350 Charm of the Vampire: every 13 kills (8 in a versus match) heals a heart with a gulp, a double gulp for
|
||||
// Tainted Magdalene.
|
||||
void Entity_Player::trigger_vampire_charm_kill()
|
||||
{
|
||||
int kills = g_game->deathmatchManager.is_active() ? VAMPIRE_KILLS_VERSUS : VAMPIRE_KILLS;
|
||||
if (!HasCollectible(COLLECTIBLE_CHARM_OF_THE_VAMPIRE)) return;
|
||||
if ((int)++vampireCharmKills < kills || isDead) return;
|
||||
|
||||
sound_play(playerType == PLAYER_MAGDALENE_B ? SOUND_VAMP_DOUBLE : SOUND_VAMP_GULP);
|
||||
AddHearts(1, true, false);
|
||||
vampireCharmKills -= kills;
|
||||
heart_effect_spawn(*this);
|
||||
}
|
||||
Reference in new issue
Block a user