Curation round 13: grid entities, more enemies, Caves, boss helpers and five bosses, chests and costumes, curses and alt stages, the Lua API
This commit is contained in:
1 parent
f8ce24fc6c
commit
8ae02a8422
160 files changed
+16231
-1689
No files matched your search
+77
-11
@@ -1,16 +1,53 @@
|
||||
#include "grid_entity_lock.h"
|
||||
#include "log.h"
|
||||
#include "entity_pickup.h"
|
||||
#include "game.h"
|
||||
#include "room.h"
|
||||
|
||||
// 00711780 Loads the block, a coin block under Pay To Play.
|
||||
// The grid path a standing block claims, and how near a player must come to open it.
|
||||
constexpr int GRID_PATH_LOCK = 4000;
|
||||
constexpr float UNLOCK_DISTANCE_SQUARED = 961;
|
||||
|
||||
// A broken block's drop: one time in ten, a heart a quarter of the time (Daemon's Tail takes some back), else a penny.
|
||||
constexpr float LOCK_DROP_CHANCE = 0.1f;
|
||||
constexpr float LOCK_HEART_CHANCE = 0.25f;
|
||||
|
||||
// 00711780 Loads the block, a coin block under Pay To Play, standing solid or already broken.
|
||||
void GridEntity_Lock::subclass_init()
|
||||
{
|
||||
reconstruction_missing("GridEntity_Lock::subclass_init 00711780");
|
||||
sprite.Load("gfx/grid/grid_locks.anm2", GRAPHICS_LOAD);
|
||||
isCoinLock = g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_PAY_TO_PLAY, LAZARUS_SHARE_CHECK);
|
||||
if (state != 0)
|
||||
{
|
||||
sprite.SetFrame("Broken", 0);
|
||||
collisionClass = COLLISION_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
sprite.SetFrame(isCoinLock ? "IdleCoin" : "Idle", 0);
|
||||
collisionClass = COLLISION_WALL;
|
||||
path_set(GRID_PATH_LOCK);
|
||||
}
|
||||
|
||||
// 00711950 Animates the block and unblocks the cell once it breaks.
|
||||
// 00711950 Frees the cell once the breaking animation breaks, and lets the players near a standing block open it.
|
||||
void GridEntity_Lock::Update()
|
||||
{
|
||||
reconstruction_missing("GridEntity_Lock::Update 00711950");
|
||||
if (sprite.animState.animData && sprite.IsEventTriggered("Break"))
|
||||
{
|
||||
collisionClass = COLLISION_NONE;
|
||||
path_set(0);
|
||||
}
|
||||
if (state == 0)
|
||||
{
|
||||
Vector position = Position();
|
||||
for (size_t i = 0; i < g_game->playerManager.playerList.size(); i++)
|
||||
{
|
||||
Entity_Player* player = g_game->playerManager.playerList[i];
|
||||
Vector offset = vector_make(player->pos.x - position.x, player->pos.y - position.y);
|
||||
bool isNear = offset.y * offset.y + offset.x * offset.x < UNLOCK_DISTANCE_SQUARED;
|
||||
if (player->variant == PLAYER_VARIANT_PLAYER && isNear) try_unlock(*player, false);
|
||||
}
|
||||
}
|
||||
sprite.Update();
|
||||
}
|
||||
|
||||
// 00711f30 Draws the sprite on its cell.
|
||||
@@ -25,14 +62,43 @@ WaterClipInfo GridEntity_Lock::GetWaterClipInfo()
|
||||
return {collisionClass != COLLISION_NONE ? WATER_CLIP_SOLID : WATER_CLIP_FLAT, 0};
|
||||
}
|
||||
|
||||
// 00711af0 Breaks the block with a player's key or coins.
|
||||
void GridEntity_Lock::try_unlock(Entity_Player&, bool)
|
||||
// 00711af0 Breaks the standing block with a player's key (Paper Clip's strong form needs none) or, under Pay To Play,
|
||||
// a coin. Forced, it costs nothing.
|
||||
void GridEntity_Lock::try_unlock(Entity_Player& player, bool isForce)
|
||||
{
|
||||
reconstruction_missing("GridEntity_Lock::try_unlock 00711af0");
|
||||
if (state != 0) return;
|
||||
|
||||
if (!isForce && !isCoinLock && player.GetTrinketMultiplier(TRINKET_PAPER_CLIP) < 2 && !player.TryUseKey()) return;
|
||||
if (!isForce && isCoinLock)
|
||||
{
|
||||
if (player.numCoins < 1) return;
|
||||
player.AddCoins(-1);
|
||||
}
|
||||
grid_sound_play(isCoinLock ? SOUND_COIN_INSERT : SOUND_UNLOCK);
|
||||
break_open(&player);
|
||||
}
|
||||
|
||||
// 00711bb0 Breaks the block open.
|
||||
void GridEntity_Lock::break_open(Entity_Player&)
|
||||
// 00711bb0 Breaks the block open (golden with a golden key), and one time in ten drops a heart or a penny. A block
|
||||
// broken by no one counts the first player with Daemon's Tail.
|
||||
void GridEntity_Lock::break_open(Entity_Player* player)
|
||||
{
|
||||
reconstruction_missing("GridEntity_Lock::break_open 00711bb0");
|
||||
grid_sound_play(SOUND_METAL_BLOCKBREAK);
|
||||
if (isCoinLock) sprite.Play("BreakingCoin");
|
||||
else sprite.Play(player && player->hasGoldenKey ? "BreakingGolden" : "Breaking");
|
||||
state = 1;
|
||||
|
||||
RNG dropRng = {spawnSeed, 1, 5, 16};
|
||||
if (dropRng.RandomFloat() >= LOCK_DROP_CHANCE) return;
|
||||
if (!player)
|
||||
for (Entity_Player* candidate : g_game->playerManager.playerList)
|
||||
if (candidate->variant == PLAYER_VARIANT_PLAYER && candidate->HasTrinket(TRINKET_DAEMONS_TAIL))
|
||||
{
|
||||
player = candidate;
|
||||
break;
|
||||
}
|
||||
|
||||
bool isHeart = dropRng.RandomFloat() < LOCK_HEART_CHANCE &&
|
||||
(!player || player->GetTrinketRNG(TRINKET_DAEMONS_TAIL).Next() % DAEMONS_TAIL_ODDS == 0);
|
||||
g_game->Spawn({.position = Position(), .type = ENTITY_PICKUP, .variant = isHeart ? PICKUP_HEART : PICKUP_COIN,
|
||||
.seed = dropRng.Next()});
|
||||
}
|
||||
Reference in new issue
Block a user