- exported all native components of APlayerPawn.

Only the class definition itself remains and needs to be taken care of.
This commit is contained in:
Christoph Oelckers 2019-01-03 18:01:58 +01:00
parent 3314a1efe5
commit c18e895272
20 changed files with 139 additions and 272 deletions

View file

@ -821,6 +821,7 @@ public:
void Crash();
// Return starting health adjusted by skill level
double AttackOffset(double offset = 0);
int SpawnHealth() const;
virtual int GetMaxHealth(bool withupgrades = false) const;
int GetGibHealth() const;

View file

@ -3,6 +3,7 @@
#include "actor.h"
#include "r_defs.h"
#include "g_levellocals.h"
#include "d_player.h"
// These depend on both actor.h and r_defs.h so they cannot be in either file without creating a circular dependency.
inline DVector3 AActor::PosRelative(int portalgroup) const
@ -79,3 +80,16 @@ inline double AActor::GetGravity() const
if (flags & MF_NOGRAVITY) return 0;
return level.gravity * Sector->gravity * Gravity * 0.00125;
}
inline double AActor::AttackOffset(double offset)
{
if (player != NULL)
{
return (FloatVar(NAME_AttackZOffset) + offset) * player->crouchfactor;
}
else
{
return 8 + offset;
}
}

View file

@ -82,55 +82,6 @@ FString GetPrintableDisplayName(PClassActor *cls);
class APlayerPawn : public AActor
{
DECLARE_CLASS(APlayerPawn, AActor)
HAS_OBJECT_POINTERS
public:
virtual void Serialize(FSerializer &arc);
int BonusHealth;
int MugShotMaxHealth;
int PlayerFlags;
double FullHeight;
TObjPtr<AActor*> InvSel; // selected inventory item
// [GRB] Player class properties
double JumpZ;
double GruntSpeed;
double FallingScreamMinSpeed, FallingScreamMaxSpeed;
double ViewHeight;
FTextureID ScoreIcon;
int SpawnMask;
FName MorphWeapon;
double AttackZOffset; // attack height, relative to player center
double UseRange; // [NS] Distance at which player can +use
// Everything below this point is only used by scripted code or through the scripted variable interface.
int crouchsprite;
int MaxHealth;
int RunHealth;
TObjPtr<AActor*> InvFirst; // first inventory item displayed on inventory bar
// [GRB] Player class properties
double ForwardMove1, ForwardMove2;
double SideMove1, SideMove2;
double AirCapacity; // Multiplier for air supply underwater.
double HexenArmor[5];
// [CW] Fades for when you are being damaged.
PalEntry DamageFade;
// [SP] ViewBob Multiplier
double ViewBob;
double curBob;
// Former class properties that were moved into the object to get rid of the meta class.
FName SoundClass; // Sound class
FName Portrait;
FName Slot[10];
PClassActor *FlechetteType;
};
void PlayIdle(AActor *player);
@ -142,8 +93,6 @@ void PlayIdle(AActor *player);
enum
{
PPF_NOTHRUSTWHENINVUL = 1, // Attacks do not thrust the player if they are invulnerable.
PPF_CANSUPERMORPH = 2, // Being remorphed into this class can give you a Tome of Power
PPF_CROUCHABLEMORPH = 4, // This morphed player can crouch
};
//
@ -461,9 +410,15 @@ public:
double GetDeltaViewHeight() const
{
return (mo->ViewHeight + crouchviewdelta - viewheight) / 8;
return (mo->FloatVar(NAME_ViewHeight) + crouchviewdelta - viewheight) / 8;
}
double DefaultViewHeight() const
{
return mo->FloatVar(NAME_ViewHeight);
}
void Uncrouch()
{
if (crouchfactor != 1)
@ -473,7 +428,7 @@ public:
crouchdir = 0;
crouching = 0;
crouchviewdelta = 0;
viewheight = mo ? mo->ViewHeight : 0;
viewheight = mo ? mo->FloatVar(NAME_ViewHeight) : 0;
}
}

View file

@ -157,7 +157,7 @@ void FS_EmulateCmd(char * string)
for(int i=0;i<MAXPLAYERS;i++)
{
// No, this is not correct. But this is the way Legacy WADs expect it to be handled!
if (players[i].mo != NULL) players[i].mo->ViewHeight = playerviewheight;
if (players[i].mo != NULL) players[i].mo->FloatVar(NAME_ViewHeight) = playerviewheight;
players[i].viewheight = playerviewheight;
players[i].Uncrouch();
}

