- added Xaser's submission for accessing accuracy and stamina from DECORATE and ACS.

- added DECORATE properties for accuracy and stamina.
- Since these changes move properties from player_t to AActor all savegame compatibility code was removed and the min. savegame version bumped.


SVN r3427 (trunk)
This commit is contained in:
Christoph Oelckers 2012-03-11 09:08:35 +00:00
parent f94b38fd7f
commit e4880d162f
20 changed files with 94 additions and 141 deletions

View file

@ -851,6 +851,8 @@ public:
int special; // special int special; // special
int args[5]; // special arguments int args[5]; // special arguments
int accuracy, stamina; // [RH] Strife stats -- [XA] moved here for DECORATE/ACS access.
AActor *inext, **iprev;// Links to other mobjs in same bucket AActor *inext, **iprev;// Links to other mobjs in same bucket
TObjPtr<AActor> goal; // Monster's goal if not chasing anything TObjPtr<AActor> goal; // Monster's goal if not chasing anything
int waterlevel; // 0=none, 1=feet, 2=waist, 3=eyes int waterlevel; // 0=none, 1=feet, 2=waist, 3=eyes

View file

@ -330,8 +330,6 @@ public:
int air_finished; // [RH] Time when you start drowning int air_finished; // [RH] Time when you start drowning
WORD accuracy, stamina; // [RH] Strife stats
FName LastDamageType; // [RH] For damage-specific pain and death sounds FName LastDamageType; // [RH] For damage-specific pain and death sounds
//Added by MC: //Added by MC:

View file

@ -1367,12 +1367,8 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad)
<< level.aircontrol << level.aircontrol
<< level.teamdamage << level.teamdamage
<< level.maptime << level.maptime
<< i; << i
<< level.nextmusic;
if (SaveVersion >= 3313)
{
arc << level.nextmusic;
}
// Hub transitions must keep the current total time // Hub transitions must keep the current total time
if (!hubLoad) if (!hubLoad)

View file

@ -1301,8 +1301,8 @@ void APowerTargeter::PositionAccuracy ()
if (player != NULL) if (player != NULL)
{ {
player->psprites[ps_targetleft].sx = (160-3)*FRACUNIT - ((100 - player->accuracy) << FRACBITS); player->psprites[ps_targetleft].sx = (160-3)*FRACUNIT - ((100 - player->mo->accuracy) << FRACBITS);
player->psprites[ps_targetright].sx = (160-3)*FRACUNIT + ((100 - player->accuracy) << FRACBITS); player->psprites[ps_targetright].sx = (160-3)*FRACUNIT + ((100 - player->mo->accuracy) << FRACBITS);
} }
} }

View file

