Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
add mod files (2)
  • Loading branch information
generic-name-guy authored Oct 28, 2022
1 parent b5fc928 commit 03d6570
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ZSCRIPT/EventHandler_WeaponTilter.zs
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);
}
}
58 changes: 58 additions & 0 deletions ZSCRIPT/Inventory_WeaponTilter.zs
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);
}
}
}
}

0 comments on commit 03d6570

Please sign in to comment.