- started adding a GLSL state structure

Update to ZDoom r1183:

- Added and fixed Boss death submission for random spawner.
- Added functions to FActorInfo that can set the damage factors and
  pain chances to reduce the chance of new errors when working with
  these features.
- Fixed: The handling of the deprecated FIRERESIST flag didn't work.
  There were 3 problems:
  * Actor defaults have no class information so HandleDeprecatedFlags
    needs to be passed a pointer to the ActorInfo.
  * The DamageFactors list is only created when needed so the code needs to
    check if it already exists.
  * damage factors are stored as fixed_t but this set a float.
- Fixed: Timidity::Renderer::reset_voices() must completely zero the
  voices. Because this wasn't done, note_on() could try to access
  the sample for a voice that had never been played yet and access
  random memory. There may be other places where it's a problem, but
  this is where I noticed it, by chance.
- Added a traditional Strife color set for the automap.


git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@164 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2008-08-23 21:48:24 +00:00
parent 6e41b5eec9
commit 66a753dcfd
16 changed files with 368 additions and 127 deletions

View file

@ -1,3 +1,8 @@
/*
** 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"
@ -10,12 +15,7 @@
#include "a_action.h"
#include "thingdef/thingdef.h"
/*
- in the decorate definition define multiple drop items
- use the function GetDropItems to get the first drop item, then iterate over them and count how many dropitems are defined.
- with M_Random( ) % NUMBEROFDROPITEMS you get a random drop item number (let's call it n)
- use GetDropItems again to get the first drop item, then iterate to the n-th drop item
*/
#define MAX_RANDOMSPAWNERS_RECURSION 32 // Should be largely more than enough, honestly.
static FRandom pr_randomspawn("RandomSpawn");
class ARandomSpawner : public AActor
@ -32,10 +32,8 @@ class ARandomSpawner : public AActor
Super::PostBeginPlay();
drop = di = GetDropItems(RUNTIME_TYPE(this));
// Always make sure it actually exists.
if (di != NULL)
{
// First, we get the size of the array...
while (di != NULL)
{
if (di->Name != NAME_None)
@ -59,7 +57,9 @@ class ARandomSpawner : public AActor
}
}
// So now we can spawn the dropped item.
if (pr_randomspawn() <= di->probability) // prob 255 = always spawn, prob 0 = never spawn.
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
@ -77,11 +77,32 @@ class ARandomSpawner : public AActor
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;
}
}
Destroy();
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)