This commit is contained in:
Christoph Oelckers 2016-07-16 08:30:33 +02:00
commit 943a799aee
8 changed files with 70 additions and 32 deletions

View file

@ -532,7 +532,10 @@ public:
void TickPSprites(); void TickPSprites();
void DestroyPSprites(); void DestroyPSprites();
DPSprite *FindPSprite(int layer); DPSprite *FindPSprite(int layer);
DPSprite *GetPSprite(PSPLayers layer); // Used ONLY for compatibility with the old hardcoded layers. // Used ONLY for compatibility with the old hardcoded layers.
// Make sure that a state is properly set after calling this unless
// you are 100% sure the context already implies the layer exists.
DPSprite *GetPSprite(PSPLayers layer);
}; };
// Bookkeeping on players - state. // Bookkeeping on players - state.

View file

@ -123,9 +123,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers)
void P_UpdateBeak (AActor *self) void P_UpdateBeak (AActor *self)
{ {
if (self->player != nullptr) DPSprite *pspr;
if (self->player != nullptr && (pspr = self->player->FindPSprite(PSP_WEAPON)) != nullptr)
{ {
self->player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP + self->player->chickenPeck / 2; pspr->y = WEAPONTOP + self->player->chickenPeck / 2;
} }
} }

View file

@ -352,23 +352,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns)
if (self->player != nullptr && self->player->mo == self) if (self->player != nullptr && self->player->mo == self)
{ {
FState *firehands = self->FindState("FireHands"); P_SetPsprite(self->player, PSP_STRIFEHANDS, self->FindState("FireHands"));
if (firehands != NULL)
{
DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS);
if (psp != nullptr)
{
psp->SetState(firehands);
psp->Flags &= PSPF_ADDWEAPON | PSPF_ADDBOB;
psp->y = WEAPONTOP;
}
self->player->ReadyWeapon = nullptr; 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;
} }
}
return 0; return 0;
} }
@ -388,14 +378,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrispyPlayer)
if (self->player != nullptr && self->player->mo == self) if (self->player != nullptr && self->player->mo == self)
{ {
self->player->playerstate = PST_DEAD;
DPSprite *psp; DPSprite *psp;
psp = self->player->GetPSprite(PSP_STRIFEHANDS); psp = self->player->GetPSprite(PSP_STRIFEHANDS);
FState *firehandslower = self->FindState("FireHandsLower"); FState *firehandslower = self->FindState("FireHandsLower");
FState *firehands = self->FindState("FireHands"); FState *firehands = self->FindState("FireHands");
if (firehandslower != NULL && firehands != NULL && firehands < firehandslower) FState *state = psp->GetState();
psp->SetState(psp->GetState() + (firehandslower - firehands));
if (state != nullptr && firehandslower != nullptr && firehands != nullptr && firehands < firehandslower)
{
self->player->playerstate = PST_DEAD;
psp->SetState(state + (firehandslower - firehands));
}
else if (state == nullptr)
{
psp->SetState(nullptr);
}
} }
return 0; return 0;
} }
@ -407,13 +405,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_HandLower)
if (self->player != nullptr) if (self->player != nullptr)
{ {
DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS); DPSprite *psp = self->player->GetPSprite(PSP_STRIFEHANDS);
if (psp->GetState() == nullptr)
{
psp->SetState(nullptr);
return 0;
}
psp->y += 9; psp->y += 9;
if (psp->y > WEAPONBOTTOM*2) if (psp->y > WEAPONBOTTOM*2)
{ {
psp->SetState(nullptr); psp->SetState(nullptr);
} }
if (self->player->extralight > 0) self->player->extralight--; if (self->player->extralight > 0) self->player->extralight--;
} }
return 0; return 0;
} }

View file

