- Used the new explosion handling to clean up the old style projectile

definitions. The SimpleProjectile class is gone and it uses the meta
  data and A_ExplodeParms instead now.
- Removed the deprecation warnings for explosion parameters again because 
  the new system is fully inheritable and therefore useful.
- Changed the explosion properties into meta data and adjusted A_ExplodeParams
  to use these when called without any parameters. Also removed all special
  parsing for A_Explode so now this function can be called with expressions
  like any other function.
- Changed DECORATE parsing so that functions with completely optional 
  parameter lists don't create an empty list when called without parameters.

SVN r274 (trunk)
This commit is contained in:
Christoph Oelckers 2006-07-29 10:47:14 +00:00
parent 06681ec72d
commit 3f90f1655c
6 changed files with 81 additions and 153 deletions

View File

@ -1,3 +1,16 @@
July 29, 2008 (Changes by Graf Zahl)
- Used the new explosion handling to clean up the old style projectile
definitions. The SimpleProjectile class is gone and it uses the meta
data and A_ExplodeParms instead now.
- Removed the deprecation warnings for explosion parameters again because
the new system is fully inheritable and therefore useful again.
- Changed the explosion properties into meta data and adjusted A_ExplodeParams
to use these when called without any parameters. Also removed all special
parsing for A_Explode so now this function can be called with expressions
like any other function.
- Changed DECORATE parsing so that functions with completely optional
parameter lists don't create an empty list when called without parameters.
July 28, 2008 July 28, 2008
- Version bump to 2.1.4. - Version bump to 2.1.4.
- Fixed: Friendlies would not turn to face you when you engaged them in - Fixed: Friendlies would not turn to face you when you engaged them in

View File

