Skip to content

Instantly share code, notes, and snippets.

@lopezloo
Last active July 20, 2020 19:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lopezloo/8ac64f2a4bf3abaa79ac94bb06dc0385 to your computer and use it in GitHub Desktop.
Save lopezloo/8ac64f2a4bf3abaa79ac94bb06dc0385 to your computer and use it in GitHub Desktop.
POSTAL^2*SUPERHOT
/*
POSTAL^2*SUPERHOT
Version 0.0.5
by lopezloo
Steam workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=865086638
ModDB: http://www.moddb.com/mods/postal2superhot
YouTube: https://youtu.be/BNyZFmCSwVo
Changelog:
0.0.5
* Fixed pause menu is slowing down.
* Time is not slowing down anymore when player is opening door.
0.0.4
* Fixed game is slowing down while loading save.
0.0.3
* Removed debug logs.
0.0.2
* Changed the way how dude falling is handled.
* Time transition is a bit more smooth.
* Zero division fix.
0.0.1
* Initial release.
*/
class SUPERHOT extends P2GameMod;
const SPEED_MIN = 0.1;
const SPEED_MAX = 1.0;
// Below this value, player usually decelerates
const TRUST_ME_IM_NOT_MOVING = 300;
event Tick(float Delta)
{
local int i;
local P2Player p2p;
local P2Projectile outProjectile;
local DoorMover outDoor;
p2p = P2GameInfo(Level.Game).GetPlayer();
if (
// if dude is fine
p2p.Pawn != None
&& p2p.Pawn.Health > 0
// if game is not paused
&& Level.Pauser == None
// if dude is not looking at map etc. (not reliable, it's None when map is fading out in new game sequence)
&& p2p.CurrentScreen == None
// if map screen isn't fading
&& (p2p.MyMapScreen.FadeAlpha <= 1 || p2p.MyMapScreen.FadeAlpha == 255)
// if loading screen isn't showing (it's 1 during normal play, it's 255 before first game load fading)
&& (p2p.MyLoadScreen.FadeAlpha <= 1)
// if dude is not falling (dude has 0 velocity at some jump point)
&& p2p.Pawn.Physics != PHYS_Falling
// if dude is not moving
&& VSize(p2p.Pawn.Velocity) <= TRUST_ME_IM_NOT_MOVING
// if dude foot is idling
&& P2Pawn(p2p.Pawn).MyFoot.IsIdle()
&& (
// if dude has weapon
p2p.Pawn.Weapon == None
// or if dude weapon is idling (not shooting, reloading, showing/hiding up etc.)
|| p2p.Pawn.Weapon.IsIdle()
// or he is waiting for blade (machete)
|| p2p.Pawn.Weapon.IsInState('WaitingOnBlade')
// or he is throwing projectile
|| (
// if this weapon can create projectile
p2p.Pawn.Weapon.AmmoType.ProjectileClass != None
&& (
p2p.Pawn.Weapon.IsInState('NormalFire') // scissors
|| p2p.Pawn.Weapon.IsInState('ClientFiring') // grenade throw start
|| p2p.Pawn.Weapon.IsInState('Reloading') // grenade throw a bit later
)
)
)
)
{
foreach p2p.Pawn.RadiusActors(class'DoorMover', outDoor, 80.0)
{
if (!outDoor.bOpen && outDoor.bOpening && outDoor.SavedTrigger == p2p.Pawn)
{
// Dude is opening door
P2GameInfoSingle(Level.Game).SetGameSpeedNoSave(SPEED_MAX);
return;
}
}
// Player animals ignores time dilation (AnimalController.uc:122), alter this behaviour
for (i=0; i<p2p.AnimalFriends.Length; i++)
{
p2p.AnimalFriends[i].bIgnoreTimeDilation = false;
}
for (i=0; i<p2p.AwFriends.Length; i++)
{
p2p.AwFriends[i].bIgnoreTimeDilation = false;
}
// Player projectiles are player childs and ignores time dilation, so set owner to none
foreach p2p.Pawn.ChildActors(class'P2Projectile', outProjectile)
{
outProjectile.SetOwner(None);
}
if (VSize(p2p.Pawn.Velocity) == 0)
{
P2GameInfoSingle(Level.Game).SetGameSpeedNoSave(SPEED_MIN);
}
else
{
// Smoothly decelerate game speed
P2GameInfoSingle(Level.Game).SetGameSpeedNoSave( FMax(VSize(p2p.Pawn.Velocity)/TRUST_ME_IM_NOT_MOVING, SPEED_MIN) );
}
}
else
{
P2GameInfoSingle(Level.Game).SetGameSpeedNoSave(SPEED_MAX);
}
}
defaultproperties
{
GroupName=""
FriendlyName="SUPERHOT"
Description="Time moves only when you move!"
// Force update this even if game is paused
bAlwaysTick=true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment