This commit is contained in:
Christoph Oelckers 2016-06-17 16:18:24 +02:00
commit b7d13c0711
44 changed files with 1202 additions and 576 deletions

View file

@ -807,11 +807,12 @@ void SetDehParams(FState *state, int codepointer)
VMFunctionBuilder buildit; VMFunctionBuilder buildit;
// Allocate registers used to pass parameters in. // Allocate registers used to pass parameters in.
// self, stateowner, state (all are pointers) // self, stateowner, state (all are pointers)
buildit.Registers[REGT_POINTER].Get(3); buildit.Registers[REGT_POINTER].Get(NAP);
// Emit code to pass the standard action function parameters. // Emit code to pass the standard action function parameters.
buildit.Emit(OP_PARAM, 0, REGT_POINTER, 0); for (int i = 0; i < NAP; i++)
buildit.Emit(OP_PARAM, 0, REGT_POINTER, 1); {
buildit.Emit(OP_PARAM, 0, REGT_POINTER, 2); buildit.Emit(OP_PARAM, 0, REGT_POINTER, i);
}
// Emit code for action parameters. // Emit code for action parameters.
int argcount = MBFCodePointerFactories[codepointer](buildit, value1, value2); int argcount = MBFCodePointerFactories[codepointer](buildit, value1, value2);
buildit.Emit(OP_TAIL_K, buildit.GetConstantAddress(sym->Variants[0].Implementation, ATAG_OBJECT), NAP + argcount, 0); buildit.Emit(OP_TAIL_K, buildit.GetConstantAddress(sym->Variants[0].Implementation, ATAG_OBJECT), NAP + argcount, 0);
@ -2114,7 +2115,7 @@ static int PatchCodePtrs (int dummy)
else else
{ {
TArray<DWORD> &args = sym->Variants[0].ArgFlags; TArray<DWORD> &args = sym->Variants[0].ArgFlags;
if ((sym->Flags & (VARF_Method | VARF_Action)) != (VARF_Method | VARF_Action) || (args.Size() > 3 && !(args[3] & VARF_Optional))) if ((sym->Flags & (VARF_Method | VARF_Action)) != (VARF_Method | VARF_Action) || (args.Size() > NAP && !(args[NAP] & VARF_Optional)))
{ {
Printf("Frame %d: Incompatible code pointer '%s'\n", frame, Line2); Printf("Frame %d: Incompatible code pointer '%s'\n", frame, Line2);
sym = NULL; sym = NULL;
@ -2726,7 +2727,7 @@ static bool LoadDehSupp ()
else else
{ {
TArray<DWORD> &args = sym->Variants[0].ArgFlags; TArray<DWORD> &args = sym->Variants[0].ArgFlags;
if ((sym->Flags & (VARF_Method|VARF_Action)) != (VARF_Method | VARF_Action) || (args.Size() > 3 && !(args[3] & VARF_Optional))) if ((sym->Flags & (VARF_Method|VARF_Action)) != (VARF_Method | VARF_Action) || (args.Size() > NAP && !(args[NAP] & VARF_Optional)))
{ {
sc.ScriptMessage("Incompatible code pointer '%s'", sc.String); sc.ScriptMessage("Incompatible code pointer '%s'", sc.String);
} }

View file

@ -380,6 +380,7 @@ class player_t
{ {
public: public:
player_t(); player_t();
~player_t();
player_t &operator= (const player_t &p); player_t &operator= (const player_t &p);
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
@ -435,6 +436,7 @@ public:
AWeapon *ReadyWeapon; AWeapon *ReadyWeapon;
AWeapon *PendingWeapon; // WP_NOCHANGE if not changing AWeapon *PendingWeapon; // WP_NOCHANGE if not changing
TObjPtr<DPSprite> psprites; // view sprites (gun, etc)
int cheats; // bit flags int cheats; // bit flags
int timefreezer; // Player has an active time freezer int timefreezer; // Player has an active time freezer
@ -454,7 +456,6 @@ public:
int extralight; // so gun flashes light up areas int extralight; // so gun flashes light up areas
short fixedcolormap; // can be set to REDCOLORMAP, etc. short fixedcolormap; // can be set to REDCOLORMAP, etc.
short fixedlightlevel; short fixedlightlevel;
pspdef_t psprites[NUMPSPRITES]; // view sprites (gun, etc)
int morphTics; // player is a chicken/pig if > 0 int morphTics; // player is a chicken/pig if > 0
PClassPlayerPawn *MorphedPlayerClass; // [MH] (for SBARINFO) class # for this player instance when morphed PClassPlayerPawn *MorphedPlayerClass; // [MH] (for SBARINFO) class # for this player instance when morphed
int MorphStyle; // which effects to apply for this player instance when morphed int MorphStyle; // which effects to apply for this player instance when morphed
@ -526,6 +527,12 @@ public:
} }
int GetSpawnClass(); int GetSpawnClass();
// PSprite layers
void TickPSprites();
void DestroyPSprites();
DPSprite *FindPSprite(int layer);
DPSprite *GetPSprite(PSPLayers layer); // Used ONLY for compatibility with the old hardcoded layers.
}; };
// Bookkeeping on players - state. // Bookkeeping on players - state.

View file

@ -126,11 +126,11 @@ DMovingCeiling::DMovingCeiling ()
{ {
} }
DMovingCeiling::DMovingCeiling (sector_t *sector) DMovingCeiling::DMovingCeiling (sector_t *sector, bool interpolate)
: DMover (sector) : DMover (sector)
{ {
sector->ceilingdata = this; sector->ceilingdata = this;
interpolation = sector->SetInterpolation(sector_t::CeilingMove, true); if (interpolate) interpolation = sector->SetInterpolation(sector_t::CeilingMove, true);
} }
bool sector_t::MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed) bool sector_t::MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed)

View file

@ -49,7 +49,7 @@ class DMovingCeiling : public DMover
{ {
DECLARE_CLASS (DMovingCeiling, DMover) DECLARE_CLASS (DMovingCeiling, DMover)
public: public:
DMovingCeiling (sector_t *sector); DMovingCeiling (sector_t *sector, bool interpolate = true);
protected: protected:
DMovingCeiling (); DMovingCeiling ();
}; };

View file

@ -73,16 +73,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePistol)
bool accurate; bool accurate;
if (self->player != NULL) if (self->player != nullptr)
{ {
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
{ {
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; return 0;
P_SetPsprite (self->player, ps_flash, weapon->FindState(NAME_Flash)); P_SetPsprite(self->player, PSP_FLASH, weapon->FindState(NAME_Flash), true);
self->player->psprites[ps_flash].processPending = true;
} }
self->player->mo->PlayAttacking2 (); self->player->mo->PlayAttacking2 ();
@ -263,19 +262,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun)
int i; int i;
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM);
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
{ {
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; return 0;
P_SetPsprite (player, ps_flash, weapon->FindState(NAME_Flash)); P_SetPsprite(player, PSP_FLASH, weapon->FindState(NAME_Flash), true);
self->player->psprites[ps_flash].processPending = true;
} }
player->mo->PlayAttacking2 (); player->mo->PlayAttacking2 ();
@ -300,19 +298,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
int damage; int damage;
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
{ {
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 2))
return 0; return 0;
P_SetPsprite (player, ps_flash, weapon->FindState(NAME_Flash)); P_SetPsprite(player, PSP_FLASH, weapon->FindState(NAME_Flash), true);
self->player->psprites[ps_flash].processPending = true;
} }
player->mo->PlayAttacking2 (); player->mo->PlayAttacking2 ();
@ -384,15 +381,13 @@ void P_SetSafeFlash(AWeapon *weapon, player_t *player, FState *flashstate, int i
if (flashstate + index < cls->OwnedStates + cls->NumOwnedStates) if (flashstate + index < cls->OwnedStates + cls->NumOwnedStates)
{ {
// we're ok so set the state // we're ok so set the state
P_SetPsprite (player, ps_flash, flashstate + index); P_SetPsprite(player, PSP_FLASH, flashstate + index, true);
player->psprites[ps_flash].processPending = true;
return; return;
} }
else else
{ {
// oh, no! The state is beyond the end of the state table so use the original flash state. // oh, no! The state is beyond the end of the state table so use the original flash state.
P_SetPsprite (player, ps_flash, flashstate); P_SetPsprite(player, PSP_FLASH, flashstate, true);
player->psprites[ps_flash].processPending = true;
return; return;
} }
} }
@ -408,8 +403,7 @@ void P_SetSafeFlash(AWeapon *weapon, player_t *player, FState *flashstate, int i
{ // Invalid state. With no index offset, it should at least be valid. { // Invalid state. With no index offset, it should at least be valid.
index = 0; index = 0;
} }
P_SetPsprite (player, ps_flash, flashstate + index); P_SetPsprite(player, PSP_FLASH, flashstate + index, true);
player->psprites[ps_flash].processPending = true;
} }
// //
@ -421,13 +415,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun)
player_t *player; player_t *player;
if (self == NULL || NULL == (player = self->player)) if (self == nullptr || nullptr == (player = self->player))
{ {
return 0; return 0;
} }
AWeapon *weapon = player->ReadyWeapon; AWeapon *weapon = player->ReadyWeapon;
if (weapon != NULL && ACTION_CALL_FROM_WEAPON()) if (weapon != nullptr && ACTION_CALL_FROM_WEAPON())
{ {
if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1)) if (!weapon->DepleteAmmo (weapon->bAltFire, true, 1))
return 0; return 0;
@ -435,12 +429,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCGun)
S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM);
FState *flash = weapon->FindState(NAME_Flash); FState *flash = weapon->FindState(NAME_Flash);
if (flash != NULL) if (flash != nullptr)
{ {
// [RH] Fix for Sparky's messed-up Dehacked patch! Blargh! // [RH] Fix for Sparky's messed-up Dehacked patch! Blargh!
FState * atk = weapon->FindState(NAME_Fire); FState * atk = weapon->FindState(NAME_Fire);
int theflash = clamp (int(player->psprites[ps_weapon].state - atk), 0, 1); int theflash = clamp (int(player->GetPSprite(PSP_WEAPON)->GetState() - atk), 0, 1);
if (flash[theflash].sprite != flash->sprite) if (flash[theflash].sprite != flash->sprite)
{ {
@ -636,6 +630,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG)
// A_BFGSpray // A_BFGSpray
// Spawn a BFG explosion on every monster in view // Spawn a BFG explosion on every monster in view
// //
enum BFG_Flags
{
BFGF_HURTSOURCE = 1,
BFGF_MISSILEORIGIN = 2,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
@ -646,12 +646,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
PARAM_FLOAT_OPT (distance) { distance = 0; } PARAM_FLOAT_OPT (distance) { distance = 0; }
PARAM_ANGLE_OPT (vrange) { vrange = 0.; } PARAM_ANGLE_OPT (vrange) { vrange = 0.; }
PARAM_INT_OPT (defdamage) { defdamage = 0; } PARAM_INT_OPT (defdamage) { defdamage = 0; }
PARAM_INT_OPT (flags) { flags = 0; }
int i; int i;
int j; int j;
int damage; int damage;
DAngle an; DAngle an;
FTranslatedLineTarget t; FTranslatedLineTarget t;
AActor *originator;
if (spraytype == NULL) spraytype = PClass::FindActor("BFGExtra"); if (spraytype == NULL) spraytype = PClass::FindActor("BFGExtra");
if (numrays <= 0) numrays = 40; if (numrays <= 0) numrays = 40;
@ -664,13 +666,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
if (!self->target) if (!self->target)
return 0; return 0;
// [XA] Set the originator of the rays to the projectile (self) if
// the new flag is set, else set it to the player (self->target)
originator = (flags & BFGF_MISSILEORIGIN) ? self : (AActor *)(self->target);
// offset angles from its attack angle // offset angles from its attack angle
for (i = 0; i < numrays; i++) for (i = 0; i < numrays; i++)
{ {
an = self->Angles.Yaw - angle / 2 + angle / numrays*i; an = self->Angles.Yaw - angle / 2 + angle / numrays*i;
// self->target is the originator (player) of the missile P_AimLineAttack(originator, an, distance, &t, vrange);
P_AimLineAttack(self->target, an, distance, &t, vrange);
if (t.linetarget != NULL) if (t.linetarget != NULL)
{ {
@ -681,7 +686,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
if (spray != NULL) if (spray != NULL)
{ {
if (spray->flags6 & MF6_MTHRUSPECIES && self->target->GetSpecies() == t.linetarget->GetSpecies()) if ((spray->flags6 & MF6_MTHRUSPECIES && self->target->GetSpecies() == t.linetarget->GetSpecies()) ||
(!(flags & BFGF_HURTSOURCE) && self->target == t.linetarget)) // [XA] Don't hit oneself unless we say so.
{ {
spray->Destroy(); // [MC] Remove it because technically, the spray isn't trying to "hit" them. spray->Destroy(); // [MC] Remove it because technically, the spray isn't trying to "hit" them.
continue; continue;
@ -704,7 +710,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
damage = defdamage; damage = defdamage;
} }
int newdam = P_DamageMobj(t.linetarget, self->target, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.angleFromSource.Degrees); int newdam = P_DamageMobj(t.linetarget, originator, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.angleFromSource.Degrees);
P_TraceBleed(newdam > 0 ? newdam : damage, &t, self); P_TraceBleed(newdam > 0 ? newdam : damage, &t, self);
} }
} }

View file

@ -1750,6 +1750,8 @@ void G_DoPlayerPop(int playernum)
players[playernum].mo = NULL; players[playernum].mo = NULL;
players[playernum].camera = NULL; players[playernum].camera = NULL;
} }
players[playernum].DestroyPSprites();
} }
void G_ScreenShot (char *filename) void G_ScreenShot (char *filename)

View file

@ -123,9 +123,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers)
void P_UpdateBeak (AActor *self) void P_UpdateBeak (AActor *self)
{ {
if (self->player != NULL) if (self->player != nullptr)
{ {
self->player->psprites[ps_weapon].sy = WEAPONTOP + self->player->chickenPeck / 2; self->player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP + self->player->chickenPeck / 2;
} }
} }
@ -141,12 +141,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakRaise)
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
player->psprites[ps_weapon].sy = WEAPONTOP; player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetReadyState()); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState());
return 0; return 0;
} }
@ -192,7 +192,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1)
} }
P_PlayPeck (player->mo); P_PlayPeck (player->mo);
player->chickenPeck = 12; player->chickenPeck = 12;
player->psprites[ps_weapon].tics -= pr_beakatkpl1() & 7; player->GetPSprite(PSP_WEAPON)->Tics -= pr_beakatkpl1() & 7;
return 0; return 0;
} }
@ -227,6 +227,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2)
} }
P_PlayPeck (player->mo); P_PlayPeck (player->mo);
player->chickenPeck = 12; player->chickenPeck = 12;
player->psprites[ps_weapon].tics -= pr_beakatkpl2()&3; player->GetPSprite(PSP_WEAPON)->Tics -= pr_beakatkpl2()&3;
return 0; return 0;
} }

