-
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.
- Loading branch information
1 parent
2cde4a4
commit 71a9938
Showing
3 changed files
with
47 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,3 @@ | ||
server bool smpb_enable = false; | ||
server float smpb_range = 3000; | ||
server int smpb_tics = 8; |
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,4 @@ | ||
gameinfo | ||
{ | ||
AddEventHandlers = "SMPBEventHandler" | ||
} |
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,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); | ||
} | ||
} | ||
} | ||
} |