@ -44,26 +44,6 @@ void DLightningThinker::Serialize (FArchive &arc)
arc << Stopped << NextLightningFlash << LightningFlashCount; arc << Stopped << NextLightningFlash << LightningFlashCount;
if (SaveVersion < 3243)
{
// Do nothing with old savegames and just keep whatever the constructor made
// but read the obsolete data from the savegame
for (i = (numsectors + (numsectors+7)/8); i > 0; --i)
{
if (SaveVersion < 3223)
{
BYTE bytelight;
arc << bytelight;
}
else
{
short shortlight;
arc << shortlight;
}
}
return;
}
if (arc.IsLoading ()) if (arc.IsLoading ())
{ {
if (LightningLightLevels != NULL) if (LightningLightLevels != NULL)

View file

@ -188,7 +188,7 @@ bool P_GiveBody (AActor *actor, int num)
num = clamp(num, -65536, 65536); // prevent overflows for bad values num = clamp(num, -65536, 65536); // prevent overflows for bad values
if (player != NULL) if (player != NULL)
{ {
max = static_cast<APlayerPawn*>(actor)->GetMaxHealth() + player->stamina; max = static_cast<APlayerPawn*>(actor)->GetMaxHealth() + player->mo->stamina;
// [MH] First step in predictable generic morph effects // [MH] First step in predictable generic morph effects
if (player->morphTics) if (player->morphTics)
{ {
@ -196,7 +196,7 @@ bool P_GiveBody (AActor *actor, int num)
{ {
if (!(player->MorphStyle & MORPH_ADDSTAMINA)) if (!(player->MorphStyle & MORPH_ADDSTAMINA))
{ {
max -= player->stamina; max -= player->mo->stamina;
} }
} }
else // old health behaviour else // old health behaviour
@ -204,7 +204,7 @@ bool P_GiveBody (AActor *actor, int num)
max = MAXMORPHHEALTH; max = MAXMORPHHEALTH;
if (player->MorphStyle & MORPH_ADDSTAMINA) if (player->MorphStyle & MORPH_ADDSTAMINA)
{ {
max += player->stamina; max += player->mo->stamina;
} }
} }
} }
@ -1483,7 +1483,7 @@ bool AHealth::TryPickup (AActor *&other)
PrevHealth = other->player->health; PrevHealth = other->player->health;
if (max == 0) if (max == 0)
{ {
max = static_cast<APlayerPawn*>(other)->GetMaxHealth() + player->stamina; max = static_cast<APlayerPawn*>(other)->GetMaxHealth() + player->mo->stamina;
// [MH] First step in predictable generic morph effects // [MH] First step in predictable generic morph effects
if (player->morphTics) if (player->morphTics)
{ {
@ -1491,7 +1491,7 @@ bool AHealth::TryPickup (AActor *&other)
{ {
if (!(player->MorphStyle & MORPH_ADDSTAMINA)) if (!(player->MorphStyle & MORPH_ADDSTAMINA))
{ {
max -= player->stamina; max -= player->mo->stamina;
} }
} }
else // old health behaviour else // old health behaviour
@ -1499,7 +1499,7 @@ bool AHealth::TryPickup (AActor *&other)
max = MAXMORPHHEALTH; max = MAXMORPHHEALTH;
if (player->MorphStyle & MORPH_ADDSTAMINA) if (player->MorphStyle & MORPH_ADDSTAMINA)
{ {
max += player->stamina; max += player->mo->stamina;
} }
} }
} }

View file

@ -1270,10 +1270,10 @@ class CommandDrawNumber : public CommandDrawString
num = statusBar->CPlayer->mo->InvSel->Amount; num = statusBar->CPlayer->mo->InvSel->Amount;
break; break;
case ACCURACY: case ACCURACY:
num = statusBar->CPlayer->accuracy; num = statusBar->CPlayer->mo->accuracy;
break; break;
case STAMINA: case STAMINA:
num = statusBar->CPlayer->stamina; num = statusBar->CPlayer->mo->stamina;
break; break;
case KEYS: case KEYS:
num = 0; num = 0;
@ -2455,7 +2455,7 @@ class CommandDrawBar : public SBarInfoCommand
max = 0; max = 0;
} }
else //default to the class's health else //default to the class's health
max = statusBar->CPlayer->mo->GetMaxHealth() + statusBar->CPlayer->stamina; max = statusBar->CPlayer->mo->GetMaxHealth() + statusBar->CPlayer->mo->stamina;
break; break;
case ARMOR: case ARMOR:
value = statusBar->armor != NULL ? statusBar->armor->Amount : 0; value = statusBar->armor != NULL ? statusBar->armor->Amount : 0;
@ -2970,7 +2970,7 @@ class CommandDrawGem : public SBarInfoCommand
void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged)
{ {
goalValue = armor ? statusBar->armor->Amount : statusBar->CPlayer->mo->health; goalValue = armor ? statusBar->armor->Amount : statusBar->CPlayer->mo->health;
int max = armor ? 100 : statusBar->CPlayer->mo->GetMaxHealth() + statusBar->CPlayer->stamina; int max = armor ? 100 : statusBar->CPlayer->mo->GetMaxHealth() + statusBar->CPlayer->mo->stamina;
if(max != 0 && goalValue > 0) if(max != 0 && goalValue > 0)
{ {
goalValue = (goalValue*100)/max; goalValue = (goalValue*100)/max;

View file

@ -230,9 +230,9 @@ static void DrawStatus(player_t * CPlayer, int x, int y)
if (hud_showstats) if (hud_showstats)
{ {
mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->accuracy); mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->mo->accuracy);
DrawStatLine(x, y, "Ac:", tempstr); DrawStatLine(x, y, "Ac:", tempstr);
mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->stamina); mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->mo->stamina);
DrawStatLine(x, y, "St:", tempstr); DrawStatLine(x, y, "St:", tempstr);
} }

View file

