diff --git a/CVarInfo.txt b/CVarInfo.txt index d9b4059..d522bbe 100644 --- a/CVarInfo.txt +++ b/CVarInfo.txt @@ -10,5 +10,6 @@ server bool zb_talk = true; server bool zb_cooprespawn = false; server bool zb_respawn = true; server bool zb_autonoderespawn = true; +server string zb_nodevar = "nodelist"; -server string zb_names = "Jack,Persephone,Èmille,Robert,Amanda,Maria,Mary,Josh,Wagner,John,Louis,Gabriel,Renato,Alejandro,Alexander,Heinrich,Caesar,Walter,Amy,Lawrence,Marylenne,Leonhart,Leonard,Jackson,Lee,Bert,Humberto,Mike,Pablo,Michael,Hitchcock,Hilton,Ronald,Robinson,Son,House,Romulus,Peter,Peterson,Zephyrus,Robin,Paul,Paula,Thorson,Robohead,Minchson,James,Jamilton,Greg,Gregor,Gregory,Victoria,Anita,Whindersson,Melody,Xonon,Xihil,Thought,Hope,Rebecca,Prince,Larry,Barry,Garry,Garmond,Barney"; \ No newline at end of file +server string zb_names = "Jack,Persephone,Èmille,Robert,Amanda,Maria,Mary,Josh,Wagner,John,Louis,Gabriel,Renato,Alejandro,Alexander,Heinrich,Caesar,Walter,Amy,Lawrence,Marylenne,Leonhart,Leonard,Jackson,Lee,Bert,Humberto,Mike,Pablo,Michael,Hitchcock,Hilton,Ronald,Robinson,Son,House,Romulus,Peter,Peterson,Zephyrus,Robin,Paul,Paula,Thorson,Robohead,Minchson,James,Jamilton,Greg,Gregor,Gregory,Victoria,Anita,Whindersson,Melody,Xonon,Xihil,Thought,Hope,Rebecca,Prince,Larry,Barry,Garry,Garmond,Barney"; diff --git a/ZScript.zsc b/ZScript.zsc index 6507454..a53d175 100644 --- a/ZScript.zsc +++ b/ZScript.zsc @@ -215,10 +215,10 @@ class ZTBotController : Actor } for ( let i = 0; i < UseHistory.Size(); i++ ) { - if ( UseHistory[i].Used == td.HitLine && age - UseHistory[i].When < CVar.GetCVar('zb_autouseinterval').GetFloat() ) + if ( UseHistory[i].Used == td.HitLine && age - UseHistory[i].When < CVar.FindCVar('zb_autouseinterval').GetFloat() ) return false; - else if ( age - UseHistory[i].When >= CVar.GetCVar('zb_autouseinterval').GetFloat() ) + else if ( age - UseHistory[i].When >= CVar.FindCVar('zb_autouseinterval').GetFloat() ) UseHistory.Delete(i--); } @@ -259,7 +259,7 @@ class ZTBotController : Actor return null; Array goals; - let iter = ThinkerIterator.Create("ZTPathNode", STAT_DEFAULT); + let iter = ThinkerIterator.Create("ZTPathNode", 91); ZTPathNode cur; while ( cur = ZTPathNode(iter.Next()) ) @@ -278,7 +278,7 @@ class ZTBotController : Actor GruntInterval = 0; - if ( CVar.GetCVar('deathmatch').GetInt() > 0 ) + if ( CVar.FindCVar('deathmatch').GetInt() > 0 ) bFRIENDLY = false; debugCount = 0; @@ -292,7 +292,7 @@ class ZTBotController : Actor loader = ZetaWeaponModule(Spawn("ZetaWeaponModule")); Array wmodules; - let tp = CVar.GetCVar("zb_wtypes").GetString(); + let tp = CVar.FindCVar("zb_wtypes").GetString(); tp.Split(wmodules, ";"); for ( int i = 0; i < wmodules.Size(); i++ ) @@ -334,7 +334,7 @@ class ZTBotController : Actor rightObs = ObstacleChecker.MakeFor(self, -45, 8 * Speed); Array botNames; - CVar.GetCVar('zb_names').GetString().Split(botNames, ','); + CVar.FindCVar('zb_names').GetString().Split(botNames, ','); myName = botNames[Random(0, botNames.Size() - 1)]; } @@ -371,7 +371,7 @@ class ZTBotController : Actor double chanceDenom = 1; uint found = 0; - let iter = ThinkerIterator.Create("ZTPathNode", STAT_DEFAULT); + let iter = ThinkerIterator.Create("ZTPathNode", 91); while ((pn = ZTPathNode(iter.Next())) != null) { if (pn.nodeType == ZTPathNode.NT_RESPAWN) { @@ -396,6 +396,7 @@ class ZTBotController : Actor spawnPos.y += FRandom(-16, 16); SetPossessed(ZetaBotPawn(Spawn(possessedType, spawnPos))); + possessed.angle = chosen.angle; Spawn("TeleportFog", spawnPos); DebugLog(LT_VERBOSE, String.format("%s respawned!", myName)); @@ -412,7 +413,7 @@ class ZTBotController : Actor possessedType = possessed.GetClass(); possessed.cont = self; - if ( CVar.GetCVar("deathmatch").GetInt() == 1 ) + if ( CVar.FindCVar("deathmatch").GetInt() == 1 ) other.bFRIENDLY == false; averageSpeed = 0; @@ -701,12 +702,12 @@ class ZTBotController : Actor bool isEnemy(Actor from, Actor other) { - return from.bFRIENDLY != other.bFRIENDLY || ( !from.bFRIENDLY && other.CheckClass("PlayerPawn", AAPTR_DEFAULT, true) ) || CVar.GetCVar('deathmatch').GetInt() > 0; + return from.bFRIENDLY != other.bFRIENDLY || ( !from.bFRIENDLY && other.CheckClass("PlayerPawn", AAPTR_DEFAULT, true) ) || CVar.FindCVar('deathmatch').GetInt() > 0; } ZTPathNode ClosestNode(Actor other) { - ThinkerIterator iter = ThinkerIterator.Create("ZTPathNode", STAT_DEFAULT); + ThinkerIterator iter = ThinkerIterator.Create("ZTPathNode", 91); ZTPathNode best = null; ZTPathNode cur = null; @@ -734,7 +735,7 @@ class ZTBotController : Actor ZTPathNode ClosestVisibleNode(Actor other) { - ThinkerIterator iter = ThinkerIterator.Create("ZTPathNode", STAT_DEFAULT); + ThinkerIterator iter = ThinkerIterator.Create("ZTPathNode", 91); ZTPathNode best = null; ZTPathNode cur = null; @@ -826,8 +827,12 @@ class ZTBotController : Actor { if ( age - lastShot > 0 ) { - DebugLog(LT_VERBOSE, myName.." fired a "..lastWeap.GetClassName().."!"); + DebugLog(LT_VERBOSE, myName.." alt-fired a "..lastWeap.GetClassName().."!"); lastWeap.AltFire(possessed, enemy); + + if (lastWeap.altammouse > 0) + possessed.A_TakeInventory(lastWeap.altammotype, lastWeap.altammouse); + lastShot = age + lastWeap.IntervalSeconds(); DebugLog(LT_VERBOSE, myName.." can shoot again after "..lastWeap.IntervalSeconds().." seconds, or alt-fire after "..lastWeap.AltIntervalSeconds().." seconds!"); @@ -837,12 +842,16 @@ class ZTBotController : Actor return false; } - if ( lastWeap.CanFire(possessed) ) + else if ( lastWeap.CanFire(possessed) ) { if ( age - lastShot > 0 ) { - DebugLog(LT_VERBOSE, myName.." alt-fired a "..lastWeap.GetClassName().."!"); + DebugLog(LT_VERBOSE, myName.." fired a "..lastWeap.GetClassName().."!"); lastWeap.Fire(possessed, enemy); + + if (lastWeap.ammouse > 0) + possessed.A_TakeInventory(lastWeap.ammotype, lastWeap.ammouse); + lastShot = age + lastWeap.IntervalSeconds(); DebugLog(LT_VERBOSE, myName.." can shoot again after "..lastWeap.IntervalSeconds().." seconds, or alt-fire after "..lastWeap.AltIntervalSeconds().." seconds!"); @@ -1267,7 +1276,7 @@ class ZTBotController : Actor BotChat("TARG", 0.8); - if ( !possessed.CheckSight(enemy) ) + if ( !LineOfSight(enemy) ) { lastEnemyPos = enemy.pos; SetBotState(BS_HUNTING); @@ -1298,34 +1307,40 @@ class ZTBotController : Actor else { - if ( currNode != null && bstate != BS_HUNTING ) navDest = currNode.RandomNeighbor(); + if ( currNode != null && ( bstate != BS_HUNTING || navDest == null ) ) navDest = currNode.RandomNeighbor(); if ( bstate == BS_HUNTING ) { - double lastPosDist = (possessed.pos.x - lastEnemyPos.x) * (possessed.pos.x - lastEnemyPos.x) + (possessed.pos.y - lastEnemyPos.y) * (possessed.pos.y - lastEnemyPos.y); - if ( enemy == null || enemy.Health <= 0 ) { enemy = null; SetBotState(BS_WANDERING); } - else if ( possessed.CheckSight(enemy) || possessed.Distance3D(enemy) < 96 ) + else if ( LineOfSight(enemy) || possessed.Distance3D(enemy) < 96 ) { + AimToward(enemy, 15); SetBotState(BS_ATTACKING); - - else if ( lastPosDist < 16384 || lastPosDist > 4194304 ) - { - enemy = null; - SetBotState(BS_WANDERING); } - + else { - MoveTowardPos(lastEnemyPos, 3); + double velSqLen = (possessed.vel.x * possessed.vel.x) + (possessed.vel.y * possessed.vel.y); + double lastPosSqDist = ((possessed.pos.x - lastEnemyPos.x) * (possessed.pos.x - lastEnemyPos.x)) + + ((possessed.pos.y - lastEnemyPos.y) * (possessed.pos.y - lastEnemyPos.y)); - if ( FRandom(0, 1) < 0.06 ) - possessed.Jump(); + if ( velSqLen < 16 || possessed.blockingLine != null || lastPosSqDist < 16384 ) + { + enemy = null; + SetBotState(BS_WANDERING); + } + + else { + MoveTowardPos(lastEnemyPos, 3); - AutoUseAtAngle(0); + if ( FRandom(0, 1) < 0.06 ) + possessed.Jump(); + + AutoUseAtAngle(0); + } } } @@ -1507,7 +1522,7 @@ class ZTBotController : Actor { if ( enemy != null && enemy.Health >= 1 ) // health is integer { - if ( !possessed.CheckSight(enemy) ) + if ( !LineOfSight(enemy) ) { possessed.EndShoot(); lastEnemyPos = enemy.pos; @@ -1654,7 +1669,7 @@ class ZetaBot : Actor Super.PostBeginPlay(); bool bHasNode; - let ni = ThinkerIterator.create("ZTPathNode", STAT_DEFAULT); + let ni = ThinkerIterator.create("ZTPathNode", 91); if ( ni.Next() ) bHasNode = true; @@ -1672,7 +1687,7 @@ class ZetaBot : Actor cont.possessed.angle = angle; if ( zb_autonoderespawn ) { - let iter = ThinkerIterator.Create("ZTPathNode", STAT_DEFAULT); + let iter = ThinkerIterator.Create("ZTPathNode", 91); bool can = true; ZTPathNode pn; @@ -1736,7 +1751,7 @@ class ZetaSpirit : Actor Super.PostBeginPlay(); bool bHasNode; - let ni = ThinkerIterator.create("ZTPathNode", STAT_DEFAULT); + let ni = ThinkerIterator.create("ZTPathNode", 91); if ( ni.Next() ) bHasNode = true; diff --git a/ZetaCode/Pathing.zsc b/ZetaCode/Pathing.zsc index 30ae6d7..d141578 100644 --- a/ZetaCode/Pathing.zsc +++ b/ZetaCode/Pathing.zsc @@ -77,8 +77,9 @@ class ZTPathNode : Actor Super.BeginPlay(); id = 0; + ChangeStatNum(91); - let iter = ThinkerIterator.create("ZTPathNode"); + let iter = ThinkerIterator.Create("ZTPathNode", 91); while ( iter.Next() ) id++; @@ -88,11 +89,6 @@ class ZTPathNode : Actor { super.PostBeginPlay(); - /* - if ( !bPlopped ) - uploadLevel(); - */ - DebugLog(LT_VERBOSE, "Created new node: "..serialize()); } @@ -138,40 +134,6 @@ class ZTPathNode : Actor return serializeAll(list); } - static string uploadLevel(String cvName = "nodelist") - { - String code = CVar.FindCVar(cvName).GetString(); - - if ( code == "::NONE" ) - code = serializeLevel(); - - else - { - String c; - uint i = 0; - - while ( true ) - { - c = split(code, ";;", i++); - - if ( split(c, "::", 0) == level.mapName) - break; - - if ( c == "" ) - { - code = serializeLevel()..";;"..code; - CVar.FindCVar(cvName).SetString(code); - return code; - } - } - - code = code.Left(sindex(code, c))..serializeLevel()..code.Mid(sindex(code, c) + c.Length()); - } - - CVar.FindCVar(cvName).SetString(code); - return code; - } - static String split(string other, string sep, uint index) { String res = ""; @@ -456,11 +418,26 @@ class ZTPathNode : Actor return diffZ <= Distance2D(next) || CheckSight(next); } + + override void Tick() { + if ( CVar.FindCVar("zb_debug").GetInt() < 1 ) + SetStateLabel("DLoop"); + + else { + angle += 18; + SetStateLabel("DVisible"); + } + + Super.Tick(); + } Default { Scale 0.35; - Height 32; + Height 16; + Radius 18; + Alpha 0.25; + RenderStyle "Translucent"; } States @@ -470,24 +447,11 @@ class ZTPathNode : Actor Goto DLoop; DLoop: - TNT1 A 1; - TNT1 A 0 - { - if ( CVar.FindCVar("zb_debug").GetInt() > 0 ) - SetStateLabel("DVisible"); - } + TNT1 A 2; Loop; DVisible: - NODE A 1 Bright; - CAND A 0 - { - if ( CVar.FindCVar("zb_debug").GetInt() < 1 ) - SetStateLabel("DLoop"); - - else - angle += 18; - } + NODE A 2 Bright; Loop; } } @@ -585,11 +549,48 @@ class ZTUploadNodes : Actor { override void BeginPlay() { - String code = ZTPathNode.uploadLevel("nodelist"); + //String code = ZTPathNode.uploadLevel(); + uploadLevel(CVar.FindCVar("zb_nodevar").GetString()); // A_PrintBold("'"..code.."'"); Destroy(); } + + static void uploadLevel(String cvName) + { + if (CVar.FindCVar(cvName) == null) + return; + + String code = CVar.FindCVar(cvName).GetString(); + + if ( code == "::NONE" || code == "" ) + code = ZTPathNode.serializeLevel(); + + else + { + String c; + uint i = 0; + + while ( true ) + { + c = ZTPathNode.split(code, ";;", i++); + + if ( ZTPathNode.split(c, "::", 0) == level.mapName) + break; + + if ( c == "" ) + { + code = ZTPathNode.serializeLevel()..";;"..code; + CVar.FindCVar(cvName).SetString(code); + return; + } + } + + code = code.Left(ZTPathNode.sindex(code, c))..ZTPathNode.serializeLevel()..code.Mid(ZTPathNode.sindex(code, c) + c.Length()); + } + + CVar.FindCVar(cvName).SetString(code); + } } class ZTPromptNodes : Actor @@ -597,12 +598,12 @@ class ZTPromptNodes : Actor override void BeginPlay() { ZTPathNode n; - let iter = ThinkerIterator.Create("ZTPathNode"); + let iter = ThinkerIterator.Create("ZTPathNode", 91); while ( n = ZTPathNode(iter.Next()) ) n.Destroy(); - cvar cv = CVar.FindCVar("nodelist"); + cvar cv = CVar.FindCVar(CVar.FindCVar("zb_nodevar").GetString()); if ( cv == null ) { @@ -626,7 +627,7 @@ class ZTDeleteNodes : Actor override void BeginPlay() { ZTPathNode n; - let iter = ThinkerIterator.Create("ZTPathNode"); + let iter = ThinkerIterator.Create("ZTPathNode", 91); String logged = "Deleted %u nodes."; uint count = 0; diff --git a/ZetaCode/PawnClasses/ZetaBotPawn.zsc b/ZetaCode/PawnClasses/ZetaBotPawn.zsc index ac90b6f..02407ac 100644 --- a/ZetaCode/PawnClasses/ZetaBotPawn.zsc +++ b/ZetaCode/PawnClasses/ZetaBotPawn.zsc @@ -237,7 +237,9 @@ class ZetaBotPawn : Actor if ( w != null ) { - w.vel = Vec3Offset(FRandom(-2, 2), FRandom(-2, 2), FRandom(0, 2.5), true); + w.vel.x = vel.x + FRandom(-5, 5); + w.vel.y = vel.y + FRandom(-5, 5); + w.vel.z = vel.z + FRandom(2, 7); Inventory ammo1 = FindInventory(w.AmmoType1); Inventory ammo2 = FindInventory(w.AmmoType2); diff --git a/ZetaCode/WeaponSupport/Doom/ZetaBFG.zsc b/ZetaCode/WeaponSupport/Doom/ZetaBFG.zsc index e70fb77..a84e114 100644 --- a/ZetaCode/WeaponSupport/Doom/ZetaBFG.zsc +++ b/ZetaCode/WeaponSupport/Doom/ZetaBFG.zsc @@ -4,6 +4,7 @@ class ZetaBFG : ZetaWeapon { ZetaWeapon.FireInterval 11428571; ZetaWeapon.MinAmmo 40; + ZetaWeapon.AmmoUse 40; ZetaWeapon.AmmoType "Cell"; } @@ -31,4 +32,4 @@ class ZetaBFG : ZetaWeapon shooter.SpawnMissileAngle("BFGBall", shooter.angle, pitch); } -} \ No newline at end of file +} diff --git a/ZetaCode/WeaponSupport/Doom/ZetaSSG.zsc b/ZetaCode/WeaponSupport/Doom/ZetaSSG.zsc index dc496c0..aef8173 100644 --- a/ZetaCode/WeaponSupport/Doom/ZetaSSG.zsc +++ b/ZetaCode/WeaponSupport/Doom/ZetaSSG.zsc @@ -4,6 +4,7 @@ class ZetaSSG : ZetaWeapon { ZetaWeapon.FireInterval 15428571; ZetaWeapon.MinAmmo 2; + ZetaWeapon.AmmoUse 2; ZetaWeapon.AmmoType "Shell"; } @@ -27,4 +28,4 @@ class ZetaSSG : ZetaWeapon ZetaBullet.FireBullets(shooter, "Gold", target, random(1, 3), 20, 11.2, 7.1); shooter.A_PlaySound("weapons/sshotf", CHAN_WEAPON); } -} \ No newline at end of file +} diff --git a/ZetaCode/WeaponSupport/SentientMushes/ZetaFireBallista.zsc b/ZetaCode/WeaponSupport/SentientMushes/ZetaFireBallista.zsc index 7b959ce..a0678ea 100644 --- a/ZetaCode/WeaponSupport/SentientMushes/ZetaFireBallista.zsc +++ b/ZetaCode/WeaponSupport/SentientMushes/ZetaFireBallista.zsc @@ -7,6 +7,7 @@ class Minigun : ZetaWeapon ZetaWeapon.MinAmmo 1; ZetaWeapon.AmmoType "BallistaAmmo"; ZetaWeapon.AltMinAmmo 3; + ZetaWeapon.AltAmmoUse 3; ZetaWeapon.AltAmmoType "BallistaAmmo"; } @@ -44,4 +45,4 @@ class Minigun : ZetaWeapon shooter.A_PlaySound("fireballista/shoot"); } -} \ No newline at end of file +} diff --git a/ZetaCode/WeaponSupport/SentientMushes/ZetaHeavyMinigun.zsc b/ZetaCode/WeaponSupport/SentientMushes/ZetaHeavyMinigun.zsc index 993e42c..b2ba17d 100644 --- a/ZetaCode/WeaponSupport/SentientMushes/ZetaHeavyMinigun.zsc +++ b/ZetaCode/WeaponSupport/SentientMushes/ZetaHeavyMinigun.zsc @@ -28,4 +28,4 @@ class ZetaHeavyMinigun : ZetaWeapon shooter.A_PlaySound("ak64/shoot", CHAN_WEAPON); shooter.A_Recoil(0.6); } -} \ No newline at end of file +} diff --git a/ZetaCode/WeaponSupport/SentientMushes/ZetaRocketeer.zsc b/ZetaCode/WeaponSupport/SentientMushes/ZetaRocketeer.zsc index f3ee075..12833df 100644 --- a/ZetaCode/WeaponSupport/SentientMushes/ZetaRocketeer.zsc +++ b/ZetaCode/WeaponSupport/SentientMushes/ZetaRocketeer.zsc @@ -6,6 +6,7 @@ class ZetaRocketeer : ZetaWeapon ZetaWeapon.AltFireInterval 5714285; ZetaWeapon.MinAmmo 1; ZetaWeapon.AltMinAmmo 1; + ZetaWeapon.AltAmmoUse 0; ZetaWeapon.AmmoType "RocketAmmo"; ZetaWeapon.AltAmmoType "RocketAmmo"; } @@ -56,4 +57,4 @@ class ZetaRocketeer : ZetaWeapon shooter.SpawnMissileAngle(rf, shooter.angle, shooter.pitch); } } -} \ No newline at end of file +} diff --git a/ZetaCode/WeaponSupport/Strife/ZetaMauler1.zsc b/ZetaCode/WeaponSupport/Strife/ZetaMauler1.zsc index a14f171..4b1e70d 100644 --- a/ZetaCode/WeaponSupport/Strife/ZetaMauler1.zsc +++ b/ZetaCode/WeaponSupport/Strife/ZetaMauler1.zsc @@ -4,6 +4,7 @@ class ZetaMauler1 : ZetaWeapon { ZetaWeapon.FireInterval 9428571; ZetaWeapon.MinAmmo 20; + ZetaWeapon.AmmoUse 20; ZetaWeapon.AmmoType "EnergyPod1"; } diff --git a/ZetaCode/WeaponSupport/Strife/ZetaMauler2.zsc b/ZetaCode/WeaponSupport/Strife/ZetaMauler2.zsc index 6e2c018..d48eb1d 100644 --- a/ZetaCode/WeaponSupport/Strife/ZetaMauler2.zsc +++ b/ZetaCode/WeaponSupport/Strife/ZetaMauler2.zsc @@ -4,6 +4,7 @@ class ZetaMauler2 : ZetaWeapon { ZetaWeapon.FireInterval 15428571; ZetaWeapon.MinAmmo 30; + ZetaWeapon.AmmoUse 30; ZetaWeapon.AmmoType "EnergyPod"; } diff --git a/ZetaCode/WeaponSupport/ZetaWeapon.zsc b/ZetaCode/WeaponSupport/ZetaWeapon.zsc index 55c53a1..801c86c 100644 --- a/ZetaCode/WeaponSupport/ZetaWeapon.zsc +++ b/ZetaCode/WeaponSupport/ZetaWeapon.zsc @@ -6,6 +6,8 @@ class ZetaWeapon : Actor property AmmoType: ammotype; property AltMinAmmo: altminammo; property AltAmmoType: altammotype; + property AmmoUse: ammouse; + property AltAmmoUse: altammouse; int interval; int altinterval; @@ -13,6 +15,8 @@ class ZetaWeapon : Actor string ammotype; int altminammo; string altammotype; + int ammouse; + int altammouse; default { @@ -20,6 +24,8 @@ class ZetaWeapon : Actor ZetaWeapon.AltFireInterval 10000000; ZetaWeapon.MinAmmo 0; ZetaWeapon.AltMinAmmo 0; + ZetaWeapon.AmmoUse 1; + ZetaWeapon.AltAmmoUse 1; ZetaWeapon.AmmoType "Clip"; ZetaWeapon.AltAmmoType "Clip"; } @@ -242,4 +248,4 @@ class ZTMyWeapon : ZetaWeapon { else shooter.SpawnMissileAngle(ALtMissileType, shooter.angle, target == null ? 0 : ((target.pos.z - shooter.pos.z) * 20 / target.Distance2D(shooter))); } -} \ No newline at end of file +} diff --git a/config b/config index d14e6c7..189eeeb 100644 --- a/config +++ b/config @@ -1,6 +1,6 @@ #!/bin/bash NAME=ZetaBot -VERSION=0.5.1 +VERSION=0.6.0 ADDFOLDER ZetaCode ADDFOLDER sprites