mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- scriptified the basic attack functions, its properties and the explosion properties to test the new metadata system.
This commit is contained in:
parent
a93a7e1cac
commit
b6a1fe7fc6
10 changed files with 101 additions and 200 deletions
|
@ -623,12 +623,20 @@ DEFINE_ACTION_FUNCTION(DObject, MSTime)
|
|||
|
||||
void *DObject::ScriptVar(FName field, PType *type)
|
||||
{
|
||||
auto sym = dyn_cast<PField>(GetClass()->Symbols.FindSymbol(field, true));
|
||||
auto cls = GetClass();
|
||||
auto sym = dyn_cast<PField>(cls->Symbols.FindSymbol(field, true));
|
||||
if (sym && (sym->Type == type || type == nullptr))
|
||||
{
|
||||
return (((char*)this) + sym->Offset);
|
||||
if (!(sym->Flags & VARF_Meta))
|
||||
{
|
||||
return (((char*)this) + sym->Offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (cls->Meta + sym->Offset);
|
||||
}
|
||||
}
|
||||
// This is only for internal use so I_Error is fine.
|
||||
I_Error("Variable %s not found in %s\n", field.GetChars(), GetClass()->TypeName.GetChars());
|
||||
I_Error("Variable %s not found in %s\n", field.GetChars(), cls->TypeName.GetChars());
|
||||
return nullptr;
|
||||
}
|
||||
|
|
13
src/info.cpp
13
src/info.cpp
|
@ -262,11 +262,6 @@ PClassActor::PClassActor()
|
|||
CameraHeight = INT_MIN;
|
||||
|
||||
DropItems = NULL;
|
||||
|
||||
DontHurtShooter = false;
|
||||
ExplosionRadius = -1;
|
||||
MeleeDamage = 0;
|
||||
|
||||
// Record this in the master list.
|
||||
AllActorClasses.Push(this);
|
||||
}
|
||||
|
@ -330,14 +325,6 @@ void PClassActor::DeriveData(PClass *newclass)
|
|||
|
||||
newa->DropItems = DropItems;
|
||||
|
||||
newa->DontHurtShooter = DontHurtShooter;
|
||||
newa->ExplosionRadius = ExplosionRadius;
|
||||
newa->ExplosionDamage = ExplosionDamage;
|
||||
newa->MeleeDamage = MeleeDamage;
|
||||
newa->MeleeSound = MeleeSound;
|
||||
newa->MissileName = MissileName;
|
||||
newa->MissileHeight = MissileHeight;
|
||||
|
||||
newa->VisibleToPlayerClass = VisibleToPlayerClass;
|
||||
|
||||
if (DamageFactors != NULL)
|
||||
|
|
|
@ -311,15 +311,6 @@ public:
|
|||
FString SourceLumpName;
|
||||
FIntCVar *distancecheck;
|
||||
|
||||
// Old Decorate compatibility stuff
|
||||
bool DontHurtShooter;
|
||||
int ExplosionRadius;
|
||||
int ExplosionDamage;
|
||||
int MeleeDamage;
|
||||
FSoundID MeleeSound;
|
||||
FName MissileName;
|
||||
double MissileHeight;
|
||||
|
||||
// These are only valid for inventory items.
|
||||
TArray<PClassActor *> RestrictedToPlayerClass;
|
||||
TArray<PClassActor *> ForbiddenToPlayerClass;
|
||||
|
|
|
@ -400,6 +400,9 @@ xx(VisibleEndPitch)
|
|||
xx(Format)
|
||||
xx(PickupMsg)
|
||||
xx(Respawnable)
|
||||
xx(ExplosionDamage)
|
||||
xx(ExplosionRadius)
|
||||
xx(DontHurtShooter)
|
||||
|
||||
// Various actor names which are used internally
|
||||
xx(MapSpot)
|
||||
|
|
|
@ -86,7 +86,6 @@ AActor *SingleActorFromTID(int tid, AActor *defactor);
|
|||
|
||||
|
||||
static FRandom pr_camissile ("CustomActorfire");
|
||||
static FRandom pr_camelee ("CustomMelee");
|
||||
static FRandom pr_cabullet ("CustomBullet");
|
||||
static FRandom pr_cajump ("CustomJump");
|
||||
static FRandom pr_cwbullet ("CustomWpBullet");
|
||||
|
@ -924,86 +923,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_CopyFriendliness)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Customizable attack functions which use actor parameters.
|
||||
//
|
||||
//==========================================================================
|
||||
static void DoAttack (AActor *self, bool domelee, bool domissile,
|
||||
int MeleeDamage, FSoundID MeleeSound, PClassActor *MissileType,double MissileHeight)
|
||||
{
|
||||
if (self->target == NULL) return;
|
||||
|
||||
A_FaceTarget (self);
|
||||
if (domelee && MeleeDamage>0 && self->CheckMeleeRange ())
|
||||
{
|
||||
int damage = pr_camelee.HitDice(MeleeDamage);
|
||||
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
|
||||
int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
|
||||
P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
|
||||
}
|
||||
else if (domissile && MissileType != NULL)
|
||||
{
|
||||
// This seemingly senseless code is needed for proper aiming.
|
||||
double add = MissileHeight + self->GetBobOffset() - 32;
|
||||
self->AddZ(add);
|
||||
AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, MissileType, false);
|
||||
self->AddZ(-add);
|
||||
|
||||
if (missile)
|
||||
{
|
||||
// automatic handling of seeker missiles
|
||||
if (missile->flags2&MF2_SEEKERMISSILE)
|
||||
{
|
||||
missile->tracer=self->target;
|
||||
}
|
||||
P_CheckMissileSpawn(missile, self->radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_MeleeAttack)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
int MeleeDamage = self->GetClass()->MeleeDamage;
|
||||
FSoundID MeleeSound = self->GetClass()->MeleeSound;
|
||||
DoAttack(self, true, false, MeleeDamage, MeleeSound, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_MissileAttack)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PClassActor *MissileType = PClass::FindActor(self->GetClass()->MissileName);
|
||||
DoAttack(self, false, true, 0, 0, MissileType, self->GetClass()->MissileHeight);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_ComboAttack)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
int MeleeDamage = self->GetClass()->MeleeDamage;
|
||||
FSoundID MeleeSound = self->GetClass()->MeleeSound;
|
||||
PClassActor *MissileType = PClass::FindActor(self->GetClass()->MissileName);
|
||||
DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, self->GetClass()->MissileHeight);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_BasicAttack)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT (melee_damage);
|
||||
PARAM_SOUND (melee_sound);
|
||||
PARAM_CLASS (missile_type, AActor);
|
||||
PARAM_FLOAT (missile_height);
|
||||
|
||||
if (missile_type != NULL)
|
||||
{
|
||||
DoAttack(self, true, true, melee_damage, melee_sound, missile_type, missile_height);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Custom sound functions.
|
||||
|
@ -1261,9 +1180,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Explode)
|
|||
|
||||
if (damage < 0) // get parameters from metadata
|
||||
{
|
||||
damage = self->GetClass()->ExplosionDamage;
|
||||
distance = self->GetClass()->ExplosionRadius;
|
||||
flags = !self->GetClass()->DontHurtShooter;
|
||||
damage = self->IntVar(NAME_ExplosionDamage);
|
||||
distance = self->IntVar(NAME_ExplosionRadius);
|
||||
flags = !self->BoolVar(NAME_DontHurtShooter);
|
||||
alert = false;
|
||||
}
|
||||
if (distance <= 0) distance = damage;
|
||||
|
|
|
@ -328,13 +328,6 @@ DEFINE_FIELD(PClassActor, HowlSound)
|
|||
DEFINE_FIELD(PClassActor, BloodType)
|
||||
DEFINE_FIELD(PClassActor, BloodType2)
|
||||
DEFINE_FIELD(PClassActor, BloodType3)
|
||||
DEFINE_FIELD(PClassActor, DontHurtShooter)
|
||||
DEFINE_FIELD(PClassActor, ExplosionRadius)
|
||||
DEFINE_FIELD(PClassActor, ExplosionDamage)
|
||||
DEFINE_FIELD(PClassActor, MeleeDamage)
|
||||
DEFINE_FIELD(PClassActor, MeleeSound)
|
||||
DEFINE_FIELD(PClassActor, MissileName)
|
||||
DEFINE_FIELD(PClassActor, MissileHeight)
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -445,18 +445,18 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults,
|
|||
else if (def == DEF_Projectile && sc.Compare ("ExplosionRadius"))
|
||||
{
|
||||
sc.MustGetNumber ();
|
||||
bag.Info->ExplosionRadius = sc.Number;
|
||||
defaults->IntVar(NAME_ExplosionRadius) = sc.Number;
|
||||
extra.bExplosive = true;
|
||||
}
|
||||
else if (def == DEF_Projectile && sc.Compare ("ExplosionDamage"))
|
||||
{
|
||||
sc.MustGetNumber ();
|
||||
bag.Info->ExplosionDamage = sc.Number;
|
||||
defaults->IntVar(NAME_ExplosionDamage) = sc.Number;
|
||||
extra.bExplosive = true;
|
||||
}
|
||||
else if (def == DEF_Projectile && sc.Compare ("DoNotHurtShooter"))
|
||||
{
|
||||
bag.Info->DontHurtShooter = true;
|
||||
defaults->BoolVar(NAME_DontHurtShooter) = true;
|
||||
}
|
||||
else if (def == DEF_Projectile && sc.Compare ("Damage"))
|
||||
{
|
||||
|
|
|
@ -1001,35 +1001,6 @@ DEFINE_PROPERTY(hitobituary, S, Actor)
|
|||
static_cast<PClassActor *>(info)->HitObituary = str;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(donthurtshooter, 0, Actor)
|
||||
{
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
static_cast<PClassActor *>(info)->DontHurtShooter = true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(explosionradius, I, Actor)
|
||||
{
|
||||
PROP_INT_PARM(id, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
static_cast<PClassActor *>(info)->ExplosionRadius = id;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(explosiondamage, I, Actor)
|
||||
{
|
||||
PROP_INT_PARM(id, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
static_cast<PClassActor *>(info)->ExplosionDamage = id;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
|
@ -1068,16 +1039,6 @@ DEFINE_PROPERTY(meleethreshold, F, Actor)
|
|||
defaults->meleethreshold = id;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(meleedamage, I, Actor)
|
||||
{
|
||||
PROP_INT_PARM(id, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
static_cast<PClassActor *>(info)->MeleeDamage = id;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
|
@ -1087,36 +1048,6 @@ DEFINE_PROPERTY(meleerange, F, Actor)
|
|||
defaults->meleerange = id;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(meleesound, S, Actor)
|
||||
{
|
||||
PROP_STRING_PARM(str, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
static_cast<PClassActor *>(info)->MeleeSound = str;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(missiletype, S, Actor)
|
||||
{
|
||||
PROP_STRING_PARM(str, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
static_cast<PClassActor *>(info)->MissileName = str;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(missileheight, F, Actor)
|
||||
{
|
||||
PROP_DOUBLE_PARM(id, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
|
||||
static_cast<PClassActor *>(info)->MissileHeight = id;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
|
|
|
@ -281,6 +281,7 @@ static void ParseSingleFile(const char *filename, int lump, void *parser, ZCCPar
|
|||
tokentype = ZCC_FLOATCONST;
|
||||
break;
|
||||
|
||||
case TK_None: // 'NONE' is a token for SBARINFO but not here.
|
||||
case TK_Identifier:
|
||||
value.Int = FName(sc.String);
|
||||
tokentype = ZCC_IDENTIFIER;
|
||||
|
|
|
@ -204,14 +204,23 @@ class Actor : Thinker native
|
|||
native meta Name BloodType; // Blood replacement type
|
||||
native meta Name BloodType2; // Bloopsplatter replacement type
|
||||
native meta Name BloodType3; // AxeBlood replacement type
|
||||
native meta bool DontHurtShooter;
|
||||
native meta int ExplosionRadius;
|
||||
native meta int ExplosionDamage;
|
||||
native meta int MeleeDamage;
|
||||
native meta Sound MeleeSound;
|
||||
native meta Name MissileName;
|
||||
native meta double MissileHeight;
|
||||
|
||||
meta bool DontHurtShooter;
|
||||
meta int ExplosionRadius;
|
||||
meta int ExplosionDamage;
|
||||
meta int MeleeDamage;
|
||||
meta Sound MeleeSound;
|
||||
meta double MissileHeight;
|
||||
meta Name MissileName;
|
||||
|
||||
Property prefix: none;
|
||||
Property MeleeDamage: MeleeDamage;
|
||||
Property MeleeSound: MeleeSound;
|
||||
Property MissileHeight: MissileHeight;
|
||||
Property MissileType: MissileName;
|
||||
Property DontHurtShooter: DontHurtShooter;
|
||||
Property ExplosionRadius: ExplosionRadius;
|
||||
Property ExplosionDamage: ExplosionDamage;
|
||||
|
||||
// need some definition work first
|
||||
//FRenderStyle RenderStyle;
|
||||
|
@ -271,6 +280,7 @@ class Actor : Thinker native
|
|||
DefThreshold 100;
|
||||
BloodType "Blood", "BloodSplatter", "AxeBlood";
|
||||
ExplosionDamage 128;
|
||||
ExplosionRadius -1; // i.e. use ExplosionDamage value
|
||||
MissileHeight 32;
|
||||
SpriteAngle 0;
|
||||
SpriteRotation 0;
|
||||
|
@ -725,6 +735,68 @@ class Actor : Thinker native
|
|||
native bool A_LineEffect(int boomspecial = 0, int tag = 0);
|
||||
// End of MBF redundant functions.
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// old customizable attack functions which use actor parameters.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
private void DoAttack (bool domelee, bool domissile, int MeleeDamage, Sound MeleeSound, Class<Actor> MissileType,double MissileHeight)
|
||||
{
|
||||
if (target == NULL) return;
|
||||
|
||||
A_FaceTarget ();
|
||||
if (domelee && MeleeDamage>0 && CheckMeleeRange ())
|
||||
{
|
||||
int damage = random[CustomMelee](1, 8) * MeleeDamage;
|
||||
if (MeleeSound) A_PlaySound (MeleeSound, CHAN_WEAPON);
|
||||
int newdam = target.DamageMobj (self, self, damage, 'Melee');
|
||||
target.TraceBleed (newdam > 0 ? newdam : damage, self);
|
||||
}
|
||||
else if (domissile && MissileType != NULL)
|
||||
{
|
||||
// This seemingly senseless code is needed for proper aiming.
|
||||
double add = MissileHeight + GetBobOffset() - 32;
|
||||
AddZ(add);
|
||||
Actor missile = SpawnMissileXYZ (Pos + (0, 0, 32), target, MissileType, false);
|
||||
AddZ(-add);
|
||||
|
||||
if (missile)
|
||||
{
|
||||
// automatic handling of seeker missiles
|
||||
if (missile.bSeekerMissile)
|
||||
{
|
||||
missile.tracer = target;
|
||||
}
|
||||
missile.CheckMissileSpawn(radius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deprecated void A_MeleeAttack()
|
||||
{
|
||||
DoAttack(true, false, MeleeDamage, MeleeSound, NULL, 0);
|
||||
}
|
||||
|
||||
deprecated void A_MissileAttack()
|
||||
{
|
||||
Class<Actor> MissileType = MissileName;
|
||||
DoAttack(false, true, 0, 0, MissileType, MissileHeight);
|
||||
}
|
||||
|
||||
deprecated void A_ComboAttack()
|
||||
{
|
||||
Class<Actor> MissileType = MissileName;
|
||||
DoAttack(true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight);
|
||||
}
|
||||
|
||||
void A_BasicAttack(int melee_damage, sound melee_sound, class<actor> missile_type, double missile_height)
|
||||
{
|
||||
DoAttack(true, true, melee_damage, melee_sound, missile_type, missile_height);
|
||||
}
|
||||
|
||||
|
||||
native void A_MonsterRail();
|
||||
native void A_Pain();
|
||||
native void A_NoBlocking(bool drop = true);
|
||||
|
@ -753,9 +825,6 @@ class Actor : Thinker native
|
|||
native void A_Wander(int flags = 0);
|
||||
native void A_Look2();
|
||||
|
||||
deprecated native void A_MissileAttack();
|
||||
deprecated native void A_MeleeAttack();
|
||||
deprecated native void A_ComboAttack();
|
||||
deprecated native void A_BulletAttack();
|
||||
native void A_WolfAttack(int flags = 0, sound whattoplay = "weapons/pistol", double snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, double runspeed = 160.0, class<Actor> pufftype = "BulletPuff");
|
||||
native void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false);
|
||||
|
@ -793,7 +862,6 @@ class Actor : Thinker native
|
|||
native void A_RaiseMaster(int flags = 0);
|
||||
native void A_RaiseChildren(int flags = 0);
|
||||
native void A_RaiseSiblings(int flags = 0);
|
||||
deprecated native void A_BasicAttack(int meleedamage, sound meleesound, class<actor> missiletype, double missileheight);
|
||||
action native bool, Actor A_ThrowGrenade(class<Actor> itemtype, double zheight = 0, double xyvel = 0, double zvel = 0, bool useammo = true);
|
||||
native void A_Weave(int xspeed, int yspeed, double xdist, double ydist);
|
||||
native bool A_Morph(class<Actor> type, int duration = 0, int flags = 0, class<Actor> enter_flash = null, class<Actor> exit_flash = null);
|
||||
|
|
Loading…
Reference in a new issue