@ -82,7 +82,7 @@ bool AHealthTraining::TryPickup (AActor *&toucher)
AInventory *coin = Spawn<ACoin> (0,0,0, NO_REPLACE); AInventory *coin = Spawn<ACoin> (0,0,0, NO_REPLACE);
if (coin != NULL) if (coin != NULL)
{ {
coin->Amount = toucher->player->accuracy*5 + 300; coin->Amount = toucher->player->mo->accuracy*5 + 300;
if (!coin->CallTryPickup (toucher)) if (!coin->CallTryPickup (toucher))
{ {
coin->Destroy (); coin->Destroy ();
@ -339,9 +339,9 @@ bool AUpgradeStamina::TryPickup (AActor *&toucher)
if (toucher->player == NULL) if (toucher->player == NULL)
return false; return false;
toucher->player->stamina += Amount; toucher->player->mo->stamina += Amount;
if (toucher->player->stamina >= MaxAmount) if (toucher->player->mo->stamina >= MaxAmount)
toucher->player->stamina = MaxAmount; toucher->player->mo->stamina = MaxAmount;
P_GiveBody (toucher, -100); P_GiveBody (toucher, -100);
GoAwayAndDie (); GoAwayAndDie ();
@ -354,9 +354,9 @@ IMPLEMENT_CLASS (AUpgradeAccuracy)
bool AUpgradeAccuracy::TryPickup (AActor *&toucher) bool AUpgradeAccuracy::TryPickup (AActor *&toucher)
{ {
if (toucher->player == NULL || toucher->player->accuracy >= 100) if (toucher->player == NULL || toucher->player->mo->accuracy >= 100)
return false; return false;
toucher->player->accuracy += 10; toucher->player->mo->accuracy += 10;
GoAwayAndDie (); GoAwayAndDie ();
return true; return true;
} }

View file

@ -100,7 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
int power; int power;
AActor *linetarget; AActor *linetarget;
power = MIN(10, self->player->stamina / 10); power = MIN(10, self->player->mo->stamina / 10);
damage = (pr_jabdagger() % (power + 8)) * (power + 2); damage = (pr_jabdagger() % (power + 8)) * (power + 2);
if (self->FindInventory<APowerStrength>()) if (self->FindInventory<APowerStrength>())
@ -237,7 +237,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
if (ti) if (ti)
{ {
savedangle = self->angle; savedangle = self->angle;
self->angle += pr_electric.Random2 () << (18 - self->player->accuracy * 5 / 100); self->angle += pr_electric.Random2 () << (18 - self->player->mo->accuracy * 5 / 100);
self->player->mo->PlayAttacking2 (); self->player->mo->PlayAttacking2 ();
P_SpawnPlayerMissile (self, ti); P_SpawnPlayerMissile (self, ti);
self->angle = savedangle; self->angle = savedangle;
@ -263,7 +263,7 @@ void P_StrifeGunShot (AActor *mo, bool accurate, angle_t pitch)
if (mo->player != NULL && !accurate) if (mo->player != NULL && !accurate)
{ {
angle += pr_sgunshot.Random2() << (20 - mo->player->accuracy * 5 / 100); angle += pr_sgunshot.Random2() << (20 - mo->player->mo->accuracy * 5 / 100);
} }
P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, NAME_StrifePuff); P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_None, NAME_StrifePuff);
@ -324,7 +324,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile)
} }
savedangle = self->angle; savedangle = self->angle;
self->angle += pr_minimissile.Random2() << (19 - player->accuracy * 5 / 100); self->angle += pr_minimissile.Random2() << (19 - player->mo->accuracy * 5 / 100);
player->mo->PlayAttacking2 (); player->mo->PlayAttacking2 ();
P_SpawnPlayerMissile (self, PClass::FindClass("MiniMissile")); P_SpawnPlayerMissile (self, PClass::FindClass("MiniMissile"));
self->angle = savedangle; self->angle = savedangle;

View file

@ -664,8 +664,8 @@ private:
// Show miscellaneous status items. // Show miscellaneous status items.
// Print stats // Print stats
DrINumber2 (CPlayer->accuracy, left+268*xscale, top+28*yscale, 7*xscale, imgFONY0); DrINumber2 (CPlayer->mo->accuracy, left+268*xscale, top+28*yscale, 7*xscale, imgFONY0);
DrINumber2 (CPlayer->stamina, left+268*xscale, top+52*yscale, 7*xscale, imgFONY0); DrINumber2 (CPlayer->mo->stamina, left+268*xscale, top+52*yscale, 7*xscale, imgFONY0);
// How many keys does the player have? // How many keys does the player have?
for (i = 0, item = CPlayer->mo->Inventory; for (i = 0, item = CPlayer->mo->Inventory;

View file

@ -2031,21 +2031,6 @@ void FBehavior::StaticStopMyScripts (AActor *actor)
//========================================================================== //==========================================================================
void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte) void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte)
{
if (SaveVersion < 3359)
{
if (was2byte)
{
WORD oldver;
arc << oldver;
scriptnum = oldver;
}
else
{
arc << scriptnum;
}
}
else
{ {
arc << scriptnum; arc << scriptnum;
// If the script number is negative, then it's really a name. // If the script number is negative, then it's really a name.
@ -2063,7 +2048,6 @@ void P_SerializeACSScriptNumber(FArchive &arc, int &scriptnum, bool was2byte)
} }
} }
} }
}
//---- The ACS Interpreter ----// //---- The ACS Interpreter ----//
@ -2819,6 +2803,8 @@ enum
APROP_ScaleY = 30, APROP_ScaleY = 30,
APROP_Dormant = 31, APROP_Dormant = 31,
APROP_Mass = 32, APROP_Mass = 32,
APROP_Accuracy = 33,
APROP_Stamina = 34,
}; };
// These are needed for ACS's APROP_RenderStyle // These are needed for ACS's APROP_RenderStyle
@ -3012,6 +2998,14 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
actor->Mass = value; actor->Mass = value;
break; break;
case APROP_Accuracy:
actor->accuracy = value;
break;
case APROP_Stamina:
actor->stamina = value;
break;
default: default:
// do nothing. // do nothing.
break; break;
@ -3078,6 +3072,8 @@ int DLevelScript::GetActorProperty (int tid, int property)
case APROP_ScaleX: return actor->scaleX; case APROP_ScaleX: return actor->scaleX;
case APROP_ScaleY: return actor->scaleY; case APROP_ScaleY: return actor->scaleY;
case APROP_Mass: return actor->Mass; case APROP_Mass: return actor->Mass;
case APROP_Accuracy: return actor->accuracy;
case APROP_Stamina: return actor->stamina;
default: return 0; default: return 0;
} }
@ -3116,6 +3112,8 @@ int DLevelScript::CheckActorProperty (int tid, int property, int value)
case APROP_ScaleX: case APROP_ScaleX:
case APROP_ScaleY: case APROP_ScaleY:
case APROP_Mass: case APROP_Mass:
case APROP_Accuracy:
case APROP_Stamina:
return (GetActorProperty(tid, property) == value); return (GetActorProperty(tid, property) == value);
// Boolean values need to compare to a binary version of value // Boolean values need to compare to a binary version of value