View file

@ -259,7 +259,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
FTranslatedLineTarget t; FTranslatedLineTarget t;
int actualdamage = 0; int actualdamage = 0;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
@ -267,13 +267,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
PARAM_INT(power); PARAM_INT(power);
AWeapon *weapon = player->ReadyWeapon; AWeapon *weapon = player->ReadyWeapon;
if (weapon != NULL) if (weapon != nullptr)
{ {
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
player->GetPSprite(PSP_WEAPON)->x = ((pr_gatk() & 3) - 2);
player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP + (pr_gatk() & 3);
} }
player->psprites[ps_weapon].sx = ((pr_gatk()&3)-2);
player->psprites[ps_weapon].sy = WEAPONTOP + (pr_gatk()&3);
Angle = self->Angles.Yaw; Angle = self->Angles.Yaw;
if (power) if (power)
{ {
@ -425,7 +426,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL1)
AActor *ball; AActor *ball;
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
@ -436,13 +437,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL1)
return 0; return 0;
} }
AWeapon *weapon = player->ReadyWeapon; AWeapon *weapon = player->ReadyWeapon;
if (weapon != NULL) if (weapon != nullptr)
{ {
if (!weapon->DepleteAmmo(weapon->bAltFire)) if (!weapon->DepleteAmmo(weapon->bAltFire))
return 0; return 0;
player->GetPSprite(PSP_WEAPON)->x = ((pr_maceatk() & 3) - 2);
player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP + (pr_maceatk() & 3);
} }
player->psprites[ps_weapon].sx = ((pr_maceatk() & 3) - 2);
player->psprites[ps_weapon].sy = WEAPONTOP + (pr_maceatk() & 3);
ball = P_SpawnPlayerMissile(self, PClass::FindActor("MaceFX1"), self->Angles.Yaw + (((pr_maceatk() & 7) - 4) * (360. / 256))); ball = P_SpawnPlayerMissile(self, PClass::FindActor("MaceFX1"), self->Angles.Yaw + (((pr_maceatk() & 7) - 4) * (360. / 256)));
if (ball) if (ball)
{ {
@ -1158,11 +1160,11 @@ IMPLEMENT_CLASS (APhoenixRodPowered)
void APhoenixRodPowered::EndPowerup () void APhoenixRodPowered::EndPowerup ()
{ {
P_SetPsprite (Owner->player, ps_weapon, SisterWeapon->GetReadyState());
DepleteAmmo (bAltFire); DepleteAmmo (bAltFire);
Owner->player->refire = 0; Owner->player->refire = 0;
S_StopSound (Owner, CHAN_WEAPON); S_StopSound (Owner, CHAN_WEAPON);
Owner->player->ReadyWeapon = SisterWeapon; Owner->player->ReadyWeapon = SisterWeapon;
P_SetPsprite(Owner->player, PSP_WEAPON, SisterWeapon->GetReadyState());
} }
class APhoenixFX1 : public AActor class APhoenixFX1 : public AActor
@ -1298,7 +1300,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2)
player_t *player; player_t *player;
APhoenixRod *flamethrower; APhoenixRod *flamethrower;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
@ -1306,9 +1308,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2)
soundid = "weapons/phoenixpowshoot"; soundid = "weapons/phoenixpowshoot";
flamethrower = static_cast<APhoenixRod *> (player->ReadyWeapon); flamethrower = static_cast<APhoenixRod *> (player->ReadyWeapon);
if (flamethrower == NULL || --flamethrower->FlameCount == 0) if (flamethrower == nullptr || --flamethrower->FlameCount == 0)
{ // Out of flame { // Out of flame
P_SetPsprite (player, ps_weapon, flamethrower->FindState("Powerdown")); P_SetPsprite(player, PSP_WEAPON, flamethrower->FindState("Powerdown"));
player->refire = 0; player->refire = 0;
S_StopSound (self, CHAN_WEAPON); S_StopSound (self, CHAN_WEAPON);
return 0; return 0;

View file

@ -58,7 +58,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
FTranslatedLineTarget t; FTranslatedLineTarget t;
PClassActor *puff; PClassActor *puff;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
if (t.linetarget) if (t.linetarget)
{ {
P_LineAttack(pmo, angle, 1.5 * MELEERANGE, slope, damage, NAME_Melee, puff, false, &t); P_LineAttack(pmo, angle, 1.5 * MELEERANGE, slope, damage, NAME_Melee, puff, false, &t);
if (t.linetarget != NULL) if (t.linetarget != nullptr)
{ {
pmo->Angles.Yaw = t.angleFromSource; pmo->Angles.Yaw = t.angleFromSource;
if (((t.linetarget->player && (!t.linetarget->IsTeammate(pmo) || level.teamdamage != 0)) || t.linetarget->flags3&MF3_ISMONSTER) if (((t.linetarget->player && (!t.linetarget->IsTeammate(pmo) || level.teamdamage != 0)) || t.linetarget->flags3&MF3_ISMONSTER)
@ -89,13 +89,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
{ {
pmo->health = player->health = newLife; pmo->health = player->health = newLife;
} }
if (weapon != NULL) if (weapon != nullptr)
{ {
FState * newstate = weapon->FindState("Drain"); FState * newstate = weapon->FindState("Drain");
if (newstate != NULL) P_SetPsprite(player, ps_weapon, newstate); if (newstate != nullptr) P_SetPsprite(player, PSP_WEAPON, newstate);
} }
} }
if (weapon != NULL) if (weapon != nullptr)
{ {
weapon->DepleteAmmo(weapon->bAltFire, false); weapon->DepleteAmmo(weapon->bAltFire, false);
} }
@ -187,7 +187,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink)
{ {
if (!--self->weaponspecial) if (!--self->weaponspecial)
{ {
P_SetPsprite (self->player, ps_weapon, self->player->ReadyWeapon->FindState ("Blink")); P_SetPsprite(self->player, PSP_WEAPON, self->player->ReadyWeapon->FindState ("Blink"));
self->weaponspecial = (pr_blink()+50)>>2; self->weaponspecial = (pr_blink()+50)>>2;
} }
else else

View file

@ -70,13 +70,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady)
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
if (player->ReadyWeapon->Ammo1->Amount) if (player->ReadyWeapon->Ammo1->Amount)
{ {
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("ReadyGlow")); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("ReadyGlow"));
} }
else else
{ {
@ -97,13 +97,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG)
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
if (player->ReadyWeapon->Ammo1->Amount <= 0) if (player->ReadyWeapon->Ammo1->Amount <= 0)
{ {
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Ready")); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Ready"));
} }
else else
{ {
@ -124,13 +124,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp)
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
if (player->ReadyWeapon->Ammo1->Amount) if (player->ReadyWeapon->Ammo1->Amount)
{ {
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("SelectGlow")); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("SelectGlow"));
} }
else else
{ {
@ -151,13 +151,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG)
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
if (player->ReadyWeapon->Ammo1->Amount <= 0) if (player->ReadyWeapon->Ammo1->Amount <= 0)
{ {
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Select")); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Select"));
} }
else else
{ {
@ -178,13 +178,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckAtk)
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
if (player->ReadyWeapon->Ammo1->Amount) if (player->ReadyWeapon->Ammo1->Amount)
{ {
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("FireGlow")); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("FireGlow"));
} }
return 0; return 0;
} }
@ -210,7 +210,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
PClassActor *pufftype; PClassActor *pufftype;
FTranslatedLineTarget t; FTranslatedLineTarget t;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
@ -241,7 +241,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
if (t.linetarget) if (t.linetarget)
{ {
P_LineAttack(pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &t); P_LineAttack(pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &t);
if (t.linetarget != NULL) if (t.linetarget != nullptr)
{ {
if (t.linetarget->flags3&MF3_ISMONSTER || t.linetarget->player) if (t.linetarget->flags3&MF3_ISMONSTER || t.linetarget->player)
{ {
@ -265,15 +265,15 @@ axedone:
if (useMana == 2) if (useMana == 2)
{ {
AWeapon *weapon = player->ReadyWeapon; AWeapon *weapon = player->ReadyWeapon;
if (weapon != NULL) if (weapon != nullptr)
{ {
weapon->DepleteAmmo (weapon->bAltFire, false); weapon->DepleteAmmo (weapon->bAltFire, false);
if ((weapon->Ammo1 == NULL || weapon->Ammo1->Amount == 0) && if ((weapon->Ammo1 == nullptr || weapon->Ammo1->Amount == 0) &&
(!(weapon->WeaponFlags & WIF_PRIMARY_USES_BOTH) || (!(weapon->WeaponFlags & WIF_PRIMARY_USES_BOTH) ||
weapon->Ammo2 == NULL || weapon->Ammo2->Amount == 0)) weapon->Ammo2 == nullptr || weapon->Ammo2->Amount == 0))
{ {
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Fire") + 5); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Fire") + 5);
} }
} }
} }

View file

@ -105,7 +105,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
int i; int i;
player_t *player; player_t *player;
if (NULL == (player = self->player)) if (nullptr == (player = self->player))
{ {
return 0; return 0;
} }
@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
if (pmo->weaponspecial >= 3) if (pmo->weaponspecial >= 3)
{ {
pmo->weaponspecial = 0; pmo->weaponspecial = 0;
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState("Fire2")); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState("Fire2"));
S_Sound (pmo, CHAN_VOICE, "*fistgrunt", 1, ATTN_NORM); S_Sound (pmo, CHAN_VOICE, "*fistgrunt", 1, ATTN_NORM);
} }
return 0; return 0;

View file

@ -37,9 +37,9 @@ void APigPlayer::MorphPlayerThink ()
} }
if(Vel.X == 0 && Vel.Y == 0 && pr_pigplayerthink() < 64) if(Vel.X == 0 && Vel.Y == 0 && pr_pigplayerthink() < 64)
{ // Snout sniff { // Snout sniff
if (player->ReadyWeapon != NULL) if (player->ReadyWeapon != nullptr)
{ {
P_SetPsprite(player, ps_weapon, player->ReadyWeapon->FindState("Grunt")); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState("Grunt"));
} }
S_Sound (this, CHAN_VOICE, "PigActive1", 1, ATTN_NORM); // snort S_Sound (this, CHAN_VOICE, "PigActive1", 1, ATTN_NORM); // snort
return; return;

View file

