RingRacers/src/objects/item-spot.c
James R 7ce12f37dc Spawn Battle monitors
- Item count has always scaled up with player count. Items
spawn every N tics. Previously, these items were evenly
distributed across all item spots. Now, only one monitor
is spawned at a time and the number of items inside scales
up.

- Emeralds spawn inside of monitors instead of loosely.
- Sphere boxes should spawn in the same way as before.

- Once a monitor has been spawned at an item spot, no more
monitors can be spawned there until that one is destroyed.
There's an additional delay of one spawn interval before
a monitor can be spawned in that location again. This is
so a monitor cannot ever instantly spawn back if one is
destroyed at just the right time.
2023-01-03 05:31:30 -08:00

35 lines
706 B
C

#include "../doomdef.h"
#include "../m_fixed.h"
#include "../k_objects.h"
#include "../k_battle.h"
#include "../p_tick.h"
#include "../p_local.h"
#define spot_monitor(o) ((o)->target)
#define spot_cool(o) ((o)->threshold)
boolean
Obj_ItemSpotIsAvailable (const mobj_t *spot)
{
return P_MobjWasRemoved(spot_monitor(spot)) &&
(leveltime - spot_cool(spot)) > BATTLE_SPAWN_INTERVAL;
}
void
Obj_ItemSpotAssignMonitor
( mobj_t * spot,
mobj_t * monitor)
{
P_SetTarget(&spot_monitor(spot), monitor);
Obj_MonitorSetItemSpot(monitor, spot);
}
void
Obj_ItemSpotUpdate (mobj_t *spot)
{
if (P_MobjWasRemoved(spot_monitor(spot)) ||
spot_monitor(spot)->health <= 0)
{
spot_cool(spot) = leveltime;
}
}