View file

@ -230,12 +230,9 @@ void AActor::Serialize (FArchive &arc)
<< velz << velz
<< tics << tics
<< state << state
<< Damage; << Damage
if (SaveVersion >= 3227) << projectileKickback
{ << flags
arc << projectileKickback;
}
arc << flags
<< flags2 << flags2
<< flags3 << flags3
<< flags4 << flags4
@ -270,6 +267,8 @@ void AActor::Serialize (FArchive &arc)
arc << args[0]; arc << args[0];
} }
arc << args[1] << args[2] << args[3] << args[4] arc << args[1] << args[2] << args[3] << args[4]
<< accuracy
<< stamina
<< goal << goal
<< waterlevel << waterlevel
<< MinMissileChance << MinMissileChance
@ -305,14 +304,10 @@ void AActor::Serialize (FArchive &arc)
<< maxtargetrange << maxtargetrange
<< meleethreshold << meleethreshold
<< meleerange << meleerange
<< DamageType; << DamageType
if (SaveVersion >= 3237)
{
arc
<< PainType << PainType
<< DeathType; << DeathType
} << gravity
arc << gravity
<< FastChaseStrafeCount << FastChaseStrafeCount
<< master << master
<< smokecounter << smokecounter
@ -321,22 +316,16 @@ void AActor::Serialize (FArchive &arc)
<< VisibleToTeam // [BB] << VisibleToTeam // [BB]
<< pushfactor << pushfactor
<< Species << Species
<< Score; << Score
if (SaveVersion >= 3113) << DesignatedTeam
{ << lastpush << lastbump
arc << DesignatedTeam;
}
arc << lastpush << lastbump
<< PainThreshold << PainThreshold
<< DamageFactor << DamageFactor
<< WeaveIndexXY << WeaveIndexZ << WeaveIndexXY << WeaveIndexZ
<< PoisonDamageReceived << PoisonDurationReceived << PoisonPeriodReceived << Poisoner << PoisonDamageReceived << PoisonDurationReceived << PoisonPeriodReceived << Poisoner
<< PoisonDamage << PoisonDuration << PoisonPeriod; << PoisonDamage << PoisonDuration << PoisonPeriod
if (SaveVersion >= 3235) << PoisonDamageType << PoisonDamageTypeReceived
{ << ConversationRoot << Conversation;
arc << PoisonDamageType << PoisonDamageTypeReceived;
}
arc << ConversationRoot << Conversation;
{ {
FString tagstr; FString tagstr;

View file

@ -326,18 +326,9 @@ void P_SerializeWorld (FArchive &arc)
for (i = 0, sec = sectors; i < numsectors; i++, sec++) for (i = 0, sec = sectors; i < numsectors; i++, sec++)
{ {
arc << sec->floorplane arc << sec->floorplane
<< sec->ceilingplane; << sec->ceilingplane
if (SaveVersion < 3223) << sec->lightlevel
{ << sec->special
BYTE bytelight;
arc << bytelight;
sec->lightlevel = bytelight;
}
else
{
arc << sec->lightlevel;
}
arc << sec->special
<< sec->tag << sec->tag
<< sec->soundtraversed << sec->soundtraversed
<< sec->seqType << sec->seqType

View file

@ -727,17 +727,7 @@ IMPLEMENT_CLASS (DLightTransfer)
void DLightTransfer::Serialize (FArchive &arc) void DLightTransfer::Serialize (FArchive &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
if (SaveVersion < 3223) arc << LastLight << Source << TargetTag << CopyFloor;
{
BYTE bytelight;
arc << bytelight;
LastLight = bytelight;
}
else
{
arc << LastLight;
}
arc << Source << TargetTag << CopyFloor;
} }
DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor) DLightTransfer::DLightTransfer (sector_t *srcSec, int target, bool copyFloor)
@ -820,17 +810,7 @@ IMPLEMENT_CLASS (DWallLightTransfer)
void DWallLightTransfer::Serialize (FArchive &arc) void DWallLightTransfer::Serialize (FArchive &arc)
{ {
Super::Serialize (arc); Super::Serialize (arc);
if (SaveVersion < 3223) arc << LastLight << Source << TargetID << Flags;
{
BYTE bytelight;
arc << bytelight;
LastLight = bytelight;
}
else
{
arc << LastLight;
}
arc << Source << TargetID << Flags;
} }
DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, BYTE flags) DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, BYTE flags)

