share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
changeset 13278 8f579173b161
parent 12355 193eba524369
child 14406 6c21bd8547dd
equal deleted inserted replaced
13277:5984e8c6cbeb 13278:8f579173b161
    56 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    56 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    57 
    57 
    58 local numhhs = 0
    58 local numhhs = 0
    59 local hhs = {}
    59 local hhs = {}
    60 
    60 
    61 local currName
       
    62 local lastName
       
    63 local started = false
    61 local started = false
    64 local switchStage = 0
       
    65 
       
    66 local hogCounter
       
    67 
       
    68 function CountHog(gear)
       
    69 	hogCounter = hogCounter +1
       
    70 end
       
    71 
    62 
    72 function onNewAmmoStore(groupIndex, hogIndex)
    63 function onNewAmmoStore(groupIndex, hogIndex)
    73 
    64 
    74 	SetAmmo(amSkip, 9, 0, 0, 0)
    65 	SetAmmo(amSkip, 9, 0, 0, 0)
    75 
    66 
   181 
   172 
   182 end
   173 end
   183 
   174 
   184 function onGameInit()
   175 function onGameInit()
   185 	ClearGameFlags()
   176 	ClearGameFlags()
   186 	EnableGameFlags(gfRandomOrder, gfResetWeps, gfInfAttack, gfPlaceHog, gfPerHogAmmo)
   177 	EnableGameFlags(gfRandomOrder, gfResetWeps, gfInfAttack, gfPlaceHog, gfPerHogAmmo, gfSwitchHog)
   187 	Delay = 10
   178 	Delay = 10
   188 	HealthCaseProb = 100
   179 	HealthCaseProb = 100
   189 end
   180 end
   190 
   181 
   191 function onGameStart()
   182 function onGameStart()
   211 
   202 
   212 end
   203 end
   213 
   204 
   214 
   205 
   215 function onNewTurn()
   206 function onNewTurn()
   216 	currName = GetHogName(CurrentHedgehog)
   207 
   217 	lastName = GetHogName(CurrentHedgehog)
       
   218 	started = true
   208 	started = true
   219 	switchStage = 0
   209 	AddCaption(loc("Prepare yourself") .. ", " .. GetHogName(CurrentHedgehog).. "!")
   220 end
       
   221 
       
   222 function onGameTick20()
       
   223 
       
   224 	if (CurrentHedgehog ~= nil) then
       
   225 
       
   226 		currName = GetHogName(CurrentHedgehog)
       
   227 
       
   228 		if (currName ~= lastName) and (switchStage > 5) then
       
   229 			AddCaption(loc("Switched to ") .. currName .. "!")
       
   230 		end
       
   231 
       
   232 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 5) then
       
   233 
       
   234 			AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!")
       
   235 
       
   236 			hogCounter = 0
       
   237 			runOnHogsInTeam(CountHog, GetHogTeamName(CurrentHedgehog) )
       
   238 
       
   239 			if hogCounter > 1 then
       
   240 
       
   241 				switchStage = switchStage + 1
       
   242 
       
   243 				if switchStage == 1 then
       
   244 					AddAmmo(CurrentHedgehog, amSwitch, 1)
       
   245 
       
   246 				elseif switchStage == 2 then
       
   247 					SetWeapon(amSwitch)
       
   248 				elseif switchStage == 3 then
       
   249 					SetGearMessage(CurrentHedgehog,gmAttack)
       
   250 				elseif switchStage == 4 then
       
   251 					switchStage = 6
       
   252 					AddAmmo(CurrentHedgehog, amSwitch, 0)
       
   253 				end
       
   254 
       
   255 			else
       
   256 				switchStage = 6
       
   257 			end
       
   258 
       
   259 
       
   260 		end
       
   261 
       
   262 		lastName = currName
       
   263 
       
   264 	end
       
   265 
   210 
   266 end
   211 end
   267 
   212 
   268 function onGearAdd(gear)
   213 function onGearAdd(gear)
   269 
   214 
   276 
   221 
   277 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
   222 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
   278 		trackGear(gear)
   223 		trackGear(gear)
   279 	end
   224 	end
   280 
   225 
   281 
       
   282 end
   226 end
   283 
   227 
   284 function onGearDelete(gear)
   228 function onGearDelete(gear)
   285 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
   229 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
   286 		trackDeletion(gear)
   230 		trackDeletion(gear)
   287 	end
   231 	end
   288 end
   232 end
   289 
   233 
   290 function onAmmoStoreInit()
       
   291 --
       
   292 end
       
   293