@ -50,6 +50,7 @@
#include "a_action.h" #include "a_action.h"
#include "decallib.h" #include "decallib.h"
#include "i_system.h" #include "i_system.h"
#include "thingdef.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -72,33 +73,10 @@ struct FExtraInfo
unsigned int FireDeathStart, FireDeathEnd; unsigned int FireDeathStart, FireDeathEnd;
bool bSolidOnDeath, bSolidOnBurn; bool bSolidOnDeath, bSolidOnBurn;
bool bBurnAway, bDiesAway, bGenericIceDeath; bool bBurnAway, bDiesAway, bGenericIceDeath;
bool bExplosive;
fixed_t DeathHeight, BurnHeight; fixed_t DeathHeight, BurnHeight;
int ExplosionRadius, ExplosionDamage;
bool ExplosionShooterImmune;
}; };
class ASimpleProjectile : public AActor
{
DECLARE_STATELESS_ACTOR (ASimpleProjectile, AActor);
public:
void Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << HurtShooter << ExplosionRadius << ExplosionDamage;
}
void GetExplodeParms (int &damage, int &dist, bool &hurtSource)
{
damage = ExplosionDamage;
dist = ExplosionRadius;
hurtSource = HurtShooter;
}
bool HurtShooter;
int ExplosionRadius, ExplosionDamage;
};
IMPLEMENT_ABSTRACT_ACTOR (ASimpleProjectile)
class AFakeInventory : public AInventory class AFakeInventory : public AInventory
{ {
DECLARE_STATELESS_ACTOR (AFakeInventory, AInventory); DECLARE_STATELESS_ACTOR (AFakeInventory, AInventory);
@ -352,7 +330,7 @@ static void ParseDecorate (void (*process)(FState *, int))
} }
else if (SC_Compare ("Projectile")) else if (SC_Compare ("Projectile"))
{ {
parent = RUNTIME_CLASS(ASimpleProjectile); parent = RUNTIME_CLASS(AActor);
def = DEF_Projectile; def = DEF_Projectile;
SC_MustGetString (); SC_MustGetString ();
} }
@ -479,9 +457,9 @@ static void ParseDecorate (void (*process)(FState *, int))
if (def == DEF_Projectile) if (def == DEF_Projectile)
{ {
if (extra.ExplosionRadius > 0) if (extra.bExplosive)
{ {
info->OwnedStates[extra.DeathStart].Action = A_Explode; info->OwnedStates[extra.DeathStart].Action = A_ExplodeParms;
} }
} }
else else
@ -577,15 +555,6 @@ static void ParseDecorate (void (*process)(FState *, int))
} }
if (def == DEF_Projectile) if (def == DEF_Projectile)
{ {
if (extra.ExplosionRadius > 0)
{
((ASimpleProjectile *)(type->Defaults))->ExplosionRadius =
extra.ExplosionRadius;
((ASimpleProjectile *)(type->Defaults))->ExplosionDamage =
extra.ExplosionDamage > 0 ? extra.ExplosionDamage : extra.ExplosionRadius;
((ASimpleProjectile *)(type->Defaults))->HurtShooter =
!extra.ExplosionShooterImmune;
}
((AActor *)(type->Defaults))->flags |= MF_DROPOFF|MF_MISSILE; ((AActor *)(type->Defaults))->flags |= MF_DROPOFF|MF_MISSILE;
} }
((AActor *)(type->Defaults))->SpawnState = &info->OwnedStates[extra.SpawnStart]; ((AActor *)(type->Defaults))->SpawnState = &info->OwnedStates[extra.SpawnStart];
@ -736,16 +705,18 @@ static void ParseInsideDecoration (FActorInfo *info, AActor *defaults,
else if (def == DEF_Projectile && SC_Compare ("ExplosionRadius")) else if (def == DEF_Projectile && SC_Compare ("ExplosionRadius"))
{ {
SC_MustGetNumber (); SC_MustGetNumber ();
extra.ExplosionRadius = sc_Number; info->Class->Meta.SetMetaInt(ACMETA_ExplosionRadius, sc_Number);
extra.bExplosive = true;
} }
else if (def == DEF_Projectile && SC_Compare ("ExplosionDamage")) else if (def == DEF_Projectile && SC_Compare ("ExplosionDamage"))
{ {
SC_MustGetNumber (); SC_MustGetNumber ();
extra.ExplosionDamage = sc_Number; info->Class->Meta.SetMetaInt(ACMETA_ExplosionDamage, sc_Number);
extra.bExplosive = true;
} }
else if (def == DEF_Projectile && SC_Compare ("DoNotHurtShooter")) else if (def == DEF_Projectile && SC_Compare ("DoNotHurtShooter"))
{ {
extra.ExplosionShooterImmune = true; info->Class->Meta.SetMetaInt(ACMETA_DontHurtShooter, true);
} }
else if (def == DEF_Projectile && SC_Compare ("Damage")) else if (def == DEF_Projectile && SC_Compare ("Damage"))
{ {

View File

@ -3860,30 +3860,6 @@ AActor *P_SpawnPuff (const PClass *pufftype, fixed_t x, fixed_t y, fixed_t z, an
puff->renderflags |= RF_INVISIBLE; puff->renderflags |= RF_INVISIBLE;
} }
/* This code assumes that no object can be used outside its own game.
Since that is no longer the case it doesn't work anymore.
if (gameinfo.gametype == GAME_Doom)
{
// don't make punches spark on the wall
if (attackrange == MELEERANGE)
{
FState *state = puff->state;
int i;
for (i = 0; i < 2 && state->GetNextState(); i++)
state = state->GetNextState();
puff->SetState (state);
}
if (cl_pufftype && updown != 3)
{
P_DrawSplash2 (32, x, y, z, dir, updown, 1);
puff->renderflags |= RF_INVISIBLE;
}
}*/
if (hitthing && puff->SeeSound) if (hitthing && puff->SeeSound)
{ // Hit thing sound { // Hit thing sound
S_SoundID (puff, CHAN_BODY, puff->SeeSound, 1, ATTN_NORM); S_SoundID (puff, CHAN_BODY, puff->SeeSound, 1, ATTN_NORM);

View File

@ -610,6 +610,7 @@ AFuncDesc AFTable[]=
FUNC(A_CentaurDefend, NULL) FUNC(A_CentaurDefend, NULL)
FUNC(A_BishopMissileWeave, NULL) FUNC(A_BishopMissileWeave, NULL)
FUNC(A_CStaffMissileSlither, NULL) FUNC(A_CStaffMissileSlither, NULL)
FUNC(A_PlayerScream, NULL)
FUNC(A_SkullPop, "m") FUNC(A_SkullPop, "m")
{"A_CheckPlayerDone", A_CheckSkullDone, NULL }, {"A_CheckPlayerDone", A_CheckSkullDone, NULL },
@ -698,6 +699,7 @@ AFuncDesc AFTable[]=
FUNC(A_CustomMeleeAttack, "XXXsty" ) FUNC(A_CustomMeleeAttack, "XXXsty" )
FUNC(A_Burst, "M") FUNC(A_Burst, "M")
FUNC(A_RadiusThrust, "xxy") FUNC(A_RadiusThrust, "xxy")
{"A_Explode", A_ExplodeParms, "xxy" },
}; };
//========================================================================== //==========================================================================
@ -949,13 +951,6 @@ static int CreateBloodTranslation(PalEntry color)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
enum
{
ACMETA_BASE = 0x83000,
ACMETA_DropItems, // Int (index into DropItemList)
};
static void FreeDropItemChain(FDropItem *chain) static void FreeDropItemChain(FDropItem *chain)
{ {
while (chain != NULL) while (chain != NULL)
@ -1000,12 +995,6 @@ FDropItem *GetDropItems(AActor * actor)
// //
//========================================================================== //==========================================================================
struct FExplodeParms
{
bool HurtShooter;
int ExplosionRadius, ExplosionDamage;
};
struct FBasicAttack struct FBasicAttack
{ {
int MeleeDamage; int MeleeDamage;
@ -1021,17 +1010,8 @@ struct Baggage
bool StateSet; bool StateSet;
int CurrentState; int CurrentState;
FExplodeParms EParms;
FDropItem *DropItemList; FDropItem *DropItemList;
FBasicAttack BAttack; FBasicAttack BAttack;
const char *PuffType;
const char *HitPuffType;
int AttackSound;
int AmmoGive;
int WeapNum;
}; };
@ -1138,8 +1118,6 @@ FState ** FindState(AActor * actor, const PClass * type, const char * name)
static void ResetBaggage (Baggage *bag) static void ResetBaggage (Baggage *bag)
{ {
bag->EParms.ExplosionDamage = bag->EParms.ExplosionRadius = 128;
bag->EParms.HurtShooter = true;
bag->DropItemList = NULL; bag->DropItemList = NULL;
bag->BAttack.MeleeDamage = 0; bag->BAttack.MeleeDamage = 0;
bag->BAttack.MissileHeight = 32*FRACUNIT; bag->BAttack.MissileHeight = 32*FRACUNIT;
@ -1373,35 +1351,6 @@ bool DoSpecialFunctions(FState & state, bool multistate, int * statecount, Bagga
return true; return true;
} }
// Override the normal A_Explode with a parameterized version
if (SC_Compare ("A_Explode"))
{
int paramindex=PrepareStateParameters(&state, 3);
FExplodeParms local_eparms = bag.EParms;
if (SC_CheckString ("(")) // Parameters are optional
{
SC_MustGetNumber ();
local_eparms.ExplosionDamage = sc_Number;
SC_MustGetStringName (",");
SC_MustGetNumber ();
local_eparms.ExplosionRadius = sc_Number;
if (SC_CheckString(","))
{
SC_MustGetNumber ();
local_eparms.HurtShooter = !!sc_Number;
}
SC_MustGetStringName (")");
}
StateParameters[paramindex] = local_eparms.ExplosionDamage;
StateParameters[paramindex+1] = local_eparms.ExplosionRadius;
StateParameters[paramindex+2] = local_eparms.HurtShooter;
state.Action = A_ExplodeParms;
return true;
}
// Check for A_MeleeAttack, A_MissileAttack, or A_ComboAttack // Check for A_MeleeAttack, A_MissileAttack, or A_ComboAttack
int batk = SC_MatchString (BasicAttackNames); int batk = SC_MatchString (BasicAttackNames);
if (batk >= 0) if (batk >= 0)
@ -1649,7 +1598,6 @@ do_stop:
{ {
const char * params = afd->parameters; const char * params = afd->parameters;
int numparams = (int)strlen(params); int numparams = (int)strlen(params);
int paramindex = PrepareStateParameters(&state, numparams);
int v; int v;
if (!islower(*params)) if (!islower(*params))
@ -1660,6 +1608,8 @@ do_stop:
{ {
if (!SC_CheckString("(")) goto endofstate; if (!SC_CheckString("(")) goto endofstate;
} }
int paramindex = PrepareStateParameters(&state, numparams);
while (*params) while (*params)
{ {
switch(*params) switch(*params)
@ -2739,9 +2689,7 @@ static void ActorHitObituary (AActor *defaults, Baggage &bag)
//========================================================================== //==========================================================================
static void ActorDontHurtShooter (AActor *defaults, Baggage &bag) static void ActorDontHurtShooter (AActor *defaults, Baggage &bag)
{ {
Printf (TEXTCOLOR_YELLOW "DontHurtShooter in %s is deprecated and will be removed in 2.2.0.\n", bag.Info->Class->Meta.SetMetaInt (ACMETA_DontHurtShooter, true);
bag.Info->Class->TypeName.GetChars());
bag.EParms.HurtShooter=false;
} }
//========================================================================== //==========================================================================
@ -2749,10 +2697,8 @@ static void ActorDontHurtShooter (AActor *defaults, Baggage &bag)
//========================================================================== //==========================================================================
static void ActorExplosionRadius (AActor *defaults, Baggage &bag) static void ActorExplosionRadius (AActor *defaults, Baggage &bag)
{ {
Printf (TEXTCOLOR_YELLOW "ExplosionRadius in %s is deprecated and will be removed in 2.2.0.\n",
bag.Info->Class->TypeName.GetChars());
SC_MustGetNumber(); SC_MustGetNumber();
bag.EParms.ExplosionRadius=sc_Number; bag.Info->Class->Meta.SetMetaInt (ACMETA_ExplosionRadius, sc_Number);
} }
//========================================================================== //==========================================================================
@ -2760,10 +2706,8 @@ static void ActorExplosionRadius (AActor *defaults, Baggage &bag)
//========================================================================== //==========================================================================
static void ActorExplosionDamage (AActor *defaults, Baggage &bag) static void ActorExplosionDamage (AActor *defaults, Baggage &bag)
{ {
Printf (TEXTCOLOR_YELLOW "ExplosionDamage in %s is deprecated and will be removed in 2.2.0.\n",
bag.Info->Class->TypeName.GetChars());
SC_MustGetNumber(); SC_MustGetNumber();
bag.EParms.ExplosionDamage=sc_Number; bag.Info->Class->Meta.SetMetaInt (ACMETA_ExplosionDamage, sc_Number);
} }
//========================================================================== //==========================================================================

View File

@ -45,6 +45,17 @@ FDropItem *GetDropItems(AActor * actor);
extern FState * CallingState; extern FState * CallingState;
int CheckIndex(int paramsize, FState ** pcallstate=NULL); int CheckIndex(int paramsize, FState ** pcallstate=NULL);
void A_ExplodeParms(AActor * self);
enum
{
ACMETA_BASE = 0x83000,
ACMETA_DropItems, // Int (index into DropItemList)
ACMETA_ExplosionDamage,
ACMETA_ExplosionRadius,
ACMETA_DontHurtShooter,
};

View File

@ -456,22 +456,24 @@ void A_JumpIfInTargetInventory(AActor * self)
void A_ExplodeParms (AActor *self) void A_ExplodeParms (AActor *self)
{ {
int damage = 128; int damage;
int distance = 128; int distance;
bool hurtSource = true; bool hurtSource;
int index=CheckIndex(3); int index=CheckIndex(3);
if (index>=0) if (index>=0)
{ {
if (StateParameters[index] != 0) damage = EvalExpressionI (StateParameters[index], self);
{ distance = EvalExpressionI (StateParameters[index+1], self);
damage = StateParameters[index]; hurtSource = EvalExpressionN (StateParameters[index+2], self);
} if (damage == 0) damage = 128;
if (StateParameters[index+1] != 0) if (distance == 0) distance = damage;
{ }
distance = StateParameters[index+1]; else
} {
hurtSource = !!StateParameters[index+2]; damage = self->GetClass()->Meta.GetMetaInt (ACMETA_ExplosionDamage, 128);
distance = self->GetClass()->Meta.GetMetaInt (ACMETA_ExplosionRadius, damage);
hurtSource = !self->GetClass()->Meta.GetMetaInt (ACMETA_DontHurtShooter);
} }
P_RadiusAttack (self, self->target, damage, distance, self->DamageType, hurtSource); P_RadiusAttack (self, self->target, damage, distance, self->DamageType, hurtSource);
@ -490,16 +492,19 @@ void A_ExplodeParms (AActor *self)
void A_RadiusThrust (AActor *self) void A_RadiusThrust (AActor *self)
{ {
int force = 0;
int distance = 0;
bool affectSource = true;
int index=CheckIndex(3); int index=CheckIndex(3);
if (index<0) return; if (index>=0)
{
int force = EvalExpressionI (StateParameters[index], self); force = EvalExpressionI (StateParameters[index], self);
if (force==0) force=128; distance = EvalExpressionI (StateParameters[index+1], self);
affectSource = EvalExpressionN (StateParameters[index+2], self);
int distance = EvalExpressionI (StateParameters[index+1], self); }
if (distance==0) distance=128; if (force == 0) force = 128;
if (distance == 0) distance = force;
bool affectSource = EvalExpressionN (StateParameters[index+2], self);;
P_RadiusAttack (self, self->target, force, distance, self->DamageType, affectSource, false, false); P_RadiusAttack (self, self->target, force, distance, self->DamageType, affectSource, false, false);
if (self->z <= self->floorz + (distance<<FRACBITS)) if (self->z <= self->floorz + (distance<<FRACBITS))
@ -1353,10 +1358,14 @@ void A_SetTranslucent(AActor * self)
//=========================================================================== //===========================================================================
void A_FadeIn(AActor * self) void A_FadeIn(AActor * self)
{ {
fixed_t reduce = 0;
int index=CheckIndex(1, NULL); int index=CheckIndex(1, NULL);
if (index<0) return; if (index>=0)
{
fixed_t reduce = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT); reduce = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT);
}
if (reduce == 0) reduce = FRACUNIT/10; if (reduce == 0) reduce = FRACUNIT/10;
if (self->RenderStyle==STYLE_Normal) self->RenderStyle=STYLE_Translucent; if (self->RenderStyle==STYLE_Normal) self->RenderStyle=STYLE_Translucent;
@ -1373,10 +1382,14 @@ void A_FadeIn(AActor * self)
//=========================================================================== //===========================================================================
void A_FadeOut(AActor * self) void A_FadeOut(AActor * self)
{ {
fixed_t reduce = 0;
int index=CheckIndex(1, NULL); int index=CheckIndex(1, NULL);
if (index<0) return; if (index>=0)
{
fixed_t reduce = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT); reduce = fixed_t(EvalExpressionF (StateParameters[index], self) * FRACUNIT);
}
if (reduce == 0) reduce = FRACUNIT/10; if (reduce == 0) reduce = FRACUNIT/10;
if (self->RenderStyle==STYLE_Normal) self->RenderStyle=STYLE_Translucent; if (self->RenderStyle==STYLE_Normal) self->RenderStyle=STYLE_Translucent;