View file

@ -269,8 +269,6 @@ player_t::player_t()
respawn_time(0), respawn_time(0),
camera(0), camera(0),
air_finished(0), air_finished(0),
accuracy(0),
stamina(0),
savedyaw(0), savedyaw(0),
savedpitch(0), savedpitch(0),
angle(0), angle(0),
@ -2616,7 +2614,6 @@ void player_t::Serialize (FArchive &arc)
<< BlendG << BlendG
<< BlendB << BlendB
<< BlendA << BlendA
<< accuracy << stamina
<< LogText << LogText
<< ConversationNPC << ConversationNPC
<< ConversationPC << ConversationPC

View file

@ -82,6 +82,8 @@ DEFINE_MEMBER_VARIABLE(scaleX, AActor)
DEFINE_MEMBER_VARIABLE(scaleY, AActor) DEFINE_MEMBER_VARIABLE(scaleY, AActor)
DEFINE_MEMBER_VARIABLE(Damage, AActor) DEFINE_MEMBER_VARIABLE(Damage, AActor)
DEFINE_MEMBER_VARIABLE(Score, AActor) DEFINE_MEMBER_VARIABLE(Score, AActor)
DEFINE_MEMBER_VARIABLE(accuracy, AActor)
DEFINE_MEMBER_VARIABLE(stamina, AActor)
//========================================================================== //==========================================================================
// //

View file

@ -1257,6 +1257,24 @@ DEFINE_PROPERTY(visibletoplayerclass, S_s, Actor)
} }
} }
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(accuracy, I, Actor)
{
PROP_INT_PARM(i, 0);
defaults->accuracy = i;
}
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(stamina, I, Actor)
{
PROP_INT_PARM(i, 0);
defaults->stamina = i;
}
//========================================================================== //==========================================================================
// //
// Special inventory properties // Special inventory properties

View file

@ -75,7 +75,7 @@
// SAVESIG should match SAVEVER. // SAVESIG should match SAVEVER.
// MINSAVEVER is the minimum level snapshot version that can be loaded. // MINSAVEVER is the minimum level snapshot version that can be loaded.
#define MINSAVEVER 3100 #define MINSAVEVER 3427
#if SVN_REVISION_NUMBER < MINSAVEVER #if SVN_REVISION_NUMBER < MINSAVEVER
// If we don't know the current revision write something very high to ensure that // If we don't know the current revision write something very high to ensure that

View file

@ -54,6 +54,8 @@ ACTOR Actor native //: Thinker
native fixed_t scaleX; native fixed_t scaleX;
native fixed_t scaleY; native fixed_t scaleY;
native int score; native int score;
native int accuracy;
native int stamina;
// Meh, MBF redundant functions. Only for DeHackEd support. // Meh, MBF redundant functions. Only for DeHackEd support.
action native A_Turn(float angle = 0); action native A_Turn(float angle = 0);