@ -372,9 +372,9 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
bool wantFast; bool wantFast;
int i; int i;
G_ClearHubInfo();
if (!savegamerestore) if (!savegamerestore)
{ {
G_ClearHubInfo();
G_ClearSnapshots (); G_ClearSnapshots ();
P_RemoveDefereds (); P_RemoveDefereds ();

View file

@ -1109,17 +1109,17 @@ void APowerWeaponLevel2::InitEffect ()
Super::InitEffect(); Super::InitEffect();
if (Owner->player == NULL) if (Owner->player == nullptr)
return; return;
weapon = Owner->player->ReadyWeapon; weapon = Owner->player->ReadyWeapon;
if (weapon == NULL) if (weapon == nullptr)
return; return;
sister = weapon->SisterWeapon; sister = weapon->SisterWeapon;
if (sister == NULL) if (sister == nullptr)
return; return;
if (!(sister->WeaponFlags & WIF_POWERED_UP)) if (!(sister->WeaponFlags & WIF_POWERED_UP))
@ -1131,7 +1131,7 @@ void APowerWeaponLevel2::InitEffect ()
if (weapon->GetReadyState() != sister->GetReadyState()) if (weapon->GetReadyState() != sister->GetReadyState())
{ {
P_SetPsprite (Owner->player, ps_weapon, sister->GetReadyState()); P_SetPsprite(Owner->player, PSP_WEAPON, sister->GetReadyState());
} }
} }
@ -1294,29 +1294,42 @@ void APowerTargeter::Travelled ()
void APowerTargeter::InitEffect () void APowerTargeter::InitEffect ()
{ {
// Why is this called when the inventory isn't even attached yet
// in APowerup::CreateCopy?
if (!Owner->FindInventory(GetClass(), true))
return;
player_t *player; player_t *player;
Super::InitEffect(); Super::InitEffect();
if ((player = Owner->player) == NULL) if ((player = Owner->player) == nullptr)
return; return;
FState *state = FindState("Targeter"); FState *state = FindState("Targeter");
if (state != NULL) if (state != nullptr)
{ {
P_SetPsprite (player, ps_targetcenter, state + 0); P_SetPsprite(player, PSP_TARGETCENTER, state + 0);
P_SetPsprite (player, ps_targetleft, state + 1); P_SetPsprite(player, PSP_TARGETLEFT, state + 1);
P_SetPsprite (player, ps_targetright, state + 2); P_SetPsprite(player, PSP_TARGETRIGHT, state + 2);
} }
player->psprites[ps_targetcenter].sx = (160-3); player->GetPSprite(PSP_TARGETCENTER)->x = (160-3);
player->psprites[ps_targetcenter].sy = player->GetPSprite(PSP_TARGETCENTER)->y =
player->psprites[ps_targetleft].sy = player->GetPSprite(PSP_TARGETLEFT)->y =
player->psprites[ps_targetright].sy = (100-3); player->GetPSprite(PSP_TARGETRIGHT)->y = (100-3);
PositionAccuracy (); PositionAccuracy ();
} }
void APowerTargeter::AttachToOwner(AActor *other)
{
Super::AttachToOwner(other);
// Let's actually properly call this for the targeters.
InitEffect();
}
bool APowerTargeter::HandlePickup(AInventory *item) bool APowerTargeter::HandlePickup(AInventory *item)
{ {
if (Super::HandlePickup(item)) if (Super::HandlePickup(item))
@ -1327,13 +1340,11 @@ bool APowerTargeter::HandlePickup(AInventory *item)
return false; return false;
} }
void APowerTargeter::DoEffect () void APowerTargeter::DoEffect ()
{ {
Super::DoEffect (); Super::DoEffect ();
if (Owner != NULL && Owner->player != NULL) if (Owner != nullptr && Owner->player != nullptr)
{ {
player_t *player = Owner->player; player_t *player = Owner->player;
@ -1342,17 +1353,17 @@ void APowerTargeter::DoEffect ()
{ {
FState *state = FindState("Targeter"); FState *state = FindState("Targeter");
if (state != NULL) if (state != nullptr)
{ {
if (EffectTics & 32) if (EffectTics & 32)
{ {
P_SetPsprite (player, ps_targetright, NULL); P_SetPsprite(player, PSP_TARGETRIGHT, nullptr);
P_SetPsprite (player, ps_targetleft, state+1); P_SetPsprite(player, PSP_TARGETLEFT, state + 1);
} }
else if (EffectTics & 16) else if (EffectTics & 16)
{ {
P_SetPsprite (player, ps_targetright, state+2); P_SetPsprite(player, PSP_TARGETRIGHT, state + 2);
P_SetPsprite (player, ps_targetleft, NULL); P_SetPsprite(player, PSP_TARGETLEFT, nullptr);
} }
} }
} }
@ -1362,11 +1373,17 @@ void APowerTargeter::DoEffect ()
void APowerTargeter::EndEffect () void APowerTargeter::EndEffect ()
{ {
Super::EndEffect(); Super::EndEffect();
if (Owner != NULL && Owner->player != NULL) if (Owner != nullptr && Owner->player != nullptr)
{ {
P_SetPsprite (Owner->player, ps_targetcenter, NULL); // Calling GetPSprite here could crash if we're creating a new game.
P_SetPsprite (Owner->player, ps_targetleft, NULL); // This is because P_SetupLevel nulls the player's mo before destroying
P_SetPsprite (Owner->player, ps_targetright, NULL); // every DThinker which in turn ends up calling this.
// However P_SetupLevel is only called after G_NewInit which calls
// every player's dtor which destroys all their psprites.
DPSprite *pspr;
if ((pspr = Owner->player->FindPSprite(PSP_TARGETCENTER)) != nullptr) pspr->SetState(nullptr);
if ((pspr = Owner->player->FindPSprite(PSP_TARGETLEFT)) != nullptr) pspr->SetState(nullptr);
if ((pspr = Owner->player->FindPSprite(PSP_TARGETRIGHT)) != nullptr) pspr->SetState(nullptr);
} }
} }
@ -1374,10 +1391,10 @@ void APowerTargeter::PositionAccuracy ()
{ {
player_t *player = Owner->player; player_t *player = Owner->player;
if (player != NULL) if (player != nullptr)
{ {
player->psprites[ps_targetleft].sx = (160-3) - ((100 - player->mo->accuracy)); player->GetPSprite(PSP_TARGETLEFT)->x = (160-3) - ((100 - player->mo->accuracy));
player->psprites[ps_targetright].sx = (160-3)+ ((100 - player->mo->accuracy)); player->GetPSprite(PSP_TARGETRIGHT)->x = (160-3)+ ((100 - player->mo->accuracy));
} }
} }

View file

@ -182,6 +182,7 @@ protected:
void EndEffect (); void EndEffect ();
void PositionAccuracy (); void PositionAccuracy ();
void Travelled (); void Travelled ();
void AttachToOwner(AActor *other);
bool HandlePickup(AInventory *item); bool HandlePickup(AInventory *item);
}; };

View file

@ -608,15 +608,18 @@ bool AWeapon::DepleteAmmo (bool altFire, bool checkEnough, int ammouse)
void AWeapon::PostMorphWeapon () void AWeapon::PostMorphWeapon ()
{ {
if (Owner == NULL) DPSprite *pspr;
if (Owner == nullptr)
{ {
return; return;
} }
Owner->player->PendingWeapon = WP_NOCHANGE; Owner->player->PendingWeapon = WP_NOCHANGE;
Owner->player->ReadyWeapon = this; Owner->player->ReadyWeapon = this;
Owner->player->psprites[ps_weapon].sy = WEAPONBOTTOM;
Owner->player->refire = 0; Owner->player->refire = 0;
P_SetPsprite (Owner->player, ps_weapon, GetUpState());
pspr = Owner->player->GetPSprite(PSP_WEAPON);
pspr->y = WEAPONBOTTOM;
pspr->SetState(GetUpState());
} }
//=========================================================================== //===========================================================================

View file

@ -2786,7 +2786,7 @@ class CommandDrawBar : public SBarInfoCommand
// [BL] Since we used a percentage (in order to get the most fluid animation) // [BL] Since we used a percentage (in order to get the most fluid animation)
// we need to establish a cut off point so the last pixel won't hang as the animation slows // we need to establish a cut off point so the last pixel won't hang as the animation slows
if(pixel == -1 && statusBar->Images[foreground]) if(pixel == -1 && statusBar->Images[foreground])
pixel = MAX(1., 1./statusBar->Images[foreground]->GetWidth()); pixel = MAX(1 / 65536., 1./statusBar->Images[foreground]->GetWidth());
if(fabs(drawValue - value) < pixel) if(fabs(drawValue - value) < pixel)
drawValue = value; drawValue = value;

View file

@ -350,11 +350,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns)
S_Sound (self, CHAN_VOICE, "human/imonfire", 1, ATTN_NORM); S_Sound (self, CHAN_VOICE, "human/imonfire", 1, ATTN_NORM);
if (self->player != NULL && self->player->mo == self) if (self->player != nullptr && self->player->mo == self)
{ {
P_SetPsprite (self->player, ps_weapon, self->FindState("FireHands")); DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS);
P_SetPsprite (self->player, ps_flash, NULL); if (psp != nullptr)
self->player->ReadyWeapon = NULL; {
psp->SetState(self->FindState("FireHands"));
psp->Flags &= PSPF_ADDWEAPON | PSPF_ADDBOB;
psp->y = WEAPONTOP;
}
self->player->ReadyWeapon = nullptr;
self->player->PendingWeapon = WP_NOCHANGE; self->player->PendingWeapon = WP_NOCHANGE;
self->player->playerstate = PST_LIVE; self->player->playerstate = PST_LIVE;
self->player->extralight = 3; self->player->extralight = 3;
@ -376,12 +382,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
if (self->player != NULL && self->player->mo == self) if (self->player != nullptr && self->player->mo == self)
{ {
self->player->playerstate = PST_DEAD; self->player->playerstate = PST_DEAD;
P_SetPsprite (self->player, ps_weapon,
self->player->psprites[ps_weapon].state + DPSprite *psp;
(self->FindState("FireHandsLower") - self->FindState("FireHands"))); psp = self->player->GetPSprite(PSP_STRIFEHANDS);
psp->SetState(psp->GetState() + (self->FindState("FireHandsLower") - self->FindState("FireHands")));
} }
return 0; return 0;
} }
@ -390,13 +397,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_HandLower)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
if (self->player != NULL) if (self->player != nullptr)
{ {
pspdef_t *psp = &self->player->psprites[ps_weapon]; DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS);
psp->sy += 9; psp->y += 9;
if (psp->sy > WEAPONBOTTOM*2) if (psp->y > WEAPONBOTTOM*2)
{ {
P_SetPsprite (self->player, ps_weapon, NULL); psp->SetState(nullptr);
} }
if (self->player->extralight > 0) self->player->extralight--; if (self->player->extralight > 0) self->player->extralight--;
} }

View file

@ -216,10 +216,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClearFlash)
player_t *player = self->player; player_t *player = self->player;
if (player == NULL) if (player == nullptr)
return 0; return 0;
P_SetPsprite (player, ps_flash, NULL); P_SetPsprite (player, PSP_FLASH, nullptr);
return 0; return 0;
} }
@ -233,9 +233,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShowElectricFlash)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
if (self->player != NULL) if (self->player != nullptr)
{ {
P_SetPsprite (self->player, ps_flash, self->player->ReadyWeapon->FindState(NAME_Flash)); P_SetPsprite (self->player, PSP_FLASH, self->player->ReadyWeapon->FindState(NAME_Flash));
} }
return 0; return 0;
} }
@ -498,10 +498,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler2Pre)
S_Sound (self, CHAN_WEAPON, "weapons/mauler2charge", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/mauler2charge", 1, ATTN_NORM);
if (self->player != NULL) if (self->player != nullptr)
{ {
self->player->psprites[ps_weapon].sx += pr_mauler2.Random2() / 64.; self->player->GetPSprite(PSP_WEAPON)->x += pr_mauler2.Random2() / 64.;
self->player->psprites[ps_weapon].sy += pr_mauler2.Random2() / 64.; self->player->GetPSprite(PSP_WEAPON)->y += pr_mauler2.Random2() / 64.;
} }
return 0; return 0;
} }
@ -698,24 +698,23 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade)
DAngle an; DAngle an;
AWeapon *weapon; AWeapon *weapon;
if (player == NULL || grenadetype == NULL) if (player == nullptr || grenadetype == nullptr)
return 0; return 0;
if ((weapon = player->ReadyWeapon) == NULL) if ((weapon = player->ReadyWeapon) == nullptr)
return 0; return 0;
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
P_SetPsprite (player, ps_flash, flash); P_SetPsprite (player, PSP_FLASH, flash, true);
self->player->psprites[ps_flash].processPending = true;
if (grenadetype != NULL) if (grenadetype != nullptr)
{ {
self->AddZ(32); self->AddZ(32);
grenade = P_SpawnSubMissile (self, grenadetype, self); grenade = P_SpawnSubMissile (self, grenadetype, self);
self->AddZ(-32); self->AddZ(-32);
if (grenade == NULL) if (grenade == nullptr)
return 0; return 0;
if (grenade->SeeSound != 0) if (grenade->SeeSound != 0)
@ -849,15 +848,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilView)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
DPSprite *pspr;
int pieces; int pieces;
if (self->player == NULL) if (self->player == nullptr)
{ {
return 0; return 0;
} }
pieces = static_cast<ASigil*>(self->player->ReadyWeapon)->NumPieces; pieces = static_cast<ASigil*>(self->player->ReadyWeapon)->NumPieces;
P_SetPsprite (self->player, ps_weapon, pspr = self->player->GetPSprite(PSP_WEAPON);
self->player->psprites[ps_weapon].state + pieces); pspr->SetState(pspr->GetState() + pieces);
return 0; return 0;
} }
@ -875,9 +875,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilDown)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
DPSprite *pspr;
int pieces; int pieces;
if (self->player == NULL) if (self->player == nullptr)
{ {
return 0; return 0;
} }
@ -887,8 +888,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilDown)
{ {
pieces = static_cast<ASigil*>(self->player->ReadyWeapon)->NumPieces; pieces = static_cast<ASigil*>(self->player->ReadyWeapon)->NumPieces;
} }
P_SetPsprite (self->player, ps_weapon, pspr = self->player->GetPSprite(PSP_WEAPON);
self->player->psprites[ps_weapon].state + pieces); pspr->SetState(pspr->GetState() + pieces);
return 0; return 0;
} }
@ -904,15 +905,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_SelectSigilAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
DPSprite *pspr;
int pieces; int pieces;
if (self->player == NULL) if (self->player == nullptr)
{ {
return 0; return 0;
} }
pieces = static_cast<ASigil*>(self->player->ReadyWeapon)->NumPieces; pieces = static_cast<ASigil*>(self->player->ReadyWeapon)->NumPieces;
P_SetPsprite (self->player, ps_weapon, pspr = self->player->GetPSprite(PSP_WEAPON);
self->player->psprites[ps_weapon].state + 4*pieces - 3); pspr->SetState(pspr->GetState() + 4*pieces - 3);
return 0; return 0;
} }

View file

