Skip to content

Commit

Permalink
Add ignore list for Wall Detector
Browse files Browse the repository at this point in the history
  • Loading branch information
proydoha committed Dec 24, 2024
1 parent bb4574e commit 60aa221
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 38 deletions.
1 change: 0 additions & 1 deletion DECORATE.dec
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
//Player
#include decorate/Detectors/FloorChecker.dec
//#include decorate/Detectors/WalkThing.dec
#include decorate/Detectors/WallHit.dec
28 changes: 0 additions & 28 deletions decorate/Detectors/WallHit.dec

This file was deleted.

1 change: 1 addition & 0 deletions zscript.zs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ version "4.6"
#include "zscript/DropoffDetector/Toby_DropoffSoundEmitter.zs"
#include "zscript/DropoffDetector/Toby_DropoffSoundEmitterManagerItem.zs"
#include "zscript/DropoffDetector/Toby_WallDetector.zs"
#include "zscript/DropoffDetector/Toby_WallHit.zs"
#include "zscript/DropoffDetector/Toby_DropoffDetectorHandler.zs"

//Target detector
Expand Down
16 changes: 13 additions & 3 deletions zscript/DropoffDetector/Toby_DropoffDetectorHandler.zs
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
class Toby_DropoffDetectorHandler : EventHandler
{
override void PlayerSpawned (PlayerEvent e)
Toby_ClassIgnoreListLoaderStaticHandler wallHitIgnoreListLoader;

override void OnRegister()
{
let player = players [e.PlayerNumber].mo;
player.GiveInventory ("Toby_DropoffSoundEmitterManagerItem", 1);
wallHitIgnoreListLoader = Toby_ClassIgnoreListLoaderStaticHandler.GetInstance();
}

override void PlayerSpawned(PlayerEvent e)
{
Actor playerActor = players[e.PlayerNumber].mo;
playerActor.GiveInventory("Toby_DropoffSoundEmitterManagerItem", 1);

Toby_DropoffSoundEmitterManagerItem manager = Toby_DropoffSoundEmitterManagerItem(playerActor.FindInventory("Toby_DropoffSoundEmitterManagerItem"));
manager.SetHandlerReference(self);
}
}
10 changes: 10 additions & 0 deletions zscript/DropoffDetector/Toby_DropoffSoundEmitterManagerItem.zs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Toby_DropoffSoundEmitterManagerItem : Inventory
{
private Toby_WallDetector wallDetector;
private Toby_DropoffDetectorHandler handler;

default
{
Expand All @@ -26,6 +27,10 @@ class Toby_DropoffSoundEmitterManagerItem : Inventory
if (!wallDetector) {
wallDetector = Toby_WallDetector.Create(owner);
}
if (!wallDetector.handler)
{
wallDetector.SetHandlerReference(handler);
}

if(!frontEmitter)
{
Expand Down Expand Up @@ -80,4 +85,9 @@ class Toby_DropoffSoundEmitterManagerItem : Inventory
}
}
}

void SetHandlerReference(Toby_DropoffDetectorHandler handler)
{
self.handler = handler;
}
}
22 changes: 16 additions & 6 deletions zscript/DropoffDetector/Toby_WallDetector.zs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Toby_WallDetector: Thinker
private Actor owner;
private int cooldown;
private int cooldownMax;
Toby_DropoffDetectorHandler handler;

static Toby_WallDetector Create(Actor owner)
{
Expand All @@ -22,19 +23,28 @@ class Toby_WallDetector: Thinker
}
}

void SetHandlerReference(Toby_DropoffDetectorHandler handler)
{
self.handler = handler;
}

private void SpawnWallHitActors()
{
if (!owner) { return; }
PlayerInfo player = owner.player;
if (!player) { return; }
if (player.cmd.forwardmove == 0 && player.cmd.sidemove == 0) { return; }
if (cooldown != 0) { return; }
//owner.A_ThrowGrenade("WallHit", -12, 2.5, 1);
//owner.A_ThrowGrenade("WallHit", -12, -2.5, 1);
owner.A_SpawnProjectile("WallHit",28,0,0,2,0);
owner.A_SpawnProjectile("WallHit",28,0,180,2,0);
owner.A_SpawnProjectile("WallHit",28,0,100,2,0);
owner.A_SpawnProjectile("WallHit",28,0,260,2,0);

Toby_WallHit projectile1 = Toby_WallHit(owner.A_SpawnProjectile("Toby_WallHit",28,0,0,2,0));
Toby_WallHit projectile2 = Toby_WallHit(owner.A_SpawnProjectile("Toby_WallHit",28,0,180,2,0));
Toby_WallHit projectile3 = Toby_WallHit(owner.A_SpawnProjectile("Toby_WallHit",28,0,100,2,0));
Toby_WallHit projectile4 = Toby_WallHit(owner.A_SpawnProjectile("Toby_WallHit",28,0,260,2,0));

projectile1.SetHandlerReference(handler);
projectile2.SetHandlerReference(handler);
projectile3.SetHandlerReference(handler);
projectile4.SetHandlerReference(handler);
cooldown = cooldownMax;
}
}
52 changes: 52 additions & 0 deletions zscript/DropoffDetector/Toby_WallHit.zs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
class Toby_WallHit : Actor
{
Toby_DropoffDetectorHandler handler;

default
{
Radius 9;
Height 8;
Speed 2;
Health 1;
Damage 0;
Projectile;
+NOTIMEFREEZE;
+NOBLOCKMAP;
+BLOCKASPLAYER;
-NOGRAVITY;
DeathSound "misc/wallhit";
}

States
{
Spawn:
TNT1 A 1;
TNT1 A 1;
TNT1 A 3;
TNT1 A 0;
Stop;

Death:
TNT1 A 1;
Stop;
}

void SetHandlerReference(Toby_DropoffDetectorHandler handler)
{
self.handler = handler;
}

override int SpecialMissileHit(Actor victim)
{
if (!handler) { return Super.SpecialMissileHit(victim); }
if (handler.wallHitIgnoreListLoader.IsInIgnoreList(victim, handler.wallHitIgnoreListLoader.wallHitIgnoreList)) { return 1; }
return Super.SpecialMissileHit(victim);
}

override bool CanCollideWith(Actor other, bool passive)
{
if (!handler) { return Super.CanCollideWith(other, passive); }
if (handler.wallHitIgnoreListLoader.IsInIgnoreList(other, handler.wallHitIgnoreListLoader.wallHitIgnoreList)) { return false; }
return Super.CanCollideWith(other, passive);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Toby_ClassIgnoreListLoaderStaticHandler : StaticEventHandler
{
Toby_ClassIgnoreListContainer universalPickupBeaconIgnoreList;
Toby_ClassIgnoreListContainer snapToTargetIgnoreList;
Toby_ClassIgnoreListContainer wallHitIgnoreList;

static Toby_ClassIgnoreListLoaderStaticHandler GetInstance()
{
Expand All @@ -12,6 +13,7 @@ class Toby_ClassIgnoreListLoaderStaticHandler : StaticEventHandler
{
universalPickupBeaconIgnoreList = Toby_ClassIgnoreListContainer.Create("Toby_UniversalPickupBeaconIgnoreList");
snapToTargetIgnoreList = Toby_ClassIgnoreListContainer.Create("Toby_SnapToTargetIgnoreList");
wallHitIgnoreList = Toby_ClassIgnoreListContainer.Create("Toby_WallHitIgnoreList");
Toby_Logger.Message("Toby_ClassIgnoreListLoaderStaticHandler registered!", "Toby_Developer");
}

Expand Down
Empty file.

0 comments on commit 60aa221

Please sign in to comment.