From 00e88cd9eafbdb23de04a862336490f486e84298 Mon Sep 17 00:00:00 2001 From: Robert Fritzen Date: Wed, 20 Dec 2017 12:15:32 -0600 Subject: [PATCH] Summoner Zombie, Bug Fix Upgraded the summoner zombie to the new AI type, fixed a few typos in two of the other zombie files which prevented the move function from properly looping. --- scripts/TWM2/Zombie/ZombieCore.cs | 8 +- scripts/TWM2/Zombie/ZombieTypes/Normal.cs | 2 +- scripts/TWM2/Zombie/ZombieTypes/Shifter.cs | 2 +- scripts/TWM2/Zombie/ZombieTypes/Summoner.cs | 161 +++++++++++--------- 4 files changed, 102 insertions(+), 71 deletions(-) diff --git a/scripts/TWM2/Zombie/ZombieCore.cs b/scripts/TWM2/Zombie/ZombieCore.cs index 94e2a59..3bd3004 100644 --- a/scripts/TWM2/Zombie/ZombieCore.cs +++ b/scripts/TWM2/Zombie/ZombieCore.cs @@ -101,6 +101,9 @@ $Zombie::Shifter_Teleport_PrepTime = 1500; //$Zombie::Shifter_Teleport_Cooldown: The cooldown between each teleport $Zombie::Shifter_Teleport_Cooldown = 12500; +//$Zombie::Summoner_Cooldown: The cooldown of the summoner zombie's summon ability +$Zombie::Summoner_Cooldown = 25000; + //MISC Globals, Do not edit. $Zombie::killpoints = 5; $Zombie::RogThread = "cel1"; @@ -292,6 +295,8 @@ function TWM2Lib_Zombie_Core(%functionName, %arg1, %arg2, %arg3, %arg4) { %arg1.canJump = %arg3; case "recentshift": %arg1.recentShift = %arg3; + case "cansummon": + %arg1.cansummon = %arg3; case "canshield": %arg1.canShield = %arg3; case "firingweapon": @@ -542,7 +547,8 @@ function TWM2Lib_Zombie_Core(%functionName, %arg1, %arg2, %arg3, %arg4) { case 10: %zombie = new player() { Datablock = "SummonerZombieArmor"; - }; + }; + %zombie.canSummon = 1; //Sniper Zombie case 11: diff --git a/scripts/TWM2/Zombie/ZombieTypes/Normal.cs b/scripts/TWM2/Zombie/ZombieTypes/Normal.cs index 2514254..4081bba 100644 --- a/scripts/TWM2/Zombie/ZombieTypes/Normal.cs +++ b/scripts/TWM2/Zombie/ZombieTypes/Normal.cs @@ -112,5 +112,5 @@ function ZombieArmor::Move(%datablock, %zombie) { %zombie.hastarget = 0; %zombie.zombieRmove = schedule(%zombie.updateTimeFrequency, %zombie, "TWM2Lib_Zombie_Core", "zRandomMoveLoop", %zombie); } - %zombie.moveloop = %datablock.schedule(%zombie.updateTimeFrequency, %datablock, "Move", %zombie); + %zombie.moveloop = %datablock.schedule(%zombie.updateTimeFrequency, "Move", %zombie); } diff --git a/scripts/TWM2/Zombie/ZombieTypes/Shifter.cs b/scripts/TWM2/Zombie/ZombieTypes/Shifter.cs index 8631d24..35520df 100644 --- a/scripts/TWM2/Zombie/ZombieTypes/Shifter.cs +++ b/scripts/TWM2/Zombie/ZombieTypes/Shifter.cs @@ -118,5 +118,5 @@ function ShifterZombieArmor::Move(%datablock, %zombie) { %zombie.hastarget = 0; %zombie.zombieRmove = schedule(%zombie.updateTimeFrequency, %zombie, "TWM2Lib_Zombie_Core", "zRandomMoveLoop", %zombie); } - %zombie.moveloop = %datablock.schedule(%zombie.updateTimeFrequency, %datablock, "Move", %zombie); + %zombie.moveloop = %datablock.schedule(%zombie.updateTimeFrequency, "Move", %zombie); } \ No newline at end of file diff --git a/scripts/TWM2/Zombie/ZombieTypes/Summoner.cs b/scripts/TWM2/Zombie/ZombieTypes/Summoner.cs index 2546c56..15a866b 100644 --- a/scripts/TWM2/Zombie/ZombieTypes/Summoner.cs +++ b/scripts/TWM2/Zombie/ZombieTypes/Summoner.cs @@ -1,3 +1,5 @@ +$TWM2::ArmorHasCollisionFunction[SummonerZombieArmor] = true; + datablock PlayerData(SummonerZombieArmor) : LightMaleHumanArmor { runForce = 60.20 * 90; runEnergyDrain = 0.0; @@ -34,75 +36,98 @@ datablock PlayerData(SummonerZombieArmor) : LightMaleHumanArmor { max[Grenade] = 0; }; -function SummonerZombiemovetotarget(%zombie){ - if(!isobject(%Zombie)) - return; - if(%Zombie.getState() $= "dead") - return; - %pos = %zombie.getworldboxcenter(); - %closestClient = ZombieLookForTarget(%zombie); - %closestDistance = getWord(%closestClient,1); - %closestClient = getWord(%closestClient,0).Player; - if(%closestDistance <= $zombie::detectDist){ - if(%zombie.hastarget != 1){ - %zombie.hastarget = 1; +function SummonerZombieArmor::armorCollisionFunction(%datablock, %zombie, %colPlayer) { + if(!isObject(%zombie) || %zombie.getState() $= "dead") { + return; } - %chance = (getrandom() * 20); - if(%chance >= 19) { - %chance = (getRandom() * 12); - if(%chance <= 11) - serverPlay3d("ZombieMoan",%zombie.getWorldBoxCenter()); - else - serverPlay3d("ZombieHOWL",%zombie.getWorldBoxCenter()); - } - - if(%zombie.SumTicks $= "") { - %zombie.SumTicks = 19; //summon right away Pl0x - } - %zombie.SumTicks++; - if(%zombie.SumTicks > 20) { - %zombie.SumTicks = 0; - %Ct = GetRandom(1,3); - %type = GetRandom(1, 8); - if(%type > 5) { - %type += 3; - if(%type == 10) { //summoners don;t summon more summoners - %type = 12; - } - } - %SumPos = vectorAdd(VectorAdd(TWM2Lib_MainControl("getRandomPosition", 20 TAB 1), "0 0 7"), %zombie.getPosition()); - %c = CreateEmitter(%SumPos, NightmareGlobeEmitter, "0 0 1"); - %c.schedule(((%Ct * 1000) + 500), "delete"); - for(%i = 1; %i <= %ct; %i++) { - %time = %i * 1000; - schedule(%time, 0, "TWM2Lib_Zombie_Core", "SpawnZombie", "zSpawnCommand", %type, %SumPos); - } - } - - %vector = ZgetFacingDirection(%zombie,%closestClient,%pos); - - %fmultiplier = $Zombie::ForwardSpeed; - if(%closestDistance <= $zombie::lungDist && %zombie.canjump == 1) - %fmultiplier = (%fmultiplier * 4); - %vector = vectorscale(%vector, %Fmultiplier); - %upvec = "150"; - if(%closestDistance <= $zombie::lungDist && %zombie.canjump == 1){ - %upvec = %upvec * 2; - %zombie.canjump = 0; - schedule(1500, %zombie, "Zsetjump", %zombie); + if(!isObject(%colPlayer) || %colPlayer.getState() $= "dead") { + return; } - %x = Getword(%vector,0); - %y = Getword(%vector,1); - %z = Getword(%vector,2); - if(%z >= 600) - %upvec = (%upvec * 5); - %vector = %x@" "@%y@" "@%upvec; - %zombie.applyImpulse(%pos, %vector); - } - else if(%zombie.hastarget == 1){ - %zombie.hastarget = 0; - %zombie.zombieRmove = schedule(100, %zombie, "ZSetRandomMove", %zombie); - } - %zombie.moveloop = schedule(500, %zombie, "SummonerZombiemovetotarget", %zombie); + //Check to make sure we're not hitting another zombie / boss + if(%colPlayer.isBoss || %colPlayer.isZombie || %colPlayer.rapierShield) { + return; + } + //Damage. + %causeInfect = %zombie.damage_infectOnTouch; + %baseDamage = %zombie.damage_amountOnTouch; + %multiplier = %zombie.damage_alreadyInfectedMultiplier; + + %total = %colPlayer.infected ? (%baseDamage * %multiplier) : %baseDamage; + + %pushVector = vectorscale(%colPlayer.getvelocity(), 100); + %colPlayer.applyimpulse(%colPlayer.getposition(), %pushVector); + if(%causeInfect) { + %colPlayer.Infected = 1; + %colPlayer.InfectedLoop = schedule(10, %colPlayer, "TWM2Lib_Zombie_Core", "InfectLoop", %colPlayer, "impact"); + } + %colPlayer.damage(0, %colPlayer.getPosition(), %total, $DamageType::Zombie); } +function SummonerZombieArmor::AI(%datablock, %zombie) { + if(!isObject(%zombie) || %zombie.getState() $= "dead") { + return; + } + %pos = %zombie.getWorldBoxCenter(); + %closestClient = TWM2Lib_Zombie_Core("lookForTarget", %zombie); + %closestDistance = getWord(%closestClient, 1); + %closestClient = getWord(%closestClient, 0).Player; + + if(isObject(%closestClient) && %closestClient.getState() !$= "dead") { + if(%closestDistance <= $zombie::detectDist) { + %zombie.targetPlayer = %closestClient; + %zombie.moveloop = %datablock.Move(%zombie); + } + } + + if(isObject(%zombie.targetPlayer)) { + //Summoner Logic + if(%zombie.canSummon) { + %Ct = GetRandom(1, 3); + %type = GetRandom(1, 8); + if(%type > 5) { + %type += 3; + if(%type == 10) { //summoners don;t summon more summoners + %type = 12; + } + } + %SumPos = vectorAdd(VectorAdd(TWM2Lib_MainControl("getRandomPosition", 20 TAB 1), "0 0 7"), %zombie.getPosition()); + %c = CreateEmitter(%SumPos, NightmareGlobeEmitter, "0 0 1"); + %c.schedule(((%Ct * 1000) + 500), "delete"); + for(%i = 1; %i <= %ct; %i++) { + %time = %i * 1000; + schedule(%time, 0, "TWM2Lib_Zombie_Core", "SpawnZombie", "zSpawnCommand", %type, %SumPos); + } + TWM2Lib_Zombie_Core("setZFlag", %zombie, "canSummon", 0); + schedule($Zombie::Summoner_Cooldown, 0, TWM2Lib_Zombie_Core, "setZFlag", %zombie, "canSummon", 1); + } + } + %datablock.schedule(%zombie.updateTimeFrequency, "AI", %zombie); +} + +function SummonerZombieArmor::Move(%datablock, %zombie) { + if(!isObject(%zombie) || %zombie.getState() $= "dead") { + return; + } + %pos = %zombie.getWorldBoxCenter(); + TWM2Lib_Zombie_Core("playZAudio", %zombie, 100, 40); + // + %vector = TWM2Lib_Zombie_Core("zombieGetFacingDirection", %zombie, %zombie.targetPlayer.getPosition()); + if(%closestDistance <= $Zombie::LungeDistance && %zombie.canjump == 1) { + %vector = vectorScale(%vector, 4); + } + %vector = vectorScale(%vector, %zombie.speed); + %upvec = "150"; + if(vectorDist(%pos, %zombie.targetPlayer.getPosition()) <= $Zombie::LungeDistance && %zombie.canjump == 1) { + %upvec *= 2; + TWM2Lib_Zombie_Core("setZFlag", %zombie, "canJump", 0); + schedule($Zombie::BaseJumpCooldown, 0, TWM2Lib_Zombie_Core, "setZFlag", %zombie, "canJump", 1); + } + %x = Getword(%vector, 0); + %y = Getword(%vector, 1); + %z = Getword(%vector, 2); + if(%z >= 600) { + %upvec = (%upvec * 5); + } + %vector = %x@" "@%y@" "@%upvec; + %zombie.applyImpulse(%pos, %vector); +} \ No newline at end of file