- made GetDeathHeight a virtual scripted function.

- made GetGibHealth a virtual scripted function.
- removed a few more native meta properties.
This commit is contained in:
Christoph Oelckers 2017-02-28 13:40:46 +01:00
parent d5250d6b9f
commit 851984efe0
14 changed files with 80 additions and 115 deletions

View file

@ -41,6 +41,7 @@
class PClass;
class PType;
class FSerializer;
class FSoundID;
class DObject;
/*
@ -483,6 +484,7 @@ public:
// Add other types as needed.
bool &BoolVar(FName field);
int &IntVar(FName field);
FSoundID &SoundVar(FName field);
PalEntry &ColorVar(FName field);
FName &NameVar(FName field);
double &FloatVar(FName field);

View file

@ -728,6 +728,11 @@ inline int &DObject::IntVar(FName field)
return *(int*)ScriptVar(field, TypeSInt32);
}
inline FSoundID &DObject::SoundVar(FName field)
{
return *(FSoundID*)ScriptVar(field, TypeSound);
}
inline PalEntry &DObject::ColorVar(FName field)
{
return *(PalEntry*)ScriptVar(field, TypeColor);

View file

@ -56,6 +56,7 @@ DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mBackButton)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenMapNameFont)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenEnteringFont)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, mStatscreenFinishedFont)
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, gibfactor)
const char *GameNames[17] =

View file

@ -251,10 +251,6 @@ PClassActor::PClassActor()
DamageFactors = NULL;
PainChances = NULL;
DeathHeight = -1;
BurnHeight = -1;
GibHealth = INT_MIN;
DropItems = NULL;
// Record this in the master list.
AllActorClasses.Push(this);
@ -301,11 +297,7 @@ void PClassActor::DeriveData(PClass *newclass)
newa->DefaultStateUsage = DefaultStateUsage;
newa->Obituary = Obituary;
newa->HitObituary = HitObituary;
newa->DeathHeight = DeathHeight;
newa->BurnHeight = BurnHeight;
newa->BloodColor = BloodColor;
newa->GibHealth = GibHealth;
newa->HowlSound = HowlSound;
newa->distancecheck = distancecheck;
newa->DropItems = DropItems;

View file

@ -292,11 +292,7 @@ public:
FString Obituary; // Player was killed by this actor
FString HitObituary; // Player was killed by this actor in melee
double DeathHeight; // Height on normal death
double BurnHeight; // Height on burning death
PalEntry BloodColor; // Colorized blood
int GibHealth; // Negative health below which this monster dies an extreme death
FSoundID HowlSound; // Sound being played when electrocuted or poisoned
FDropItem *DropItems;
FString SourceLumpName;

View file

@ -393,6 +393,7 @@ xx(ReactionTime)
xx(MeleeRange)
xx(Speed)
xx(FastSpeed)
xx(HowlSound)
xx(Clamp)
xx(VisibleStartAngle)
xx(VisibleStartPitch)

View file

@ -4232,7 +4232,7 @@ enum
SOUND_Howl,
};
static FSoundID GetActorSound(const AActor *actor, int soundtype)
static FSoundID GetActorSound(AActor *actor, int soundtype)
{
switch (soundtype)
{
@ -4245,7 +4245,7 @@ static FSoundID GetActorSound(const AActor *actor, int soundtype)
case SOUND_Bounce: return actor->BounceSound;
case SOUND_WallBounce: return actor->WallBounceSound;
case SOUND_CrushPain: return actor->CrushPainSound;
case SOUND_Howl: return actor->GetClass()->HowlSound;
case SOUND_Howl: return actor->SoundVar(NAME_HowlSound);
default: return 0;
}
}

View file

@ -438,22 +438,6 @@ DEFINE_ACTION_FUNCTION(AActor, GetSpawnHealth)
return 0;
}
//==========================================================================
//
// GetGibHealth
//
//==========================================================================
DEFINE_ACTION_FUNCTION(AActor, GetGibHealth)
{
if (numret > 0)
{
PARAM_SELF_PROLOGUE(AActor);
ret->SetInt(self->GetGibHealth());
return 1;
}
return 0;
}
//==========================================================================
//
// GetSpriteAngle

View file

@ -411,23 +411,11 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags)
}
flags6 |= MF6_KILLED;
// [RH] Allow the death height to be overridden using metadata.
double metaheight = -1;
if (DamageType == NAME_Fire)
IFVIRTUAL(AActor, GetDeathHeight)
{
metaheight = GetClass()->BurnHeight;
}
if (metaheight < 0)
{
metaheight = GetClass()->DeathHeight;
}
if (metaheight < 0)
{
Height *= 0.25;
}
else
{
Height = MAX<double> (metaheight, 0);
VMValue params[] = { (DObject*)this };
VMReturn ret(&Height);
GlobalVMStack.Call(func, params, 1, &ret, 1);
}
// [RH] If the thing has a special, execute and remove it

View file

@ -319,11 +319,7 @@ DEFINE_FIELD(AActor, WoundHealth)
DEFINE_FIELD(PClassActor, Obituary)
DEFINE_FIELD(PClassActor, HitObituary)
DEFINE_FIELD(PClassActor, DeathHeight)
DEFINE_FIELD(PClassActor, BurnHeight)
DEFINE_FIELD(PClassActor, BloodColor)
DEFINE_FIELD(PClassActor, GibHealth)
DEFINE_FIELD(PClassActor, HowlSound)
//DEFINE_FIELD(PClassActor, BloodColor)
//==========================================================================
//
@ -3516,7 +3512,7 @@ int AActor::GetMissileDamage (int mask, int add)
void AActor::Howl ()
{
FSoundID howl = GetClass()->HowlSound;
FSoundID howl = IntVar(NAME_HowlSound);
if (!S_IsActorPlayingSomething(this, CHAN_BODY, howl))
{
S_Sound (this, CHAN_BODY, howl, 1, ATTN_NORM);
@ -7481,9 +7477,10 @@ void AActor::Crash()
{
FState *crashstate = NULL;
int gibh = GetGibHealth();
if (DamageType != NAME_None)
{
if (health < GetGibHealth())
if (health < gibh)
{ // Extreme death
FName labels[] = { NAME_Crash, NAME_Extreme, DamageType };
crashstate = FindState (3, labels, true);
@ -7495,7 +7492,7 @@ void AActor::Crash()
}
if (crashstate == NULL)
{
if (health < GetGibHealth())
if (health < gibh)
{ // Extreme death
crashstate = FindState(NAME_Crash, NAME_Extreme);
}
@ -7601,16 +7598,15 @@ void AActor::Revive()
int AActor::GetGibHealth() const
{
int gibhealth = GetClass()->GibHealth;
if (gibhealth != INT_MIN)
IFVIRTUAL(AActor, GetGibHealth)
{
return -abs(gibhealth);
}
else
{
return -int(SpawnHealth() * gameinfo.gibfactor);
VMValue params[] = { (DObject*)this };
int h;
VMReturn ret(&h);
GlobalVMStack.Call(func, params, 1, &ret, 1);
return h;
}
return -SpawnHealth();
}
double AActor::GetCameraHeight() const
@ -8294,9 +8290,9 @@ void PrintMiscActorInfo(AActor *query)
query->args[0], query->args[1], query->args[2], query->args[3],
query->args[4], query->special1, query->special2);
Printf("\nTID: %d", query->tid);
Printf("\nCoord= x: %f, y: %f, z:%f, floor:%f, ceiling:%f.",
Printf("\nCoord= x: %f, y: %f, z:%f, floor:%f, ceiling:%f, height= %f",
query->X(), query->Y(), query->Z(),
query->floorz, query->ceilingz);
query->floorz, query->ceilingz, query->Height);
Printf("\nSpeed= %f, velocity= x:%f, y:%f, z:%f, combined:%f.\n",
query->Speed, query->Vel.X, query->Vel.Y, query->Vel.Z, query->Vel.Length());
Printf("Scale: x:%f, y:%f\n", query->Scale.X, query->Scale.Y);

View file

@ -223,7 +223,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
{
extra.DeathHeight = ((AActor*)(type->Defaults))->Height;
}
type->DeathHeight = extra.DeathHeight;
((AActor*)(type->Defaults))->FloatVar("DeathHeight") = extra.DeathHeight;
}
bag.statedef.SetStateLabel("Death", &type->OwnedStates[extra.DeathStart]);
}
@ -262,7 +262,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
}
if (extra.BurnHeight == 0) extra.BurnHeight = ((AActor*)(type->Defaults))->Height;
type->BurnHeight = extra.BurnHeight;
((AActor*)(type->Defaults))->FloatVar("BurnHeight") = extra.BurnHeight;
bag.statedef.SetStateLabel("Burn", &type->OwnedStates[extra.FireDeathStart]);
}

View file

@ -592,16 +592,6 @@ DEFINE_PROPERTY(health, I, Actor)
defaults->health=id;
}
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(gibhealth, I, Actor)
{
PROP_INT_PARM(id, 0);
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
static_cast<PClassActor *>(info)->GibHealth = id;
}
//==========================================================================
//
//==========================================================================
@ -887,16 +877,6 @@ DEFINE_PROPERTY(activesound, S, Actor)
defaults->ActiveSound = str;
}
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(howlsound, S, Actor)
{
PROP_STRING_PARM(str, 0);
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
static_cast<PClassActor *>(info)->HowlSound = str;
}
//==========================================================================
//
//==========================================================================
@ -1000,26 +980,6 @@ DEFINE_PROPERTY(hitobituary, S, Actor)
static_cast<PClassActor *>(info)->HitObituary = str;
}
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(deathheight, F, Actor)
{
PROP_DOUBLE_PARM(h, 0);
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
static_cast<PClassActor *>(info)->DeathHeight = MAX(0., h);
}
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(burnheight, F, Actor)
{
PROP_DOUBLE_PARM(h, 0);
assert(info->IsKindOf(RUNTIME_CLASS(PClassActor)));
static_cast<PClassActor *>(info)->BurnHeight = MAX(0., h);
}
//==========================================================================
//
//==========================================================================

View file

@ -193,16 +193,16 @@ class Actor : Thinker native
native double RadiusDamageFactor; // Radius damage factor
native double SelfDamageFactor;
native double StealthAlpha;
native int WoundHealth; // Health needed to enter wound state
//native color BloodColor; // won't be accessible for now because it needs refactoring to remove the 255-translations limit.
native meta String Obituary; // Player was killed by this actor
native meta String HitObituary; // Player was killed by this actor in melee
native meta double DeathHeight; // Height on normal death
native meta double BurnHeight; // Height on burning death
native meta color BloodColor; // Colorized blood
native meta int GibHealth; // Negative health below which this monster dies an extreme death
native meta int WoundHealth; // Health needed to enter wound state
native meta Sound HowlSound; // Sound being played when electrocuted or poisoned
meta double DeathHeight; // Height on normal death
meta double BurnHeight; // Height on burning death
meta int GibHealth; // Negative health below which this monster dies an extreme death
meta Sound HowlSound; // Sound being played when electrocuted or poisoned
meta Name BloodType; // Blood replacement type
meta Name BloodType2; // Bloopsplatter replacement type
meta Name BloodType3; // AxeBlood replacement type
@ -225,6 +225,10 @@ class Actor : Thinker native
Property ExplosionDamage: ExplosionDamage;
Property BloodType: BloodType, BloodType2, BloodType3;
Property FastSpeed: FastSpeed;
Property HowlSound: HowlSound;
Property GibHealth: GibHealth;
Property DeathHeight: DeathHeight;
Property BurnHeight: BurnHeight;
// need some definition work first
//FRenderStyle RenderStyle;
@ -298,8 +302,9 @@ class Actor : Thinker native
SelfDamageFactor 1;
StealthAlpha 0;
WoundHealth 6;
GibHealth int.min;
DeathHeight -1;
BurnHeight -1;
}
// Functions
@ -383,6 +388,41 @@ class Actor : Thinker native
}
return bloodcls;
}
virtual int GetGibHealth()
{
if (GibHealth != int.min)
{
return -abs(GibHealth);
}
else
{
return -int(GetSpawnHealth() * gameinfo.gibfactor);
}
}
virtual double GetDeathHeight()
{
// [RH] Allow the death height to be overridden using metadata.
double metaheight = -1;
if (DamageType == 'Fire')
{
metaheight = BurnHeight;
}
if (metaheight < 0)
{
metaheight = DeathHeight;
}
if (metaheight < 0)
{
return Height * 0.25;
}
else
{
return MAX(metaheight, 0);
}
}
native static class<Actor> GetReplacement(class<Actor> cls);
native static class<Actor> GetReplacee(class<Actor> cls);
@ -559,7 +599,6 @@ class Actor : Thinker native
native double GetAngle(int flags, int ptr = AAPTR_TARGET);
native double GetZAt(double px = 0, double py = 0, double angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
native int GetSpawnHealth();
native int GetGibHealth();
native double GetCrouchFactor(int ptr = AAPTR_PLAYER1);
native double GetCVar(string cvar);
native int GetPlayerInput(int inputnum, int ptr = AAPTR_DEFAULT);

View file

@ -310,6 +310,7 @@ struct GameInfoStruct native
native GIFont mStatscreenMapNameFont;
native GIFont mStatscreenEnteringFont;
native GIFont mStatscreenFinishedFont;
native double gibfactor;
}
class Object native