mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-01 09:41:58 +00:00
- Used the one unused byte in the state structure as a flag to tell what type the NextState parameter is. The code did some rather unsafe checks with it to determine its type. - moved all state related code into a new file: p_states.cpp. - merged all FindState functions. All the different variations are now inlined and call the same function to do the real work. - did some code cleanup and reorganization in thingdef.cpp. - Replaced the translation parser for TEXTURES with FRemapTable::AddToTranslation. - To get the game name the screenshot code might as well use the globally available GameNames array instead of creating its own list. - Moved backpack names for cheat into gameinfo. - Fixed: SNDINFO must be loaded before the textures. However, this required some changes to the MAPINFO parser which tried to access the texture manager to check if the level name patches exist. That check had to be moved to where the intermission screen is set up. - Fixed: 'bloodcolor' ignored the first parameter value when given a list of integers. Please note that this creates an incompatibility between old and new versions so if you want to create something that works with both 2.2.0 and current versions better use the string format version for the color parameter! - Rewrote the DECORATE property parser so that the parser is completely separated from the property handlers. This should allow reuse of all the handler code for a new format if Doomscript requires one. - Fixed: PClass::InitializeActorInfo copied too many bytes if a subclass's defaults were larger than the parent's. - Moved A_ChangeFlag to thingdef_codeptr.cpp. - Moved translation related code from thingdef_properties.cpp to r_translate.cpp and rewrote the translation parser to use FScanner instead of strtol. - replaced DECORATE's 'alpha default' by 'defaultalpha' for consistency. Since this was never used outside zdoom.pk3 it's not critical. - Removed support for game specific pickup messages because the only thing this was ever used for - Raven's invulnerability item - has already been split up into a Heretic and Hexen version. - Fixed: The Timidity config parser always tried to process the note number, even if it wasn't specified. - Fixed: When UpdateJoystickMenu() modifies the menu items for different controllers, the joystick axis selectors need to NULL the d.graycheck field, since this is shared by the axis sensitivity sliders' step values. - Fixed: The crosshair must be initialized after the texture manager because on the fly texture creation for graphics patches is no longer supported. - Fixed a few Linux compile errors. - Changed: Replaced weapons should not be given by generic cheats, only when explicitly giving them. - Changed 'give weapon' cheat so that in single player it only gives weapons belonging to the current game or are placed in a weapon slot to avoid giving the Chex Quest weapons in Doom and vice versa. - Fixed: The texture manager must be the first thing to be initialized because MAPINFO and DECORATE both can reference textures and letting them create their own textures is not safe. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@181 b0f79afe-0144-0410-b225-9a4edf0717df
108 lines
3.2 KiB
C++
108 lines
3.2 KiB
C++
/*
|
|
** a_randomspawner.cpp
|
|
** A thing that randomly spawns one item in a list of many, before disappearing.
|
|
*/
|
|
|
|
#include "actor.h"
|
|
#include "info.h"
|
|
#include "m_random.h"
|
|
#include "p_local.h"
|
|
#include "p_enemy.h"
|
|
#include "s_sound.h"
|
|
#include "statnums.h"
|
|
#include "gstrings.h"
|
|
#include "a_action.h"
|
|
#include "thingdef/thingdef.h"
|
|
|
|
#define MAX_RANDOMSPAWNERS_RECURSION 32 // Should be largely more than enough, honestly.
|
|
static FRandom pr_randomspawn("RandomSpawn");
|
|
|
|
class ARandomSpawner : public AActor
|
|
{
|
|
DECLARE_CLASS (ARandomSpawner, AActor)
|
|
|
|
void PostBeginPlay()
|
|
{
|
|
AActor *newmobj = NULL;
|
|
FDropItem *di; // di will be our drop item list iterator
|
|
FDropItem *drop; // while drop stays as the reference point.
|
|
int n=0;
|
|
|
|
Super::PostBeginPlay();
|
|
|
|
drop = di = GetDropItems();
|
|
if (di != NULL)
|
|
{
|
|
while (di != NULL)
|
|
{
|
|
if (di->Name != NAME_None)
|
|
{
|
|
if (di->amount < 0) di->amount = 1; // default value is -1, we need a positive value.
|
|
n += di->amount; // this is how we can weight the list.
|
|
di = di->Next;
|
|
}
|
|
}
|
|
// Then we reset the iterator to the start position...
|
|
di = drop;
|
|
// Take a random number...
|
|
n = pr_randomspawn(n);
|
|
// And iterate in the array up to the random number chosen.
|
|
while (n > 0)
|
|
{
|
|
if (di->Name != NAME_None)
|
|
{
|
|
n -= di->amount;
|
|
if (di->Next != NULL) di = di->Next; else n=0;
|
|
}
|
|
}
|
|
// So now we can spawn the dropped item.
|
|
if (special1 >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions
|
|
Spawn("Unknown", x, y, z, NO_REPLACE); // Show that there's a problem.
|
|
else if (pr_randomspawn() <= di->probability) // prob 255 = always spawn, prob 0 = never spawn.
|
|
{
|
|
newmobj = Spawn(di->Name, x, y, z, ALLOW_REPLACE);
|
|
// copy everything relevant
|
|
newmobj->SpawnAngle = newmobj->angle = angle;
|
|
newmobj->special = special;
|
|
newmobj->args[0] = args[0];
|
|
newmobj->args[1] = args[1];
|
|
newmobj->args[2] = args[2];
|
|
newmobj->args[3] = args[3];
|
|
newmobj->args[4] = args[4];
|
|
newmobj->SpawnFlags = SpawnFlags;
|
|
newmobj->HandleSpawnFlags();
|
|
newmobj->tid = tid;
|
|
newmobj->AddToHash();
|
|
newmobj->momx = momx;
|
|
newmobj->momy = momy;
|
|
newmobj->momz = momz;
|
|
newmobj->master = master; // For things such as DamageMaster/DamageChildren, transfer mastery.
|
|
newmobj->target = target;
|
|
newmobj->tracer = tracer;
|
|
newmobj->CopyFriendliness(this, false);
|
|
// Special1 is used to count how many recursions we're in.
|
|
if (newmobj->IsKindOf(PClass::FindClass("RandomSpawner")))
|
|
newmobj->special1 = ++special1;
|
|
|
|
}
|
|
}
|
|
if ((newmobj != NULL) && ((newmobj->flags4 & MF4_BOSSDEATH) || (newmobj->flags2 & MF2_BOSS)))
|
|
this->target = newmobj; // If the spawned actor has either of those flags, it's a boss.
|
|
else Destroy(); // "else" because a boss-replacing spawner must wait until it can call A_BossDeath.
|
|
}
|
|
|
|
void Tick() // This function is needed for handling boss replacers
|
|
{
|
|
Super::Tick();
|
|
if (target == NULL || target->health <= 0)
|
|
{
|
|
health = 0;
|
|
CALL_ACTION(A_BossDeath, this);
|
|
Destroy();
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
IMPLEMENT_CLASS (ARandomSpawner)
|
|
|