Skip to content

Commit

Permalink
- initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Jul 3, 2022
1 parent 2cde4a4 commit 71a9938
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cvarinfo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
server bool smpb_enable = false;
server float smpb_range = 3000;
server int smpb_tics = 8;
4 changes: 4 additions & 0 deletions mapinfo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gameinfo
{
AddEventHandlers = "SMPBEventHandler"
}
40 changes: 40 additions & 0 deletions zscript.zc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Version "4.8.0"

class SMPBEventHandler : EventHandler
{
override void WorldTick()
{
if (!smpb_enable)
return;

int slowdownspeed = smpb_tics;
float slowrange = smpb_range;

if ((gametic % slowdownspeed) != 0)
return;

ThinkerIterator it = ThinkerIterator.Create("Actor", Thinker.STAT_DEFAULT);

actor mo;

while (mo = Actor(it.Next()))
{
bool inrange = false;
for (int i = 0; i < MAXPLAYERS; i++)
{
if (players[i].mo && players[i].camera)
{
float dx = int(players[i].camera.Pos.X - mo.Pos.X);
float dy = int(players[i].camera.Pos.Y - mo.Pos.Y);
float qdist = dx * dx + dy * dy - slowrange * slowrange;
if (qdist < 0)
inrange = true;
}
}
if (!inrange && !(mo.player))
{
mo.Tics += (slowdownspeed - 1);
}
}
}
}

0 comments on commit 71a9938

Please sign in to comment.