@ -69,14 +69,14 @@ void FState::SetAction(const char *name)
ActionFunc = FindGlobalActionFunction(name)->Variants[0].Implementation; ActionFunc = FindGlobalActionFunction(name)->Variants[0].Implementation;
} }
bool FState::CallAction(AActor *self, AActor *stateowner, FState **stateret) bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info, FState **stateret)
{ {
if (ActionFunc != NULL) if (ActionFunc != NULL)
{ {
ActionCycles.Clock(); ActionCycles.Clock();
static VMFrameStack stack; static VMFrameStack stack;
VMValue params[3] = { self, stateowner, VMValue(this, ATAG_STATE) }; VMValue params[3] = { self, stateowner, VMValue(info, ATAG_STATEINFO) };
// If the function returns a state, store it at *stateret. // If the function returns a state, store it at *stateret.
// If it doesn't return a state but stateret is non-NULL, we need // If it doesn't return a state but stateret is non-NULL, we need
// to set *stateret to NULL. // to set *stateret to NULL.

View file

@ -55,6 +55,21 @@ struct FActorInfo;
class FArchive; class FArchive;
class FIntCVar; class FIntCVar;
enum EStateType
{
STATE_Actor,
STATE_Psprite,
STATE_StateChain,
};
struct FStateParamInfo
{
FState *mCallingState;
EStateType mStateType;
int mPSPIndex;
};
// Sprites that are fixed in position because they can have special meanings. // Sprites that are fixed in position because they can have special meanings.
enum enum
{ {
@ -129,7 +144,7 @@ struct FState
void SetAction(VMFunction *func) { ActionFunc = func; } void SetAction(VMFunction *func) { ActionFunc = func; }
void ClearAction() { ActionFunc = NULL; } void ClearAction() { ActionFunc = NULL; }
void SetAction(const char *name); void SetAction(const char *name);
bool CallAction(AActor *self, AActor *stateowner, FState **stateret); bool CallAction(AActor *self, AActor *stateowner, FStateParamInfo *stateinfo, FState **stateret);
static PClassActor *StaticFindStateOwner (const FState *state); static PClassActor *StaticFindStateOwner (const FState *state);
static PClassActor *StaticFindStateOwner (const FState *state, PClassActor *info); static PClassActor *StaticFindStateOwner (const FState *state, PClassActor *info);
static FRandom pr_statetics; static FRandom pr_statetics;
@ -338,7 +353,7 @@ void AddStateLight(FState *state, const char *lname);
PARAM_PROLOGUE; \ PARAM_PROLOGUE; \
PARAM_OBJECT (self, type); \ PARAM_OBJECT (self, type); \
PARAM_OBJECT_OPT (stateowner, AActor) { stateowner = self; } \ PARAM_OBJECT_OPT (stateowner, AActor) { stateowner = self; } \
PARAM_STATE_OPT (callingstate) { callingstate = NULL; } \ PARAM_STATEINFO_OPT (stateinfo) { stateinfo = nullptr; } \
#define PARAM_ACTION_PROLOGUE PARAM_ACTION_PROLOGUE_TYPE(AActor) #define PARAM_ACTION_PROLOGUE PARAM_ACTION_PROLOGUE_TYPE(AActor)

View file

@ -314,7 +314,7 @@ void cht_DoCheat (player_t *player, int cheat)
// [GRB] // [GRB]
case CHT_RESSURECT: case CHT_RESSURECT:
if (player->playerstate != PST_LIVE && player->mo != NULL) if (player->playerstate != PST_LIVE && player->mo != nullptr)
{ {
if (player->mo->IsKindOf(RUNTIME_CLASS(APlayerChunk))) if (player->mo->IsKindOf(RUNTIME_CLASS(APlayerChunk)))
{ {
@ -343,9 +343,9 @@ void cht_DoCheat (player_t *player, int cheat)
player->mo->Translation = TRANSLATION(TRANSLATION_Players, BYTE(player-players)); player->mo->Translation = TRANSLATION(TRANSLATION_Players, BYTE(player-players));
} }
player->mo->DamageType = NAME_None; player->mo->DamageType = NAME_None;
if (player->ReadyWeapon != NULL) if (player->ReadyWeapon != nullptr)
{ {
P_SetPsprite(player, ps_weapon, player->ReadyWeapon->GetUpState()); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetUpState());
} }
if (player->morphTics > 0) if (player->morphTics > 0)
@ -932,10 +932,8 @@ void cht_Take (player_t *player, const char *name, int amount)
if (weapon) if (weapon)
weapon->Destroy (); weapon->Destroy ();
player->ReadyWeapon = NULL; player->ReadyWeapon = nullptr;
player->PendingWeapon = WP_NOCHANGE; player->PendingWeapon = WP_NOCHANGE;
player->psprites[ps_weapon].state = NULL;
player->psprites[ps_flash].state = NULL;
} }
} }

View file

@ -526,7 +526,7 @@ DAnimatedDoor::DAnimatedDoor ()
} }
DAnimatedDoor::DAnimatedDoor (sector_t *sec) DAnimatedDoor::DAnimatedDoor (sector_t *sec)
: DMovingCeiling (sec) : DMovingCeiling (sec, false)
{ {
} }

View file

@ -475,8 +475,8 @@ void P_RunEffect (AActor *actor, int effects)
speed = (M_Random () - 128) * (1./200); speed = (M_Random () - 128) * (1./200);
particle->Vel.X += speed * an.Cos(); particle->Vel.X += speed * an.Cos();
particle->Vel.Y += speed * an.Sin(); particle->Vel.Y += speed * an.Sin();
particle->Vel.Z -= 1. / 80; particle->Vel.Z += 1. / 80;
particle->Acc.Z -= 1. / 40; particle->Acc.Z += 1. / 40;
if (M_Random () & 7) if (M_Random () & 7)
particle->color = grey2; particle->color = grey2;
else else

View file

@ -76,7 +76,6 @@ extern int bmapnegy;
// P_PSPR // P_PSPR
// //
void P_SetupPsprites (player_t* curplayer, bool startweaponup); void P_SetupPsprites (player_t* curplayer, bool startweaponup);
void P_MovePsprites (player_t* curplayer);
void P_DropWeapon (player_t* player); void P_DropWeapon (player_t* player);
@ -334,6 +333,7 @@ struct FRailParams
double drift = 1.0; double drift = 1.0;
PClassActor *spawnclass = nullptr; PClassActor *spawnclass = nullptr;
int SpiralOffset = 270; int SpiralOffset = 270;
int limit = 0;
}; // [RH] Shoot a railgun }; // [RH] Shoot a railgun
void P_RailAttack(FRailParams *params); void P_RailAttack(FRailParams *params);

View file

@ -4610,6 +4610,8 @@ struct RailData
bool ThruSpecies; bool ThruSpecies;
bool MThruSpecies; bool MThruSpecies;
bool ThruActors; bool ThruActors;
int limit;
int count;
}; };
static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata)
@ -4664,7 +4666,11 @@ static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata)
} }
data->RailHits.Push(newhit); data->RailHits.Push(newhit);
return data->StopAtOne ? TRACE_Stop : TRACE_Continue; if (data->limit)
{
data->count++;
}
return (data->StopAtOne || (data->limit && (data->count >= data->limit))) ? TRACE_Stop : TRACE_Continue;
} }
//========================================================================== //==========================================================================
@ -4706,7 +4712,8 @@ void P_RailAttack(FRailParams *p)
RailData rail_data; RailData rail_data;
rail_data.Caller = source; rail_data.Caller = source;
rail_data.limit = p->limit;
rail_data.count = 0;
rail_data.StopAtOne = !!(p->flags & RAF_NOPIERCE); rail_data.StopAtOne = !!(p->flags & RAF_NOPIERCE);
start.X = xy.X; start.X = xy.X;
start.Y = xy.Y; start.Y = xy.Y;

View file

@ -556,7 +556,8 @@ bool AActor::SetState (FState *newstate, bool nofunction)
if (!nofunction) if (!nofunction)
{ {
FState *returned_state; FState *returned_state;
if (newstate->CallAction(this, this, &returned_state)) FStateParamInfo stp = { newstate, STATE_Actor, PSP_WEAPON };
if (newstate->CallAction(this, this, &stp, &returned_state))
{ {
// Check whether the called action function resulted in destroying the actor // Check whether the called action function resulted in destroying the actor
if (ObjectFlags & OF_EuthanizeMe) if (ObjectFlags & OF_EuthanizeMe)
@ -997,12 +998,10 @@ void AActor::ClearInventory()
invp = &inv->Inventory; invp = &inv->Inventory;
} }
} }
if (player != NULL) if (player != nullptr)
{ {
player->ReadyWeapon = NULL; player->ReadyWeapon = nullptr;
player->PendingWeapon = WP_NOCHANGE; player->PendingWeapon = WP_NOCHANGE;
player->psprites[ps_weapon].state = NULL;
player->psprites[ps_flash].state = NULL;
} }
} }
@ -3868,7 +3867,8 @@ bool AActor::CheckNoDelay()
// For immediately spawned objects with the NoDelay flag set for their // For immediately spawned objects with the NoDelay flag set for their
// Spawn state, explicitly call the current state's function. // Spawn state, explicitly call the current state's function.
FState *newstate; FState *newstate;
if (state->CallAction(this, this, &newstate)) FStateParamInfo stp = { state, STATE_Actor, PSP_WEAPON };
if (state->CallAction(this, this, &stp, &newstate))
{ {
if (ObjectFlags & OF_EuthanizeMe) if (ObjectFlags & OF_EuthanizeMe)
{ {

File diff suppressed because it is too large Load diff

View file

@ -34,59 +34,82 @@
// the right spot at 320x200. // the right spot at 320x200.
#define WEAPONTOP (32+6./16) #define WEAPONTOP (32+6./16)
class AInventory;
class FArchive;
// //
// Overlay psprites are scaled shapes // Overlay psprites are scaled shapes
// drawn directly on the view screen, // drawn directly on the view screen,
// coordinates are given for a 320*200 view screen. // coordinates are given for a 320*200 view screen.
// //
typedef enum enum PSPLayers // These are all called by the owner's ReadyWeapon.
{ {
ps_weapon, PSP_STRIFEHANDS = -1,
ps_flash, PSP_WEAPON = 1,
ps_targetcenter, PSP_FLASH = 1000,
ps_targetleft, PSP_TARGETCENTER = INT_MAX - 2,
ps_targetright, PSP_TARGETLEFT,
NUMPSPRITES PSP_TARGETRIGHT,
} psprnum_t;
/*
inline FArchive &operator<< (FArchive &arc, psprnum_t &i)
{
BYTE val = (BYTE)i;
arc << val;
i = (psprnum_t)val;
return arc;
}
*/
struct pspdef_t
{
FState* state; // a NULL state means not active
int tics;
double sx;
double sy;
int sprite;
int frame;
bool processPending; // true: waiting for periodic processing on this tick
}; };
class FArchive; enum PSPFlags
{
PSPF_ADDWEAPON = 1 << 0,
PSPF_ADDBOB = 1 << 1,
PSPF_POWDOUBLE = 1 << 2,
PSPF_CVARFAST = 1 << 3,
};
FArchive &operator<< (FArchive &, pspdef_t &); class DPSprite : public DObject
{
DECLARE_CLASS (DPSprite, DObject)
HAS_OBJECT_POINTERS
public:
DPSprite(player_t *owner, AActor *caller, int id);
class player_t; static void NewTick();
class AActor; void SetState(FState *newstate, bool pending = false);
struct FState;
int GetID() const { return ID; }
int GetSprite() const { return Sprite; }
int GetFrame() const { return Frame; }
FState* GetState() const { return State; }
DPSprite* GetNext() { return Next; }
AActor* GetCaller() { return Caller; }
double x, y;
double oldx, oldy;
bool firstTic;
int Tics;
int Flags;
private:
DPSprite () {}
void Serialize(FArchive &arc);
void Tick();
void Destroy();
TObjPtr<AActor> Caller;
TObjPtr<DPSprite> Next;
player_t *Owner;
FState *State;
int Sprite;
int Frame;
int ID;
bool processPending; // true: waiting for periodic processing on this tick
friend class player_t;
friend void CopyPlayer(player_t *dst, player_t *src, const char *name);
};
void P_NewPspriteTick(); void P_NewPspriteTick();
void P_SetPsprite (player_t *player, int position, FState *state, bool nofunction=false);
void P_CalcSwing (player_t *player); void P_CalcSwing (player_t *player);
void P_SetPsprite(player_t *player, PSPLayers id, FState *state, bool pending = false);
void P_BringUpWeapon (player_t *player); void P_BringUpWeapon (player_t *player);
void P_FireWeapon (player_t *player); void P_FireWeapon (player_t *player);
void P_DropWeapon (player_t *player); void P_DropWeapon (player_t *player);
void P_BobWeapon (player_t *player, pspdef_t *psp, float *x, float *y, double ticfrac); void P_BobWeapon (player_t *player, float *x, float *y, double ticfrac);
DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0); DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0);
void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch); void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch);

View file