@ -216,15 +216,29 @@ DPSprite *player_t::GetPSprite(PSPLayers layer)
} }
// Always update the caller here in case we switched weapon // Always update the caller here in case we switched weapon
// or if the layer was being used by an inventory item before. // or if the layer was being used by something else before.
pspr->Caller = newcaller; pspr->Caller = newcaller;
if (newcaller != oldcaller) if (newcaller != oldcaller)
{ // Only change the flags if this layer was created now or if we updated the caller. { // Only reset stuff if this layer was created now or if it was being used before.
if (layer >= PSP_TARGETCENTER) if (layer >= PSP_TARGETCENTER)
{ // The targeter layers were affected by those. { // The targeter layers were affected by those.
pspr->Flags |= (PSPF_CVARFAST|PSPF_POWDOUBLE); pspr->Flags = (PSPF_CVARFAST|PSPF_POWDOUBLE);
} }
else
{
pspr->Flags = (PSPF_ADDWEAPON|PSPF_ADDBOB|PSPF_CVARFAST|PSPF_POWDOUBLE);
}
if (layer == PSP_STRIFEHANDS)
{
// Some of the old hacks rely on this layer coming from the FireHands state.
// This is the ONLY time a psprite's state is actually null.
pspr->State = nullptr;
pspr->y = WEAPONTOP;
}
pspr->oldx = pspr->x;
pspr->oldy = pspr->y;
} }
return pspr; return pspr;

View file

@ -42,7 +42,7 @@ class FArchive;
// 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.
// //
enum PSPLayers // These are all called by the owner's ReadyWeapon. enum PSPLayers
{ {
PSP_STRIFEHANDS = -1, PSP_STRIFEHANDS = -1,
PSP_WEAPON = 1, PSP_WEAPON = 1,

View file

@ -329,13 +329,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance)
// NON-ACTION function to get the angle in degrees (normalized to -180..180) // NON-ACTION function to get the angle in degrees (normalized to -180..180)
// //
//========================================================================== //==========================================================================
enum GAFlags
{
GAF_RELATIVE = 1,
GAF_SWITCH = 1 << 1,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle) DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle)
{ {
if (numret > 0) if (numret > 0)
{ {
assert(ret != NULL); assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(relative); PARAM_INT(flags);
PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; } PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; }
AActor *target = COPY_AAPTR(self, ptr); AActor *target = COPY_AAPTR(self, ptr);
@ -346,9 +352,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetAngle)
} }
else else
{ {
DVector3 diff = self->Vec3To(target); DVector3 diff = (flags & GAF_SWITCH) ? target->Vec3To(self) : self->Vec3To(target);
DAngle angto = diff.Angle(); DAngle angto = diff.Angle();
if (relative) angto = deltaangle(self->Angles.Yaw, angto); DAngle yaw = (flags & GAF_SWITCH) ? target->Angles.Yaw : self->Angles.Yaw;
if (flags & GAF_RELATIVE) angto = deltaangle(yaw, angto);
ret->SetFloat(angto.Degrees); ret->SetFloat(angto.Degrees);
} }
return 1; return 1;
@ -5669,7 +5676,9 @@ enum RadiusGiveFlags
RGF_MONSTERS | RGF_MONSTERS |
RGF_OBJECTS | RGF_OBJECTS |
RGF_VOODOO | RGF_VOODOO |
RGF_CORPSES | RGF_MISSILES, RGF_CORPSES |
RGF_MISSILES |
RGF_ITEMS,
}; };
static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amount, double distance, int flags, PClassActor *filter, FName species, double mindist) static bool DoRadiusGive(AActor *self, AActor *thing, PClassActor *item, int amount, double distance, int flags, PClassActor *filter, FName species, double mindist)

View file

@ -41,7 +41,7 @@ ACTOR Actor native //: Thinker
native bool IsPointerEqual(int ptr_select1, int ptr_select2); native bool IsPointerEqual(int ptr_select1, int ptr_select2);
native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT); native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT);
native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT); native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT);
native float GetAngle(bool relative, int ptr = AAPTR_DEFAULT); native float GetAngle(int flags, int ptr = AAPTR_DEFAULT);
native float GetZAt(float px = 0, float py = 0, float angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT); native float GetZAt(float px = 0, float py = 0, float angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
native int GetSpawnHealth(); native int GetSpawnHealth();
native int GetGibHealth(); native int GetGibHealth();

View file

@ -652,3 +652,9 @@ enum
BT_USER3 = 1<<23, BT_USER3 = 1<<23,
BT_USER4 = 1<<24, BT_USER4 = 1<<24,
}; };
// Flags for GetAngle
enum
{
GAF_RELATIVE = 1,
GAF_SWITCH = 1 << 1,
};