- change teleport freeze handling to a player property plus virtual override on PlayerPawn for increased configurability.

This commit is contained in:
Christoph Oelckers 2018-11-24 21:37:00 +01:00
parent 337750b874
commit b6d0d5008e
4 changed files with 28 additions and 54 deletions

View file

@ -200,55 +200,6 @@ bool AInventory::Grind(bool items)
return Super::Grind(items);
}
//===========================================================================
//
// AInventory :: GetSpeedFactor
//
//===========================================================================
double AInventory::GetSpeedFactor()
{
double factor = 1.;
auto self = this;
while (self != nullptr)
{
IFVIRTUALPTR(self, AInventory, GetSpeedFactor)
{
VMValue params[1] = { (DObject*)self };
double retval;
VMReturn ret(&retval);
VMCall(func, params, 1, &ret, 1);
factor *= retval;
}
self = self->Inventory;
}
return factor;
}
//===========================================================================
//
// AInventory :: GetNoTeleportFreeze
//
//===========================================================================
bool AInventory::GetNoTeleportFreeze ()
{
auto self = this;
while (self != nullptr)
{
IFVIRTUALPTR(self, AInventory, GetNoTeleportFreeze)
{
VMValue params[1] = { (DObject*)self };
int retval;
VMReturn ret(&retval);
VMCall(func, params, 1, &ret, 1);
if (retval) return true;
}
self = self->Inventory;
}
return false;
}
//===========================================================================
//
// AInventory :: Use

View file

@ -83,7 +83,6 @@ public:
void DepleteOrDestroy (); // virtual on the script side.
bool CallUse(bool pickup); // virtual on the script side.
PalEntry CallGetBlend(); // virtual on the script side.
double GetSpeedFactor(); // virtual on the script side.
bool GetNoTeleportFreeze(); // virtual on the script side.
bool DoRespawn();

View file

@ -203,9 +203,14 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags)
// [BC] && bHaltVelocity.
if (thing->player && ((flags & TELF_DESTFOG) || !(flags & TELF_KEEPORIENTATION)) && !(flags & TELF_KEEPVELOCITY))
{
// Freeze player for about .5 sec
if (thing->Inventory == NULL || !thing->Inventory->GetNoTeleportFreeze())
thing->reactiontime = 18;
int time = 18;
IFVIRTUALPTR(thing, APlayerPawn, GetTeleportFreezeTime)
{
VMValue param = thing;
VMReturn ret(&time);
VMCall(func, &param, 1, &ret, 1);
}
thing->reactiontime = time;
}
if (thing->flags & MF_MISSILE)
{

View file

@ -52,6 +52,7 @@ class PlayerPawn : Actor native
meta Name HealingRadiusType;
meta Name InvulMode;
meta int TeleportFreezeTime;
property prefix: Player;
property HealRadiusType: HealingradiusType;
@ -69,6 +70,7 @@ class PlayerPawn : Actor native
property MorphWeapon: MorphWeapon;
property FlechetteType: FlechetteType;
property Portrait: Portrait;
property TeleportFreezeTime: TeleportFreezeTime;
Default
{
@ -106,6 +108,7 @@ class PlayerPawn : Actor native
Player.FlechetteType "ArtiPoisonBag3";
Player.AirCapacity 1;
Player.ViewBob 1;
Player.TeleportFreezeTime 18;
Obituary "$OB_MPDEFAULT";
}
@ -1700,6 +1703,23 @@ class PlayerPawn : Actor native
}
}
//===========================================================================
//
//
//
//===========================================================================
virtual int GetTeleportFreezeTime()
{
if (TeleportFreezeTime <= 0) return 0;
let item = inv;
while (item != null)
{
if (item.GetNoTeleportFreeze()) return 0;
item = item.inv;
}
return TeleportFreezeTime;
}
//----------------------------------------------------------------------------
//
@ -2009,7 +2029,6 @@ struct PlayerInfo native play // self is what internally is known as player_t
return (mo.ViewHeight + crouchviewdelta - viewheight) / 8;
}
}
struct PlayerClass native