@ -56,7 +56,7 @@
#include "p_acs.h" #include "p_acs.h"
#include "p_terrain.h" #include "p_terrain.h"
static void CopyPlayer (player_t *dst, player_t *src, const char *name); void CopyPlayer (player_t *dst, player_t *src, const char *name);
static void ReadOnePlayer (FArchive &arc, bool skipload); static void ReadOnePlayer (FArchive &arc, bool skipload);
static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNow, bool skipload); static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNow, bool skipload);
static void SpawnExtraPlayers (); static void SpawnExtraPlayers ();
@ -255,7 +255,7 @@ static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNo
delete[] nametemp; delete[] nametemp;
} }
static void CopyPlayer (player_t *dst, player_t *src, const char *name) void CopyPlayer (player_t *dst, player_t *src, const char *name)
{ {
// The userinfo needs to be saved for real players, but it // The userinfo needs to be saved for real players, but it
// needs to come from the save for bots. // needs to come from the save for bots.
@ -274,7 +274,7 @@ static void CopyPlayer (player_t *dst, player_t *src, const char *name)
dst->cheats |= chasecam; dst->cheats |= chasecam;
if (dst->Bot != NULL) if (dst->Bot != nullptr)
{ {
botinfo_t *thebot = bglobal.botinfo; botinfo_t *thebot = bglobal.botinfo;
while (thebot && stricmp (name, thebot->name)) while (thebot && stricmp (name, thebot->name))
@ -296,10 +296,23 @@ static void CopyPlayer (player_t *dst, player_t *src, const char *name)
dst->userinfo.SkinNumChanged(R_FindSkin(skins[dst->userinfo.GetSkin()].name, dst->CurrentPlayerClass)); dst->userinfo.SkinNumChanged(R_FindSkin(skins[dst->userinfo.GetSkin()].name, dst->CurrentPlayerClass));
// Make sure the player pawn points to the proper player struct. // Make sure the player pawn points to the proper player struct.
if (dst->mo != NULL) if (dst->mo != nullptr)
{ {
dst->mo->player = dst; dst->mo->player = dst;
} }
// Same for the psprites.
DPSprite *pspr = dst->psprites;
while (pspr)
{
pspr->Owner = dst;
pspr = pspr->Next;
}
// Don't let the psprites be destroyed when src is destroyed.
src->psprites = nullptr;
// These 2 variables may not be overwritten. // These 2 variables may not be overwritten.
dst->attackdown = attackdown; dst->attackdown = attackdown;
dst->usedown = usedown; dst->usedown = usedown;

View file

@ -3329,14 +3329,17 @@ void P_LoadReject (MapData * map, bool junk)
// //
// [RH] P_LoadBehavior // [RH] P_LoadBehavior
// //
void P_LoadBehavior (MapData * map) void P_LoadBehavior(MapData * map)
{ {
map->Seek(ML_BEHAVIOR); if (map->Size(ML_BEHAVIOR) > 0)
FBehavior::StaticLoadModule (-1, map->file, map->Size(ML_BEHAVIOR));
if (!FBehavior::StaticCheckAllGood ())
{ {
Printf ("ACS scripts unloaded.\n"); map->Seek(ML_BEHAVIOR);
FBehavior::StaticUnloadModules (); FBehavior::StaticLoadModule(-1, map->file, map->Size(ML_BEHAVIOR));
}
if (!FBehavior::StaticCheckAllGood())
{
Printf("ACS scripts unloaded.\n");
FBehavior::StaticUnloadModules();
} }
} }

View file

@ -87,7 +87,7 @@ void P_Ticker (void)
if (paused || P_CheckTickerPaused()) if (paused || P_CheckTickerPaused())
return; return;
P_NewPspriteTick(); DPSprite::NewTick();
// [RH] Frozen mode is only changed every 4 tics, to make it work with A_Tracer(). // [RH] Frozen mode is only changed every 4 tics, to make it work with A_Tracer().
if ((level.time & 3) == 0) if ((level.time & 3) == 0)

View file

@ -434,7 +434,7 @@ bool FTraceInfo::LineCheck(intercept_t *in, double dist, DVector3 hit)
sector_t *hsec = CurSector->GetHeightSec(); sector_t *hsec = CurSector->GetHeightSec();
if (Results->CrossedWater == NULL && if (Results->CrossedWater == NULL &&
hsec != NULL && hsec != NULL &&
//CurSector->heightsec->waterzone && Start.Z > hsec->floorplane.ZatPoint(Start) &&
hit.Z <= hsec->floorplane.ZatPoint(hit)) hit.Z <= hsec->floorplane.ZatPoint(hit))
{ {
// hit crossed a water plane // hit crossed a water plane
@ -846,6 +846,7 @@ bool FTraceInfo::TraceTraverse (int ptflags)
if (Results->CrossedWater == NULL && if (Results->CrossedWater == NULL &&
CurSector->heightsec != NULL && CurSector->heightsec != NULL &&
CurSector->heightsec->floorplane.ZatPoint(Start) < Start.Z &&
CurSector->heightsec->floorplane.ZatPoint(Results->HitPos) >= Results->HitPos.Z) CurSector->heightsec->floorplane.ZatPoint(Results->HitPos) >= Results->HitPos.Z)
{ {
// Save the result so that the water check doesn't destroy it. // Save the result so that the water check doesn't destroy it.

View file

@ -270,6 +270,7 @@ player_t::player_t()
WeaponState(0), WeaponState(0),
ReadyWeapon(0), ReadyWeapon(0),
PendingWeapon(0), PendingWeapon(0),
psprites(0),
cheats(0), cheats(0),
timefreezer(0), timefreezer(0),
refire(0), refire(0),
@ -315,7 +316,11 @@ player_t::player_t()
{ {
memset (&cmd, 0, sizeof(cmd)); memset (&cmd, 0, sizeof(cmd));
memset (frags, 0, sizeof(frags)); memset (frags, 0, sizeof(frags));
memset (psprites, 0, sizeof(psprites)); }
player_t::~player_t()
{
DestroyPSprites();
} }
player_t &player_t::operator=(const player_t &p) player_t &player_t::operator=(const player_t &p)
@ -371,7 +376,7 @@ player_t &player_t::operator=(const player_t &p)
extralight = p.extralight; extralight = p.extralight;
fixedcolormap = p.fixedcolormap; fixedcolormap = p.fixedcolormap;
fixedlightlevel = p.fixedlightlevel; fixedlightlevel = p.fixedlightlevel;
memcpy(psprites, &p.psprites, sizeof(psprites)); psprites = p.psprites;
morphTics = p.morphTics; morphTics = p.morphTics;
MorphedPlayerClass = p.MorphedPlayerClass; MorphedPlayerClass = p.MorphedPlayerClass;
MorphStyle = p.MorphStyle; MorphStyle = p.MorphStyle;
@ -433,6 +438,7 @@ size_t player_t::FixPointers (const DObject *old, DObject *rep)
if (ReadyWeapon == old) ReadyWeapon = static_cast<AWeapon *>(rep), changed++; if (ReadyWeapon == old) ReadyWeapon = static_cast<AWeapon *>(rep), changed++;
if (PendingWeapon == old) PendingWeapon = static_cast<AWeapon *>(rep), changed++; if (PendingWeapon == old) PendingWeapon = static_cast<AWeapon *>(rep), changed++;
if (*&PremorphWeapon == old) PremorphWeapon = static_cast<AWeapon *>(rep), changed++; if (*&PremorphWeapon == old) PremorphWeapon = static_cast<AWeapon *>(rep), changed++;
if (psprites == old) psprites = static_cast<DPSprite *>(rep), changed++;
if (*&ConversationNPC == old) ConversationNPC = replacement, changed++; if (*&ConversationNPC == old) ConversationNPC = replacement, changed++;
if (*&ConversationPC == old) ConversationPC = replacement, changed++; if (*&ConversationPC == old) ConversationPC = replacement, changed++;
if (*&MUSINFOactor == old) MUSINFOactor = replacement, changed++; if (*&MUSINFOactor == old) MUSINFOactor = replacement, changed++;
@ -451,6 +457,7 @@ size_t player_t::PropagateMark()
GC::Mark(ConversationPC); GC::Mark(ConversationPC);
GC::Mark(MUSINFOactor); GC::Mark(MUSINFOactor);
GC::Mark(PremorphWeapon); GC::Mark(PremorphWeapon);
GC::Mark(psprites);
if (PendingWeapon != WP_NOCHANGE) if (PendingWeapon != WP_NOCHANGE)
{ {
GC::Mark(PendingWeapon); GC::Mark(PendingWeapon);
@ -1370,34 +1377,37 @@ void APlayerPawn::ActivateMorphWeapon ()
{ {
PClassActor *morphweapon = PClass::FindActor (MorphWeapon); PClassActor *morphweapon = PClass::FindActor (MorphWeapon);
player->PendingWeapon = WP_NOCHANGE; player->PendingWeapon = WP_NOCHANGE;
player->psprites[ps_weapon].sy = WEAPONTOP;
if (morphweapon == NULL || !morphweapon->IsDescendantOf (RUNTIME_CLASS(AWeapon))) if (player->ReadyWeapon != nullptr)
{
player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
}
if (morphweapon == nullptr || !morphweapon->IsDescendantOf (RUNTIME_CLASS(AWeapon)))
{ // No weapon at all while morphed! { // No weapon at all while morphed!
player->ReadyWeapon = NULL; player->ReadyWeapon = nullptr;
P_SetPsprite (player, ps_weapon, NULL);
} }
else else
{ {
player->ReadyWeapon = static_cast<AWeapon *>(player->mo->FindInventory (morphweapon)); player->ReadyWeapon = static_cast<AWeapon *>(player->mo->FindInventory (morphweapon));
if (player->ReadyWeapon == NULL) if (player->ReadyWeapon == nullptr)
{ {
player->ReadyWeapon = static_cast<AWeapon *>(player->mo->GiveInventoryType (morphweapon)); player->ReadyWeapon = static_cast<AWeapon *>(player->mo->GiveInventoryType (morphweapon));
if (player->ReadyWeapon != NULL) if (player->ReadyWeapon != nullptr)
{ {
player->ReadyWeapon->GivenAsMorphWeapon = true; // flag is used only by new beastweap semantics in P_UndoPlayerMorph player->ReadyWeapon->GivenAsMorphWeapon = true; // flag is used only by new beastweap semantics in P_UndoPlayerMorph
} }
} }
if (player->ReadyWeapon != NULL) if (player->ReadyWeapon != nullptr)
{ {
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetReadyState()); P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->GetReadyState());
}
else
{
P_SetPsprite (player, ps_weapon, NULL);
} }
} }
P_SetPsprite (player, ps_flash, NULL);
if (player->ReadyWeapon != nullptr)
{
P_SetPsprite(player, PSP_FLASH, nullptr);
}
player->PendingWeapon = WP_NOCHANGE; player->PendingWeapon = WP_NOCHANGE;
} }
@ -2114,7 +2124,7 @@ void P_DeathThink (player_t *player)
int dir; int dir;
DAngle delta; DAngle delta;
P_MovePsprites (player); player->TickPSprites();
player->onground = (player->mo->Z() <= player->mo->floorz); player->onground = (player->mo->Z() <= player->mo->floorz);
if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk))) if (player->mo->IsKindOf (RUNTIME_CLASS(APlayerChunk)))
@ -2634,7 +2644,7 @@ void P_PlayerThink (player_t *player)
} }
} }
// Cycle psprites // Cycle psprites
P_MovePsprites (player); player->TickPSprites();
// Other Counters // Other Counters
if (player->damagecount) if (player->damagecount)
@ -3064,8 +3074,56 @@ void player_t::Serialize (FArchive &arc)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
arc << frags[i]; arc << frags[i];
for (i = 0; i < NUMPSPRITES; i++)
arc << psprites[i]; if (SaveVersion < 4547)
{
int layer = PSP_WEAPON;
for (i = 0; i < 5; i++)
{
FState *state;
int tics;
double sx, sy;
int sprite;
int frame;
arc << state << tics
<< sx << sy
<< sprite << frame;
if (state != nullptr &&
((layer < PSP_TARGETCENTER && ReadyWeapon != nullptr) ||
(layer >= PSP_TARGETCENTER && mo->FindInventory(RUNTIME_CLASS(APowerTargeter), true))))
{
DPSprite *pspr;
pspr = GetPSprite(PSPLayers(layer));
pspr->State = state;
pspr->Tics = tics;
pspr->Sprite = sprite;
pspr->Frame = frame;
pspr->Owner = this;
if (layer == PSP_FLASH)
{
pspr->x = 0;
pspr->y = 0;
}
else
{
pspr->x = sx;
pspr->y = sy;
}
}
if (layer == PSP_WEAPON)
layer = PSP_FLASH;
else if (layer == PSP_FLASH)
layer = PSP_TARGETCENTER;
else
layer++;
}
}
else
arc << psprites;
arc << CurrentPlayerClass; arc << CurrentPlayerClass;

View file

