share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
changeset 6747 3f85b103f29f
parent 5827 a416f1070fdf
child 7143 cd86f95b46c9
equal deleted inserted replaced
6746:e13058484d72 6747:3f85b103f29f
     1 ----------------------------------
     1 ----------------------------------
     2 -- THE SPECIALISTS MODE 0.6
     2 -- THE SPECIALISTS MODE 0.7
     3 -- by mikade
     3 -- by mikade
     4 ----------------------------------
     4 ----------------------------------
     5 
     5 
     6 -- version history
     6 -- version history
     7 -----------------
     7 -----------------
    38 ----------------
    38 ----------------
    39 -- version 0.6
    39 -- version 0.6
    40 ----------------
    40 ----------------
    41 -- for the meanwhile, don't drop any crates except health crates
    41 -- for the meanwhile, don't drop any crates except health crates
    42 
    42 
       
    43 ----------------
       
    44 -- version 0.7
       
    45 ----------------
       
    46 -- perhogadmsdf :D :D :D :D
       
    47 
    43 --------------------
    48 --------------------
    44 --TO DO
    49 --TO DO
    45 --------------------
    50 --------------------
    46 
    51 
    47 -- balance hog health, maybe
    52 -- balance hog health, maybe
    48 -- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
    53 -- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
    49 -- set crate drops etc. (super crate for each class? or will this ruin the mode's simplicity?)
       
    50 
    54 
    51 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    55 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    52 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
    56 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
    53 
    57 
    54 local numhhs = 0
    58 local numhhs = 0
    63 
    67 
    64 function CountHog(gear)
    68 function CountHog(gear)
    65 	hogCounter = hogCounter +1
    69 	hogCounter = hogCounter +1
    66 end
    70 end
    67 
    71 
       
    72 function onNewAmmoStore(groupIndex, hogIndex)
       
    73 
       
    74 	SetAmmo(amSkip, 9, 0, 0, 0)
       
    75 
       
    76 	if hogIndex == 0 then
       
    77 		SetAmmo(amBazooka, 1, 0, 0, 0)
       
    78 		SetAmmo(amGrenade, 1, 0, 0, 0)
       
    79 		SetAmmo(amShotgun, 1, 0, 0, 0)
       
    80 	elseif hogIndex == 1 then
       
    81 		SetAmmo(amGirder, 2, 0, 0, 0)
       
    82 		SetAmmo(amBlowTorch, 1, 0, 0, 0)
       
    83 		SetAmmo(amPickHammer, 1, 0, 0, 0)
       
    84 	elseif hogIndex == 2 then
       
    85 		SetAmmo(amRope, 9, 0, 0, 0)
       
    86 		SetAmmo(amParachute, 9, 0, 0, 0)
       
    87 		SetAmmo(amFirePunch, 1, 0, 0, 0)
       
    88 	elseif hogIndex == 3 then
       
    89 		SetAmmo(amDynamite, 1, 0, 0, 0)
       
    90 		SetAmmo(amMine, 1, 0, 0, 0)
       
    91 		SetAmmo(amDrill, 1, 0, 0, 0)
       
    92 	elseif hogIndex == 4 then
       
    93 		SetAmmo(amSniperRifle, 1, 0, 0, 0)
       
    94 		SetAmmo(amDEagle, 1, 0, 0, 0)
       
    95 		SetAmmo(amPortalGun, 2, 0, 0, 0)
       
    96 	elseif hogIndex == 5 then
       
    97 		SetAmmo(amSeduction, 9, 0, 0, 0)
       
    98 		SetAmmo(amResurrector, 1, 0, 0, 0)
       
    99 		SetAmmo(amInvulnerable, 1, 0, 0, 0)
       
   100 	elseif hogIndex == 6 then
       
   101 		SetAmmo(amFlamethrower, 1, 0, 0, 0)
       
   102 		SetAmmo(amMolotov, 1, 0, 0, 0)
       
   103 		SetAmmo(amNapalm, 1, 0, 0, 0)
       
   104 	elseif hogIndex == 7 then
       
   105 		SetAmmo(amBaseballBat, 1, 0, 0, 0)
       
   106 		SetAmmo(amGasBomb, 1, 0, 0, 0)
       
   107 		SetAmmo(amKamikaze, 1, 0, 0, 0)
       
   108 	end
       
   109 
       
   110 end
       
   111 
    68 function CreateTeam()
   112 function CreateTeam()
    69 
   113 
    70         currTeam = ""
   114 	currTeam = ""
    71         lastTeam = ""
   115 	lastTeam = ""
    72         z = 0
   116 	z = 0
    73 
   117 
    74         for i = 0, (numhhs-1) do
   118 	for i = 0, (numhhs-1) do
    75 
   119 
    76                 currTeam = GetHogTeamName(hhs[i])
   120 			currTeam = GetHogTeamName(hhs[i])
    77 
   121 
    78                 if currTeam == lastTeam then
   122 			if currTeam == lastTeam then
    79                         z = z + 1
   123 					z = z + 1
    80                 else
   124 			else
    81                         z = 1
   125 					z = 1
    82                 end
   126 			end
    83 
   127 
    84                 if z == 1 then
   128 			if z == 1 then
    85 
   129 
    86                         SetHogName(hhs[i],"Soldier")
   130 					SetHogName(hhs[i],"Soldier")
    87                         SetHogHat(hhs[i], "sf_vega")
   131 					SetHogHat(hhs[i], "sf_vega")
    88                         SetHealth(hhs[i],200)
   132 					SetHealth(hhs[i],200)
    89 
   133 
    90                 elseif z == 2 then
   134 			elseif z == 2 then
    91 
   135 
    92                         SetHogHat(hhs[i], "Glasses")
   136 					SetHogHat(hhs[i], "Glasses")
    93                         SetHogName(hhs[i],"Engineer")
   137 					SetHogName(hhs[i],"Engineer")
    94 
   138 
    95                 elseif z == 3 then
   139 			elseif z == 3 then
    96 
   140 
    97                         SetHogName(hhs[i],"Ninja")
   141 					SetHogName(hhs[i],"Ninja")
    98                         SetHogHat(hhs[i], "NinjaFull")
   142 					SetHogHat(hhs[i], "NinjaFull")
    99                         SetHealth(hhs[i],80)
   143 					SetHealth(hhs[i],80)
   100 
   144 
   101                 elseif z == 4 then
   145 			elseif z == 4 then
   102 
   146 
   103                         SetHogName(hhs[i],"Demo")
   147 					SetHogName(hhs[i],"Demo")
   104                         SetHogHat(hhs[i], "Skull")
   148 					SetHogHat(hhs[i], "Skull")
   105                         SetHealth(hhs[i],200)
   149 					SetHealth(hhs[i],200)
   106 
   150 
   107                 elseif z == 5 then
   151 			elseif z == 5 then
   108 
   152 
   109                         SetHogName(hhs[i],"Sniper")
   153 					SetHogName(hhs[i],"Sniper")
   110                         SetHogHat(hhs[i], "Sniper")
   154 					SetHogHat(hhs[i], "Sniper")
   111                         SetHealth(hhs[i],120)
   155 					SetHealth(hhs[i],120)
   112 
   156 
   113                 elseif z == 6 then
   157 			elseif z == 6 then
   114 
   158 
   115                         SetHogName(hhs[i],"Saint")
   159 					SetHogName(hhs[i],"Saint")
   116                         SetHogHat(hhs[i], "angel")
   160 					SetHogHat(hhs[i], "angel")
   117                         SetHealth(hhs[i],300)
   161 					SetHealth(hhs[i],300)
   118 
   162 
   119                 elseif z == 7 then
   163 			elseif z == 7 then
   120 
   164 
   121                         SetHogName(hhs[i],"Pyro")
   165 					SetHogName(hhs[i],"Pyro")
   122                         SetHogHat(hhs[i], "Gasmask")
   166 					SetHogHat(hhs[i], "Gasmask")
   123                         SetHealth(hhs[i],150)
   167 					SetHealth(hhs[i],150)
   124 
   168 
   125                 elseif z == 8 then
   169 			elseif z == 8 then
   126 
   170 
   127                         SetHogName(hhs[i],"Loon")
   171 					SetHogName(hhs[i],"Loon")
   128                         SetHogHat(hhs[i], "clown")
   172 					SetHogHat(hhs[i], "clown")
   129                         SetHealth(hhs[i],100)
   173 					SetHealth(hhs[i],100)
   130 
   174 
   131                 end
   175 			end
   132 
   176 
   133                 lastTeam = GetHogTeamName(hhs[i])
   177 			lastTeam = GetHogTeamName(hhs[i])
   134 
   178 
   135         end
   179 	end
   136 
       
   137 end
       
   138 
       
   139 function ResetAllAmmo()
       
   140 
       
   141         AddAmmo(CurrentHedgehog, amBazooka, 0)
       
   142         AddAmmo(CurrentHedgehog, amGrenade, 0)
       
   143         AddAmmo(CurrentHedgehog, amShotgun, 0)
       
   144 
       
   145         AddAmmo(CurrentHedgehog, amGirder, 0)
       
   146         AddAmmo(CurrentHedgehog, amBlowTorch, 0)
       
   147         AddAmmo(CurrentHedgehog, amPickHammer, 0)
       
   148         AddAmmo(CurrentHedgehog, amSwitch, 0)
       
   149 
       
   150         AddAmmo(CurrentHedgehog, amRope, 0)
       
   151         AddAmmo(CurrentHedgehog, amParachute, 0)
       
   152         AddAmmo(CurrentHedgehog, amFirePunch, 0)
       
   153 
       
   154         AddAmmo(CurrentHedgehog, amDynamite, 0)
       
   155         AddAmmo(CurrentHedgehog, amDrill, 0)
       
   156         AddAmmo(CurrentHedgehog, amMine, 0)
       
   157 
       
   158         AddAmmo(CurrentHedgehog, amSniperRifle, 0)
       
   159         AddAmmo(CurrentHedgehog, amDEagle, 0)
       
   160         AddAmmo(CurrentHedgehog, amPortalGun, 0)
       
   161 
       
   162         AddAmmo(CurrentHedgehog, amSeduction, 0)
       
   163         AddAmmo(CurrentHedgehog, amResurrector, 0)
       
   164         AddAmmo(CurrentHedgehog, amInvulnerable, 0)
       
   165 
       
   166         AddAmmo(CurrentHedgehog, amFlamethrower, 0)
       
   167         AddAmmo(CurrentHedgehog, amMolotov, 0)
       
   168         AddAmmo(CurrentHedgehog, amNapalm, 0)
       
   169 
       
   170         AddAmmo(CurrentHedgehog, amBaseballBat, 0)
       
   171         AddAmmo(CurrentHedgehog, amGasBomb, 0)
       
   172         AddAmmo(CurrentHedgehog, amKamikaze, 0)
       
   173 
       
   174 end
       
   175 
       
   176 function AssignAmmo()
       
   177 
       
   178         ResetAllAmmo()
       
   179         n = GetHogName(CurrentHedgehog)
       
   180 
       
   181         AddAmmo(CurrentHedgehog, amSkip,100)
       
   182 
       
   183         if n == "Soldier" then
       
   184                 AddAmmo(CurrentHedgehog, amBazooka,1)
       
   185                 AddAmmo(CurrentHedgehog, amGrenade,1)
       
   186                 AddAmmo(CurrentHedgehog, amShotgun,1)
       
   187         elseif n == "Engineer" then
       
   188                 AddAmmo(CurrentHedgehog, amGirder, 2)
       
   189                 AddAmmo(CurrentHedgehog, amBlowTorch, 1)
       
   190                 AddAmmo(CurrentHedgehog, amPickHammer, 1)
       
   191         elseif n == "Ninja" then
       
   192                 AddAmmo(CurrentHedgehog, amRope, 100)
       
   193                 AddAmmo(CurrentHedgehog, amParachute, 100)
       
   194                 AddAmmo(CurrentHedgehog, amFirePunch, 1)
       
   195         elseif n == "Demo" then
       
   196                 AddAmmo(CurrentHedgehog, amDynamite, 1)
       
   197                 AddAmmo(CurrentHedgehog, amMine, 1)
       
   198                 AddAmmo(CurrentHedgehog, amDrill, 1)
       
   199         elseif n == "Sniper" then
       
   200                 AddAmmo(CurrentHedgehog, amSniperRifle, 1)
       
   201                 AddAmmo(CurrentHedgehog, amDEagle, 1)
       
   202                 AddAmmo(CurrentHedgehog, amPortalGun, 2)
       
   203         elseif n == "Saint" then
       
   204                 AddAmmo(CurrentHedgehog, amSeduction, 100)
       
   205                 AddAmmo(CurrentHedgehog, amResurrector, 1)
       
   206                 AddAmmo(CurrentHedgehog, amInvulnerable, 1)
       
   207         elseif n == "Pyro" then
       
   208                 AddAmmo(CurrentHedgehog, amFlamethrower, 1)
       
   209                 AddAmmo(CurrentHedgehog, amMolotov, 1)
       
   210                 AddAmmo(CurrentHedgehog, amNapalm, 1)
       
   211         elseif n == "Loon" then
       
   212                 AddAmmo(CurrentHedgehog, amBaseballBat, 1)
       
   213                 AddAmmo(CurrentHedgehog, amGasBomb, 1)
       
   214                 AddAmmo(CurrentHedgehog, amKamikaze, 1)
       
   215         end
       
   216 
   180 
   217 end
   181 end
   218 
   182 
   219 function onGameInit()
   183 function onGameInit()
   220         GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog
   184 	GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog +gfPerHogAmmo
   221         Delay = 10
   185 	Delay = 10
   222 	HealthCaseProb = 100
   186 	HealthCaseProb = 100
   223 end
   187 end
   224 
   188 
   225 function onGameStart()
   189 function onGameStart()
   226 
   190 
   227         CreateTeam()
   191 	CreateTeam()
   228 
   192 
   229         ShowMission     (
   193 	ShowMission     (
   230                                 loc("THE SPECIALISTS"),
   194                                 loc("THE SPECIALISTS"),
   231                                 loc("a Hedgewars mini-game"),
   195                                 loc("a Hedgewars mini-game"),
   232 
   196 
   233                                 loc("Eliminate the enemy specialists.") .. "|" ..
   197                                 loc("Eliminate the enemy specialists.") .. "|" ..
   234                                 " " .. "|" ..
   198                                 " " .. "|" ..
   245 
   209 
   246 end
   210 end
   247 
   211 
   248 
   212 
   249 function onNewTurn()
   213 function onNewTurn()
   250         currName = GetHogName(CurrentHedgehog)
   214 	currName = GetHogName(CurrentHedgehog)
   251         lastName = GetHogName(CurrentHedgehog)
   215 	lastName = GetHogName(CurrentHedgehog)
   252         AssignAmmo()
   216 	started = true
   253         started = true
   217 	switchStage = 0
   254         switchStage = 0
       
   255 end
   218 end
   256 
   219 
   257 function onGameTick()
   220 function onGameTick()
   258 
   221 
   259 	if (CurrentHedgehog ~= nil) then
   222 	if (CurrentHedgehog ~= nil) then
   260 
   223 
   261 		currName = GetHogName(CurrentHedgehog)
   224 		currName = GetHogName(CurrentHedgehog)
   262 
   225 
   263 		if (currName ~= lastName) and (switchStage > 100) then
   226 		if (currName ~= lastName) and (switchStage > 100) then
   264 			AddCaption(loc("Switched to ") .. currName .. "!")
   227 			AddCaption(loc("Switched to ") .. currName .. "!")
   265 			AssignAmmo()
       
   266 		end
   228 		end
   267 
   229 
   268 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then
   230 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then
   269 
   231 
   270 			AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!")
   232 			AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!")
   301 
   263 
   302 end
   264 end
   303 
   265 
   304 function onGearAdd(gear)
   266 function onGearAdd(gear)
   305 
   267 
   306         if GetGearType(gear) == gtHedgehog then
   268     if GetGearType(gear) == gtHedgehog then
   307                 hhs[numhhs] = gear
   269 		hhs[numhhs] = gear
   308                 numhhs = numhhs + 1
   270 		numhhs = numhhs + 1
   309         elseif (GetGearType(gear) == gtMine) and (started == true) then
   271 	elseif (GetGearType(gear) == gtMine) and (started == true) then
   310 		SetTimer(gear,5000)
   272 		SetTimer(gear,5000)
   311 	end
   273 	end
   312 
   274 
   313 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
   275 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
   314 		trackGear(gear)
   276 		trackGear(gear)