From 60aa22198d59cf20b48d913b5f948a7323b8d080 Mon Sep 17 00:00:00 2001 From: Proydoha Date: Tue, 24 Dec 2024 17:07:23 +0200 Subject: [PATCH] Add ignore list for Wall Detector --- DECORATE.dec | 1 - decorate/Detectors/WallHit.dec | 28 ---------- zscript.zs | 1 + .../Toby_DropoffDetectorHandler.zs | 16 ++++-- .../Toby_DropoffSoundEmitterManagerItem.zs | 10 ++++ zscript/DropoffDetector/Toby_WallDetector.zs | 22 +++++--- zscript/DropoffDetector/Toby_WallHit.zs | 52 +++++++++++++++++++ ...Toby_ClassIgnoreListLoaderStaticHandler.zs | 2 + .../IgnoreLists/Toby_WallHitIgnoreList.txt | 0 9 files changed, 94 insertions(+), 38 deletions(-) delete mode 100644 decorate/Detectors/WallHit.dec create mode 100644 zscript/DropoffDetector/Toby_WallHit.zs create mode 100644 zscript/IgnoreLists/Toby_WallHitIgnoreList.txt diff --git a/DECORATE.dec b/DECORATE.dec index 8d3d55b..9011fc2 100644 --- a/DECORATE.dec +++ b/DECORATE.dec @@ -5,4 +5,3 @@ //Player #include decorate/Detectors/FloorChecker.dec //#include decorate/Detectors/WalkThing.dec -#include decorate/Detectors/WallHit.dec diff --git a/decorate/Detectors/WallHit.dec b/decorate/Detectors/WallHit.dec deleted file mode 100644 index 5385a1b..0000000 --- a/decorate/Detectors/WallHit.dec +++ /dev/null @@ -1,28 +0,0 @@ -actor WallHit -{ - Radius 9 - Height 8 - Speed 2 - Health 1 - Damage 0 - Mass 9000000000 - Projectile - +NoBlockmap - +NOTIMEFREEZE - -NOGRAVITY - +THRUGHOST - +BLOCKASPLAYER - //+ActivatePCross - SeeSound "null" - DeathSound "misc/wallhit" - States - { - Spawn: - TNT1 A 5 - Stop - - Death: - TNT1 A 1 - Stop - } -} diff --git a/zscript.zs b/zscript.zs index 8d0b680..44af911 100644 --- a/zscript.zs +++ b/zscript.zs @@ -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 diff --git a/zscript/DropoffDetector/Toby_DropoffDetectorHandler.zs b/zscript/DropoffDetector/Toby_DropoffDetectorHandler.zs index de8bcd3..8b273df 100644 --- a/zscript/DropoffDetector/Toby_DropoffDetectorHandler.zs +++ b/zscript/DropoffDetector/Toby_DropoffDetectorHandler.zs @@ -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); } } diff --git a/zscript/DropoffDetector/Toby_DropoffSoundEmitterManagerItem.zs b/zscript/DropoffDetector/Toby_DropoffSoundEmitterManagerItem.zs index 068ca87..2c38fae 100644 --- a/zscript/DropoffDetector/Toby_DropoffSoundEmitterManagerItem.zs +++ b/zscript/DropoffDetector/Toby_DropoffSoundEmitterManagerItem.zs @@ -1,6 +1,7 @@ class Toby_DropoffSoundEmitterManagerItem : Inventory { private Toby_WallDetector wallDetector; + private Toby_DropoffDetectorHandler handler; default { @@ -26,6 +27,10 @@ class Toby_DropoffSoundEmitterManagerItem : Inventory if (!wallDetector) { wallDetector = Toby_WallDetector.Create(owner); } + if (!wallDetector.handler) + { + wallDetector.SetHandlerReference(handler); + } if(!frontEmitter) { @@ -80,4 +85,9 @@ class Toby_DropoffSoundEmitterManagerItem : Inventory } } } + + void SetHandlerReference(Toby_DropoffDetectorHandler handler) + { + self.handler = handler; + } } diff --git a/zscript/DropoffDetector/Toby_WallDetector.zs b/zscript/DropoffDetector/Toby_WallDetector.zs index d8117ce..930144a 100644 --- a/zscript/DropoffDetector/Toby_WallDetector.zs +++ b/zscript/DropoffDetector/Toby_WallDetector.zs @@ -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) { @@ -22,6 +23,11 @@ class Toby_WallDetector: Thinker } } + void SetHandlerReference(Toby_DropoffDetectorHandler handler) + { + self.handler = handler; + } + private void SpawnWallHitActors() { if (!owner) { return; } @@ -29,12 +35,16 @@ class Toby_WallDetector: Thinker 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; } } diff --git a/zscript/DropoffDetector/Toby_WallHit.zs b/zscript/DropoffDetector/Toby_WallHit.zs new file mode 100644 index 0000000..dde7187 --- /dev/null +++ b/zscript/DropoffDetector/Toby_WallHit.zs @@ -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); + } +} diff --git a/zscript/IgnoreLists/Toby_ClassIgnoreListLoaderStaticHandler.zs b/zscript/IgnoreLists/Toby_ClassIgnoreListLoaderStaticHandler.zs index f5962e5..531d7d3 100644 --- a/zscript/IgnoreLists/Toby_ClassIgnoreListLoaderStaticHandler.zs +++ b/zscript/IgnoreLists/Toby_ClassIgnoreListLoaderStaticHandler.zs @@ -2,6 +2,7 @@ class Toby_ClassIgnoreListLoaderStaticHandler : StaticEventHandler { Toby_ClassIgnoreListContainer universalPickupBeaconIgnoreList; Toby_ClassIgnoreListContainer snapToTargetIgnoreList; + Toby_ClassIgnoreListContainer wallHitIgnoreList; static Toby_ClassIgnoreListLoaderStaticHandler GetInstance() { @@ -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"); } diff --git a/zscript/IgnoreLists/Toby_WallHitIgnoreList.txt b/zscript/IgnoreLists/Toby_WallHitIgnoreList.txt new file mode 100644 index 0000000..e69de29