@ -92,6 +92,7 @@ extern double globaluclip, globaldclip;
extern float MaskedScaleY; extern float MaskedScaleY;
#define MINZ double((2048*4) / double(1 << 20)) #define MINZ double((2048*4) / double(1 << 20))
#define BASEXCENTER (160)
#define BASEYCENTER (100) #define BASEYCENTER (100)
EXTERN_CVAR (Bool, st_scale) EXTERN_CVAR (Bool, st_scale)
@ -111,9 +112,15 @@ double pspriteyscale;
fixed_t sky1scale; // [RH] Sky 1 scale factor fixed_t sky1scale; // [RH] Sky 1 scale factor
fixed_t sky2scale; // [RH] Sky 2 scale factor fixed_t sky2scale; // [RH] Sky 2 scale factor
vissprite_t *VisPSprites[NUMPSPRITES]; // Used to store a psprite's drawing information if it needs to be drawn later.
int VisPSpritesX1[NUMPSPRITES]; struct vispsp_t
FDynamicColormap *VisPSpritesBaseColormap[NUMPSPRITES]; {
vissprite_t *vis;
FDynamicColormap *basecolormap;
int x1;
};
TArray<vispsp_t> vispsprites;
unsigned int vispspindex;
static int spriteshade; static int spriteshade;
@ -1269,48 +1276,40 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside)
} }
} }
// //
// R_DrawPSprite // R_DrawPSprite
// //
void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double sy) void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac)
{ {
double tx; double tx;
int x1; int x1;
int x2; int x2;
double sx, sy;
spritedef_t* sprdef; spritedef_t* sprdef;
spriteframe_t* sprframe; spriteframe_t* sprframe;
FTextureID picnum; FTextureID picnum;
WORD flip; WORD flip;
FTexture* tex; FTexture* tex;
vissprite_t* vis; vissprite_t* vis;
static vissprite_t avis[NUMPSPRITES + 1]; bool noaccel;
static vissprite_t *avisp[countof(avis)]; static TArray<vissprite_t> avis;
bool noaccel;
assert(pspnum >= 0 && pspnum < NUMPSPRITES); if (avis.Size() < vispspindex + 1)
avis.Reserve(avis.Size() - vispspindex + 1);
if (avisp[0] == NULL)
{
for (unsigned i = 0; i < countof(avis); ++i)
{
avisp[i] = &avis[i];
}
}
// decide which patch to use // decide which patch to use
if ( (unsigned)psp->sprite >= (unsigned)sprites.Size ()) if ((unsigned)pspr->GetSprite() >= (unsigned)sprites.Size())
{ {
DPrintf ("R_DrawPSprite: invalid sprite number %i\n", psp->sprite); DPrintf("R_DrawPSprite: invalid sprite number %i\n", pspr->GetSprite());
return; return;
} }
sprdef = &sprites[psp->sprite]; sprdef = &sprites[pspr->GetSprite()];
if (psp->frame >= sprdef->numframes) if (pspr->GetFrame() >= sprdef->numframes)
{ {
DPrintf ("R_DrawPSprite: invalid sprite frame %i : %i\n", psp->sprite, psp->frame); DPrintf("R_DrawPSprite: invalid sprite frame %i : %i\n", pspr->GetSprite(), pspr->GetFrame());
return; return;
} }
sprframe = &SpriteFrames[sprdef->spriteframes + psp->frame]; sprframe = &SpriteFrames[sprdef->spriteframes + pspr->GetFrame()];
picnum = sprframe->Texture[0]; picnum = sprframe->Texture[0];
flip = sprframe->Flip & 1; flip = sprframe->Flip & 1;
@ -1319,15 +1318,37 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
if (tex->UseType == FTexture::TEX_Null) if (tex->UseType == FTexture::TEX_Null)
return; return;
if (pspr->firstTic)
{ // Can't interpolate the first tic.
pspr->firstTic = false;
pspr->oldx = pspr->x;
pspr->oldy = pspr->y;
}
sx = pspr->oldx + (pspr->x - pspr->oldx) * ticfrac;
sy = pspr->oldy + (pspr->y - pspr->oldy) * ticfrac;
if (pspr->Flags & PSPF_ADDBOB)
{
sx += bobx;
sy += boby;
}
if (pspr->Flags & PSPF_ADDWEAPON && pspr->GetID() != PSP_WEAPON)
{
sx += wx;
sy += wy;
}
// calculate edges of the shape // calculate edges of the shape
tx = sx - (320 / 2); tx = sx - BASEXCENTER;
tx -= tex->GetScaledLeftOffset(); tx -= tex->GetScaledLeftOffset();
x1 = xs_RoundToInt(CenterX + tx * pspritexscale); x1 = xs_RoundToInt(CenterX + tx * pspritexscale);
// off the right side // off the right side
if (x1 > viewwidth) if (x1 > viewwidth)
return; return;
tx += tex->GetScaledWidth(); tx += tex->GetScaledWidth();
x2 = xs_RoundToInt(CenterX + tx * pspritexscale); x2 = xs_RoundToInt(CenterX + tx * pspritexscale);
@ -1335,9 +1356,9 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
// off the left side // off the left side
if (x2 <= 0) if (x2 <= 0)
return; return;
// store information in a vissprite // store information in a vissprite
vis = avisp[NUMPSPRITES]; vis = &avis[vispspindex];
vis->renderflags = owner->renderflags; vis->renderflags = owner->renderflags;
vis->floorclip = 0; vis->floorclip = 0;
@ -1345,14 +1366,10 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
if (camera->player && (RenderTarget != screen || if (camera->player && (RenderTarget != screen ||
viewheight == RenderTarget->GetHeight() || viewheight == RenderTarget->GetHeight() ||
(RenderTarget->GetWidth() > 320 && !st_scale))) (RenderTarget->GetWidth() > (BASEXCENTER * 2) && !st_scale)))
{ // Adjust PSprite for fullscreen views { // Adjust PSprite for fullscreen views
AWeapon *weapon = NULL; AWeapon *weapon = dyn_cast<AWeapon>(pspr->GetCaller());
if (camera->player != NULL) if (weapon != nullptr && weapon->YAdjust != 0)
{
weapon = camera->player->ReadyWeapon;
}
if (pspnum <= ps_flash && weapon != NULL && weapon->YAdjust != 0)
{ {
if (RenderTarget != screen || viewheight == RenderTarget->GetHeight()) if (RenderTarget != screen || viewheight == RenderTarget->GetHeight())
{ {
@ -1360,11 +1377,11 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
} }
else else
{ {
vis->texturemid -= StatusBar->GetDisplacement () * weapon->YAdjust; vis->texturemid -= StatusBar->GetDisplacement() * weapon->YAdjust;
} }
} }
} }
if (pspnum <= ps_flash) if (pspr->GetID() < PSP_TARGETCENTER)
{ // Move the weapon down for 1280x1024. { // Move the weapon down for 1280x1024.
vis->texturemid -= BaseRatioSizes[WidescreenRatio][2]; vis->texturemid -= BaseRatioSizes[WidescreenRatio][2];
} }
@ -1388,11 +1405,11 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
} }
if (vis->x1 > x1) if (vis->x1 > x1)
vis->startfrac += vis->xiscale*(vis->x1-x1); vis->startfrac += vis->xiscale*(vis->x1 - x1);
noaccel = false; noaccel = false;
FDynamicColormap *colormap_to_use = NULL; FDynamicColormap *colormap_to_use = nullptr;
if (pspnum <= ps_flash) if (pspr->GetID() < PSP_TARGETCENTER)
{ {
vis->Style.Alpha = float(owner->Alpha); vis->Style.Alpha = float(owner->Alpha);
vis->Style.RenderStyle = owner->RenderStyle; vis->Style.RenderStyle = owner->RenderStyle;
@ -1413,16 +1430,16 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
{ {
if (invertcolormap) if (invertcolormap)
{ // Fade to white { // Fade to white
mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255,255,255), mybasecolormap->Desaturate); mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(255, 255, 255), mybasecolormap->Desaturate);
invertcolormap = false; invertcolormap = false;
} }
else else
{ // Fade to black { // Fade to black
mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0,0,0), mybasecolormap->Desaturate); mybasecolormap = GetSpecialLights(mybasecolormap->Color, MAKERGB(0, 0, 0), mybasecolormap->Desaturate);
} }
} }
if (realfixedcolormap != NULL) if (realfixedcolormap != nullptr)
{ // fixed color { // fixed color
vis->Style.colormap = realfixedcolormap->Colormap; vis->Style.colormap = realfixedcolormap->Colormap;
} }
@ -1436,25 +1453,25 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
{ {
vis->Style.colormap = mybasecolormap->Maps + fixedlightlev; vis->Style.colormap = mybasecolormap->Maps + fixedlightlev;
} }
else if (!foggy && psp->state->GetFullbright()) else if (!foggy && pspr->GetState()->GetFullbright())
{ // full bright { // full bright
vis->Style.colormap = mybasecolormap->Maps; // [RH] use basecolormap vis->Style.colormap = mybasecolormap->Maps; // [RH] use basecolormap
} }
else else
{ // local light { // local light
vis->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP (0, spriteshade) << COLORMAPSHIFT); vis->Style.colormap = mybasecolormap->Maps + (GETPALOOKUP(0, spriteshade) << COLORMAPSHIFT);
} }
} }
if (camera->Inventory != NULL) if (camera->Inventory != nullptr)
{ {
lighttable_t *oldcolormap = vis->Style.colormap; lighttable_t *oldcolormap = vis->Style.colormap;
camera->Inventory->AlterWeaponSprite (&vis->Style); camera->Inventory->AlterWeaponSprite(&vis->Style);
if (vis->Style.colormap != oldcolormap) if (vis->Style.colormap != oldcolormap)
{ {
// The colormap has changed. Is it one we can easily identify? // The colormap has changed. Is it one we can easily identify?
// If not, then don't bother trying to identify it for // If not, then don't bother trying to identify it for
// hardware accelerated drawing. // hardware accelerated drawing.
if (vis->Style.colormap < SpecialColormaps[0].Colormap || if (vis->Style.colormap < SpecialColormaps[0].Colormap ||
vis->Style.colormap > SpecialColormaps.Last().Colormap) vis->Style.colormap > SpecialColormaps.Last().Colormap)
{ {
noaccel = true; noaccel = true;
@ -1462,7 +1479,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
// Has the basecolormap changed? If so, we can't hardware accelerate it, // Has the basecolormap changed? If so, we can't hardware accelerate it,
// since we don't know what it is anymore. // since we don't know what it is anymore.
else if (vis->Style.colormap < mybasecolormap->Maps || else if (vis->Style.colormap < mybasecolormap->Maps ||
vis->Style.colormap >= mybasecolormap->Maps + NUMCOLORMAPS*256) vis->Style.colormap >= mybasecolormap->Maps + NUMCOLORMAPS * 256)
{ {
noaccel = true; noaccel = true;
} }
@ -1482,7 +1499,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
} }
// If the main colormap has fixed lights, and this sprite is being drawn with that // If the main colormap has fixed lights, and this sprite is being drawn with that
// colormap, disable acceleration so that the lights can remain fixed. // colormap, disable acceleration so that the lights can remain fixed.
if (!noaccel && realfixedcolormap == NULL && if (!noaccel && realfixedcolormap == nullptr &&
NormalLightHasFixedLights && mybasecolormap == &NormalLight && NormalLightHasFixedLights && mybasecolormap == &NormalLight &&
vis->pic->UseBasePalette()) vis->pic->UseBasePalette())
{ {
@ -1505,18 +1522,19 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, double sx, double
style.CheckFuzz(); style.CheckFuzz();
if (style.BlendOp != STYLEOP_Fuzz) if (style.BlendOp != STYLEOP_Fuzz)
{ {
VisPSpritesX1[pspnum] = x1; if (vispsprites.Size() < vispspindex + 1)
VisPSpritesBaseColormap[pspnum] = colormap_to_use; vispsprites.Reserve(vispsprites.Size() - vispspindex + 1);
VisPSprites[pspnum] = vis;
swapvalues(avisp[pspnum], avisp[NUMPSPRITES]); vispsprites[vispspindex].vis = vis;
vispsprites[vispspindex].basecolormap = colormap_to_use;
vispsprites[vispspindex].x1 = x1;
vispspindex++;
return; return;
} }
} }
R_DrawVisSprite (vis); R_DrawVisSprite(vis);
} }
//========================================================================== //==========================================================================
// //
// R_DrawPlayerSprites // R_DrawPlayerSprites
@ -1527,7 +1545,8 @@ void R_DrawPlayerSprites ()
{ {
int i; int i;
int lightnum; int lightnum;
pspdef_t* psp; DPSprite* psp;
DPSprite* weapon;
sector_t* sec = NULL; sector_t* sec = NULL;
static sector_t tempsec; static sector_t tempsec;
int floorlight, ceilinglight; int floorlight, ceilinglight;
@ -1540,28 +1559,35 @@ void R_DrawPlayerSprites ()
(r_deathcamera && camera->health <= 0)) (r_deathcamera && camera->health <= 0))
return; return;
if(fixedlightlev < 0 && viewsector->e && viewsector->e->XFloor.lightlist.Size()) { if (fixedlightlev < 0 && viewsector->e && viewsector->e->XFloor.lightlist.Size())
for(i = viewsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--) {
if(ViewPos.Z <= viewsector->e->XFloor.lightlist[i].plane.Zat0()) { for (i = viewsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
{
if (ViewPos.Z <= viewsector->e->XFloor.lightlist[i].plane.Zat0())
{
rover = viewsector->e->XFloor.lightlist[i].caster; rover = viewsector->e->XFloor.lightlist[i].caster;
if(rover) { if (rover)
if(rover->flags & FF_DOUBLESHADOW && ViewPos.Z <= rover->bottom.plane->Zat0()) {
if (rover->flags & FF_DOUBLESHADOW && ViewPos.Z <= rover->bottom.plane->Zat0())
break; break;
sec = rover->model; sec = rover->model;
if(rover->flags & FF_FADEWALLS) if (rover->flags & FF_FADEWALLS)
basecolormap = sec->ColorMap; basecolormap = sec->ColorMap;
else else
basecolormap = viewsector->e->XFloor.lightlist[i].extra_colormap; basecolormap = viewsector->e->XFloor.lightlist[i].extra_colormap;
} }
break; break;
} }
if(!sec) { }
if(!sec)
{
sec = viewsector; sec = viewsector;
basecolormap = sec->ColorMap; basecolormap = sec->ColorMap;
} }
floorlight = ceilinglight = sec->lightlevel; floorlight = ceilinglight = sec->lightlevel;
} else { }
// This used to use camera->Sector but due to interpolation that can be incorrect else
{ // This used to use camera->Sector but due to interpolation that can be incorrect
// when the interpolated viewpoint is in a different sector than the camera. // when the interpolated viewpoint is in a different sector than the camera.
sec = R_FakeFlat (viewsector, &tempsec, &floorlight, sec = R_FakeFlat (viewsector, &tempsec, &floorlight,
&ceilinglight, false); &ceilinglight, false);
@ -1585,27 +1611,47 @@ void R_DrawPlayerSprites ()
if (camera->player != NULL) if (camera->player != NULL)
{ {
double centerhack = CenterY; double centerhack = CenterY;
float ofsx, ofsy; double wx, wy;
float bobx, boby;
CenterY = viewheight / 2; CenterY = viewheight / 2;
P_BobWeapon (camera->player, &camera->player->psprites[ps_weapon], &ofsx, &ofsy, r_TicFracF); P_BobWeapon (camera->player, &bobx, &boby, r_TicFracF);
// Interpolate the main weapon layer once so as to be able to add it to other layers.
if ((weapon = camera->player->FindPSprite(PSP_WEAPON)) != nullptr)
{
if (weapon->firstTic)
{
wx = weapon->x;
wy = weapon->y;
}
else
{
wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF;
wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF;
}
}
else
{
wx = 0;
wy = 0;
}
// add all active psprites // add all active psprites
for (i = 0, psp = camera->player->psprites; psp = camera->player->psprites;
i < NUMPSPRITES; while (psp)
i++, psp++)
{ {
// [RH] Don't draw the targeter's crosshair if the player already has a crosshair set. // [RH] Don't draw the targeter's crosshair if the player already has a crosshair set.
if (psp->state && (i != ps_targetcenter || CrosshairImage == NULL)) // It's possible this psprite's caller is now null but the layer itself hasn't been destroyed
// because it didn't tick yet (if we typed 'take all' while in the console for example).
// In this case let's simply not draw it to avoid crashing.
if ((psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && psp->GetCaller() != nullptr)
{ {
R_DrawPSprite (psp, i, camera, psp->sx + ofsx, psp->sy + ofsy); R_DrawPSprite(psp, camera, bobx, boby, wx, wy, r_TicFracF);
}
// [RH] Don't bob the targeter.
if (i == ps_flash)
{
ofsx = ofsy = 0;
} }
psp = psp->GetNext();
} }
CenterY = centerhack; CenterY = centerhack;
@ -1623,65 +1669,62 @@ void R_DrawPlayerSprites ()
void R_DrawRemainingPlayerSprites() void R_DrawRemainingPlayerSprites()
{ {
for (int i = 0; i < NUMPSPRITES; ++i) for (unsigned int i = 0; i < vispspindex; i++)
{ {
vissprite_t *vis; vissprite_t *vis;
vis = VisPSprites[i]; vis = vispsprites[i].vis;
VisPSprites[i] = NULL; FDynamicColormap *colormap = vispsprites[i].basecolormap;
bool flip = vis->xiscale < 0;
FSpecialColormap *special = NULL;
PalEntry overlay = 0;
FColormapStyle colormapstyle;
bool usecolormapstyle = false;
if (vis != NULL) if (vis->Style.colormap >= SpecialColormaps[0].Colormap &&
vis->Style.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap)
{ {
FDynamicColormap *colormap = VisPSpritesBaseColormap[i]; // Yuck! There needs to be a better way to store colormaps in the vissprite... :(
bool flip = vis->xiscale < 0; ptrdiff_t specialmap = (vis->Style.colormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap);
FSpecialColormap *special = NULL; special = &SpecialColormaps[specialmap];
PalEntry overlay = 0;
FColormapStyle colormapstyle;
bool usecolormapstyle = false;
if (vis->Style.colormap >= SpecialColormaps[0].Colormap &&
vis->Style.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap)
{
// Yuck! There needs to be a better way to store colormaps in the vissprite... :(
ptrdiff_t specialmap = (vis->Style.colormap - SpecialColormaps[0].Colormap) / sizeof(FSpecialColormap);
special = &SpecialColormaps[specialmap];
}
else if (colormap->Color == PalEntry(255,255,255) &&
colormap->Desaturate == 0)
{
overlay = colormap->Fade;
overlay.a = BYTE(((vis->Style.colormap - colormap->Maps) >> 8) * 255 / NUMCOLORMAPS);
}
else
{
usecolormapstyle = true;
colormapstyle.Color = colormap->Color;
colormapstyle.Fade = colormap->Fade;
colormapstyle.Desaturate = colormap->Desaturate;
colormapstyle.FadeLevel = ((vis->Style.colormap - colormap->Maps) >> 8) / float(NUMCOLORMAPS);
}
screen->DrawTexture(vis->pic,
viewwindowx + VisPSpritesX1[i],
viewwindowy + viewheight/2 - vis->texturemid * vis->yscale - 0.5,
DTA_DestWidthF, FIXED2DBL(vis->pic->GetWidth() * vis->xscale),
DTA_DestHeightF, vis->pic->GetHeight() * vis->yscale,
DTA_Translation, TranslationToTable(vis->Translation),
DTA_FlipX, flip,
DTA_TopOffset, 0,
DTA_LeftOffset, 0,
DTA_ClipLeft, viewwindowx,
DTA_ClipTop, viewwindowy,
DTA_ClipRight, viewwindowx + viewwidth,
DTA_ClipBottom, viewwindowy + viewheight,
DTA_AlphaF, vis->Style.Alpha,
DTA_RenderStyle, vis->Style.RenderStyle,
DTA_FillColor, vis->FillColor,
DTA_SpecialColormap, special,
DTA_ColorOverlay, overlay.d,
DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL,
TAG_DONE);
} }
else if (colormap->Color == PalEntry(255,255,255) &&
colormap->Desaturate == 0)
{
overlay = colormap->Fade;
overlay.a = BYTE(((vis->Style.colormap - colormap->Maps) >> 8) * 255 / NUMCOLORMAPS);
}
else
{
usecolormapstyle = true;
colormapstyle.Color = colormap->Color;
colormapstyle.Fade = colormap->Fade;
colormapstyle.Desaturate = colormap->Desaturate;
colormapstyle.FadeLevel = ((vis->Style.colormap - colormap->Maps) >> 8) / float(NUMCOLORMAPS);
}
screen->DrawTexture(vis->pic,
viewwindowx + vispsprites[i].x1,
viewwindowy + viewheight/2 - vis->texturemid * vis->yscale - 0.5,
DTA_DestWidthF, FIXED2DBL(vis->pic->GetWidth() * vis->xscale),
DTA_DestHeightF, vis->pic->GetHeight() * vis->yscale,
DTA_Translation, TranslationToTable(vis->Translation),
DTA_FlipX, flip,
DTA_TopOffset, 0,
DTA_LeftOffset, 0,
DTA_ClipLeft, viewwindowx,
DTA_ClipTop, viewwindowy,
DTA_ClipRight, viewwindowx + viewwidth,
DTA_ClipBottom, viewwindowy + viewheight,
DTA_AlphaF, vis->Style.Alpha,
DTA_RenderStyle, vis->Style.RenderStyle,
DTA_FillColor, vis->FillColor,
DTA_SpecialColormap, special,
DTA_ColorOverlay, overlay.d,
DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL,
TAG_DONE);
} }
vispspindex = 0;
} }
// //
@ -2463,7 +2506,7 @@ void R_ProjectParticle (particle_t *particle, const sector_t *sector, int shade,
return; return;
yscale = xs_RoundToInt(YaspectMul * xscale); yscale = xs_RoundToInt(YaspectMul * xscale);
ty = FLOAT2FIXED(particle->Pos.Z - ViewPos.Z); ty = particle->Pos.Z - ViewPos.Z;
y1 = xs_RoundToInt(CenterY - (ty + psize) * yscale); y1 = xs_RoundToInt(CenterY - (ty + psize) * yscale);
y2 = xs_RoundToInt(CenterY - (ty - psize) * yscale); y2 = xs_RoundToInt(CenterY - (ty - psize) * yscale);

View file

@ -130,7 +130,6 @@ void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Sp
void R_CacheSprite (spritedef_t *sprite); void R_CacheSprite (spritedef_t *sprite);
void R_SortVisSprites (int (*compare)(const void *, const void *), size_t first); void R_SortVisSprites (int (*compare)(const void *, const void *), size_t first);
void R_AddSprites (sector_t *sec, int lightlevel, int fakeside); void R_AddSprites (sector_t *sec, int lightlevel, int fakeside);
void R_AddPSprites ();
void R_DrawSprites (); void R_DrawSprites ();
void R_ClearSprites (); void R_ClearSprites ();
void R_DrawMasked (); void R_DrawMasked ();

View file

@ -350,7 +350,7 @@ int MatchString (const char *in, const char **strings);
//#define PUSH_PARAMINFO self, stateowner, CallingState, ParameterIndex, statecall //#define PUSH_PARAMINFO self, stateowner, CallingState, ParameterIndex, statecall
#define CALL_ACTION(name,self) { /*AF_##name(self, self, NULL, 0, NULL)*/ \ #define CALL_ACTION(name,self) { /*AF_##name(self, self, NULL, 0, NULL)*/ \
VMValue params[3] = { self, self, VMValue(NULL, ATAG_STATE) }; \ VMValue params[3] = { self, self, VMValue(NULL, ATAG_STATEINFO) }; \
stack->Call(name##_VMPtr, params, countof(params), NULL, 0, NULL); \ stack->Call(name##_VMPtr, params, countof(params), NULL, 0, NULL); \
} }
@ -360,7 +360,7 @@ int MatchString (const char *in, const char **strings);
#define ACTION_RETURN_BOOL(v) ACTION_RETURN_INT(v) #define ACTION_RETURN_BOOL(v) ACTION_RETURN_INT(v)
// Checks to see what called the current action function // Checks to see what called the current action function
#define ACTION_CALL_FROM_ACTOR() (callingstate == self->state) #define ACTION_CALL_FROM_ACTOR() (stateinfo == nullptr || stateinfo->mStateType == STATE_Actor)
#define ACTION_CALL_FROM_WEAPON() (self->player && callingstate != self->state && !(stateowner->flags5 & MF5_INSTATECALL)) #define ACTION_CALL_FROM_WEAPON() (self->player && stateinfo != nullptr && stateinfo->mStateType == STATE_Psprite)
#define ACTION_CALL_FROM_INVENTORY() (!(stateowner->flags5 & MF5_INSTATECALL)) #define ACTION_CALL_FROM_INVENTORY() (stateinfo != nullptr && stateinfo->mStateType == STATE_StateChain)
#endif #endif

View file

@ -95,6 +95,7 @@ static FRandom pr_spawnitemex ("SpawnItemEx");
static FRandom pr_burst ("Burst"); static FRandom pr_burst ("Burst");
static FRandom pr_monsterrefire ("MonsterRefire"); static FRandom pr_monsterrefire ("MonsterRefire");
static FRandom pr_teleport("A_Teleport"); static FRandom pr_teleport("A_Teleport");
static FRandom pr_bfgselfdamage("BFGSelfDamage");
//========================================================================== //==========================================================================
// //
@ -132,8 +133,9 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState *state)
VMFrameStack stack; VMFrameStack stack;
PPrototype *proto = state->ActionFunc->Proto; PPrototype *proto = state->ActionFunc->Proto;
VMReturn *wantret; VMReturn *wantret;
FStateParamInfo stp = { state, STATE_StateChain, PSP_WEAPON };
params[2] = VMValue(state, ATAG_STATE); params[2] = VMValue(&stp, ATAG_STATEINFO);
retval = true; // assume success retval = true; // assume success
wantret = NULL; // assume no return value wanted wantret = NULL; // assume no return value wanted
numret = 0; numret = 0;
@ -1334,6 +1336,72 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust)
return 0; return 0;
} }
//==========================================================================
//
// A_RadiusDamageSelf
//
//==========================================================================
enum
{
RDSF_BFGDAMAGE = 1,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusDamageSelf)
{
PARAM_ACTION_PROLOGUE;
PARAM_INT_OPT(damage) { damage = 128; }
PARAM_FLOAT_OPT(distance) { distance = 128; }
PARAM_INT_OPT(flags) { flags = 0; }
PARAM_CLASS_OPT(flashtype, AActor) { flashtype = NULL; }
int i;
int damageSteps;
int actualDamage;
double actualDistance;
actualDistance = self->Distance3D(self->target);
if (actualDistance < distance)
{
// [XA] Decrease damage with distance. Use the BFG damage
// calculation formula if the flag is set (essentially
// a generalization of SMMU's BFG11K behavior, used
// with fraggle's blessing.)
damageSteps = damage - int(damage * actualDistance / distance);
if (flags & RDSF_BFGDAMAGE)
{
actualDamage = 0;
for (i = 0; i < damageSteps; ++i)
actualDamage += (pr_bfgselfdamage() & 7) + 1;
}
else
{
actualDamage = damageSteps;
}
// optional "flash" effect -- spawn an actor on
// the player to indicate bad things happened.
AActor *flash = NULL;
if(flashtype != NULL)
flash = Spawn(flashtype, self->target->PosPlusZ(self->target->Height / 4), ALLOW_REPLACE);
int dmgFlags = 0;
FName dmgType = NAME_BFGSplash;
if (flash != NULL)
{
if (flash->flags5 & MF5_PUFFGETSOWNER) flash->target = self->target;
if (flash->flags3 & MF3_FOILINVUL) dmgFlags |= DMG_FOILINVUL;
if (flash->flags7 & MF7_FOILBUDDHA) dmgFlags |= DMG_FOILBUDDHA;
dmgType = flash->DamageType;
}
int newdam = P_DamageMobj(self->target, self, self->target, actualDamage, dmgType, dmgFlags);
P_TraceBleed(newdam > 0 ? newdam : actualDamage, self->target, self);
}
return 0;
}
//========================================================================== //==========================================================================
// //
// Execute a line special / script // Execute a line special / script
@ -1996,6 +2064,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack)
PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; } PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; }
PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; } PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; }
PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; } PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; }
PARAM_INT_OPT (limit) { limit = 0; }
if (range == 0) range = 8192; if (range == 0) range = 8192;
if (sparsity == 0) sparsity=1.0; if (sparsity == 0) sparsity=1.0;
@ -2036,6 +2105,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack)
p.drift = driftspeed; p.drift = driftspeed;
p.spawnclass = spawnclass; p.spawnclass = spawnclass;
p.SpiralOffset = SpiralOffset; p.SpiralOffset = SpiralOffset;
p.limit = limit;
P_RailAttack(&p); P_RailAttack(&p);
return 0; return 0;
} }
@ -2073,6 +2143,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; } PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; }
PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; } PARAM_FLOAT_OPT (spawnofs_z) { spawnofs_z = 0; }
PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; } PARAM_INT_OPT (SpiralOffset) { SpiralOffset = 270; }
PARAM_INT_OPT (limit) { limit = 0; }
if (range == 0) range = 8192.; if (range == 0) range = 8192.;
if (sparsity == 0) sparsity = 1; if (sparsity == 0) sparsity = 1;
@ -2155,6 +2226,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
p.drift = driftspeed; p.drift = driftspeed;
p.spawnclass = spawnclass; p.spawnclass = spawnclass;
p.SpiralOffset = SpiralOffset; p.SpiralOffset = SpiralOffset;
p.limit = 0;
P_RailAttack(&p); P_RailAttack(&p);
self->SetXYZ(savedpos); self->SetXYZ(savedpos);
@ -5768,19 +5840,21 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_INT(tics_to_set); PARAM_INT(tics_to_set);
if (stateowner != self && self->player != NULL && stateowner->IsKindOf(RUNTIME_CLASS(AWeapon))) if (ACTION_CALL_FROM_WEAPON())
{ // Is this a weapon? Need to check psp states for a match, then. Blah. {
for (int i = 0; i < NUMPSPRITES; ++i) DPSprite *pspr = self->player->FindPSprite(stateinfo->mPSPIndex);
if (pspr != nullptr)
{ {
if (self->player->psprites[i].state == callingstate) pspr->Tics = tics_to_set;
{ return 0;
self->player->psprites[i].tics = tics_to_set;
return 0;
}
} }
} }
// Just set tics for self. else if (ACTION_CALL_FROM_ACTOR())
self->tics = tics_to_set; {
// Just set tics for self.
self->tics = tics_to_set;
}
// for inventory state chains this needs to be ignored.
return 0; return 0;
} }
@ -6931,10 +7005,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection)
{ {
DAngle current = mobj->Angles.Pitch; DAngle current = mobj->Angles.Pitch;
const DVector2 velocity = mobj->Vel.XY(); const DVector2 velocity = mobj->Vel.XY();
DAngle pitch = VecToAngle(velocity.Length(), -mobj->Vel.Z); DAngle pitch = VecToAngle(velocity.Length(), mobj->Vel.Z);
if (pitchlimit > 0) if (pitchlimit > 0)
{ {
DAngle pdelta = deltaangle(current, pitch); DAngle pdelta = deltaangle(-current, pitch);
if (fabs(pdelta) > pitchlimit) if (fabs(pdelta) > pitchlimit)
{ {

View file

@ -2916,7 +2916,7 @@ ExpEmit FxDamage::Emit(VMFunctionBuilder *build)
build->Emit(OP_LO, dmgfunc.RegNum, 0/*self*/, build->GetConstantInt(myoffsetof(AActor, Damage))); build->Emit(OP_LO, dmgfunc.RegNum, 0/*self*/, build->GetConstantInt(myoffsetof(AActor, Damage)));
// If it's non-null... // If it's non-null...
build->Emit(OP_EQA_K, 1, dmgfunc.RegNum, build->GetConstantAddress(0, ATAG_GENERIC)); build->Emit(OP_EQA_K, 1, dmgfunc.RegNum, build->GetConstantAddress(nullptr, ATAG_GENERIC));
size_t nulljump = build->Emit(OP_JMP, 0); size_t nulljump = build->Emit(OP_JMP, 0);
// ...call it // ...call it

View file

@ -152,6 +152,7 @@ enum
ATAG_AREGISTER, // pointer to an address register ATAG_AREGISTER, // pointer to an address register
ATAG_STATE, // pointer to FState ATAG_STATE, // pointer to FState
ATAG_STATEINFO, // FState plus some info.
ATAG_RNG, // pointer to FRandom ATAG_RNG, // pointer to FRandom
}; };
@ -914,6 +915,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
#define PARAM_ANGLE_OPT_AT(p,x) DAngle x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else #define PARAM_ANGLE_OPT_AT(p,x) DAngle x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_FLOAT); x = param[p].f; } else
#define PARAM_STRING_OPT_AT(p,x) FString x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_STRING); x = param[p].s(); } else #define PARAM_STRING_OPT_AT(p,x) FString x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_STRING); x = param[p].s(); } else
#define PARAM_STATE_OPT_AT(p,x) FState *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); x = (FState *)param[p].a; } else #define PARAM_STATE_OPT_AT(p,x) FState *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); x = (FState *)param[p].a; } else
#define PARAM_STATEINFO_OPT_AT(p,x) FStateParamInfo *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATEINFO || param[p].a == NULL)); x = (FStateParamInfo *)param[p].a; } else
#define PARAM_POINTER_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER); x = (type *)param[p].a; } else #define PARAM_POINTER_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER); x = (type *)param[p].a; } else
#define PARAM_OBJECT_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); x = (type *)param[p].a; assert(x == NULL || x->IsKindOf(RUNTIME_CLASS(type))); } else #define PARAM_OBJECT_OPT_AT(p,x,type) type *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); x = (type *)param[p].a; assert(x == NULL || x->IsKindOf(RUNTIME_CLASS(type))); } else
#define PARAM_CLASS_OPT_AT(p,x,base) base::MetaClass *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); x = (base::MetaClass *)param[p].a; assert(x == NULL || x->IsDescendantOf(RUNTIME_CLASS(base))); } else #define PARAM_CLASS_OPT_AT(p,x,base) base::MetaClass *x; if ((p) < numparam && param[p].Type != REGT_NIL) { assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_OBJECT || param[p].a == NULL)); x = (base::MetaClass *)param[p].a; assert(x == NULL || x->IsDescendantOf(RUNTIME_CLASS(base))); } else
@ -943,6 +945,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
#define PARAM_ANGLE_OPT(x) ++paramnum; PARAM_ANGLE_OPT_AT(paramnum,x) #define PARAM_ANGLE_OPT(x) ++paramnum; PARAM_ANGLE_OPT_AT(paramnum,x)
#define PARAM_STRING_OPT(x) ++paramnum; PARAM_STRING_OPT_AT(paramnum,x) #define PARAM_STRING_OPT(x) ++paramnum; PARAM_STRING_OPT_AT(paramnum,x)
#define PARAM_STATE_OPT(x) ++paramnum; PARAM_STATE_OPT_AT(paramnum,x) #define PARAM_STATE_OPT(x) ++paramnum; PARAM_STATE_OPT_AT(paramnum,x)
#define PARAM_STATEINFO_OPT(x) ++paramnum; PARAM_STATEINFO_OPT_AT(paramnum,x)
#define PARAM_POINTER_OPT(x,type) ++paramnum; PARAM_POINTER_OPT_AT(paramnum,x,type) #define PARAM_POINTER_OPT(x,type) ++paramnum; PARAM_POINTER_OPT_AT(paramnum,x,type)
#define PARAM_OBJECT_OPT(x,type) ++paramnum; PARAM_OBJECT_OPT_AT(paramnum,x,type) #define PARAM_OBJECT_OPT(x,type) ++paramnum; PARAM_OBJECT_OPT_AT(paramnum,x,type)
#define PARAM_CLASS_OPT(x,base) ++paramnum; PARAM_CLASS_OPT_AT(paramnum,x,base) #define PARAM_CLASS_OPT(x,base) ++paramnum; PARAM_CLASS_OPT_AT(paramnum,x,base)

View file

@ -153,7 +153,7 @@ static void InitTokenMap()
TOKENDEF (TK_NoDelay, ZCC_NODELAY); TOKENDEF (TK_NoDelay, ZCC_NODELAY);
TOKENDEF (TK_Offset, ZCC_OFFSET); TOKENDEF (TK_Offset, ZCC_OFFSET);
TOKENDEF (TK_CanRaise, ZCC_CANRAISE); TOKENDEF (TK_CanRaise, ZCC_CANRAISE);
TOKENDEF (TK_Light, ZCC_CANRAISE); TOKENDEF (TK_Light, ZCC_LIGHT);
ZCC_InitOperators(); ZCC_InitOperators();
ZCC_InitConversions(); ZCC_InitConversions();

View file

@ -56,7 +56,7 @@ ACTOR Actor native //: Thinker
// End of MBF redundant functions. // End of MBF redundant functions.
action native A_MonsterRail(); action native A_MonsterRail();
action native A_BFGSpray(class<Actor> spraytype = "BFGExtra", int numrays = 40, int damagecount = 15, float/*angle*/ angle = 90, float distance = 16*64, float/*angle*/ vrange = 32, int damage = 0); action native A_BFGSpray(class<Actor> spraytype = "BFGExtra", int numrays = 40, int damagecount = 15, float/*angle*/ angle = 90, float distance = 16*64, float/*angle*/ vrange = 32, int damage = 0, int flags = 0);
action native A_Pain(); action native A_Pain();
action native A_NoBlocking(); action native A_NoBlocking();
action native A_XScream(); action native A_XScream();
@ -190,7 +190,7 @@ ACTOR Actor native //: Thinker
native state A_Jump(int chance = 256, state label, ...); native state A_Jump(int chance = 256, state label, ...);
native void A_CustomMissile(class<Actor> missiletype, float spawnheight = 32, float spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET); native void A_CustomMissile(class<Actor> missiletype, float spawnheight = 32, float spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET);
native void A_CustomBulletAttack(float/*angle*/ spread_xy, float/*angle*/ spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", float range = 0, int flags = 0, int ptr = AAPTR_TARGET); native void A_CustomBulletAttack(float/*angle*/ spread_xy, float/*angle*/ spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", float range = 0, int flags = 0, int ptr = AAPTR_TARGET);
native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, int aim = 0, float maxdiff = 0, class<Actor> pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class<Actor> spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270); native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, int aim = 0, float maxdiff = 0, class<Actor> pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class<Actor> spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270, int limit = 0);
native state A_JumpIfHealthLower(int health, state label, int ptr_selector = AAPTR_DEFAULT); native state A_JumpIfHealthLower(int health, state label, int ptr_selector = AAPTR_DEFAULT);
native state A_JumpIfCloser(float distance, state label, bool noz = false); native state A_JumpIfCloser(float distance, state label, bool noz = false);
native state A_JumpIfTracerCloser(float distance, state label, bool noz = false); native state A_JumpIfTracerCloser(float distance, state label, bool noz = false);
@ -247,6 +247,7 @@ ACTOR Actor native //: Thinker
native void A_Burst(class<Actor> chunktype); native void A_Burst(class<Actor> chunktype);
action native A_Blast(int flags = 0, float strength = 255, float radius = 255, float speed = 20, class<Actor> blasteffect = "BlastEffect", sound blastsound = "BlastRadius"); action native A_Blast(int flags = 0, float strength = 255, float radius = 255, float speed = 20, class<Actor> blasteffect = "BlastEffect", sound blastsound = "BlastRadius");
action native A_RadiusThrust(int force = 128, int distance = -1, int flags = RTF_AFFECTSOURCE, int fullthrustdistance = 0); action native A_RadiusThrust(int force = 128, int distance = -1, int flags = RTF_AFFECTSOURCE, int fullthrustdistance = 0);
action native A_RadiusDamageSelf(int damage = 128, float distance = 128, int flags = 0, class<Actor> flashtype = "None");
action native A_Explode(int damage = -1, int distance = -1, int flags = XF_HURTSOURCE, bool alert = false, int fulldamagedistance = 0, int nails = 0, int naildamage = 10, class<Actor> pufftype = "BulletPuff"); action native A_Explode(int damage = -1, int distance = -1, int flags = XF_HURTSOURCE, bool alert = false, int fulldamagedistance = 0, int nails = 0, int naildamage = 10, class<Actor> pufftype = "BulletPuff");
action native A_Stop(); action native A_Stop();
action native A_Respawn(int flags = 1); action native A_Respawn(int flags = 1);
@ -333,6 +334,11 @@ ACTOR Actor native //: Thinker
native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0);
action native A_CopyFriendliness(int ptr_source = AAPTR_MASTER); action native A_CopyFriendliness(int ptr_source = AAPTR_MASTER);
action native A_Overlay(int layer, state start = "");
action native A_WeaponOffset(float wx = 0, float wy = 32, int flags = 0);
action native A_OverlayOffset(int layer = PSP_WEAPON, float wx = 0, float wy = 32, int flags = 0);
action native A_OverlayFlags(int layer, int flags, bool set);
native int ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0); native int ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0);
native int ACS_NamedSuspend(name script, int mapnum=0); native int ACS_NamedSuspend(name script, int mapnum=0);
native int ACS_NamedTerminate(name script, int mapnum=0); native int ACS_NamedTerminate(name script, int mapnum=0);

