- 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 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
TObjPtr<AActor> goal; // Monster's goal if not chasing anything
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
WORD accuracy, stamina; // [RH] Strife stats
FName LastDamageType; // [RH] For damage-specific pain and death sounds
//Added by MC:

View File

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

View File

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

View File

@ -44,26 +44,6 @@ void DLightningThinker::Serialize (FArchive &arc)
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 (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
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
if (player->morphTics)
{
@ -196,7 +196,7 @@ bool P_GiveBody (AActor *actor, int num)
{
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
{
max -= player->stamina;
max -= player->mo->stamina;
}
}
else // old health behaviour
@ -204,7 +204,7 @@ bool P_GiveBody (AActor *actor, int num)
max = MAXMORPHHEALTH;
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;
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
if (player->morphTics)
{
@ -1491,7 +1491,7 @@ bool AHealth::TryPickup (AActor *&other)
{
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
{
max -= player->stamina;
max -= player->mo->stamina;
}
}
else // old health behaviour
@ -1499,7 +1499,7 @@ bool AHealth::TryPickup (AActor *&other)
max = MAXMORPHHEALTH;
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;
break;
case ACCURACY:
num = statusBar->CPlayer->accuracy;
num = statusBar->CPlayer->mo->accuracy;
break;
case STAMINA:
num = statusBar->CPlayer->stamina;
num = statusBar->CPlayer->mo->stamina;
break;
case KEYS:
num = 0;
@ -2455,7 +2455,7 @@ class CommandDrawBar : public SBarInfoCommand
max = 0;
}
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;
case ARMOR:
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)
{
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)
{
goalValue = (goalValue*100)/max;

View File

@ -230,9 +230,9 @@ static void DrawStatus(player_t * CPlayer, int x, int y)
if (hud_showstats)
{
mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->accuracy);
mysnprintf(tempstr, countof(tempstr), "%i ", CPlayer->mo->accuracy);
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);
}

View File

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

View File

@ -100,7 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
int power;
AActor *linetarget;
power = MIN(10, self->player->stamina / 10);
power = MIN(10, self->player->mo->stamina / 10);
damage = (pr_jabdagger() % (power + 8)) * (power + 2);
if (self->FindInventory<APowerStrength>())
@ -237,7 +237,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
if (ti)
{
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 ();
P_SpawnPlayerMissile (self, ti);
self->angle = savedangle;
@ -263,7 +263,7 @@ void P_StrifeGunShot (AActor *mo, bool accurate, angle_t pitch)
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);
@ -324,7 +324,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile)
}
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 ();
P_SpawnPlayerMissile (self, PClass::FindClass("MiniMissile"));
self->angle = savedangle;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -82,6 +82,8 @@ DEFINE_MEMBER_VARIABLE(scaleX, AActor)
DEFINE_MEMBER_VARIABLE(scaleY, AActor)
DEFINE_MEMBER_VARIABLE(Damage, 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

View File

@ -75,7 +75,7 @@
// SAVESIG should match SAVEVER.
// MINSAVEVER is the minimum level snapshot version that can be loaded.
#define MINSAVEVER 3100
#define MINSAVEVER 3427
#if SVN_REVISION_NUMBER < MINSAVEVER
// 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 scaleY;
native int score;
native int accuracy;
native int stamina;
// Meh, MBF redundant functions. Only for DeHackEd support.
action native A_Turn(float angle = 0);