use per hog ammo game flag. improves AI play
authormikade
Sun, 26 Feb 2012 16:31:25 -0500
changeset 6747 3f85b103f29f
parent 6746 e13058484d72
child 6748 9d8763deee42
use per hog ammo game flag. improves AI play
share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua	Sun Feb 26 15:42:28 2012 -0500
+++ b/share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua	Sun Feb 26 16:31:25 2012 -0500
@@ -1,5 +1,5 @@
 ----------------------------------
--- THE SPECIALISTS MODE 0.6
+-- THE SPECIALISTS MODE 0.7
 -- by mikade
 ----------------------------------
 
@@ -40,13 +40,17 @@
 ----------------
 -- for the meanwhile, don't drop any crates except health crates
 
+----------------
+-- version 0.7
+----------------
+-- perhogadmsdf :D :D :D :D
+
 --------------------
 --TO DO
 --------------------
 
 -- balance hog health, maybe
 -- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
--- set crate drops etc. (super crate for each class? or will this ruin the mode's simplicity?)
 
 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
@@ -65,168 +69,128 @@
 	hogCounter = hogCounter +1
 end
 
-function CreateTeam()
-
-        currTeam = ""
-        lastTeam = ""
-        z = 0
-
-        for i = 0, (numhhs-1) do
-
-                currTeam = GetHogTeamName(hhs[i])
-
-                if currTeam == lastTeam then
-                        z = z + 1
-                else
-                        z = 1
-                end
+function onNewAmmoStore(groupIndex, hogIndex)
 
-                if z == 1 then
-
-                        SetHogName(hhs[i],"Soldier")
-                        SetHogHat(hhs[i], "sf_vega")
-                        SetHealth(hhs[i],200)
-
-                elseif z == 2 then
-
-                        SetHogHat(hhs[i], "Glasses")
-                        SetHogName(hhs[i],"Engineer")
-
-                elseif z == 3 then
-
-                        SetHogName(hhs[i],"Ninja")
-                        SetHogHat(hhs[i], "NinjaFull")
-                        SetHealth(hhs[i],80)
+	SetAmmo(amSkip, 9, 0, 0, 0)
 
-                elseif z == 4 then
-
-                        SetHogName(hhs[i],"Demo")
-                        SetHogHat(hhs[i], "Skull")
-                        SetHealth(hhs[i],200)
-
-                elseif z == 5 then
-
-                        SetHogName(hhs[i],"Sniper")
-                        SetHogHat(hhs[i], "Sniper")
-                        SetHealth(hhs[i],120)
-
-                elseif z == 6 then
-
-                        SetHogName(hhs[i],"Saint")
-                        SetHogHat(hhs[i], "angel")
-                        SetHealth(hhs[i],300)
-
-                elseif z == 7 then
-
-                        SetHogName(hhs[i],"Pyro")
-                        SetHogHat(hhs[i], "Gasmask")
-                        SetHealth(hhs[i],150)
-
-                elseif z == 8 then
-
-                        SetHogName(hhs[i],"Loon")
-                        SetHogHat(hhs[i], "clown")
-                        SetHealth(hhs[i],100)
-
-                end
-
-                lastTeam = GetHogTeamName(hhs[i])
-
-        end
+	if hogIndex == 0 then
+		SetAmmo(amBazooka, 1, 0, 0, 0)
+		SetAmmo(amGrenade, 1, 0, 0, 0)
+		SetAmmo(amShotgun, 1, 0, 0, 0)
+	elseif hogIndex == 1 then
+		SetAmmo(amGirder, 2, 0, 0, 0)
+		SetAmmo(amBlowTorch, 1, 0, 0, 0)
+		SetAmmo(amPickHammer, 1, 0, 0, 0)
+	elseif hogIndex == 2 then
+		SetAmmo(amRope, 9, 0, 0, 0)
+		SetAmmo(amParachute, 9, 0, 0, 0)
+		SetAmmo(amFirePunch, 1, 0, 0, 0)
+	elseif hogIndex == 3 then
+		SetAmmo(amDynamite, 1, 0, 0, 0)
+		SetAmmo(amMine, 1, 0, 0, 0)
+		SetAmmo(amDrill, 1, 0, 0, 0)
+	elseif hogIndex == 4 then
+		SetAmmo(amSniperRifle, 1, 0, 0, 0)
+		SetAmmo(amDEagle, 1, 0, 0, 0)
+		SetAmmo(amPortalGun, 2, 0, 0, 0)
+	elseif hogIndex == 5 then
+		SetAmmo(amSeduction, 9, 0, 0, 0)
+		SetAmmo(amResurrector, 1, 0, 0, 0)
+		SetAmmo(amInvulnerable, 1, 0, 0, 0)
+	elseif hogIndex == 6 then
+		SetAmmo(amFlamethrower, 1, 0, 0, 0)
+		SetAmmo(amMolotov, 1, 0, 0, 0)
+		SetAmmo(amNapalm, 1, 0, 0, 0)
+	elseif hogIndex == 7 then
+		SetAmmo(amBaseballBat, 1, 0, 0, 0)
+		SetAmmo(amGasBomb, 1, 0, 0, 0)
+		SetAmmo(amKamikaze, 1, 0, 0, 0)
+	end
 
 end
 
-function ResetAllAmmo()
+function CreateTeam()
 
-        AddAmmo(CurrentHedgehog, amBazooka, 0)
-        AddAmmo(CurrentHedgehog, amGrenade, 0)
-        AddAmmo(CurrentHedgehog, amShotgun, 0)
+	currTeam = ""
+	lastTeam = ""
+	z = 0
+
+	for i = 0, (numhhs-1) do
 
-        AddAmmo(CurrentHedgehog, amGirder, 0)
-        AddAmmo(CurrentHedgehog, amBlowTorch, 0)
-        AddAmmo(CurrentHedgehog, amPickHammer, 0)
-        AddAmmo(CurrentHedgehog, amSwitch, 0)
+			currTeam = GetHogTeamName(hhs[i])
 
-        AddAmmo(CurrentHedgehog, amRope, 0)
-        AddAmmo(CurrentHedgehog, amParachute, 0)
-        AddAmmo(CurrentHedgehog, amFirePunch, 0)
-
-        AddAmmo(CurrentHedgehog, amDynamite, 0)
-        AddAmmo(CurrentHedgehog, amDrill, 0)
-        AddAmmo(CurrentHedgehog, amMine, 0)
+			if currTeam == lastTeam then
+					z = z + 1
+			else
+					z = 1
+			end
 
-        AddAmmo(CurrentHedgehog, amSniperRifle, 0)
-        AddAmmo(CurrentHedgehog, amDEagle, 0)
-        AddAmmo(CurrentHedgehog, amPortalGun, 0)
+			if z == 1 then
 
-        AddAmmo(CurrentHedgehog, amSeduction, 0)
-        AddAmmo(CurrentHedgehog, amResurrector, 0)
-        AddAmmo(CurrentHedgehog, amInvulnerable, 0)
+					SetHogName(hhs[i],"Soldier")
+					SetHogHat(hhs[i], "sf_vega")
+					SetHealth(hhs[i],200)
+
+			elseif z == 2 then
 
-        AddAmmo(CurrentHedgehog, amFlamethrower, 0)
-        AddAmmo(CurrentHedgehog, amMolotov, 0)
-        AddAmmo(CurrentHedgehog, amNapalm, 0)
+					SetHogHat(hhs[i], "Glasses")
+					SetHogName(hhs[i],"Engineer")
 
-        AddAmmo(CurrentHedgehog, amBaseballBat, 0)
-        AddAmmo(CurrentHedgehog, amGasBomb, 0)
-        AddAmmo(CurrentHedgehog, amKamikaze, 0)
+			elseif z == 3 then
 
-end
-
-function AssignAmmo()
+					SetHogName(hhs[i],"Ninja")
+					SetHogHat(hhs[i], "NinjaFull")
+					SetHealth(hhs[i],80)
 
-        ResetAllAmmo()
-        n = GetHogName(CurrentHedgehog)
+			elseif z == 4 then
+
+					SetHogName(hhs[i],"Demo")
+					SetHogHat(hhs[i], "Skull")
+					SetHealth(hhs[i],200)
+
+			elseif z == 5 then
 
-        AddAmmo(CurrentHedgehog, amSkip,100)
+					SetHogName(hhs[i],"Sniper")
+					SetHogHat(hhs[i], "Sniper")
+					SetHealth(hhs[i],120)
+
+			elseif z == 6 then
+
+					SetHogName(hhs[i],"Saint")
+					SetHogHat(hhs[i], "angel")
+					SetHealth(hhs[i],300)
 
-        if n == "Soldier" then
-                AddAmmo(CurrentHedgehog, amBazooka,1)
-                AddAmmo(CurrentHedgehog, amGrenade,1)
-                AddAmmo(CurrentHedgehog, amShotgun,1)
-        elseif n == "Engineer" then
-                AddAmmo(CurrentHedgehog, amGirder, 2)
-                AddAmmo(CurrentHedgehog, amBlowTorch, 1)
-                AddAmmo(CurrentHedgehog, amPickHammer, 1)
-        elseif n == "Ninja" then
-                AddAmmo(CurrentHedgehog, amRope, 100)
-                AddAmmo(CurrentHedgehog, amParachute, 100)
-                AddAmmo(CurrentHedgehog, amFirePunch, 1)
-        elseif n == "Demo" then
-                AddAmmo(CurrentHedgehog, amDynamite, 1)
-                AddAmmo(CurrentHedgehog, amMine, 1)
-                AddAmmo(CurrentHedgehog, amDrill, 1)
-        elseif n == "Sniper" then
-                AddAmmo(CurrentHedgehog, amSniperRifle, 1)
-                AddAmmo(CurrentHedgehog, amDEagle, 1)
-                AddAmmo(CurrentHedgehog, amPortalGun, 2)
-        elseif n == "Saint" then
-                AddAmmo(CurrentHedgehog, amSeduction, 100)
-                AddAmmo(CurrentHedgehog, amResurrector, 1)
-                AddAmmo(CurrentHedgehog, amInvulnerable, 1)
-        elseif n == "Pyro" then
-                AddAmmo(CurrentHedgehog, amFlamethrower, 1)
-                AddAmmo(CurrentHedgehog, amMolotov, 1)
-                AddAmmo(CurrentHedgehog, amNapalm, 1)
-        elseif n == "Loon" then
-                AddAmmo(CurrentHedgehog, amBaseballBat, 1)
-                AddAmmo(CurrentHedgehog, amGasBomb, 1)
-                AddAmmo(CurrentHedgehog, amKamikaze, 1)
-        end
+			elseif z == 7 then
+
+					SetHogName(hhs[i],"Pyro")
+					SetHogHat(hhs[i], "Gasmask")
+					SetHealth(hhs[i],150)
+
+			elseif z == 8 then
+
+					SetHogName(hhs[i],"Loon")
+					SetHogHat(hhs[i], "clown")
+					SetHealth(hhs[i],100)
+
+			end
+
+			lastTeam = GetHogTeamName(hhs[i])
+
+	end
 
 end
 
 function onGameInit()
-        GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog
-        Delay = 10
+	GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog +gfPerHogAmmo
+	Delay = 10
 	HealthCaseProb = 100
 end
 
 function onGameStart()
 
-        CreateTeam()
+	CreateTeam()
 
-        ShowMission     (
+	ShowMission     (
                                 loc("THE SPECIALISTS"),
                                 loc("a Hedgewars mini-game"),
 
@@ -247,11 +211,10 @@
 
 
 function onNewTurn()
-        currName = GetHogName(CurrentHedgehog)
-        lastName = GetHogName(CurrentHedgehog)
-        AssignAmmo()
-        started = true
-        switchStage = 0
+	currName = GetHogName(CurrentHedgehog)
+	lastName = GetHogName(CurrentHedgehog)
+	started = true
+	switchStage = 0
 end
 
 function onGameTick()
@@ -262,7 +225,6 @@
 
 		if (currName ~= lastName) and (switchStage > 100) then
 			AddCaption(loc("Switched to ") .. currName .. "!")
-			AssignAmmo()
 		end
 
 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then
@@ -303,10 +265,10 @@
 
 function onGearAdd(gear)
 
-        if GetGearType(gear) == gtHedgehog then
-                hhs[numhhs] = gear
-                numhhs = numhhs + 1
-        elseif (GetGearType(gear) == gtMine) and (started == true) then
+    if GetGearType(gear) == gtHedgehog then
+		hhs[numhhs] = gear
+		numhhs = numhhs + 1
+	elseif (GetGearType(gear) == gtMine) and (started == true) then
 		SetTimer(gear,5000)
 	end