View file

@ -421,14 +421,14 @@ CCMD (invuse)
{
if (players[consoleplayer].inventorytics == 0)
{
if (players[consoleplayer].mo) SendItemUse = players[consoleplayer].mo->InvSel;
if (players[consoleplayer].mo) SendItemUse = players[consoleplayer].mo->PointerVar<AActor>(NAME_InvSel);
}
players[consoleplayer].inventorytics = 0;
}
CCMD(invquery)
{
AActor *inv = players[consoleplayer].mo->InvSel;
AActor *inv = players[consoleplayer].mo->PointerVar<AActor>(NAME_InvSel);
if (inv != NULL)
{
Printf(PRINT_HIGH, "%s (%dx)\n", inv->GetTag(), inv->IntVar(NAME_Amount));
@ -447,7 +447,7 @@ CCMD (invdrop)
{
if (players[consoleplayer].mo)
{
SendItemDrop = players[consoleplayer].mo->InvSel;
SendItemDrop = players[consoleplayer].mo->PointerVar<AActor>(NAME_InvSel);
SendItemDropAmount = -1;
}
}
@ -488,7 +488,7 @@ CCMD (select)
auto item = who->FindInventory(argv[1]);
if (item != NULL)
{
who->InvSel = item;
who->PointerVar<AActor>(NAME_InvSel) = item;
}
}
who->player->inventorytics = 5*TICRATE;

View file

@ -1393,7 +1393,7 @@ int G_FinishTravel ()
pawn->lastenemy = NULL;
pawn->player->mo = pawn;
pawn->player->camera = pawn;
pawn->player->viewheight = pawn->ViewHeight;
pawn->player->viewheight = pawn->player->DefaultViewHeight();
pawn->flags2 &= ~MF2_BLASTED;
if (oldpawn != nullptr)
{

View file

@ -461,7 +461,7 @@ FTexture *FMugShot::GetFace(player_t *player, const char *default_face, int accu
{
int angle = UpdateState(player, stateflags);
int level = 0;
int max = player->mo->MugShotMaxHealth;
int max = player->mo->IntVar(NAME_MugShotMaxHealth);
if (max < 0)
{
max = player->mo->GetMaxHealth();

View file

@ -241,7 +241,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
applyscale = false;
}
if(type == PLAYERICON)
texture = TexMan.GetTexture(statusBar->CPlayer->mo->ScoreIcon, true);
texture = TexMan.ByIndex(statusBar->CPlayer->mo->IntVar(NAME_ScoreIcon), true);
else if(type == AMMO1)
{
auto ammo = statusBar->ammo1;
@ -293,8 +293,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
}
else if(type == INVENTORYICON)
texture = TexMan.GetTexture(sprite, true);
else if(type == SELECTEDINVENTORYICON && statusBar->CPlayer->mo->InvSel != NULL)
texture = TexMan.GetTexture(statusBar->CPlayer->mo->InvSel->TextureIDVar(NAME_Icon), true);
else if(type == SELECTEDINVENTORYICON && statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) != NULL)
texture = TexMan.GetTexture(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel)->TextureIDVar(NAME_Icon), true);
else if(image >= 0)
texture = statusBar->Images[image];
@ -892,7 +892,7 @@ class CommandDrawString : public SBarInfoCommand
SetStringToTag(statusBar->CPlayer->ReadyWeapon);
break;
case INVENTORYTAG:
SetStringToTag(statusBar->CPlayer->mo->InvSel);
SetStringToTag(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel));
break;
case PLAYERNAME:
// Can't think of a good way to detect changes to this, so
@ -1465,8 +1465,8 @@ class CommandDrawNumber : public CommandDrawString
break;
}
case SELECTEDINVENTORY:
if(statusBar->CPlayer->mo->InvSel != NULL)
num = statusBar->CPlayer->mo->InvSel->IntVar(NAME_Amount);
if(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) != NULL)
num = statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel)->IntVar(NAME_Amount);
break;
case ACCURACY:
num = statusBar->CPlayer->mo->accuracy;
@ -1691,7 +1691,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
if(alternateOnEmpty)
SBarInfoCommandFlowControl::Draw(block, statusBar);
if(statusBar->CPlayer->mo->InvSel != NULL && !(level.flags & LEVEL_NOINVENTORYBAR))
if(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) != NULL && !(level.flags & LEVEL_NOINVENTORYBAR))
{
if(artiflash && statusBar->wrapper->artiflashTick)
{
@ -1708,7 +1708,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
}
CommandDrawImage::Draw(block, statusBar);
}
if(alwaysShowCounter || statusBar->CPlayer->mo->InvSel->IntVar(NAME_Amount) != 1)
if(alwaysShowCounter || statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel)->IntVar(NAME_Amount) != 1)
CommandDrawNumber::Draw(block, statusBar);
}
}
@ -1791,7 +1791,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra
{
SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged);
SetTruth(statusBar->CPlayer->mo->InvSel == NULL || (level.flags & LEVEL_NOINVENTORYBAR), block, statusBar);
SetTruth(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel) == NULL || (level.flags & LEVEL_NOINVENTORYBAR), block, statusBar);
CommandDrawImage::Tick(block, statusBar, hudChanged);
CommandDrawNumber::Tick(block, statusBar, hudChanged);
@ -2133,7 +2133,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
if(style != STYLE_Strife) //Strife draws the cursor before the icons
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
if(item == statusBar->CPlayer->mo->InvSel)
if(item == statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvSel))
{
if(style == STYLE_Heretic)
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgSELECTBOX], rx, ry+29, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
@ -2158,7 +2158,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgARTIBOX], x + (!vertical ? (i*spacing) : 0), y + (vertical ? (i*spacing) : 0), block->XOffset(), block->YOffset(), bgalpha, block->FullScreenOffsets());
// Is there something to the left?
if (!noArrows && InvFirst && PrevInv(statusBar->CPlayer->mo->InvFirst))
if (!noArrows && InvFirst && PrevInv(statusBar->CPlayer->mo->PointerVar<AActor>(NAME_InvFirst)))
{
int offset = (style != STYLE_Strife ? (style != STYLE_HexenStrict ? -12 : -10) : 14);
int yOffset = style != STYLE_HexenStrict ? 0 : -1;

View file

@ -207,9 +207,10 @@ void HU_GetPlayerWidths(int &maxnamewidth, int &maxscorewidth, int &maxiconheigh
{
maxnamewidth = width;
}
if (players[i].mo->ScoreIcon.isValid())
auto icon = FSetTextureID(players[i].mo->IntVar(NAME_ScoreIcon));
if (icon.isValid())
{
FTexture *pic = TexMan.GetTexture(players[i].mo->ScoreIcon);
FTexture *pic = TexMan.GetTexture(icon);
width = pic->GetDisplayWidth() - pic->GetDisplayLeftOffset() + 2;
if (width > maxscorewidth)
{
@ -420,9 +421,10 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
screen->DrawText (SmallFont, color, col2, y + ypadding, player->playerstate == PST_DEAD && !deathmatch ? "DEAD" : str,
DTA_CleanNoMove, true, TAG_DONE);
if (player->mo->ScoreIcon.isValid())
auto icon = FSetTextureID(player->mo->IntVar(NAME_ScoreIcon));
if (icon.isValid())
{
FTexture *pic = TexMan.GetTexture(player->mo->ScoreIcon);
FTexture *pic = TexMan.GetTexture(icon);
screen->DrawTexture (pic, col3, y,
DTA_CleanNoMove, true,
TAG_DONE);

View file

@ -1043,6 +1043,20 @@ xx(ViewBob)
xx(DamageFade)
xx(MaxHealth)
xx(crouchsprite)
xx(UseRange)
xx(AttackZOffset)
xx(SpawnMask)
xx(ScoreIcon)
xx(ViewHeight)
xx(FallingScreamMinSpeed)
xx(FallingScreamMaxSpeed)
xx(GruntSpeed)
xx(JumpZ)
xx(MugShotMaxHealth)
xx(BonusHealth)
xx(PlayerFlags)
xx(InvSel)
xx(FullHeight)
xx(BlueCard)
xx(YellowCard)

View file

@ -4231,7 +4231,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
case APROP_JumpZ:
if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
static_cast<APlayerPawn *>(actor)->JumpZ = ACSToDouble(value);
actor->FloatVar(NAME_JumpZ) = ACSToDouble(value);
break; // [GRB]
case APROP_ChaseGoal:
@ -4350,7 +4350,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
case APROP_ViewHeight:
if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
{
static_cast<APlayerPawn *>(actor)->ViewHeight = ACSToDouble(value);
actor->FloatVar(NAME_ViewHeight) = ACSToDouble(value);
if (actor->player != NULL)
{
actor->player->viewheight = ACSToDouble(value);
@ -4360,7 +4360,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value)
case APROP_AttackZOffset:
if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
static_cast<APlayerPawn *>(actor)->AttackZOffset = ACSToDouble(value);
actor->FloatVar(NAME_AttackZOffset) = ACSToDouble(value);
break;
case APROP_StencilColor:
@ -4429,7 +4429,7 @@ int DLevelScript::GetActorProperty (int tid, int property)
case APROP_JumpZ: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
{
return DoubleToACS(static_cast<APlayerPawn *>(actor)->JumpZ); // [GRB]
return DoubleToACS(actor->FloatVar(NAME_JumpZ));
}
else
{
@ -4451,16 +4451,17 @@ int DLevelScript::GetActorProperty (int tid, int property)
case APROP_MeleeRange: return DoubleToACS(actor->meleerange);
case APROP_ViewHeight: if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
{
return DoubleToACS(static_cast<APlayerPawn *>(actor)->ViewHeight);
return DoubleToACS(actor->player->DefaultViewHeight());
}
else
{
return 0;
}
case APROP_AttackZOffset:
// Note that this is inconsistent with every other place, where the return for monsters is 8, not 0!
if (actor->IsKindOf (RUNTIME_CLASS (APlayerPawn)))
{
return DoubleToACS(static_cast<APlayerPawn *>(actor)->AttackZOffset);
return DoubleToACS(actor->FloatVar(NAME_AttackZOffset));
}
else
{
@ -5462,7 +5463,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
{
if (actor->player != NULL)
{
return DoubleToACS(actor->player->mo->ViewHeight + actor->player->crouchviewdelta);
return DoubleToACS(actor->player->DefaultViewHeight() + actor->player->crouchviewdelta);
}
else
{

View file

@ -2218,15 +2218,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckLOF)
{ // default to hitscan origin
// Synced with hitscan: self->Height is strangely NON-conscientious about getting the right actor for player
pos.Z += self->Height *0.5;
if (self->player != NULL)
{
pos.Z += self->player->mo->AttackZOffset * self->player->crouchfactor;
}
else
{
pos.Z += 8;
}
pos.Z += self->Height *0.5 + self->AttackOffset();
}
if (target)
@ -4872,7 +4864,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetSize)
}
if (self->player && self->player->mo == self)
{
self->player->mo->FullHeight = newheight;
self->player->mo->FloatVar(NAME_FullHeight) = newheight;
}
ACTION_RETURN_BOOL(true);

View file

@ -1066,7 +1066,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da
else
{
// Players are optionally excluded from getting thrust by damage.
if (static_cast<APlayerPawn *>(target)->PlayerFlags & PPF_NOTHRUSTWHENINVUL)
if (target->IntVar(NAME_PlayerFlags) & PPF_NOTHRUSTWHENINVUL)
{
return 0;
}

View file

@ -4264,15 +4264,7 @@ struct aim_t
DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget, DAngle vrange,
int flags, AActor *target, AActor *friender)
{
double shootz = t1->Center() - t1->Floorclip;
if (t1->player != NULL)
{
shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor;
}
else
{
shootz += 8;
}
double shootz = t1->Center() - t1->Floorclip + t1->AttackOffset();
// can't shoot outside view angles
if (vrange == 0)
@ -4409,21 +4401,13 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
double pc = pitch.Cos();
direction = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() };
shootz = t1->Center() - t1->Floorclip;
shootz = t1->Center() - t1->Floorclip + t1->AttackOffset();
if (t1->player != NULL)
{
shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor;
if (damageType == NAME_Melee || damageType == NAME_Hitscan)
{
// this is coming from a weapon attack function which needs to transfer information to the obituary code,
// We need to preserve this info from the damage type because the actual damage type can get overridden by the puff
pflag = DMG_PLAYERATTACK;
}
}
else
{
shootz += 8;
// this is coming from a weapon attack function which needs to transfer information to the obituary code,
// We need to preserve this info from the damage type because the actual damage type can get overridden by the puff
pflag = DMG_PLAYERATTACK;
}
// [MC] If overriding, set it to the base of the actor.
@ -4866,16 +4850,7 @@ AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch,
double pc = pitch.Cos();
direction = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() };
shootz = t1->Center() - t1->Floorclip;
if (t1->player != NULL)
{
shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor;
}
else
{
shootz += 8;
}
shootz = t1->Center() - t1->Floorclip + t1->AttackOffset();
FTraceResults trace;
Origin TData;
@ -5165,14 +5140,7 @@ void P_RailAttack(FRailParams *p)
if (!(p->flags & RAF_CENTERZ))
{
if (source->player != NULL)
{
shootz += source->player->mo->AttackZOffset * source->player->crouchfactor;
}
else
{
shootz += 8;
}
shootz += source->AttackOffset();
}
int puffflags = 0;
@ -5587,7 +5555,7 @@ void P_UseLines(player_t *player)
// If the player is transitioning a portal, use the group that is at its vertical center.
DVector2 start = player->mo->GetPortalTransition(player->mo->Height / 2);
// [NS] Now queries the Player's UseRange.
DVector2 end = start + player->mo->Angles.Yaw.ToVector(player->mo->UseRange);
DVector2 end = start + player->mo->Angles.Yaw.ToVector(player->mo->FloatVar(NAME_UseRange));
// old code:
// This added test makes the "oof" sound work on 2s lines -- killough:
@ -5621,7 +5589,7 @@ int P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType)
// [NS] If it's a Player, get their UseRange.
if (PuzzleItemUser->player)
usedist = PuzzleItemUser->player->mo->UseRange;
usedist = PuzzleItemUser->player->mo->FloatVar(NAME_UseRange);
else
usedist = USERANGE;

View file

@ -836,7 +836,7 @@ int P_GetRealMaxHealth(APlayerPawn *actor, int max)
{
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
{
max -= actor->stamina + actor->BonusHealth;
max -= actor->stamina + actor->IntVar(NAME_BonusHealth);
}
}
else // old health behaviour
@ -844,7 +844,7 @@ int P_GetRealMaxHealth(APlayerPawn *actor, int max)
max = MAXMORPHHEALTH;
if (player->MorphStyle & MORPH_ADDSTAMINA)
{
max += actor->stamina + actor->BonusHealth;
max += actor->stamina + actor->IntVar(NAME_BonusHealth);
}
}
}
@ -854,7 +854,7 @@ int P_GetRealMaxHealth(APlayerPawn *actor, int max)
// Bonus health should be added on top of the item's limit.
if (player->morphTics == 0 || (player->MorphStyle & MORPH_ADDSTAMINA))
{
max += actor->BonusHealth;
max += actor->IntVar(NAME_BonusHealth);
}
}
return max;
@ -1760,9 +1760,9 @@ bool P_SeekerMissile (AActor *actor, double thresh, double turnMax, bool precise
double dist = MAX(1., actor->Distance2D(target));
// Aim at a player's eyes and at the middle of the actor for everything else.
double aimheight = target->Height/2;
if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
if (target->player)
{
aimheight = static_cast<APlayerPawn *>(target)->ViewHeight;
aimheight = target->player->DefaultViewHeight();
}
pitch = DVector2(dist, target->Z() + aimheight - actor->Center()).Angle();
}
@ -2781,7 +2781,7 @@ static void PlayerLandedOnThing (AActor *mo, AActor *onmobj)
{
grunted = false;
// Why should this number vary by gravity?
if (mo->health > 0 && mo->Vel.Z < -mo->player->mo->GruntSpeed)
if (mo->health > 0 && mo->Vel.Z < -mo->player->mo->FloatVar(NAME_GruntSpeed))
{
S_Sound (mo, CHAN_VOICE, "*grunt", 1, ATTN_NORM);
grunted = true;
@ -5057,7 +5057,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
p->extralight = 0;
p->fixedcolormap = NOFIXEDCOLORMAP;
p->fixedlightlevel = -1;
p->viewheight = mobj->ViewHeight;
p->viewheight = p->DefaultViewHeight();
p->inconsistant = 0;
p->attacker = NULL;
p->spreecount = 0;
@ -6711,15 +6711,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z,
if (z != ONFLOORZ && z != ONCEILINGZ)
{
// Doom spawns missiles 4 units lower than hitscan attacks for players.
z += source->Center() - source->Floorclip;
if (source->player != NULL) // Considering this is for player missiles, it better not be NULL.
{
z += ((source->player->mo->AttackZOffset - 4) * source->player->crouchfactor);
}
else
{
z += 4;
}
z += source->Center() - source->Floorclip + source->AttackOffset(4);
// Do not fire beneath the floor.
if (z < source->floorz)
{

View file

@ -456,7 +456,7 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetLogText)
int player_t::GetSpawnClass()
{
const PClass * type = PlayerClasses[CurrentPlayerClass].Type;
return static_cast<APlayerPawn*>(GetDefaultByType(type))->SpawnMask;
return GetDefaultByType(type)->IntVar(NAME_SpawnMask);
}
// [Nash] Set FOV
@ -666,7 +666,7 @@ bool player_t::Resurrect()
mo->Revive();
playerstate = PST_LIVE;
health = mo->health = mo->GetDefault()->health;
viewheight = ((APlayerPawn *)mo->GetDefault())->ViewHeight;
viewheight = DefaultViewHeight();
mo->renderflags &= ~RF_INVISIBLE;
mo->Height = mo->GetDefault()->Height;
mo->radius = mo->GetDefault()->radius;
@ -793,43 +793,7 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetStillBob)
//
//===========================================================================
IMPLEMENT_CLASS(APlayerPawn, false, true)
IMPLEMENT_POINTERS_START(APlayerPawn)
IMPLEMENT_POINTER(InvFirst)
IMPLEMENT_POINTER(InvSel)
IMPLEMENT_POINTERS_END
void APlayerPawn::Serialize(FSerializer &arc)
{
Super::Serialize (arc);
auto def = (APlayerPawn*)GetDefault();
arc("jumpz", JumpZ, def->JumpZ)
("maxhealth", MaxHealth, def->MaxHealth)
("bonushealth", BonusHealth, def->BonusHealth)
("runhealth", RunHealth, def->RunHealth)
("spawnmask", SpawnMask, def->SpawnMask)
("forwardmove1", ForwardMove1, def->ForwardMove1)
("forwardmove2", ForwardMove2, def->ForwardMove2)
("sidemove1", SideMove1, def->SideMove1)
("sidemove2", SideMove2, def->SideMove2)
("scoreicon", ScoreIcon, def->ScoreIcon)
("invfirst", InvFirst)
("invsel", InvSel)
("morphweapon", MorphWeapon, def->MorphWeapon)
("damagefade", DamageFade, def->DamageFade)
("playerflags", PlayerFlags, def->PlayerFlags)
("flechettetype", FlechetteType, def->FlechetteType)
("gruntspeed", GruntSpeed, def->GruntSpeed)
("fallingscreammin", FallingScreamMinSpeed, def->FallingScreamMinSpeed)
("fallingscreammaxn", FallingScreamMaxSpeed, def->FallingScreamMaxSpeed)
("userange", UseRange, def->UseRange)
("aircapacity", AirCapacity, def->AirCapacity)
("viewheight", ViewHeight, def->ViewHeight)
("viewbob", ViewBob, def->ViewBob)
("fullheight", FullHeight, def->FullHeight);
}
IMPLEMENT_CLASS(APlayerPawn, false, false)
//===========================================================================
//
@ -1193,8 +1157,8 @@ void P_CheckEnvironment(player_t *player)
// Player must be touching the floor
P_PlayerOnSpecialFlat(player, P_GetThingFloorType(player->mo));
}
if (player->mo->Vel.Z <= -player->mo->FallingScreamMinSpeed &&
player->mo->Vel.Z >= -player->mo->FallingScreamMaxSpeed && !player->morphTics &&
if (player->mo->Vel.Z <= -player->mo->FloatVar(NAME_FallingScreamMinSpeed) &&
player->mo->Vel.Z >= -player->mo->FloatVar(NAME_FallingScreamMaxSpeed) && !player->morphTics &&
player->mo->waterlevel == 0)
{
int id = S_FindSkinnedSound(player->mo, "*falling");
@ -1537,7 +1501,8 @@ void P_UnPredictPlayer ()
APlayerPawn *act = player->mo;
AActor *savedcamera = player->camera;
TObjPtr<AActor*> InvSel = act->InvSel;
auto &actInvSel = act->PointerVar<AActor*>(NAME_InvSel);
auto InvSel = actInvSel;
int inventorytics = player->inventorytics;
const bool settings_controller = player->settings_controller;
@ -1602,7 +1567,7 @@ void P_UnPredictPlayer ()
block = block->NextBlock;
}
act->InvSel = InvSel;
actInvSel = InvSel;
player->inventorytics = inventorytics;
}
}
@ -1726,39 +1691,6 @@ bool P_IsPlayerTotallyFrozen(const player_t *player)
//
//==========================================================================
DEFINE_FIELD(APlayerPawn, crouchsprite)
DEFINE_FIELD(APlayerPawn, MaxHealth)
DEFINE_FIELD(APlayerPawn, BonusHealth)
DEFINE_FIELD(APlayerPawn, MugShotMaxHealth)
DEFINE_FIELD(APlayerPawn, RunHealth)
DEFINE_FIELD(APlayerPawn, PlayerFlags)
DEFINE_FIELD(APlayerPawn, InvFirst)
DEFINE_FIELD(APlayerPawn, InvSel)
DEFINE_FIELD(APlayerPawn, JumpZ)
DEFINE_FIELD(APlayerPawn, GruntSpeed)
DEFINE_FIELD(APlayerPawn, FallingScreamMinSpeed)
DEFINE_FIELD(APlayerPawn, FallingScreamMaxSpeed)
DEFINE_FIELD(APlayerPawn, ViewHeight)
DEFINE_FIELD(APlayerPawn, ForwardMove1)
DEFINE_FIELD(APlayerPawn, ForwardMove2)
DEFINE_FIELD(APlayerPawn, SideMove1)
DEFINE_FIELD(APlayerPawn, SideMove2)
DEFINE_FIELD(APlayerPawn, ScoreIcon)
DEFINE_FIELD(APlayerPawn, SpawnMask)
DEFINE_FIELD(APlayerPawn, MorphWeapon)
DEFINE_FIELD(APlayerPawn, AttackZOffset)
DEFINE_FIELD(APlayerPawn, UseRange)
DEFINE_FIELD(APlayerPawn, AirCapacity)
DEFINE_FIELD(APlayerPawn, FlechetteType)
DEFINE_FIELD(APlayerPawn, DamageFade)
DEFINE_FIELD(APlayerPawn, ViewBob)
DEFINE_FIELD(APlayerPawn, curBob)
DEFINE_FIELD(APlayerPawn, FullHeight)
DEFINE_FIELD(APlayerPawn, SoundClass)
DEFINE_FIELD(APlayerPawn, Portrait)
DEFINE_FIELD(APlayerPawn, Slot)
DEFINE_FIELD(APlayerPawn, HexenArmor)
DEFINE_FIELD_X(PlayerInfo, player_t, mo)
DEFINE_FIELD_X(PlayerInfo, player_t, playerstate)
DEFINE_FIELD_X(PlayerInfo, player_t, original_oldbuttons)

View file

@ -411,20 +411,11 @@ static FFlagDef MoreFlagDefs[] =
DEFINE_DUMMY_FLAG(SERVERSIDEONLY, false),
};
static FFlagDef PlayerPawnFlagDefs[] =
{
// PlayerPawn flags
DEFINE_FLAG(PPF, NOTHRUSTWHENINVUL, APlayerPawn, PlayerFlags),
DEFINE_FLAG(PPF, CANSUPERMORPH, APlayerPawn, PlayerFlags),
DEFINE_FLAG(PPF, CROUCHABLEMORPH, APlayerPawn, PlayerFlags),
};
static const struct FFlagList { const PClass * const *Type; FFlagDef *Defs; int NumDefs; int Use; } FlagLists[] =
{
{ &RUNTIME_CLASS_CASTLESS(AActor), ActorFlagDefs, countof(ActorFlagDefs), 3 }, // -1 to account for the terminator
{ &RUNTIME_CLASS_CASTLESS(AActor), MoreFlagDefs, countof(MoreFlagDefs), 1 },
{ &RUNTIME_CLASS_CASTLESS(AActor), InternalActorFlagDefs, countof(InternalActorFlagDefs), 2 },
{ &RUNTIME_CLASS_CASTLESS(APlayerPawn), PlayerPawnFlagDefs, countof(PlayerPawnFlagDefs), 3 },
};
#define NUM_FLAG_LISTS (countof(FlagLists))

View file

@ -1511,10 +1511,11 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, spawnclass, L, PlayerPawn)
{
PROP_INT_PARM(type, 0);
int &SpawnMask = defaults->IntVar(NAME_SpawnMask);
if (type == 0)
{
PROP_INT_PARM(val, 1);
if (val > 0) defaults->SpawnMask |= 1<<(val-1);
if (val > 0) SpawnMask |= 1<<(val-1);
}
else
{
@ -1523,13 +1524,13 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, spawnclass, L, PlayerPawn)
PROP_STRING_PARM(str, i);
if (!stricmp(str, "Any"))
defaults->SpawnMask = 0;
SpawnMask = 0;
else if (!stricmp(str, "Fighter"))
defaults->SpawnMask |= 1;
SpawnMask |= 1;
else if (!stricmp(str, "Cleric"))
defaults->SpawnMask |= 2;
SpawnMask |= 2;
else if (!stricmp(str, "Mage"))
defaults->SpawnMask |= 4;
SpawnMask |= 4;
}
}
@ -1569,8 +1570,9 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, sidemove, F_f, PlayerPawn)
DEFINE_CLASS_PROPERTY_PREFIX(player, scoreicon, S, PlayerPawn)
{
PROP_STRING_PARM(z, 0);
defaults->ScoreIcon = TexMan.CheckForTexture(z, ETextureType::MiscPatch);
if (!defaults->ScoreIcon.isValid())
auto icon = TexMan.CheckForTexture(z, ETextureType::MiscPatch);
defaults->IntVar(NAME_ScoreIcon) = icon.GetIndex();
if (!icon.isValid())
{
bag.ScriptPosition.Message(MSG_WARNING,
"Icon '%s' for '%s' not found\n", z, info->TypeName.GetChars ());

View file

@ -95,5 +95,4 @@ extend class Actor
}
}
}