View file

@ -18,6 +18,10 @@ const int SF_NOPULLIN = 32;
const int SF_NOTURN = 64; const int SF_NOTURN = 64;
const int SF_STEALARMOR = 128; const int SF_STEALARMOR = 128;
// Flags for A_BFGSpray
const int BFGF_HURTSOURCE = 1;
const int BFGF_MISSILEORIGIN = 2;
// Flags for A_CustomMissile // Flags for A_CustomMissile
const int CMF_AIMOFFSET = 1; const int CMF_AIMOFFSET = 1;
const int CMF_AIMDIRECTION = 2; const int CMF_AIMDIRECTION = 2;
@ -180,6 +184,9 @@ const int RTF_NOIMPACTDAMAGE = 2;
const int RTF_NOTMISSILE = 4; const int RTF_NOTMISSILE = 4;
const int RTF_THRUSTZ = 16; const int RTF_THRUSTZ = 16;
// Flags for A_RadiusDamageSelf
const int RDSF_BFGDAMAGE = 1;
// Flags for A_Blast // Flags for A_Blast
const int BF_USEAMMO = 1; const int BF_USEAMMO = 1;
const int BF_DONTWARN = 2; const int BF_DONTWARN = 2;
@ -569,4 +576,20 @@ enum
WOF_KEEPX = 1, WOF_KEEPX = 1,
WOF_KEEPY = 1 << 1, WOF_KEEPY = 1 << 1,
WOF_ADD = 1 << 2, WOF_ADD = 1 << 2,
}; };
// Flags for psprite layers
enum
{
PSPF_ADDWEAPON = 1 << 0,
PSPF_ADDBOB = 1 << 1,
PSPF_POWDOUBLE = 1 << 2,
PSPF_CVARFAST = 1 << 3,
};
// Default psprite layers
enum
{
PSP_WEAPON = 1,
PSP_FLASH = 1000,
};

