- fixed: When changing weapons due to starting or ending a Tome of Power effect, the PSprite's caller needs to be changed.

In this case the PSprite animation won't be changed, only the ReadyWeapon. But in order to work, the PSprite's caller needs to change as well so that the next weapon check does not fail.
This commit is contained in:
Christoph Oelckers 2016-07-16 19:55:00 +02:00
parent 7544adfc91
commit c150116f79
3 changed files with 29 additions and 2 deletions

View file

@ -1127,12 +1127,27 @@ void APowerWeaponLevel2::InitEffect ()
assert (sister->SisterWeapon == weapon);
Owner->player->ReadyWeapon = sister;
if (weapon->GetReadyState() != sister->GetReadyState())
{
Owner->player->ReadyWeapon = sister;
P_SetPsprite(Owner->player, PSP_WEAPON, sister->GetReadyState());
}
else
{
DPSprite *psp = Owner->player->FindPSprite(PSP_WEAPON);
if (psp != nullptr && psp->GetCaller() == Owner->player->ReadyWeapon)
{
// If the weapon changes but the state does not, we have to manually change the PSprite's caller here.
psp->SetCaller(sister);
Owner->player->ReadyWeapon = sister;
}
else
{
// Something went wrong. Initiate a regular weapon change.
Owner->player->PendingWeapon = sister;
}
}
}
//===========================================================================

View file

@ -642,7 +642,18 @@ void AWeapon::EndPowerup ()
}
else
{
Owner->player->ReadyWeapon = SisterWeapon;
DPSprite *psp = Owner->player->FindPSprite(PSP_WEAPON);
if (psp != nullptr && psp->GetCaller() == Owner->player->ReadyWeapon)
{
// If the weapon changes but the state does not, we have to manually change the PSprite's caller here.
psp->SetCaller(SisterWeapon);
Owner->player->ReadyWeapon = SisterWeapon;
}
else
{
// Something went wrong. Initiate a regular weapon change.
Owner->player->PendingWeapon = SisterWeapon;
}
}
}
}

View file

@ -76,6 +76,7 @@ public:
FState* GetState() const { return State; }
DPSprite* GetNext() { return Next; }
AActor* GetCaller() { return Caller; }
void SetCaller(AActor *newcaller) { Caller = newcaller; }
double x, y;
double oldx, oldy;