View file

@ -18,37 +18,37 @@ class PlayerPawn : Actor native
// 16 pixels of bob
const MAXBOB = 16.;
native int crouchsprite;
native int MaxHealth;
native int BonusHealth;
native int MugShotMaxHealth;
native int RunHealth;
native int PlayerFlags;
native clearscope Inventory InvFirst; // first inventory item displayed on inventory bar
native clearscope Inventory InvSel; // selected inventory item
native Name SoundClass; // Sound class
native Name Portrait;
native Name Slot[10];
native double HexenArmor[5];
int crouchsprite;
int MaxHealth;
int BonusHealth;
int MugShotMaxHealth;
int RunHealth;
private int PlayerFlags;
clearscope Inventory InvFirst; // first inventory item displayed on inventory bar
clearscope Inventory InvSel; // selected inventory item
Name SoundClass; // Sound class
Name Portrait;
Name Slot[10];
double HexenArmor[5];
// [GRB] Player class properties
native double JumpZ;
native double GruntSpeed;
native double FallingScreamMinSpeed, FallingScreamMaxSpeed;
native double ViewHeight;
native double ForwardMove1, ForwardMove2;
native double SideMove1, SideMove2;
native TextureID ScoreIcon;
native int SpawnMask;
native Name MorphWeapon;
native double AttackZOffset; // attack height, relative to player center
native double UseRange; // [NS] Distance at which player can +use
native double AirCapacity; // Multiplier for air supply underwater.
native Class<Inventory> FlechetteType;
native color DamageFade; // [CW] Fades for when you are being damaged.
native double ViewBob; // [SP] ViewBob Multiplier
native double FullHeight;
native double curBob;
double JumpZ;
double GruntSpeed;
double FallingScreamMinSpeed, FallingScreamMaxSpeed;
double ViewHeight;
double ForwardMove1, ForwardMove2;
double SideMove1, SideMove2;
TextureID ScoreIcon;
int SpawnMask;
Name MorphWeapon;
double AttackZOffset; // attack height, relative to player center
double UseRange; // [NS] Distance at which player can +use
double AirCapacity; // Multiplier for air supply underwater.
Class<Inventory> FlechetteType;
color DamageFade; // [CW] Fades for when you are being damaged.
double ViewBob; // [SP] ViewBob Multiplier
double FullHeight;
double curBob;
meta Name HealingRadiusType;
meta Name InvulMode;
@ -76,6 +76,10 @@ class PlayerPawn : Actor native
property TeleportFreezeTime: TeleportFreezeTime;
property ViewBob: ViewBob;
flagdef NoThrustWhenInvul: PlayerFlags, 0;
flagdef CanSuperMorph: PlayerFlags, 1;
flagdef CrouchableMorph: PlayerFlags, 2;
Default
{
Health 100;