share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
changeset 5457 48fe8e03a9cf
parent 5382 d5321b22aed2
child 5797 d61cd92865c2
equal deleted inserted replaced
5455:df05cdb998ed 5457:48fe8e03a9cf
     1 ----------------------------------
     1 ----------------------------------
     2 -- THE SPECIALISTS MODE 0.4
     2 -- THE SPECIALISTS MODE 0.5
     3 -- by mikade
     3 -- by mikade
     4 ----------------------------------
     4 ----------------------------------
     5 
     5 
     6 -- version history
     6 -- version history
     7 -----------------
     7 -----------------
    27 ----------------
    27 ----------------
    28 -- Attempted to:
    28 -- Attempted to:
    29 -- fix potential switch explit
    29 -- fix potential switch explit
    30 -- improve user feedback on start
    30 -- improve user feedback on start
    31 
    31 
       
    32 ----------------
       
    33 -- version 0.5
       
    34 ----------------
       
    35 -- provision for variable minetimer / demo mines set to 5000ms
       
    36 -- don't autoswitch if player only has 1 hog on his team
       
    37 
    32 --------------------
    38 --------------------
    33 --TO DO
    39 --TO DO
    34 --------------------
    40 --------------------
    35 
    41 
    36 -- add proper gameflag checking, maybe
    42 -- balance hog health, maybe
    37 -- set crate drops etc.
    43 -- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
    38 -- add alternative switch
    44 -- set crate drops etc. (super crate for each class? or will this ruin the mode's simplicity?)
    39 
    45 
    40 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    46 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
    47 loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
    41 
    48 
    42 local numhhs = 0
    49 local numhhs = 0
    43 local hhs = {}
    50 local hhs = {}
    44 
    51 
    45 local currName
    52 local currName
    46 local lastName
    53 local lastName
    47 local started = false
    54 local started = false
    48 local switchStage = 0
    55 local switchStage = 0
       
    56 
       
    57 local hogCounter
       
    58 
       
    59 function CountHog(gear)
       
    60 	hogCounter = hogCounter +1
       
    61 end
    49 
    62 
    50 function CreateTeam()
    63 function CreateTeam()
    51 
    64 
    52         currTeam = ""
    65         currTeam = ""
    53         lastTeam = ""
    66         lastTeam = ""
   220                                 loc("Unlimited Attacks") .. "|" ..
   233                                 loc("Unlimited Attacks") .. "|" ..
   221 
   234 
   222                                 "", 4, 4000
   235                                 "", 4, 4000
   223                                 )
   236                                 )
   224 
   237 
       
   238 	trackTeams()
       
   239 
   225 end
   240 end
   226 
   241 
   227 
   242 
   228 function onNewTurn()
   243 function onNewTurn()
   229         currName = GetHogName(CurrentHedgehog)
   244         currName = GetHogName(CurrentHedgehog)
   230         lastName = GetHogName(CurrentHedgehog)
   245         lastName = GetHogName(CurrentHedgehog)
   231         AssignAmmo()
   246         AssignAmmo()
   232 
   247         started = true
   233         ---------------
       
   234         --switch
       
   235         started = false
       
   236         switchStage = 0
   248         switchStage = 0
   237         --AddAmmo(CurrentHedgehog, amSwitch, 1)
       
   238 	---------------
       
   239 
       
   240 end
   249 end
   241 
   250 
   242 function onGameTick()
   251 function onGameTick()
   243 
   252 
   244 	if (CurrentHedgehog ~= nil) then
   253 	if (CurrentHedgehog ~= nil) then
   252 
   261 
   253 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then			
   262 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then			
   254 			
   263 			
   255 			AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!") 
   264 			AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!") 
   256 
   265 
   257 			switchStage = switchStage + 1	
   266 			hogCounter = 0
       
   267 			runOnHogsInTeam(CountHog, GetHogTeamName(CurrentHedgehog) )
       
   268 
       
   269 			if hogCounter > 1 then
       
   270 
       
   271 				switchStage = switchStage + 1	
   258 			
   272 			
   259 			if switchStage == 1 then
   273 				if switchStage == 1 then
   260 				AddAmmo(CurrentHedgehog, amSwitch, 1)
   274 					AddAmmo(CurrentHedgehog, amSwitch, 1)
   261 				
   275 				
   262 			elseif switchStage == 2 then
   276 				elseif switchStage == 2 then
   263 				ParseCommand("setweap " .. string.char(amSwitch))
   277 					ParseCommand("setweap " .. string.char(amSwitch))
   264 			elseif switchStage == 3 then
   278 				elseif switchStage == 3 then
   265 				SetGearMessage(CurrentHedgehog,gmAttack) 
   279 					SetGearMessage(CurrentHedgehog,gmAttack) 
   266 			elseif switchStage == 4 then
   280 				elseif switchStage == 4 then
       
   281 					switchStage = 110
       
   282 					AddAmmo(CurrentHedgehog, amSwitch, 0)
       
   283 				end
       
   284 			
       
   285 			else
   267 				switchStage = 110
   286 				switchStage = 110
   268 				AddAmmo(CurrentHedgehog, amSwitch, 0)
       
   269 			end
   287 			end
       
   288 
       
   289 
   270 		end		
   290 		end		
   271 		
   291 		
   272 		lastName = currName
   292 		lastName = currName
   273 
   293 
   274 	end
   294 	end
   278 function onGearAdd(gear)
   298 function onGearAdd(gear)
   279 
   299 
   280         if GetGearType(gear) == gtHedgehog then
   300         if GetGearType(gear) == gtHedgehog then
   281                 hhs[numhhs] = gear
   301                 hhs[numhhs] = gear
   282                 numhhs = numhhs + 1
   302                 numhhs = numhhs + 1
   283         end
   303         elseif (GetGearType(gear) == gtMine) and (started == true) then
       
   304 		SetTimer(gear,5000)	
       
   305 	end
       
   306 	
       
   307 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
       
   308 		trackGear(gear)
       
   309 	end 
       
   310 
   284 
   311 
   285 end
   312 end
   286 
   313 
   287 function onGearDelete(gear)
   314 function onGearDelete(gear)
   288 --
   315 	if (GetGearType(gear) == gtHedgehog) or (GetGearType(gear) == gtResurrector) then
       
   316 		trackDeletion(gear)
       
   317 	end 
   289 end
   318 end
   290 
   319 
   291 function onAmmoStoreInit()
   320 function onAmmoStoreInit()
   292 --
   321 --
   293 end
   322 end