View file

@ -11,7 +11,7 @@ ACTOR Inventory native
action native A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class<Actor> pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = ""); action native A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class<Actor> pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = "");
action native A_FireBullets(float/*angle*/ spread_xy, float/*angle*/ spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", int flags = 1, float range = 0); action native A_FireBullets(float/*angle*/ spread_xy, float/*angle*/ spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", int flags = 1, float range = 0);
action native A_FireCustomMissile(class<Actor> missiletype, float angle = 0, bool useammo = true, float spawnofs_xy = 0, float spawnheight = 0, int flags = 0, float pitch = 0); action native A_FireCustomMissile(class<Actor> missiletype, float angle = 0, bool useammo = true, float spawnofs_xy = 0, float spawnheight = 0, int flags = 0, float pitch = 0);
action native A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class<Actor> pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class<Actor> spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270); action native A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class<Actor> pufftype = "BulletPuff", float/*angle*/ spread_xy = 0, float/*angle*/ spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class<Actor> spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270, int limit = 0);
action native A_Light(int extralight); action native A_Light(int extralight);
action native A_Light0(); action native A_Light0();
action native A_Light1(); action native A_Light1();
@ -48,8 +48,7 @@ ACTOR Inventory native
action native A_RestoreSpecialDoomThing(); action native A_RestoreSpecialDoomThing();
action native A_RestoreSpecialThing1(); action native A_RestoreSpecialThing1();
action native A_RestoreSpecialThing2(); action native A_RestoreSpecialThing2();
action native A_WeaponOffset(float wx = 0, float wy = 32, int flags = 0);
States States
{ {
HideDoomish: HideDoomish: