1725 lines
75 KiB
C++
1725 lines
75 KiB
C++
#include "entity_player.h"
|
|
#include "active_items.h"
|
|
#include "boss_ai.h"
|
|
#include "entity_bomb.h"
|
|
#include "entity_effect.h"
|
|
#include "entity_familiar.h"
|
|
#include "entity_laser.h"
|
|
#include "entity_npc.h"
|
|
#include "entity_pickup.h"
|
|
#include "entity_tear.h"
|
|
#include "game.h"
|
|
#include "grid_entity_door.h"
|
|
#include "hud.h"
|
|
#include "item_pool.h"
|
|
#include "level.h"
|
|
#include "log.h"
|
|
#include "loot_list.h"
|
|
#include "manager.h"
|
|
#include "npc_ai.h"
|
|
#include "npc_basement.h"
|
|
#include "pocket_items.h"
|
|
#include "room.h"
|
|
#include "room_grid.h"
|
|
#include "room_special.h"
|
|
#include "sfx_manager.h"
|
|
#include <array>
|
|
#include <map>
|
|
#include <set>
|
|
|
|
constexpr float NECRONOMICON_DAMAGE = 40;
|
|
constexpr int PANDORA_COINS = 20;
|
|
constexpr float NECRONOMICON_VERSUS_DAMAGE = 20;
|
|
constexpr float NECRONOMICON_VERSUS_PAGE_DAMAGE = 10;
|
|
constexpr int NECRONOMICON_SHAKE = 15;
|
|
constexpr int NECRONOMICON_PARTICLES_MIN = 3;
|
|
constexpr int NECRONOMICON_PARTICLES_RANGE = 5;
|
|
constexpr float NECRONOMICON_PARTICLE_SPEED_MIN = 2;
|
|
constexpr float NECRONOMICON_PARTICLE_SPEED_RANGE = 4;
|
|
constexpr std::array<float, 4> NECRONOMICON_SPLAT_TINT = {0.2f, 0.2f, 0.2f, 1};
|
|
constexpr ColorMod NECRONOMICON_POOF_COLOR = {{0.2f, 0.2f, 0.2f, 0.6f}, {1, 1, 1, 1}, {0, 0, 0}};
|
|
constexpr ColorMod NECRONOMICON_GORE_COLOR = {{0.2f, 0.2f, 0.2f, 1}, {1, 1, 1, 1}, {0, 0, 0}};
|
|
constexpr int BLOOD_EXPLOSION_LARGE = 3;
|
|
constexpr float QUARTER_TURN_DEGREES = 90;
|
|
constexpr float BELIAL_DAMAGE_SCALE = 1.4f;
|
|
constexpr float BELIAL_TEAR_SCALE_BONUS = 0.5f;
|
|
constexpr ColorMod FLUSH_POOP_COLOR = {{0, 0, 0, 1}, {0, 0, 0, 0}, {39 / 255.0f, 25 / 255.0f, 22 / 255.0f}};
|
|
|
|
constexpr int VERSUS_EFFECT_FRAMES = 450;
|
|
constexpr float HOURGLASS_VERSUS_SLOW = 0.9f;
|
|
|
|
constexpr int BOOK_OF_SIN_KINDS = 7;
|
|
constexpr uint32_t BOOK_OF_SIN_PICK_SHIFT = 35;
|
|
constexpr int ACHIEVEMENT_GOLDEN_HEARTS = 224;
|
|
constexpr int ACHIEVEMENT_GOLDEN_BATTERIES = 615;
|
|
|
|
constexpr float BEAN_FART_RADIUS = 85;
|
|
constexpr float BEAN_PUSH_RADIUS = 120;
|
|
|
|
constexpr float MONSTER_MANUAL_VOLUME = 0.7f;
|
|
constexpr uint32_t MONSTER_MANUAL_SHIFT = 7;
|
|
constexpr size_t LEVEL_EFFECT_ITEMS_MAX = 64;
|
|
|
|
constexpr int DEAD_SEA_SCROLLS_TRIES = 10;
|
|
// The first floor actives Dead Sea Scrolls draws from.
|
|
constexpr std::array<int, 32> DEAD_SEA_SCROLLS_ITEMS = {34, 35, 37, 38, 39, 41, 42, 44, 45, 56, 49,
|
|
58, 77, 65, 66, 78, 83, 84, 85, 86, 93, 97,
|
|
107, 102, 47, 123, 136, 146, 158, 160, 171, 192};
|
|
|
|
// Heart and battery subtypes the Book of Sin draws, with their weights.
|
|
struct SinWeight
|
|
{
|
|
int subType = 0;
|
|
int weight = 0;
|
|
int achievement = 0;
|
|
};
|
|
|
|
constexpr SinWeight BOOK_OF_SIN_HEARTS[] = {{HEART_FULL, 30},
|
|
{HEART_SOUL, 10},
|
|
{HEART_BLACK, 10},
|
|
{HEART_ETERNAL, 2},
|
|
{HEART_GOLDEN, 2, ACHIEVEMENT_GOLDEN_HEARTS},
|
|
{HEART_BONE, 2, ACHIEVEMENT_BONE_HEARTS},
|
|
{HEART_ROTTEN, 4, ACHIEVEMENT_ROTTEN_HEARTS}};
|
|
constexpr SinWeight BOOK_OF_SIN_BATTERIES[] = {
|
|
{BATTERY_NORMAL, 50}, {BATTERY_MEGA, 1}, {BATTERY_GOLDEN, 1, ACHIEVEMENT_GOLDEN_BATTERIES}};
|
|
|
|
// Spawns an effect at a position, with no spawner and a fresh seed.
|
|
static Entity* effect_spawn(int variant, const Vector& position, const Vector& velocity = {}, int subType = 0)
|
|
{
|
|
return g_game->Spawn({.position = position, .velocity = velocity, .subType = subType, .type = ENTITY_EFFECT,
|
|
.variant = variant, .seed = Random()});
|
|
}
|
|
|
|
// The Necronomicon's gore on an enemy it hurt: a poof, a dark blood burst and splat, and three to seven drops.
|
|
static void necronomicon_gore_spawn(Entity& enemy)
|
|
{
|
|
Entity* poof = effect_spawn(EFFECT_POOF01, enemy.pos);
|
|
poof->SetColor(NECRONOMICON_GORE_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
|
poof->Update();
|
|
|
|
Entity* burst = effect_spawn(EFFECT_BLOOD_EXPLOSION, enemy.pos, {}, BLOOD_EXPLOSION_LARGE);
|
|
burst->SetColor(NECRONOMICON_GORE_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
|
std::ranges::copy(NECRONOMICON_SPLAT_TINT, burst->sprite.color._tint);
|
|
|
|
Entity* splat = effect_spawn(EFFECT_BLOOD_SPLAT, enemy.pos);
|
|
splat->SetColor(NECRONOMICON_GORE_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
|
splat->Update();
|
|
|
|
for (int i = random_below(NECRONOMICON_PARTICLES_RANGE) + NECRONOMICON_PARTICLES_MIN; i > 0; i--)
|
|
{
|
|
Vector offset = vector_scale(vector_scale(random_direction(), 0.5f), enemy.size);
|
|
Vector position = vector_add(enemy.pos, offset);
|
|
Vector direction = random_direction();
|
|
Vector velocity =
|
|
vector_scale(direction, random_unit() * NECRONOMICON_PARTICLE_SPEED_RANGE + NECRONOMICON_PARTICLE_SPEED_MIN);
|
|
Entity* drop = effect_spawn(EFFECT_BLOOD_PARTICLE, position, velocity);
|
|
drop->SetColor(NECRONOMICON_GORE_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
|
drop->splatColor = NECRONOMICON_GORE_COLOR;
|
|
drop->Update();
|
|
}
|
|
}
|
|
|
|
// Necronomicon: 40 damage (more with Missing Page 2 and Missing Page) to every enemy, the screen shaken. A Necromancer's
|
|
// filled Necronomicon gives one charge back.
|
|
static void necronomicon_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
int slot = use.request.slot;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER && !(use.request.flags & USE_ALLOWNONMAIN)) return use_animate(use);
|
|
|
|
bool isVersus = g_game->deathmatchManager.is_active();
|
|
float pageDamage = isVersus ? NECRONOMICON_VERSUS_PAGE_DAMAGE : NECRONOMICON_DAMAGE;
|
|
int pages = player.GetCollectibleNum(COLLECTIBLE_MISSING_PAGE_2) + player.GetTrinketMultiplier(TRINKET_MISSING_PAGE);
|
|
float damage = pages * pageDamage + (isVersus ? NECRONOMICON_VERSUS_DAMAGE : NECRONOMICON_DAMAGE);
|
|
|
|
sound_play(SOUND_DEATH_CARD);
|
|
game_shake_screen(NECRONOMICON_SHAKE);
|
|
player.MakeGroundPoofAtSelf(NECRONOMICON_POOF_COLOR, 1);
|
|
EntityList_EL& entities = room_entities();
|
|
for (size_t i = 0; i < entities.size(); i++)
|
|
{
|
|
Entity* entity = entities[i];
|
|
if (!entity->IsEnemy() || entity == &player || entity->HasEntityFlags(FLAG_NO_TARGET)) continue;
|
|
if (entity->isInvincible || entity->HasEntityFlags(FLAG_FRIENDLY)) continue;
|
|
|
|
entity->TakeDamage(damage, DAMAGE_IGNORE_ARMOR, EntityRef(&player), DAMAGE_COUNTDOWN_FRAMES);
|
|
if (player.HasCollectible(COLLECTIBLE_JAR_OF_FLIES)) entity->AddEntityFlags(FLAG_ADD_JAR_FLY);
|
|
necronomicon_gore_spawn(*entity);
|
|
}
|
|
|
|
// The original reads the slot's data for a use from no slot too: here such a use gives no charge back.
|
|
if (slot >= 0 && player.HasPlayerForm(PLAYER_FORM_NECROMANCER) && player.activeItems[slot].varData == 1)
|
|
{
|
|
use.result.isDischarge = false;
|
|
player.AddActiveCharge(-1, slot, false, false, false);
|
|
if (player.GetActiveItem(slot) < 1)
|
|
{
|
|
player.activeItems[slot].varData = 0;
|
|
g_game->hud.InvalidateActiveItem(&player, slot);
|
|
}
|
|
player.active_used_post(slot, false, player.activeItems[slot].charge + 1);
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// The Hourglass: the room slowed, the music with it. In a versus match the other players slow down too.
|
|
static void hourglass_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
|
|
sound_play(SOUND_HOURGLASS);
|
|
use_animate(use);
|
|
g_game->room->temporaryEffects.AddCollectibleEffect(use.id, true, 1);
|
|
g_manager->musicManager.PitchSlide(g_game->room->time_scale_update());
|
|
if (!g_game->deathmatchManager.is_active()) return;
|
|
|
|
int duration = g_manager->itemConfig.GetCollectible(use.id)->maxCooldown;
|
|
for (Entity_Player* each : g_game->playerManager.playerList)
|
|
if (each != &player && each != player.twin_get())
|
|
each->AddSlowing(EntityRef(&player), duration, HOURGLASS_VERSUS_SLOW, COLOR_DEFAULT, false);
|
|
}
|
|
|
|
// Monstro's Tooth: Monstro falls on the last enemy listed (a vulnerable one first, else any but a fireplace), or a
|
|
// player listed later. The room's first entity is never picked, and with no target Monstro falls on the user.
|
|
static void monstros_tooth_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
EntityList_EL& entities = room_entities();
|
|
if (player.variant != PLAYER_VARIANT_PLAYER || entities.size() == 0) return;
|
|
|
|
Entity* target = &player;
|
|
bool isVulnerableFound = false;
|
|
for (size_t i = 1; i < entities.size(); i++)
|
|
{
|
|
Entity* entity = entities[i];
|
|
bool isEnemyTarget = entity->IsVulnerableEnemy(nullptr) ||
|
|
(entity->IsEnemy() && entity->type != ENTITY_FIREPLACE && !isVulnerableFound);
|
|
bool isTarget = entity != &player && isEnemyTarget && !entity->isDead;
|
|
if ((!isTarget && entity->type != ENTITY_PLAYER) || entity->health <= 0) continue;
|
|
|
|
target = entity;
|
|
isVulnerableFound = isVulnerableFound || entity->IsVulnerableEnemy(nullptr);
|
|
}
|
|
Entity* monstro = effect_spawn(EFFECT_MONSTROS_TOOTH, target->pos);
|
|
monstro->target = target;
|
|
monstro->Update();
|
|
use_animate(use);
|
|
}
|
|
|
|
// Adds the Book of Sin's weights to a picker: the locked kinds come as a plain one, kept apart from it.
|
|
static void sin_weights_add(WeightedOutcomePicker& picker, std::span<const SinWeight> weights)
|
|
{
|
|
for (const SinWeight& weight : weights)
|
|
{
|
|
if (!weight.achievement)
|
|
{
|
|
picker.AddOutcomeWeight(weight.subType, weight.weight);
|
|
continue;
|
|
}
|
|
bool isUnlocked = g_manager->persistentGameData.Unlocked(weight.achievement);
|
|
picker.outcomes.push_back({isUnlocked ? weight.subType : 1, weight.weight});
|
|
}
|
|
}
|
|
|
|
// The Book of Sin: a random pickup by the player, a heart, bomb, key, pill, card, coin or battery. Daemon's Tail
|
|
// usually turns a heart into another kind.
|
|
static void book_of_sin_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return use_animate(use);
|
|
|
|
sound_play(SOUND_BOOK_OF_SIN);
|
|
RNG& rng = player.GetCollectibleRNG(use.id);
|
|
int kind = (int)rng.RandomInt(BOOK_OF_SIN_KINDS);
|
|
uint32_t pickSeed = rng.Next();
|
|
Vector position = room_free_pickup_position_find({.position = player.pos, .step = PICKUP_SPOT_STEP});
|
|
int otherKind = (int)rng.RandomInt(BOOK_OF_SIN_KINDS - 1) + 1;
|
|
if (player.HasTrinket(TRINKET_DAEMONS_TAIL) && player.GetTrinketRNG(TRINKET_DAEMONS_TAIL).RandomInt(DAEMONS_TAIL_ODDS))
|
|
kind = otherKind;
|
|
|
|
constexpr std::array<int, BOOK_OF_SIN_KINDS> VARIANTS = {PICKUP_HEART, PICKUP_BOMB, PICKUP_KEY,
|
|
PICKUP_PILL, PICKUP_TAROTCARD, PICKUP_COIN,
|
|
PICKUP_LIL_BATTERY};
|
|
constexpr std::array<int, BOOK_OF_SIN_KINDS> SUBTYPES = {0, 1, KEY_NORMAL, 0, 0, 0, 0};
|
|
int subType = SUBTYPES[kind];
|
|
uint32_t seed = rng.Next();
|
|
if (kind == 0 || kind == BOOK_OF_SIN_KINDS - 1)
|
|
{
|
|
WeightedOutcomePicker picker;
|
|
sin_weights_add(picker, kind == 0 ? std::span<const SinWeight>(BOOK_OF_SIN_HEARTS) : BOOK_OF_SIN_BATTERIES);
|
|
subType = picker.PickOutcome(rng_make(pickSeed, BOOK_OF_SIN_PICK_SHIFT));
|
|
}
|
|
g_game->Spawn({.position = position, .spawner = &player, .subType = subType, .type = ENTITY_PICKUP,
|
|
.variant = VARIANTS[kind], .seed = seed});
|
|
use_animate(use);
|
|
}
|
|
|
|
// A burst of blood out of the player: a splash the way a pickup would fly, and gore and drops around it.
|
|
static void blood_burst_spawn(Entity_Player& player)
|
|
{
|
|
constexpr float BLOOD_BURST_VOLUME = 3;
|
|
constexpr float BLOOD_BURST_SPEED = 2;
|
|
constexpr float BLOOD_BURST_SPREAD = 20;
|
|
constexpr int BLOOD_BURST_GORE_MIN = 2;
|
|
constexpr int BLOOD_BURST_GORE_RANGE = 3;
|
|
constexpr int BLOOD_BURST_DROPS_MIN = 6;
|
|
constexpr int BLOOD_BURST_DROPS_RANGE = 6;
|
|
constexpr int BLOOD_PARTICLE_DROP = 99;
|
|
|
|
g_manager->sfxManager.Play(SOUND_BLOODBANK_SPAWN, {.volume = BLOOD_BURST_VOLUME});
|
|
Vector base = vector_scale(Entity_Pickup::GetRandomPickupVelocity(player.pos, nullptr, 0), BLOOD_BURST_SPEED);
|
|
effect_spawn(EFFECT_BLOOD_EXPLOSION, player.pos, base, BLOOD_EXPLOSION_LARGE);
|
|
int gore = random_below(BLOOD_BURST_GORE_RANGE) + BLOOD_BURST_GORE_MIN;
|
|
int count = random_below(BLOOD_BURST_DROPS_RANGE) + BLOOD_BURST_DROPS_MIN + gore;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
Vector direction = tear_vector_rotate(base, random_unit() * BLOOD_BURST_SPREAD - BLOOD_BURST_SPREAD / 2);
|
|
Vector velocity = vector_scale(direction, random_unit());
|
|
effect_spawn(EFFECT_BLOOD_PARTICLE, vector_add(player.pos, velocity), velocity, i < gore ? 0 : BLOOD_PARTICLE_DROP)
|
|
->Update();
|
|
}
|
|
}
|
|
|
|
// Pinking Shears: a burst of blood, and the body walks off as flight for the room (Transcendence's look). In a versus
|
|
// match both last 450 frames.
|
|
static void pinking_shears_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
|
|
blood_burst_spawn(player);
|
|
player.cacheFlags |= use.item->cacheFlags;
|
|
for (int item : {use.id, (int)COLLECTIBLE_TRANSCENDENCE})
|
|
{
|
|
TemporaryEffect effect(g_manager->itemConfig.GetCollectible(item));
|
|
if (g_game->deathmatchManager.is_active()) effect.cooldown = VERSUS_EFFECT_FRAMES;
|
|
player.temporaryEffects.AddEffect(effect, true, 1);
|
|
if (item == use.id) player.EvaluateItems();
|
|
}
|
|
use.isAddEffect = false;
|
|
}
|
|
|
|
// The Bean: a poison fart and a push around the player.
|
|
static void bean_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
|
|
game_fart({.position = player.pos, .source = &player, .radius = BEAN_FART_RADIUS});
|
|
game_butter_bean_fart(
|
|
{.position = player.pos, .source = &player, .radius = BEAN_PUSH_RADIUS, .isShowEffect = false});
|
|
}
|
|
|
|
// Monster Manual: a familiar for the floor, the one of its tagged items with the highest roll.
|
|
static void monster_manual_use(ItemUse& use)
|
|
{
|
|
constexpr int MONSTER_MANUAL_DEFAULT = COLLECTIBLE_BROTHER_BOBBY;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return use_animate(use);
|
|
|
|
g_manager->sfxManager.Play(SOUND_SATAN_GROW, {.volume = MONSTER_MANUAL_VOLUME});
|
|
RNG rng = rng_make(player.GetCollectibleRNG(use.id).Next(), MONSTER_MANUAL_SHIFT);
|
|
int pick = MONSTER_MANUAL_DEFAULT;
|
|
float best = -1;
|
|
for (size_t id = 0; id < g_manager->itemConfig.collectibles.size(); id++)
|
|
{
|
|
if (!ItemConfig::is_collectible_tagged((int)id, TAG_MONSTER_MANUAL)) continue;
|
|
float roll = rng.RandomFloat();
|
|
if (roll <= best) continue;
|
|
pick = (int)id;
|
|
best = roll;
|
|
}
|
|
if (player.levelEffectItems.size() < LEVEL_EFFECT_ITEMS_MAX)
|
|
{
|
|
player.temporaryEffects.AddCollectibleEffect(pick, true, 1);
|
|
player.levelEffectItems.push_back(pick);
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// Dead Sea Scrolls: one of 32 first floor actives used at once, named over the HUD, with its wisp for Book of
|
|
// Virtues. Ten tries skip what Cantripped or the versus rules forbid, then Tammy's Head.
|
|
static void dead_sea_scrolls_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant == PLAYER_VARIANT_PLAYER)
|
|
{
|
|
sound_play(SOUND_DEAD_SEA_SCROLLS);
|
|
if (player.itemState == 0)
|
|
{
|
|
int pick = COLLECTIBLE_TAMMYS_HEAD;
|
|
DeathmatchManager& versus = g_game->deathmatchManager;
|
|
for (int i = 0; i < DEAD_SEA_SCROLLS_TRIES; i++)
|
|
{
|
|
int id = DEAD_SEA_SCROLLS_ITEMS[player.GetCollectibleRNG(use.id).RandomInt(DEAD_SEA_SCROLLS_ITEMS.size())];
|
|
if (g_game->challenge == CHALLENGE_CANTRIPPED && ItemConfig::is_collectible_tagged(id, TAG_NO_CANTRIP))
|
|
continue;
|
|
if (versus.is_active() && versus.type->is_collectible_banned(id)) continue;
|
|
pick = id;
|
|
break;
|
|
}
|
|
std::string name = g_manager->itemConfig.GetCollectible(pick)->GetLocalizedName();
|
|
g_game->hud.show_pill_name(&player, name.c_str(), "");
|
|
player.UseActiveItem({.item = pick, .flags = USE_NOANIM});
|
|
player.TriggerBookOfVirtues(pick, 0);
|
|
}
|
|
}
|
|
if (!use.isShowAnimation) return;
|
|
bool isHeld = player.itemState != 0 && player.itemState != COLLECTIBLE_SHOOP_DA_WHOOP;
|
|
player.AnimateCollectible(use.id, isHeld ? "LiftItem" : "UseItem", "PlayerPickupSparkle");
|
|
}
|
|
|
|
// Forget Me Now's timer: the player reappears and the floor starts over on a new seed.
|
|
static void forget_me_now_restart(Entity_Effect* timer)
|
|
{
|
|
Entity* parent = timer->parent.get();
|
|
if (!parent || parent->type != ENTITY_PLAYER) return;
|
|
|
|
Entity_Player* player = static_cast<Entity_Player*>(parent);
|
|
sound_play(SOUND_FORGET_ME_NOW);
|
|
player->PlayExtraAnimation("Appear");
|
|
g_game->seedEffects.ForgetStageSeed(g_game->stage_depth_get());
|
|
g_game->stageTransition.start({.player = player, .type = STAGE_TRANSITION_FORGET_ME_NOW, .isSameStage = true});
|
|
}
|
|
|
|
// Forget Me Now: the floor restarts a frame later (during a versus fight it only buzzes). It goes once owned, or used
|
|
// through the Void.
|
|
static void forget_me_now_use(ItemUse& use)
|
|
{
|
|
if (use.player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
if (use.request.flags & (USE_OWNED | USE_VOID)) use.result.isRemove = true;
|
|
if (g_game->deathmatchManager.is_fighting()) return g_manager->sfxManager.Play(SOUND_ERROR_BUZZ);
|
|
|
|
Entity_Effect* timer = Entity_Effect::CreateTimer(reinterpret_cast<void*>(&forget_me_now_restart), 1, 0, false);
|
|
timer->parent = &use.player;
|
|
}
|
|
|
|
// FUN_0043e990 A wisp turned into a random other one: its look, config and health (kept below the new maximum) reloaded.
|
|
static void wisp_reroll(Entity_Familiar& wisp, RNG& rng)
|
|
{
|
|
int subType = Entity_Familiar::GetRandomWisp(&rng);
|
|
if (subType == wisp.subtype) return;
|
|
|
|
wisp.subtype = subType;
|
|
wisp.ResetColor();
|
|
wisp.LoadEntityConfig();
|
|
wisp.health = std::min(wisp.health, wisp.maxHitPoints);
|
|
wisp.entityGridCollisionClass = GRIDCOLL_NONE;
|
|
wisp.WispInit();
|
|
}
|
|
|
|
// The items held up until thrown or let go (Glass Cannon, Friend Ball): the item lifted, its sound played.
|
|
static void lift_sound_use(ItemUse& use, int sound)
|
|
{
|
|
use.player.SetItemState(use.id);
|
|
use.player.AnimateCollectible(use.id, "LiftItem", "PlayerPickupSparkle");
|
|
if (sound) sound_play(sound);
|
|
}
|
|
|
|
// The Boomerang: held ready to throw, with its costume.
|
|
static void boomerang_use(ItemUse& use)
|
|
{
|
|
use.player.SetItemState(use.id);
|
|
use.player.AddCostume(g_manager->itemConfig.GetNullItem(NULLITEM_BOOMERANG), false);
|
|
}
|
|
// Spawns a pickup at a free spot near the player, the seed drawn before the spot.
|
|
static Entity* pickup_spawn(Entity_Player& player, int variant, int subType, uint32_t seed)
|
|
{
|
|
Vector position = room_free_pickup_position_find({.position = player.pos, .step = PICKUP_SPOT_STEP});
|
|
return g_game->Spawn({.position = position, .spawner = &player, .subType = subType, .type = ENTITY_PICKUP,
|
|
.variant = variant, .seed = seed});
|
|
}
|
|
|
|
// Whether Book of Virtues turns this use into wisps.
|
|
static bool is_wisp_use(ItemUse& use)
|
|
{
|
|
return use.player.HasCollectible(COLLECTIBLE_BOOK_OF_VIRTUES) && use.isWispAllowed;
|
|
}
|
|
|
|
// IV Bag: half a heart of blood for one to three coins (one or two in hard mode), PHD adding one. The Keepers pay
|
|
// coin hearts instead, for a coin at most half the time (a quarter with PHD's extra, Piggy Bank doubling the odds).
|
|
static void iv_bag_use(ItemUse& use)
|
|
{
|
|
constexpr float KEEPER_COIN_ODDS = 0.5f;
|
|
constexpr float KEEPER_SECOND_COIN_ODDS = 0.25f;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return use_animate(use);
|
|
|
|
sound_play(SOUND_IV_BAG);
|
|
uint64_t flags = DAMAGE_RED_HEARTS | DAMAGE_INVINCIBLE | DAMAGE_IV_BAG;
|
|
if (g_game->challenge == CHALLENGE_GUARDIAN) flags |= DAMAGE_ISAAC_HURT;
|
|
player.damageCooldown = 0;
|
|
player.TakeDamage(1, flags, EntityRef(), DAMAGE_COUNTDOWN_FRAMES);
|
|
|
|
int coins = 0;
|
|
if (player.playerType == PLAYER_KEEPER || player.playerType == PLAYER_KEEPER_B)
|
|
{
|
|
if (player.HasCollectible(COLLECTIBLE_PHD) && random_below(2) == 0) coins = 1;
|
|
float scale = player.HasCollectible(COLLECTIBLE_PIGGY_BANK) ? 2 : 1;
|
|
coins += random_unit() * scale <= (coins == 0 ? KEEPER_COIN_ODDS : KEEPER_SECOND_COIN_ODDS);
|
|
}
|
|
else
|
|
{
|
|
int roll = (int)player.dropRNG.RandomInt(game_is_hard_mode() ? 2 : 3);
|
|
coins = std::max(roll, 1) + player.HasCollectible(COLLECTIBLE_PHD);
|
|
}
|
|
for (int i = 0; i < coins; i++) pickup_spawn(player, PICKUP_COIN, 0, Random());
|
|
use_animate(use);
|
|
}
|
|
|
|
// Best Friend: a decoy bomb enemies go after, lit for 150 frames, carrying the bomb effects, bigger and stronger.
|
|
static void best_friend_use(ItemUse& use)
|
|
{
|
|
constexpr int BEST_FRIEND_FUSE = 150;
|
|
constexpr float BEST_FRIEND_SCALE = 1.5f;
|
|
constexpr float BEST_FRIEND_DAMAGE_BONUS = 85;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
|
|
Entity* spawned = g_game->Spawn({.position = player.pos, .spawner = &player, .type = ENTITY_BOMB,
|
|
.variant = BOMB_DECOY, .seed = Random()});
|
|
Entity_Bomb* bomb = dynamic_cast<Entity_Bomb*>(spawned);
|
|
player.bestFriend = bomb;
|
|
if (!bomb) return;
|
|
|
|
sound_play(SOUND_BESTFRIEND);
|
|
bomb->SetExplosionCountdown(BEST_FRIEND_FUSE);
|
|
bomb->tearFlags = player.GetBombFlags(false);
|
|
bomb->isLoadCostumes = true;
|
|
bomb->scale = BEST_FRIEND_SCALE;
|
|
bomb->explosionDamage += BEST_FRIEND_DAMAGE_BONUS;
|
|
}
|
|
|
|
// Crystal Ball: the map shown, and a card or (half the time, Daemon's Tail usually turning it into a card) a soul heart.
|
|
static void crystal_ball_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return use_animate(use);
|
|
|
|
RNG& rng = player.GetCollectibleRNG(use.id);
|
|
g_game->ShowMap();
|
|
bool isCard = rng.RandomInt(2) == 0 ||
|
|
(player.HasTrinket(TRINKET_DAEMONS_TAIL) &&
|
|
player.GetTrinketRNG(TRINKET_DAEMONS_TAIL).RandomInt(DAEMONS_TAIL_ODDS) != 0);
|
|
uint32_t seed = rng.Next();
|
|
if (isCard) pickup_spawn(player, PICKUP_TAROTCARD, 0, seed);
|
|
else pickup_spawn(player, PICKUP_HEART, HEART_SOUL, seed);
|
|
sound_play(SOUND_CRYSTAL_BALL);
|
|
use_animate(use);
|
|
}
|
|
|
|
// The D6's ending for the dice that reroll a room: the roll's sound and the item raised.
|
|
static void dice_end(ItemUse& use)
|
|
{
|
|
if (!use.isShowAnimation) return;
|
|
sound_play_local(use.player, SOUND_D6_ROLL);
|
|
use_animate(use);
|
|
}
|
|
|
|
// The D20: the shop restocked, and every pickup but the pedestals rerolled. A chest mostly stays a chest (a plain or
|
|
// locked one), a shop item stays one. With Book of Virtues the pickups go instead, a fifth of them as wisps.
|
|
static void d20_use(ItemUse& use)
|
|
{
|
|
constexpr uint32_t D20_REROLL_SHIFT = 61;
|
|
constexpr uint32_t D20_WISP_SHIFT = 35;
|
|
constexpr int D20_WISP_ODDS = 5;
|
|
constexpr int D20_CHEST_KEEP_ODDS = 5;
|
|
constexpr int D20_OTHER_ODDS = 10;
|
|
constexpr int D20_LOCKED_CHEST_ODDS = 4;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant == PLAYER_VARIANT_PLAYER)
|
|
{
|
|
if (g_game->room->roomType == ROOM_SHOP)
|
|
room_shop_reshuffle(*g_game->room, RESHUFFLE_KEEP_ITEMS);
|
|
for (Entity* entity : entity_query(ENTITY_PICKUP, -1))
|
|
{
|
|
if (entity->isDead || entity->variant == PICKUP_COLLECTIBLE) continue;
|
|
Entity_Pickup* pickup = dynamic_cast<Entity_Pickup*>(entity);
|
|
if (!pickup || !pickup->CanReroll()) continue;
|
|
|
|
if (is_wisp_use(use))
|
|
{
|
|
RNG rng = rng_make(pickup->initSeed, D20_WISP_SHIFT);
|
|
if (rng.RandomInt(D20_WISP_ODDS) == 0)
|
|
player.AddWisp(Entity_Familiar::GetRandomWisp(&rng), pickup->pos, false, false);
|
|
pickup->Remove();
|
|
continue;
|
|
}
|
|
if (pickup->price != 0)
|
|
{
|
|
pickup->Morph(pickup->type, PICKUP_SHOPITEM, 0, true, false, false);
|
|
continue;
|
|
}
|
|
RNG rng = rng_make(pickup->initSeed, D20_REROLL_SHIFT);
|
|
bool isChest = Entity_Pickup::IsChest(pickup->variant);
|
|
if ((!isChest || rng.RandomInt(D20_CHEST_KEEP_ODDS) == 0) && rng.RandomInt(D20_OTHER_ODDS) != 0)
|
|
pickup->Morph(pickup->type, 0, 0, true, false, false);
|
|
else
|
|
{
|
|
int chest = rng.RandomInt(D20_LOCKED_CHEST_ODDS) != 0 ? PICKUP_CHEST : PICKUP_LOCKEDCHEST;
|
|
pickup->Morph(pickup->type, chest, 0, true, false, false);
|
|
}
|
|
}
|
|
}
|
|
dice_end(use);
|
|
}
|
|
|
|
// Whether Dad's Key opens a door: not a mirror, a photo door or the Mom's Heart exit, nor a barred mineshaft.
|
|
static bool is_dads_key_door(GridEntity_Door& door)
|
|
{
|
|
if (door.doorFlags & (DOOR_FLAG_MIRROR | DOOR_FLAG_PHOTO)) return false;
|
|
if ((door.doorFlags & DOOR_FLAG_MINESHAFT) && door.variant == DOOR_LOCKED_BARRED) return false;
|
|
return door.get_secret_exit_kind() != SECRET_EXIT_MOMS_HEART;
|
|
}
|
|
|
|
// Dad's Key: every door of the room unlocked or forced open, for the room.
|
|
static void dads_key_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant == PLAYER_VARIANT_PLAYER)
|
|
{
|
|
sound_play(SOUND_GOLDENKEY);
|
|
for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++)
|
|
{
|
|
GridEntity_Door* door = g_game->room->GetDoor(slot);
|
|
if (!door || !is_dads_key_door(*door) || door->TryUnlock(player, true)) continue;
|
|
door->Open();
|
|
door->TryBlowOpen(false, nullptr);
|
|
}
|
|
g_game->room->temporaryEffects.AddCollectibleEffect(use.id, true, 1);
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// The Portable Slot's coins: one or two, each with a wisp for Book of Virtues.
|
|
static void portable_slot_coins(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
|
|
sound_play(SOUND_PORTABLE_SLOT_WIN);
|
|
for (int i = std::max(random_below(3), 1); i > 0; i--)
|
|
{
|
|
pickup_spawn(player, PICKUP_COIN, 0, Random());
|
|
if (is_wisp_use(use)) player.AddWisp(use.id, player.pos, false, false);
|
|
}
|
|
}
|
|
|
|
// The Portable Slot: a coin for a slot machine's roll (Lucky Foot's luckier one). It pays a fly or pretty fly, a
|
|
// bomb, a heart, a key, a pill or coins, or nothing with a sad face. Daemon's Tail turns most hearts into coins.
|
|
static void portable_slot_use(ItemUse& use)
|
|
{
|
|
constexpr int SLOT_FLY = 3;
|
|
constexpr int SLOT_BOMB = 4;
|
|
constexpr int SLOT_HEART = 5;
|
|
constexpr int SLOT_HEART_TOO = 6;
|
|
constexpr int SLOT_KEY = 7;
|
|
constexpr int SLOT_PILL = 8;
|
|
constexpr int SLOT_SKIPPED = 9;
|
|
constexpr int SLOT_COINS_FIRST = 10;
|
|
constexpr int SLOT_COINS_LAST = 12;
|
|
|
|
struct SlotPrize
|
|
{
|
|
int outcome = 0;
|
|
int variant = 0;
|
|
int wisp = 0;
|
|
};
|
|
constexpr SlotPrize PRIZES[] = {{SLOT_BOMB, PICKUP_BOMB, COLLECTIBLE_MR_BOOM},
|
|
{SLOT_HEART, PICKUP_HEART, COLLECTIBLE_YUM_HEART},
|
|
{SLOT_HEART_TOO, PICKUP_HEART, COLLECTIBLE_YUM_HEART},
|
|
{SLOT_KEY, PICKUP_KEY, COLLECTIBLE_DADS_KEY},
|
|
{SLOT_PILL, PICKUP_PILL, COLLECTIBLE_MOMS_BOTTLE_OF_PILLS}};
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER || player.numCoins < 1) return;
|
|
|
|
player.AnimateCollectible(use.id, "UseItem", "PlayerPickupSparkle");
|
|
player.AddCoins(-1);
|
|
sound_play_local(player, SOUND_PORTABLE_SLOT_USE);
|
|
int roll = random_below(player.HasCollectible(COLLECTIBLE_LUCKY_FOOT) ? 15 : 21);
|
|
int outcome = roll + SLOT_FLY < SLOT_SKIPPED ? roll + SLOT_FLY : roll + SLOT_FLY + 1;
|
|
bool isCoins = outcome >= SLOT_COINS_FIRST && outcome <= SLOT_COINS_LAST;
|
|
if (outcome == SLOT_KEY) isCoins = random_below(3) == 0;
|
|
else if ((outcome == SLOT_HEART || outcome == SLOT_HEART_TOO) && player.HasTrinket(TRINKET_DAEMONS_TAIL))
|
|
isCoins = player.GetTrinketRNG(TRINKET_DAEMONS_TAIL).RandomInt(DAEMONS_TAIL_ODDS) != 0;
|
|
if (isCoins) return portable_slot_coins(use);
|
|
|
|
if (outcome == SLOT_FLY && random_below(3) != 0)
|
|
{
|
|
uint32_t seed = Random();
|
|
Vector position = room_free_pickup_position_find({.position = player.pos, .step = PICKUP_SPOT_STEP});
|
|
g_game->Spawn({.position = position, .type = ENTITY_FLY, .seed = seed});
|
|
return player.AnimateSad();
|
|
}
|
|
if (outcome == SLOT_FLY)
|
|
{
|
|
player.AddPrettyFly();
|
|
if (is_wisp_use(use))
|
|
for (int i = 0; i < 3; i++) player.AddWisp(COLLECTIBLE_GUPPYS_HEAD, player.pos, false, false);
|
|
return sound_play(SOUND_PORTABLE_SLOT_WIN);
|
|
}
|
|
const SlotPrize* prize = std::ranges::find(PRIZES, outcome, &SlotPrize::outcome);
|
|
if (prize == std::end(PRIZES)) return player.PlayExtraAnimation("Sad");
|
|
|
|
sound_play(SOUND_PORTABLE_SLOT_WIN);
|
|
pickup_spawn(player, prize->variant, 0, Random());
|
|
if (is_wisp_use(use)) player.AddWisp(prize->wisp, player.pos, false, false);
|
|
}
|
|
|
|
// Clear Rune: the held rune's effect copied (its charge taken from the rune), remembered for Wild Card.
|
|
static void clear_rune_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
int card = player.GetCard(0);
|
|
ItemConfig_Card* config = g_manager->itemConfig.GetCard(card);
|
|
if (player.variant == PLAYER_VARIANT_PLAYER && card != 0 && config && config->IsRune())
|
|
{
|
|
const ActiveUse& request = use.request;
|
|
if ((request.flags & USE_OWNED) && request.slot >= 0 && player.activeItems[request.slot].item == use.id)
|
|
player.activeItems[request.slot].varData = config->mimicCharge;
|
|
player.UseCard(card, USE_MIMIC | USE_NOANNOUNCER);
|
|
player.wildCardItemType = WILD_CARD_CARD;
|
|
player.wildCardItem = card;
|
|
player.wildCardVarData = 0;
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// How to Jump: a leap 60 frames along the player's way, pulled back off blocked cells and enemies onto free ground,
|
|
// or kept in place.
|
|
static void how_to_jump_use(ItemUse& use)
|
|
{
|
|
constexpr float JUMP_LOOKAHEAD = 60;
|
|
constexpr float JUMP_MARGIN = 20;
|
|
constexpr float JUMP_BACK_STEP = 10;
|
|
constexpr float JUMP_ENEMY_GAP = 5;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
|
|
Room& room = *g_game->room;
|
|
Vector target = room.GetClampedPosition(vector_add(player.pos, vector_scale(player.velocity, JUMP_LOOKAHEAD)),
|
|
JUMP_MARGIN);
|
|
Vector step = vector_sub(player.pos, target);
|
|
float remaining = vector_length(step);
|
|
step = vector_scale(vector_normalized(step), JUMP_BACK_STEP);
|
|
bool isFound = false;
|
|
while (remaining > 0 && !isFound)
|
|
{
|
|
if (room_grid_collision_at(target) != 0)
|
|
{
|
|
target = vector_add(target, step);
|
|
remaining -= vector_length(step);
|
|
continue;
|
|
}
|
|
isFound = true;
|
|
EntityList_EL& entities = room_entities();
|
|
for (size_t i = 0; i < entities.size(); i++)
|
|
{
|
|
Entity* enemy = entities[i];
|
|
float reach = enemy->size + player.size + JUMP_ENEMY_GAP;
|
|
if (!enemy->IsEnemy() || vector_length_squared(vector_sub(enemy->pos, target)) >= reach * reach) continue;
|
|
target = vector_add(target, step);
|
|
remaining -= vector_length(step);
|
|
isFound = false;
|
|
}
|
|
player.targetPosition = room.GetClampedPosition(target, JUMP_MARGIN);
|
|
player.velocity = {};
|
|
player.entityCollisionClass = ENTCOLL_NONE;
|
|
player.entityGridCollisionClass = GRIDCOLL_NONE;
|
|
}
|
|
if (remaining <= 0) player.targetPosition = player.pos;
|
|
sound_play(SOUND_HOW_TO_JUMP);
|
|
if (!player.canFly) player.PlayExtraAnimation("Jump");
|
|
}
|
|
|
|
// The D100: the D6, D20, D10, D12, D7, D8, D1 and D4 at once. Book of Virtues adds a wisp and rerolls the player's
|
|
// wisps.
|
|
static void d100_use(ItemUse& use)
|
|
{
|
|
constexpr int D100_DICE[] = {COLLECTIBLE_D6, COLLECTIBLE_D20, COLLECTIBLE_D10, COLLECTIBLE_D12,
|
|
COLLECTIBLE_D7, COLLECTIBLE_D8, COLLECTIBLE_D1, COLLECTIBLE_D4};
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant == PLAYER_VARIANT_PLAYER)
|
|
for (int die : D100_DICE) player.UseActiveItem({.item = die, .flags = USE_NOANIM});
|
|
if (is_wisp_use(use))
|
|
{
|
|
player.AddWisp(COLLECTIBLE_BOOK_OF_VIRTUES, player.pos, false, false);
|
|
for (Entity* entity : entity_query(ENTITY_FAMILIAR, Entity_Familiar::WISP))
|
|
{
|
|
Entity_Familiar* wisp = static_cast<Entity_Familiar*>(entity);
|
|
if (wisp->player == &player) wisp_reroll(*wisp, player.GetCollectibleRNG(use.id));
|
|
}
|
|
}
|
|
dice_end(use);
|
|
}
|
|
|
|
// The D4: the player's items rerolled (the actives too when the use asks to remove them). Book of Virtues trades every
|
|
// wisp for new ones, one for every second item in the history, twelve at most.
|
|
static void d4_use(ItemUse& use)
|
|
{
|
|
constexpr int D4_WISPS_MAX = 12;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (is_wisp_use(use))
|
|
{
|
|
for (Entity* wisp : entity_query(ENTITY_FAMILIAR, Entity_Familiar::WISP)) wisp->Remove();
|
|
int added = 0;
|
|
for (size_t i = 0; i < player.history.historyItems.size() && added < D4_WISPS_MAX; i += 2, added++)
|
|
player.AddWisp(Entity_Familiar::GetRandomWisp(&player.GetCollectibleRNG(COLLECTIBLE_D4)), player.pos, false,
|
|
false);
|
|
}
|
|
player.reroll_collectibles_on_damage(&player.GetCollectibleRNG(COLLECTIBLE_D4), use.request.flags & USE_REMOVEACTIVE);
|
|
dice_end(use);
|
|
}
|
|
|
|
// The D10: every living enemy that can devolves into a weaker one.
|
|
static void d10_use(ItemUse& use)
|
|
{
|
|
if (use.player.variant == PLAYER_VARIANT_PLAYER)
|
|
{
|
|
std::vector<EntityPtr> enemies;
|
|
for (Entity* entity : room_entities())
|
|
if (!entity->HasMortalDamage() && !entity->isDead && entity->CanDevolve()) enemies.emplace_back() = entity;
|
|
for (EntityPtr& enemy : enemies)
|
|
if (enemy) game_enemy_devolve(*enemy.get(), nullptr);
|
|
}
|
|
dice_end(use);
|
|
}
|
|
|
|
// Blank Card: the held card's effect copied (its charge taken from the card), remembered for Wild Card. A copied
|
|
// ? Card goes from the pockets, and not with the Void in the first slot. The Sun unlocks an achievement.
|
|
static void blank_card_use(ItemUse& use)
|
|
{
|
|
constexpr int ACHIEVEMENT_BLANK_CARD_SUN = 258;
|
|
|
|
Entity_Player& player = use.player;
|
|
int card = player.GetCard(0);
|
|
ItemConfig_Card* config = card ? g_manager->itemConfig.GetCard(card) : nullptr;
|
|
bool isVoidQuestion = card == CARD_QUESTIONMARK && player.activeItems[ACTIVE_SLOT_PRIMARY].item == COLLECTIBLE_VOID;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER || !config || isVoidQuestion || !config->IsCard())
|
|
return use_animate(use);
|
|
|
|
const ActiveUse& request = use.request;
|
|
if ((request.flags & USE_OWNED) && request.slot >= 0 && player.activeItems[request.slot].item == use.id)
|
|
player.activeItems[request.slot].varData = config->mimicCharge;
|
|
player.UseCard(card, USE_MIMIC | USE_NOANNOUNCER);
|
|
if (card == CARD_QUESTIONMARK)
|
|
{
|
|
std::shift_left(player.pocketItems.begin(), player.pocketItems.end(), 1);
|
|
player.pocketItems.back() = {.type = player.pocketItems[POCKET_SLOT_COUNT - 2].type};
|
|
use.isLuaAnimationAllowed = false;
|
|
return;
|
|
}
|
|
if (card != CARD_WILD)
|
|
{
|
|
player.wildCardItemType = WILD_CARD_CARD;
|
|
player.wildCardItem = card;
|
|
player.wildCardVarData = 0;
|
|
}
|
|
if (card == CARD_SUN) g_manager->persistentGameData.TryUnlock(ACHIEVEMENT_BLANK_CARD_SUN);
|
|
use_animate(use);
|
|
}
|
|
|
|
// The Book of Secrets: one of the map effects the floor lacks (blue map, compass, map), or the whole floor when it has
|
|
// them all. Its room effect lasts 45 frames.
|
|
static void book_of_secrets_use(ItemUse& use)
|
|
{
|
|
constexpr uint32_t SECRETS_PICK_SHIFT = 35;
|
|
constexpr int SECRETS_EFFECT_FRAMES = 45;
|
|
constexpr LevelStateFlag SECRETS_FLAGS[] = {LEVEL_STATE_BLUE_MAP_EFFECT, LEVEL_STATE_COMPASS_EFFECT,
|
|
LEVEL_STATE_MAP_EFFECT};
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant == PLAYER_VARIANT_PLAYER)
|
|
{
|
|
WeightedOutcomePicker picker;
|
|
for (int i = 0; i < 3; i++)
|
|
if (!g_game->Level::GetStateFlag(SECRETS_FLAGS[i])) picker.AddOutcomeWeight(i, 1);
|
|
if (picker.outcomes.empty())
|
|
{
|
|
g_game->isCanSeeEverything = true;
|
|
g_game->UpdateVisibility();
|
|
}
|
|
else
|
|
{
|
|
int pick = picker.PickOutcome(rng_make(player.GetCollectibleRNG(use.id).Next(), SECRETS_PICK_SHIFT));
|
|
if (pick == 0) g_game->ApplyBlueMapEffect();
|
|
else if (pick == 1) g_game->ApplyCompassEffect(true);
|
|
else g_game->ApplyMapEffect();
|
|
}
|
|
TemporaryEffect effect(g_manager->itemConfig.GetCollectible(COLLECTIBLE_BOOK_OF_SECRETS));
|
|
effect.cooldown = SECRETS_EFFECT_FRAMES;
|
|
g_game->room->temporaryEffects.AddEffect(effect, true, 1);
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// Box of Spiders: four to eight blue spiders, or as many wisps with Book of Virtues.
|
|
static void box_of_spiders_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant == PLAYER_VARIANT_PLAYER)
|
|
for (int i = random_below(5) + 4; i > 0; i--)
|
|
{
|
|
if (is_wisp_use(use))
|
|
{
|
|
player.AddWisp(use.id, player.pos, false, false);
|
|
continue;
|
|
}
|
|
player.ThrowBlueSpider(player.pos, {});
|
|
sound_play(SOUND_BOX_SPIDERS);
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// Judas' Birthright on The Jar: up to two of its hearts as a pool of blood creep and a burst, sized by them.
|
|
static void jar_belial_spill(Entity_Player& player, int hearts)
|
|
{
|
|
constexpr float JAR_SCALE_PER_HEART = 0.25f;
|
|
constexpr float JAR_SCALE_BASE = 0.5f;
|
|
constexpr float JAR_CREEP_SCALE = 3;
|
|
constexpr int JAR_CREEP_FRAMES = 450;
|
|
constexpr float JAR_BURST_LARGE = 0.75f;
|
|
|
|
player.trigger_book_of_belial_passive(COLLECTIBLE_THE_JAR, hearts);
|
|
float scale = hearts * JAR_SCALE_PER_HEART + JAR_SCALE_BASE;
|
|
Entity_Effect* creep = static_cast<Entity_Effect*>(
|
|
g_game->Spawn({.position = player.pos, .spawner = &player, .type = ENTITY_EFFECT,
|
|
.variant = EFFECT_PLAYER_CREEP_RED, .seed = Random()}));
|
|
creep->sprite.scale = vector_make(scale * JAR_CREEP_SCALE, scale * JAR_CREEP_SCALE);
|
|
creep->SetTimeout(JAR_CREEP_FRAMES);
|
|
creep->Update();
|
|
|
|
Entity_Effect* burst = static_cast<Entity_Effect*>(
|
|
effect_spawn(EFFECT_BLOOD_EXPLOSION, player.pos, {}, (hearts > JAR_BURST_LARGE) + BLOOD_EXPLOSION_LARGE));
|
|
burst->rotation = random_unit() * FULL_TURN_DEGREES;
|
|
burst->sprite.scale = vector_make(scale, scale);
|
|
burst->Update();
|
|
}
|
|
|
|
// The Jar: the hearts it collected let out as full and half hearts, Judas' Birthright spilling two of them as blood
|
|
// from the first slot, Book of Virtues a wisp for each full heart (a half-health one for a half).
|
|
static void jar_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
int slot = use.request.slot;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER || player.jarHearts <= 0) return;
|
|
|
|
g_pickupIgnoreModifiers++;
|
|
int hearts = player.jarHearts;
|
|
bool isDrop = true;
|
|
if (slot == ACTIVE_SLOT_PRIMARY)
|
|
{
|
|
if (player.HasCollectible(COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE))
|
|
{
|
|
hearts = std::min(hearts, 2);
|
|
jar_belial_spill(player, hearts);
|
|
isDrop = false;
|
|
}
|
|
if (is_wisp_use(use))
|
|
{
|
|
for (int i = hearts / 2; i > 0; i--) player.AddWisp(use.id, player.pos, false, false);
|
|
Entity_Familiar* half = hearts % 2 ? player.AddWisp(use.id, player.pos, false, false) : nullptr;
|
|
if (half) half->health = half->maxHitPoints / 2;
|
|
isDrop = false;
|
|
}
|
|
}
|
|
for (int i = isDrop ? hearts : 0; i > 0; i -= 2)
|
|
{
|
|
Vector position = room_free_pickup_position_find({.position = player.pos, .step = PICKUP_SPOT_STEP});
|
|
Entity* heart = g_game->Spawn({.position = position, .spawner = &player, .subType = i > 1 ? HEART_FULL : HEART_HALF,
|
|
.type = ENTITY_PICKUP, .variant = PICKUP_HEART, .seed = Random()});
|
|
static_cast<Entity_Pickup*>(heart)->isTouched = true;
|
|
}
|
|
player.jarHearts -= hearts;
|
|
use_animate(use);
|
|
g_pickupIgnoreModifiers--;
|
|
}
|
|
// Whether an enemy is made of poop (dips, squirts, Dingas, Dingles, Brownies, drips, splurts, clogs and Turdlings).
|
|
static bool is_poop_enemy(Entity& npc)
|
|
{
|
|
constexpr int POOP_ENEMIES[] = {ENTITY_DIP, ENTITY_SQUIRT, ENTITY_DINGA, ENTITY_DINGLE, ENTITY_BROWNIE,
|
|
ENTITY_DRIP, ENTITY_SPLURT, ENTITY_CLOG, ENTITY_CLOGGY};
|
|
|
|
return std::ranges::find(POOP_ENEMIES, npc.type) != std::end(POOP_ENEMIES) ||
|
|
(npc.type == ENTITY_GURGLING && npc.variant == GURGLING_TURDLING);
|
|
}
|
|
|
|
// The Flush: a poop enemy dies (a poop boss breaks into up to six dips by its health left), any other enemy that may be
|
|
// rerolled turns into poop. Book of Virtues adds a wisp for each. The room is flooded for its effect.
|
|
static void flush_npc(ItemUse& use, Entity_NPC& npc)
|
|
{
|
|
constexpr float FLUSH_DIPS_MAX = 6;
|
|
constexpr int DIP_CORNY = 2;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (is_poop_enemy(npc))
|
|
{
|
|
npc.KillUnique();
|
|
if (!npc.IsBoss()) return;
|
|
int dips = (int)lerp_range(npc.health, {0, npc.maxHitPoints, 0, FLUSH_DIPS_MAX});
|
|
bool isCorny = (npc.type == ENTITY_DINGLE && npc.variant == DANGLE) || npc.type == ENTITY_BROWNIE;
|
|
for (int i = 0; i < dips; i++)
|
|
{
|
|
uint32_t seed = Random();
|
|
Vector offset = vector_scale(vector_scale(random_direction(), random_unit()), npc.size);
|
|
g_game->Spawn({.position = vector_add(npc.pos, offset), .spawner = &player, .type = ENTITY_DIP,
|
|
.variant = isCorny ? DIP_CORNY : 0, .seed = seed});
|
|
}
|
|
return;
|
|
}
|
|
bool isPoopable = npc.type != ENTITY_POOP && npc.type != ENTITY_CHUB && npc.type != ENTITY_MOMS_HAND;
|
|
if (!isPoopable || !npc.IsVulnerableEnemy(nullptr) || !npc.CanReroll()) return;
|
|
|
|
npc.Remove();
|
|
Entity* poop = g_game->Spawn({.position = npc.pos, .type = ENTITY_POOP, .seed = Random()});
|
|
poop->splatColor = FLUSH_POOP_COLOR;
|
|
if (is_wisp_use(use)) player.AddWisp(use.id, player.pos, false, false);
|
|
if (npc.minecart) static_cast<Entity_NPC*>(npc.minecart.get())->MinecartUpdateChild(poop);
|
|
}
|
|
|
|
// The Flush: the room flooded for its effect, and every enemy flushed but the friendly ones. The other versus players
|
|
// take 30.
|
|
static void flush_use(ItemUse& use)
|
|
{
|
|
constexpr float FLUSH_VERSUS_DAMAGE = 30;
|
|
constexpr int FLUSH_VERSUS_COUNTDOWN = 30;
|
|
Entity_Player& player = use.player;
|
|
if (player.variant == PLAYER_VARIANT_PLAYER)
|
|
{
|
|
g_game->room->temporaryEffects.AddCollectibleEffect(use.id, true, 1);
|
|
sound_play(SOUND_FLUSH);
|
|
EntityList_EL entities = room_entities();
|
|
for (size_t i = 0; i < entities.size(); i++)
|
|
{
|
|
Entity_NPC* npc = dynamic_cast<Entity_NPC*>(entities[i]);
|
|
if (npc && npc->HasEntityFlags(FLAG_FRIENDLY)) continue;
|
|
if (entities[i]->is_player() && entities[i] != &player && g_game->deathmatchManager.is_active())
|
|
{
|
|
entities[i]->TakeDamage(FLUSH_VERSUS_DAMAGE, 0, EntityRef(), FLUSH_VERSUS_COUNTDOWN);
|
|
continue;
|
|
}
|
|
if (npc) flush_npc(use, *npc);
|
|
}
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// The Satanic Bible: two black hearts, and the floor's boss reward becomes a devil deal.
|
|
static void satanic_bible_use(ItemUse& use)
|
|
{
|
|
if (use.player.variant == PLAYER_VARIANT_PLAYER) use.player.AddBlackHearts(2);
|
|
sound_play(SOUND_SATANIC_BIBLE);
|
|
use_animate(use);
|
|
g_game->Level::SetStateFlag(LEVEL_STATE_SATANIC_BIBLE_USED, true);
|
|
}
|
|
|
|
// Head of Krampus: four thick brimstone beams out of the player's head, the upward one drawn behind it.
|
|
static void head_of_krampus_use(ItemUse& use)
|
|
{
|
|
const Vector KRAMPUS_DIRECTIONS[] = {vector_make(1, 0), vector_make(0, 1), vector_make(-1, 0), vector_make(0, -1)};
|
|
const Vector KRAMPUS_HEAD = vector_make(0, -20);
|
|
constexpr float KRAMPUS_REACH = 10;
|
|
constexpr int KRAMPUS_TIMEOUT = 31;
|
|
constexpr float KRAMPUS_DAMAGE = 10;
|
|
constexpr float KRAMPUS_VERSUS_DAMAGE = 3.5f;
|
|
constexpr float KRAMPUS_DEPTH_FRONT = 3000;
|
|
constexpr float KRAMPUS_DEPTH_BEHIND = -10;
|
|
|
|
Entity_Player& player = use.player;
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
Vector direction = KRAMPUS_DIRECTIONS[i];
|
|
Vector offset = vector_add(KRAMPUS_HEAD, vector_scale(direction, KRAMPUS_REACH));
|
|
Entity_Laser* laser = Entity_Laser::ShootAngle({.position = vector_add(player.pos, offset),
|
|
.posOffset = KRAMPUS_HEAD,
|
|
.source = &player,
|
|
.angleDegrees = i * QUARTER_TURN_DEGREES,
|
|
.timeout = KRAMPUS_TIMEOUT,
|
|
.variant = LASER_THICK_RED});
|
|
laser->renderDepthOffset = direction.y >= 0 ? KRAMPUS_DEPTH_FRONT : KRAMPUS_DEPTH_BEHIND;
|
|
laser->SetCollisionDamage(g_game->deathmatchManager.is_active() ? KRAMPUS_VERSUS_DAMAGE : KRAMPUS_DAMAGE);
|
|
laser->Update();
|
|
}
|
|
use.isLuaAnimationAllowed = false;
|
|
if (!use.isShowAnimation) return;
|
|
player.AnimateCollectible(use.id, "Pickup", "PlayerPickupSparkle");
|
|
use.isLuaAnimationAllowed = true;
|
|
}
|
|
|
|
// Magic Fingers: a coin for twice the player's damage plus 10 to every enemy, the screen shaken.
|
|
static void magic_fingers_use(ItemUse& use)
|
|
{
|
|
constexpr float MAGIC_FINGERS_BONUS = 10;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER || player.numCoins <= 0) return;
|
|
|
|
sound_play(SOUND_ROCK_CRUMBLE);
|
|
player.AddCoins(-1);
|
|
game_shake_screen(NECRONOMICON_SHAKE);
|
|
EntityList_EL& entities = room_entities();
|
|
for (size_t i = 0; i < entities.size(); i++)
|
|
{
|
|
Entity* entity = entities[i];
|
|
if (!entity->IsVulnerableEnemy(nullptr) || entity == &player) continue;
|
|
float bonus = g_game->deathmatchManager.is_active() ? 0 : MAGIC_FINGERS_BONUS;
|
|
entity->TakeDamage(player.damage * 2 + bonus, 0, EntityRef(&player), DAMAGE_COUNTDOWN_FRAMES);
|
|
}
|
|
if (is_wisp_use(use)) player.AddWisp(use.id, player.pos, false, false);
|
|
use_animate(use);
|
|
}
|
|
|
|
// The Converter: a soul heart's worth (its black hearts firing the Necronomicon) traded for a red heart container,
|
|
// or a bone heart for the Forgotten's soul. Without two soul hearts it keeps its charge.
|
|
static void converter_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
if (player.soulHearts < 2)
|
|
{
|
|
use.result.isDischarge = false;
|
|
return;
|
|
}
|
|
|
|
int soulHearts = player.soulHearts;
|
|
for (int heart = soulHearts; soulHearts - 2 < heart; heart--)
|
|
{
|
|
if (player.IsBlackHeart(heart))
|
|
{
|
|
player.RemoveBlackHeart(heart);
|
|
player.UseActiveItem({.item = COLLECTIBLE_NECRONOMICON, .flags = USE_NOANIM});
|
|
}
|
|
soulHearts = player.soulHearts;
|
|
}
|
|
player.soulHearts = soulHearts - 2;
|
|
if (player.playerType == PLAYER_THEFORGOTTEN && player.subPlayer)
|
|
{
|
|
player.subPlayer->AddBoneHearts(1);
|
|
if (player.soulHearts < 1) player.SwapForgottenForm(false, false);
|
|
}
|
|
else player.AddMaxHearts(2, false);
|
|
player.AddHearts(2, false, false);
|
|
if (is_wisp_use(use)) player.AddWisp(use.id, player.pos, false, false);
|
|
use_animate(use);
|
|
sound_play(SOUND_CONVERTER);
|
|
}
|
|
// FUN_0067d9b0 The blood look of a tear variant (Judas' Birthright's tears), or the same one when it has none.
|
|
int tear_variant_blood(int variant)
|
|
{
|
|
switch (variant)
|
|
{
|
|
case TEAR_BLUE:
|
|
return TEAR_BLOOD;
|
|
case TEAR_CUPID_BLUE:
|
|
return TEAR_CUPID_BLOOD;
|
|
case TEAR_NAIL:
|
|
return TEAR_NAIL_BLOOD;
|
|
case TEAR_PUPULA:
|
|
return TEAR_PUPULA_BLOOD;
|
|
case TEAR_GODS_FLESH:
|
|
return TEAR_GODS_FLESH_BLOOD;
|
|
case TEAR_GLAUCOMA:
|
|
return TEAR_GLAUCOMA_BLOOD;
|
|
case TEAR_EYE:
|
|
return TEAR_EYE_BLOOD;
|
|
default:
|
|
return variant;
|
|
}
|
|
}
|
|
|
|
// Judas' Birthright on a burst of tears: blood tears that pierce and fly through walls.
|
|
static void tear_belial_apply(Entity_Tear& tear)
|
|
{
|
|
int variant = tear_variant_blood(tear.variant);
|
|
if (variant != tear.variant) tear.ChangeVariant(variant);
|
|
tear.SetTearFlags(tear.tearFlags | TearFlags().set(TEAR_PIERCING) | TearFlags().set(TEAR_SPECTRAL));
|
|
}
|
|
|
|
// Isaac's Tears: a ring of eight tears with 5 bonus damage (ten with 10 and Judas' Birthright's blood tears). Book of
|
|
// Virtues trades the player's wisps for them instead, the Birthright firing anyway.
|
|
static void isaacs_tears_use(ItemUse& use)
|
|
{
|
|
constexpr float ISAACS_TEARS_SPEED = 10;
|
|
|
|
Entity_Player& player = use.player;
|
|
bool isBelial = player.HasCollectible(COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE);
|
|
if (is_wisp_use(use))
|
|
for (Entity* wisp : entity_query(ENTITY_FAMILIAR, Entity_Familiar::WISP))
|
|
if (static_cast<Entity_Familiar*>(wisp)->player == &player) wisp->Remove();
|
|
if (!is_wisp_use(use) || isBelial)
|
|
{
|
|
int count = isBelial ? 10 : 8;
|
|
float bonus = isBelial ? 10 : 5;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
float angle = (float)i / (float)count * PI_F * 2;
|
|
Vector velocity = vector_scale(vector_make(std::cos(angle), std::sin(angle)), ISAACS_TEARS_SPEED);
|
|
Entity_Tear* tear =
|
|
player.FireTear({player.pos, velocity}, TEAR_FIRE_EXTRA_SHOT, nullptr, isBelial ? BELIAL_DAMAGE_SCALE : 1);
|
|
if (isBelial)
|
|
{
|
|
tear_belial_apply(*tear);
|
|
tear->SetScale(tear->fScale + BELIAL_TEAR_SCALE_BONUS);
|
|
}
|
|
tear->SetCollisionDamage(tear->collisionDamage + bonus);
|
|
}
|
|
}
|
|
use.isLuaAnimationAllowed = false;
|
|
if (!use.isShowAnimation) return;
|
|
player.AnimateCollectible(use.id, "HideItem", "PlayerPickupSparkle");
|
|
use.isLuaAnimationAllowed = true;
|
|
}
|
|
|
|
// The Scissors: the head comes off in a burst of blood and fights on for the room (its room effect).
|
|
static void scissors_use(ItemUse& use)
|
|
{
|
|
if (use.player.variant == PLAYER_VARIANT_PLAYER) blood_burst_spawn(use.player);
|
|
}
|
|
|
|
// Placebo: the held pill's effect copied without using it up (its charge taken from the pill), remembered for Wild
|
|
// Card, and the player's farting babies fart.
|
|
static void placebo_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
int pill = player.GetPill(0);
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
if (pill == 0) return use_animate(use);
|
|
|
|
sound_play(SOUND_MOM_BOTTLE);
|
|
for (Entity* entity : entity_query(ENTITY_FAMILIAR, -1))
|
|
{
|
|
Entity_Familiar* familiar = static_cast<Entity_Familiar*>(entity);
|
|
if (familiar->player == &player) familiar->farting_baby_fart();
|
|
}
|
|
int effect = g_game->itemPool.GetPillEffect(pill, &player);
|
|
ItemConfig_Pill* config = g_manager->itemConfig.GetPillEffect(effect);
|
|
const ActiveUse& request = use.request;
|
|
if ((request.flags & USE_OWNED) && request.slot >= 0 && player.activeItems[request.slot].item == use.id && config)
|
|
player.activeItems[request.slot].varData = config->mimicCharge;
|
|
player.UsePill(effect, pill, USE_MIMIC | USE_NOANNOUNCER);
|
|
player.wildCardItemType = WILD_CARD_PILL;
|
|
player.wildCardItem = effect;
|
|
player.wildCardVarData = pill;
|
|
use_animate(use);
|
|
}
|
|
|
|
// Wooden Nickel: a penny 52 times in 100, a nickel 6 times, a dime twice.
|
|
static void wooden_nickel_use(ItemUse& use)
|
|
{
|
|
constexpr int WOODEN_NICKEL_ROLL = 100;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
|
|
sound_play(SOUND_WOODEN_NICKEL);
|
|
int roll = (int)player.GetCollectibleRNG(use.id).RandomInt(WOODEN_NICKEL_ROLL);
|
|
int coin = roll < 52 ? COIN_PENNY : roll < 58 ? COIN_NICKEL : roll < 60 ? COIN_DIME : 0;
|
|
if (coin)
|
|
{
|
|
pickup_spawn(player, PICKUP_COIN, coin, Random());
|
|
sound_play(SOUND_WOODEN_NICKEL_SPAWN);
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// Mega Bean's wisps for Book of Virtues: each of its living wisps lets out its own blast, turned at random.
|
|
static void mega_bean_wisps_blast()
|
|
{
|
|
for (Entity* entity : entity_query(ENTITY_FAMILIAR, Entity_Familiar::WISP))
|
|
{
|
|
Entity_Familiar* wisp = static_cast<Entity_Familiar*>(entity);
|
|
if (wisp->isDead || wisp->subtype != COLLECTIBLE_MEGA_BEAN) continue;
|
|
|
|
Entity_Effect* blast = static_cast<Entity_Effect*>(g_game->Spawn(
|
|
{.position = wisp->pos, .spawner = wisp->player, .type = ENTITY_EFFECT, .variant = EFFECT_CRACKWAVE, .seed = Random()}));
|
|
blast->parent = wisp;
|
|
blast->rotation = normalize_angle_degrees(random_unit() * FULL_TURN_DEGREES);
|
|
}
|
|
}
|
|
|
|
// Mega Bean: a huge poison fart and push, and the ground cracking out from the player.
|
|
static void mega_bean_use(ItemUse& use)
|
|
{
|
|
constexpr float MEGA_BEAN_FART_RADIUS = 160;
|
|
constexpr float MEGA_BEAN_FART_SCALE = 2;
|
|
constexpr float MEGA_BEAN_PUSH_RADIUS = 200;
|
|
|
|
Entity_Player& player = use.player;
|
|
game_fart({.position = player.pos, .source = &player, .radius = MEGA_BEAN_FART_RADIUS, .scale = MEGA_BEAN_FART_SCALE});
|
|
game_butter_bean_fart(
|
|
{.position = player.pos, .source = &player, .radius = MEGA_BEAN_PUSH_RADIUS, .isShowEffect = false});
|
|
Entity* crack = g_game->Spawn({.position = player.pos, .spawner = &player, .type = ENTITY_EFFECT,
|
|
.variant = EFFECT_MEGA_BEAN_EXPLOSION, .seed = Random()});
|
|
crack->targetPosition = player.pos;
|
|
crack->Update();
|
|
if (is_wisp_use(use)) mega_bean_wisps_blast();
|
|
use.isLuaAnimationAllowed = false;
|
|
if (!use.isShowAnimation) return;
|
|
player.AnimateCollectible(use.id, "UseItem", "PlayerPickupSparkle");
|
|
use.isLuaAnimationAllowed = true;
|
|
}
|
|
|
|
// Box of Friends: a copy of every familiar the player has for the room, the unique ones left out, up to 60 familiars
|
|
// in the room; with none a Demon Baby. Book of Virtues copies every wisp too, and adds its own, none of them counted as followers.
|
|
static void box_of_friends_use(ItemUse& use)
|
|
{
|
|
constexpr int FAMILIARS_MAX = 60;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
|
|
ItemConfig& config = g_manager->itemConfig;
|
|
int familiars = (int)std::ranges::count(room_entities(), (int)ENTITY_FAMILIAR, &Entity::type);
|
|
bool isFound = false;
|
|
for (int id = 1; id < (int)config.collectibles.size(); id++)
|
|
{
|
|
ItemConfig_Item* item = config.collectibles[id].get();
|
|
if (!item || (item->tags & TAG_UNIQUE_FAMILIAR) || player.GetCollectibleNum(id) <= 0) continue;
|
|
if (!ItemConfig::IsValidCollectible(id) || !config.GetCollectible(id) || config.GetCollectible(id)->type != ITEM_FAMILIAR)
|
|
continue;
|
|
if (++familiars > FAMILIARS_MAX) break;
|
|
player.temporaryEffects.AddCollectibleEffect(id, true, 1);
|
|
isFound = true;
|
|
}
|
|
if (!isFound && familiars < FAMILIARS_MAX) player.temporaryEffects.AddCollectibleEffect(COLLECTIBLE_DEMON_BABY, true, 1);
|
|
use_animate(use);
|
|
if (is_wisp_use(use))
|
|
{
|
|
for (Entity* wisp : entity_query(ENTITY_FAMILIAR, Entity_Familiar::WISP))
|
|
if (Entity_Familiar* copy = player.AddWisp(wisp->subtype, player.pos, false, false))
|
|
copy->isNotCountedAsFollower = true;
|
|
if (Entity_Familiar* own = player.AddWisp(use.id, player.pos, false, false)) own->isNotCountedAsFollower = true;
|
|
}
|
|
sound_play(SOUND_BOX_OF_FRIENDS);
|
|
}
|
|
|
|
// Tear Detonator: every tear bursts into six in a ring turned at random (Judas' Birthright's blood tears with 5 bonus
|
|
// damage), aimed back where it was.
|
|
static void tear_detonator_use(ItemUse& use)
|
|
{
|
|
constexpr float DETONATOR_STEP = 60;
|
|
constexpr float DETONATOR_SPEED = 10;
|
|
constexpr float DETONATOR_BELIAL_BONUS = 5;
|
|
|
|
Entity_Player& player = use.player;
|
|
bool isBelial = player.HasCollectible(COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE);
|
|
for (Entity* tear : entity_query(ENTITY_TEAR, -1))
|
|
{
|
|
if (tear->isDead) continue;
|
|
sound_play(SOUND_TEAR_DETONATOR);
|
|
tear->Remove();
|
|
float turn = random_unit() * FULL_TURN_DEGREES - FULL_TURN_DEGREES / 2;
|
|
for (float angle = 0; angle < FULL_TURN_DEGREES; angle += DETONATOR_STEP)
|
|
{
|
|
Vector velocity = vector_scale(vector_from_angle(angle + turn), player.shotSpeed * DETONATOR_SPEED);
|
|
Entity_Tear* shard =
|
|
player.FireTear({tear->pos, velocity}, TEAR_FIRE_EXTRA_SHOT, nullptr, isBelial ? BELIAL_DAMAGE_SCALE : 1);
|
|
shard->targetPosition = tear->pos;
|
|
if (!isBelial) continue;
|
|
tear_belial_apply(*shard);
|
|
shard->SetCollisionDamage(shard->collisionDamage + DETONATOR_BELIAL_BONUS);
|
|
shard->SetScale(shard->fScale + BELIAL_TEAR_SCALE_BONUS);
|
|
}
|
|
}
|
|
use_animate(use);
|
|
}
|
|
// Undefined: a teleport to a random treasure, secret or super secret room of the floor, or the I AM ERROR room (and,
|
|
// once in 100, the black market) when there is a next floor.
|
|
static void undefined_use(ItemUse& use)
|
|
{
|
|
constexpr int UNDEFINED_ROOM_TYPES[] = {ROOM_TREASURE, ROOM_SECRET, ROOM_SUPERSECRET};
|
|
constexpr int UNDEFINED_BLACK_MARKET_ODDS = 100;
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
|
|
Game& game = *g_game;
|
|
RNG& rng = player.GetCollectibleRNG(use.id);
|
|
std::set<int> seen;
|
|
std::vector<int> rooms;
|
|
for (int i = 0; i < game.nbRooms; i++)
|
|
{
|
|
RoomDescriptor& room = game.roomList[i];
|
|
if (!room.data || room.dimension != game.currentDimensionIdx) continue;
|
|
if (std::ranges::find(UNDEFINED_ROOM_TYPES, room.data->type) == std::end(UNDEFINED_ROOM_TYPES)) continue;
|
|
if (seen.insert(room.gridIndex).second) rooms.push_back(room.gridIndex);
|
|
}
|
|
if (game.IsNextStageAvailable())
|
|
{
|
|
if (game.GetRoomByIdx(ROOM_ERROR_IDX)->data) rooms.push_back(ROOM_ERROR_IDX);
|
|
if (rng.RandomInt(UNDEFINED_BLACK_MARKET_ODDS) == 0 && game.GetRoomByIdx(ROOM_BLACK_MARKET_IDX)->data)
|
|
rooms.push_back(ROOM_BLACK_MARKET_IDX);
|
|
}
|
|
if (rooms.empty()) return;
|
|
|
|
int roomIndex = rooms[rng.RandomInt((uint32_t)rooms.size())];
|
|
game.StartRoomTransition({.player = &player, .animation = TRANSITION_TELEPORT, .dimension = roomIndex < 0 ? 0 : -1,
|
|
.roomIndex = roomIndex});
|
|
sound_play(SOUND_TELEPORT_UNDEFINED);
|
|
}
|
|
|
|
// Ventricle Razor: a portal on a free cell under the player, the older of the pair moved here (each pair a portal
|
|
// back and forth), with a burst of blood in its colour.
|
|
static void ventricle_razor_use(ItemUse& use)
|
|
{
|
|
constexpr ColorMod PORTAL_ORANGE_COLOR = {{0, 0, 0, 1}, {0, 0, 0, 0}, {84 / 255.0f, 49 / 255.0f, 14 / 255.0f}};
|
|
constexpr ColorMod PORTAL_BLUE_COLOR = {{0, 0, 0, 1}, {0, 0, 0, 0}, {14 / 255.0f, 56 / 255.0f, 86 / 255.0f}};
|
|
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
|
|
int portal = player.ventricleRazorPortal;
|
|
sound_play(SOUND_VENTRICLE_RAZOR);
|
|
for (Entity* old : entity_query(ENTITY_EFFECT, EFFECT_WOMB_TELEPORT))
|
|
if (old->subtype == portal) old->isDead = true;
|
|
Vector position = room_free_pickup_position_find({.position = player.pos});
|
|
g_game->ventricleRazorPortals[portal] = {.gridIndex = g_game->room->GetGridIndex(position),
|
|
.roomIndex = g_game->currentRoomIdx,
|
|
.isMarked = is_wisp_use(use)};
|
|
g_game->Spawn({.position = position, .spawner = &player, .subType = portal, .type = ENTITY_EFFECT,
|
|
.variant = EFFECT_WOMB_TELEPORT, .seed = Random()})
|
|
->Update();
|
|
|
|
Entity* burst = effect_spawn(EFFECT_BLOOD_EXPLOSION, position, {}, BLOOD_EXPLOSION_LARGE);
|
|
burst->subtype = 0;
|
|
burst->SetColor(portal ? PORTAL_ORANGE_COLOR : PORTAL_BLUE_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
|
burst->sprite.rotation = random_below(4) * QUARTER_TURN_DEGREES;
|
|
burst->Update();
|
|
sound_play(SOUND_MEAT_JUMPS);
|
|
player.ventricleRazorPortal = (portal + 1) % VENTRICLE_RAZOR_PORTAL_COUNT;
|
|
use_animate(use);
|
|
}
|
|
// Diplopia: a copy of every pedestal item and pickup Jera could copy (a trinket redrawn), blind and pooled like it, a
|
|
// choice between options mirrored by a new choice. Book of Virtues copies every wisp. It goes once owned.
|
|
static void diplopia_use(ItemUse& use)
|
|
{
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return;
|
|
if (use.request.flags & (USE_OWNED | USE_VOID)) use.result.isRemove = true;
|
|
|
|
std::map<int, int> optionsCopies;
|
|
for (Entity* entity : entity_query(ENTITY_PICKUP, -1))
|
|
{
|
|
Entity_Pickup& pickup = *static_cast<Entity_Pickup*>(entity);
|
|
bool isPedestal = pickup.variant == PICKUP_COLLECTIBLE;
|
|
if (isPedestal ? pickup.subtype == COLLECTIBLE_DIPLOPIA || pickup.subtype == 0 : !pickup.CanJeraDuplicate()) continue;
|
|
|
|
int subType = pickup.variant == PICKUP_TRINKET ? 0 : pickup.subtype;
|
|
Vector position = room_free_pickup_position_find({.position = pickup.pos, .step = PICKUP_SPOT_STEP});
|
|
Entity_Pickup* copy = static_cast<Entity_Pickup*>(g_game->Spawn({.position = position, .spawner = &player,
|
|
.subType = subType, .type = ENTITY_PICKUP,
|
|
.variant = pickup.variant, .seed = pickup.initSeed}));
|
|
copy->SetForceBlind(pickup.isForceBlind);
|
|
copy->SetAlternatePedestal(pickup.GetAlternatePedestal());
|
|
copy->itemPoolType = pickup.itemPoolType;
|
|
sound_play(SOUND_DIPLOPIA);
|
|
if (pickup.optionsPickupIndex <= 0) continue;
|
|
|
|
auto found = optionsCopies.find(pickup.optionsPickupIndex);
|
|
if (found != optionsCopies.end()) copy->optionsPickupIndex = found->second;
|
|
else optionsCopies.emplace(pickup.optionsPickupIndex, copy->AssignOptionsIndex());
|
|
}
|
|
use_animate(use);
|
|
if (is_wisp_use(use))
|
|
for (Entity* wisp : entity_query(ENTITY_FAMILIAR, Entity_Familiar::WISP))
|
|
player.AddWisp(wisp->subtype, player.pos, false, false);
|
|
}
|
|
|
|
// What Pandora's Box holds: count pickups of a variant and subtype, each at a free spot near the player.
|
|
struct BoxPickups
|
|
{
|
|
int count = 1;
|
|
int subType = 1;
|
|
int variant = PICKUP_HEART;
|
|
};
|
|
|
|
// Pandora's Box puts a pickup at a free spot near the player, seeded by the box.
|
|
static void box_pickup_spawn(Entity_Player& player, const BoxPickups& pickup, uint32_t seed)
|
|
{
|
|
Vector spot = room_free_pickup_position_find({.position = player.pos, .step = PICKUP_SPOT_STEP});
|
|
g_game->Spawn({.position = spot, .spawner = &player, .subType = pickup.subType, .type = ENTITY_PICKUP,
|
|
.variant = pickup.variant, .seed = seed});
|
|
}
|
|
|
|
// Pandora's Box spills pickups.
|
|
static void box_pickups_spawn(Entity_Player& player, const BoxPickups& pickups)
|
|
{
|
|
for (int i = 0; i < pickups.count; i++)
|
|
box_pickup_spawn(player, pickups, player.GetCollectibleRNG(COLLECTIBLE_BLUE_BOX).Next());
|
|
}
|
|
|
|
// Pandora's Box puts count collectibles from a pool on pedestals.
|
|
static void box_collectibles_spawn(Entity_Player& player, ItemPoolType pool, int count)
|
|
{
|
|
RNG& rng = player.GetCollectibleRNG(COLLECTIBLE_BLUE_BOX);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
uint32_t seed = rng.Next();
|
|
int item = g_game->itemPool.GetCollectible(pool, rng.Next(), 0, 0, 0);
|
|
box_pickup_spawn(player, {.subType = item, .variant = PICKUP_COLLECTIBLE}, seed);
|
|
}
|
|
}
|
|
|
|
// Pandora's Box with the Strange Key: the key goes, and a collectible comes from each of the first pools of a shuffled
|
|
// list (six, eight or ten with the key's multiplier). The original reads an unset tenth pool with a tripled key in
|
|
// Greed mode. Here the draws stop at the end of the list.
|
|
static void strange_key_open(Entity_Player& player)
|
|
{
|
|
constexpr std::array<ItemPoolType, 10> NORMAL_POOLS = {POOL_TREASURE, POOL_BOSS, POOL_SHOP, POOL_DEVIL, POOL_ANGEL,
|
|
POOL_LIBRARY, POOL_GOLDEN_CHEST, POOL_CURSE, POOL_PLANETARIUM,
|
|
POOL_SECRET};
|
|
constexpr std::array<ItemPoolType, 9> GREED_POOLS = {POOL_GREED_TREASURE, POOL_GREED_BOSS, POOL_GREED_SHOP,
|
|
POOL_GREED_DEVIL, POOL_GREED_ANGEL, POOL_LIBRARY,
|
|
POOL_GOLDEN_CHEST, POOL_GREED_CURSE, POOL_PLANETARIUM};
|
|
int multiplier = player.GetTrinketMultiplier(TRINKET_STRANGE_KEY);
|
|
int count = multiplier == 2 ? 8 : multiplier == 3 ? 10 : 6;
|
|
player.TryRemoveTrinket(TRINKET_STRANGE_KEY);
|
|
std::vector<ItemPoolType> pools = g_game->IsGreedMode()
|
|
? std::vector<ItemPoolType>(GREED_POOLS.begin(), GREED_POOLS.end())
|
|
: std::vector<ItemPoolType>(NORMAL_POOLS.begin(), NORMAL_POOLS.end());
|
|
|
|
RNG& rng = player.GetCollectibleRNG(COLLECTIBLE_BLUE_BOX);
|
|
for (size_t i = 0; i + 1 < pools.size(); i++)
|
|
if (uint32_t offset = rng.RandomInt((uint32_t)(pools.size() - i)); offset != 0)
|
|
std::swap(pools[i], pools[i + offset]);
|
|
for (int i = 0; i < std::min(count, (int)pools.size()); i++) box_collectibles_spawn(player, pools[i], 1);
|
|
}
|
|
|
|
// What Pandora's Box gives on a Greed mode floor, by the floor.
|
|
static void greed_box_open(Entity_Player& player, int stage)
|
|
{
|
|
switch (stage)
|
|
{
|
|
case 1:
|
|
box_pickups_spawn(player, {.count = 2, .variant = PICKUP_KEY});
|
|
return box_pickups_spawn(player, {.count = 2, .variant = PICKUP_BOMB});
|
|
case 2:
|
|
box_collectibles_spawn(player, POOL_BOSS, 1);
|
|
return box_pickups_spawn(player, {.count = 2, .subType = HEART_SOUL});
|
|
case 3:
|
|
return box_pickups_spawn(player, {.count = PANDORA_COINS, .variant = PICKUP_COIN});
|
|
case 4:
|
|
return box_collectibles_spawn(player, POOL_BOSS, 2);
|
|
case 5:
|
|
box_collectibles_spawn(player, POOL_DEVIL, 1);
|
|
return box_pickups_spawn(player, {.subType = HEART_BLACK});
|
|
case 6:
|
|
case 7:
|
|
return box_pickups_spawn(player, {.variant = PICKUP_COIN});
|
|
default:
|
|
log_printf(LOG_INFO, "[warn] Blue Box, can't generate a specific collectible for the current stage %d\n", stage);
|
|
}
|
|
}
|
|
|
|
// What Pandora's Box gives, by the floor: hearts, keys and bombs, coins, boss items, the Bible, a devil or angel deal
|
|
// (by the floor's side), the Moving Box unlocked, nothing in the Chest, or the Red Key on the Home floor.
|
|
static void box_open(Entity_Player& player, int stage)
|
|
{
|
|
switch (stage)
|
|
{
|
|
case 1:
|
|
return box_pickups_spawn(player, {.count = 2, .subType = HEART_SOUL});
|
|
case 2:
|
|
box_pickups_spawn(player, {.count = 2, .variant = PICKUP_KEY});
|
|
return box_pickups_spawn(player, {.count = 2, .variant = PICKUP_BOMB});
|
|
case 3:
|
|
return box_collectibles_spawn(player, POOL_BOSS, 1);
|
|
case 4:
|
|
box_collectibles_spawn(player, POOL_BOSS, 1);
|
|
return box_pickups_spawn(player, {.count = 2, .subType = HEART_SOUL});
|
|
case 5:
|
|
return box_pickups_spawn(player, {.count = 4, .subType = HEART_SOUL});
|
|
case 6:
|
|
return box_pickups_spawn(player, {.count = PANDORA_COINS, .variant = PICKUP_COIN});
|
|
case 7:
|
|
return box_collectibles_spawn(player, POOL_BOSS, 2);
|
|
case 8:
|
|
return box_pickups_spawn(player, {.subType = COLLECTIBLE_BIBLE, .variant = PICKUP_COLLECTIBLE});
|
|
case 10:
|
|
if (!g_game->IsAltStage())
|
|
{
|
|
box_collectibles_spawn(player, POOL_DEVIL, 1);
|
|
return box_pickups_spawn(player, {.subType = HEART_BLACK});
|
|
}
|
|
box_collectibles_spawn(player, POOL_ANGEL, 1);
|
|
return box_pickups_spawn(player, {.subType = HEART_ETERNAL});
|
|
case 11:
|
|
if (g_game->IsAltStage()) return box_pickups_spawn(player, {.variant = PICKUP_COIN});
|
|
g_manager->persistentGameData.TryUnlock(ACHIEVEMENT_MOVING_BOX);
|
|
return;
|
|
case 12:
|
|
return;
|
|
case 13:
|
|
if (!g_manager->persistentGameData.Unlocked(ACHIEVEMENT_RED_KEY))
|
|
g_manager->persistentGameData.TryUnlock(ACHIEVEMENT_RED_KEY);
|
|
return box_pickups_spawn(player, {.subType = COLLECTIBLE_RED_KEY, .variant = PICKUP_COLLECTIBLE});
|
|
default:
|
|
log_printf(LOG_INFO, "[warn] Blue Box, can't generate a specific collectible for the current stage %d\n", stage);
|
|
}
|
|
}
|
|
|
|
// Pandora's Box in a versus match: a collectible for each player on one of the arena's spawn points (each used once).
|
|
// The original reads an empty list's head when the points run out. Here no more collectibles come.
|
|
static void versus_box_open()
|
|
{
|
|
constexpr float VERSUS_BOX_RADIUS = 40;
|
|
DeathmatchTypeBase& versus = *g_game->deathmatchManager.type;
|
|
std::list<Vector> points = versus.itemSpawnPoints;
|
|
|
|
for (int i = 0; i < g_game->playerManager.count_main_players() && !points.empty(); i++)
|
|
{
|
|
auto point = std::next(points.begin(), (long)(Random() % points.size()));
|
|
versus.collectible_spawn(*point, VERSUS_BOX_RADIUS);
|
|
points.erase(point);
|
|
}
|
|
}
|
|
|
|
// Pandora's Box: opened by a main player, it gives what the floor holds (or the Strange Key's collectibles, or in a
|
|
// versus match a collectible per player), one wisp
|
|
// per floor past the first with Book of Virtues and a devil familiar with Judas's kept Book of Belial. It goes once
|
|
// owned, or used through the Void.
|
|
static void pandoras_box_use(ItemUse& use)
|
|
{
|
|
constexpr std::array<int, 8> BELIAL_FAMILIARS = {278, 113, 360, 275, 417, 679, 565, 698};
|
|
Entity_Player& player = use.player;
|
|
if (player.variant != PLAYER_VARIANT_PLAYER) return use_animate(use);
|
|
|
|
sound_play_local(player, SOUND_PANDORAS_BOX);
|
|
if (use.request.flags & (USE_OWNED | USE_VOID)) use.result.isRemove = true;
|
|
int stage = g_game->stage;
|
|
if (player.HasTrinket(TRINKET_STRANGE_KEY)) strange_key_open(player);
|
|
else if (g_game->deathmatchManager.is_active()) versus_box_open();
|
|
else if (g_game->IsGreedMode()) greed_box_open(player, stage);
|
|
else box_open(player, stage);
|
|
|
|
if (is_wisp_use(use))
|
|
for (int i = 0; i < stage - 1; i++) player.AddWisp(COLLECTIBLE_BLUE_BOX, player.pos, false, false);
|
|
if (player.HasCollectible(COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE))
|
|
{
|
|
RNG& rng = player.GetCollectibleRNG(COLLECTIBLE_BLUE_BOX);
|
|
int familiar = g_game->itemPool.GetCollectibleFromList(BELIAL_FAMILIARS, rng.Next(), COLLECTIBLE_DEMON_BABY,
|
|
LIST_PICK_BLACKLIST);
|
|
uint32_t seed = rng.Next();
|
|
Vector spot = room_free_pickup_position_find({.position = player.pos, .step = PICKUP_SPOT_STEP});
|
|
g_game->Spawn({.position = spot, .subType = familiar, .type = ENTITY_PICKUP, .variant = PICKUP_COLLECTIBLE,
|
|
.seed = seed})
|
|
->Update();
|
|
}
|
|
use_animate(use);
|
|
}
|
|
|
|
// Runs the own effect of a Rebirth or early Afterbirth active (below 400) the main dispatch does not case. The ones not
|
|
// written yet stop the game.
|
|
void rebirth_item_effect_run(ItemUse& use)
|
|
{
|
|
switch (use.id)
|
|
{
|
|
case COLLECTIBLE_NECRONOMICON:
|
|
return necronomicon_use(use);
|
|
case COLLECTIBLE_HOURGLASS:
|
|
return hourglass_use(use);
|
|
case COLLECTIBLE_MONSTROS_TOOTH:
|
|
return monstros_tooth_use(use);
|
|
case COLLECTIBLE_BOOK_OF_SIN:
|
|
return book_of_sin_use(use);
|
|
case COLLECTIBLE_PINKING_SHEARS:
|
|
return pinking_shears_use(use);
|
|
case COLLECTIBLE_BEAN:
|
|
return bean_use(use);
|
|
case COLLECTIBLE_MONSTER_MANUAL:
|
|
return monster_manual_use(use);
|
|
case COLLECTIBLE_DEAD_SEA_SCROLLS:
|
|
return dead_sea_scrolls_use(use);
|
|
case COLLECTIBLE_FORGET_ME_NOW:
|
|
return forget_me_now_use(use);
|
|
case COLLECTIBLE_IV_BAG:
|
|
return iv_bag_use(use);
|
|
case COLLECTIBLE_BEST_FRIEND:
|
|
return best_friend_use(use);
|
|
case COLLECTIBLE_CRYSTAL_BALL:
|
|
return crystal_ball_use(use);
|
|
case COLLECTIBLE_D20:
|
|
return d20_use(use);
|
|
case COLLECTIBLE_DADS_KEY:
|
|
return dads_key_use(use);
|
|
case COLLECTIBLE_PORTABLE_SLOT:
|
|
return portable_slot_use(use);
|
|
case COLLECTIBLE_CLEAR_RUNE:
|
|
return clear_rune_use(use);
|
|
case COLLECTIBLE_HOW_TO_JUMP:
|
|
return how_to_jump_use(use);
|
|
case COLLECTIBLE_D100:
|
|
return d100_use(use);
|
|
case COLLECTIBLE_D4:
|
|
return d4_use(use);
|
|
case COLLECTIBLE_D10:
|
|
return d10_use(use);
|
|
case COLLECTIBLE_D12:
|
|
return d12_use(use);
|
|
case COLLECTIBLE_WE_NEED_TO_GO_DEEPER:
|
|
case COLLECTIBLE_MOMS_SHOVEL:
|
|
return deeper_use(use);
|
|
case COLLECTIBLE_BLANK_CARD:
|
|
return blank_card_use(use);
|
|
case COLLECTIBLE_BOOK_OF_SECRETS:
|
|
return book_of_secrets_use(use);
|
|
case COLLECTIBLE_BOX_OF_SPIDERS:
|
|
return box_of_spiders_use(use);
|
|
case COLLECTIBLE_THE_JAR:
|
|
return jar_use(use);
|
|
case COLLECTIBLE_FLUSH:
|
|
return flush_use(use);
|
|
case COLLECTIBLE_SATANIC_BIBLE:
|
|
return satanic_bible_use(use);
|
|
case COLLECTIBLE_HEAD_OF_KRAMPUS:
|
|
return head_of_krampus_use(use);
|
|
case COLLECTIBLE_BUTTER_BEAN:
|
|
return game_butter_bean_fart({.position = use.player.pos, .source = &use.player, .radius = BEAN_PUSH_RADIUS,
|
|
.isShowEffect = true, .isSuperKnockback = true});
|
|
case COLLECTIBLE_MAGIC_FINGERS:
|
|
return magic_fingers_use(use);
|
|
case COLLECTIBLE_CONVERTER:
|
|
return converter_use(use);
|
|
case COLLECTIBLE_ISAACS_TEARS:
|
|
return isaacs_tears_use(use);
|
|
case COLLECTIBLE_SCISSORS:
|
|
return scissors_use(use);
|
|
case COLLECTIBLE_BREATH_OF_LIFE:
|
|
use.isAddEffect = false;
|
|
return;
|
|
case COLLECTIBLE_BOOMERANG:
|
|
return boomerang_use(use);
|
|
case COLLECTIBLE_PLACEBO:
|
|
return placebo_use(use);
|
|
case COLLECTIBLE_WOODEN_NICKEL:
|
|
return wooden_nickel_use(use);
|
|
case COLLECTIBLE_MEGA_BEAN:
|
|
return mega_bean_use(use);
|
|
case COLLECTIBLE_GLASS_CANNON:
|
|
return lift_sound_use(use, 0);
|
|
case COLLECTIBLE_BOX_OF_FRIENDS:
|
|
return box_of_friends_use(use);
|
|
case COLLECTIBLE_FRIEND_BALL:
|
|
return lift_sound_use(use, SOUND_FRIENDLYBALL_RAISE);
|
|
case COLLECTIBLE_TEAR_DETONATOR:
|
|
return tear_detonator_use(use);
|
|
case COLLECTIBLE_DIPLOPIA:
|
|
return diplopia_use(use);
|
|
case COLLECTIBLE_UNDEFINED:
|
|
return undefined_use(use);
|
|
case COLLECTIBLE_VENTRICLE_RAZOR:
|
|
return ventricle_razor_use(use);
|
|
case COLLECTIBLE_BLUE_BOX:
|
|
return pandoras_box_use(use);
|
|
default:
|
|
return active_missing_report(use);
|
|
}
|
|
}
|