-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class WeaponTilterEventHandler : EventHandler | ||
{ | ||
override void PlayerEntered(PlayerEvent e) | ||
{ | ||
players[e.PlayerNumber].mo.A_GiveInventory("WeaponTilterInventory", 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class WeaponTilterInventory : Inventory | ||
{ | ||
double currentRoll, aVelocity; | ||
float rResistance, rVelocity; | ||
vector2 direction, velocityUnit; | ||
int currentTickCount; | ||
bool debug, offset; | ||
|
||
default | ||
{ | ||
Inventory.MaxAmount 1; | ||
} | ||
|
||
override void DoEffect() | ||
{ | ||
currentTickCount++; //count tick | ||
|
||
super.DoEffect(); | ||
|
||
// do nothing if the owner is null or not a player: | ||
if(!owner || !owner.player) | ||
return; | ||
|
||
let weaponsprite = owner.player.FindPSprite(PSP_WEAPON); | ||
if(weaponsprite) | ||
{ | ||
//get cvars, optimized with tick count | ||
if (currentTickCount % 35 == 0) | ||
{ | ||
rResistance = cvar.getcvar("wt_rollresistance", owner.player).getfloat(); | ||
rVelocity = cvar.getcvar("wt_rollvelocity", owner.player).getfloat(); | ||
debug = cvar.getcvar("wt_debug", owner.player).getbool(); | ||
offset = cvar.getcvar("wt_offset", owner.player).getbool(); | ||
} | ||
|
||
//calculate tilt and shit idk | ||
aVelocity = atan2(owner.vel.y, owner.player.vel.x); | ||
direction = (sin(-owner.angle), cos(-owner.angle)); | ||
velocityUnit = owner.vel.xy; | ||
currentRoll += (velocityUnit dot direction) * rVelocity; | ||
currentRoll *= rResistance; | ||
|
||
//apply tilt | ||
weaponsprite.rotation = currentRoll; | ||
|
||
if(offset) | ||
{ | ||
weaponsprite.y += (+currentRoll); | ||
} | ||
|
||
//debug | ||
if(debug) | ||
{ | ||
console.printf("roll: %f", currentRoll); | ||
} | ||
} | ||
} | ||
} |