share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
changeset 5382 d5321b22aed2
parent 5362 5f0c46e78e50
child 5457 48fe8e03a9cf
equal deleted inserted replaced
5380:6ba1e40a360c 5382:d5321b22aed2
     1 ----------------------------------
     1 ----------------------------------
     2 -- THE SPECIALISTS MODE 0.3
     2 -- THE SPECIALISTS MODE 0.4
     3 -- by mikade
     3 -- by mikade
     4 ----------------------------------
     4 ----------------------------------
     5 
     5 
     6 -- version history
     6 -- version history
     7 -----------------
     7 -----------------
    20 -- version 0.3
    20 -- version 0.3
    21 ----------------
    21 ----------------
    22 -- added switching on start
    22 -- added switching on start
    23 -- removed switch from engineer weaponset
    23 -- removed switch from engineer weaponset
    24 
    24 
       
    25 ----------------
       
    26 -- version 0.4
       
    27 ----------------
       
    28 -- Attempted to:
       
    29 -- fix potential switch explit
       
    30 -- improve user feedback on start
       
    31 
    25 --------------------
    32 --------------------
    26 --TO DO
    33 --TO DO
    27 --------------------
    34 --------------------
    28 
    35 
    29 -- add proper gameflag checking, maybe
    36 -- add proper gameflag checking, maybe
    30 -- set crate drops etc.
    37 -- set crate drops etc.
    31 -- add alternative switch
    38 -- add alternative switch
    32 
    39 
    33 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    40 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
    34 
    41 
    35 local numhhs = 0 
    42 local numhhs = 0
    36 local hhs = {} 
    43 local hhs = {}
    37 
    44 
    38 local currName 
    45 local currName
    39 local lastName
    46 local lastName
    40 local started = false
    47 local started = false
    41 local switchStage = 0
    48 local switchStage = 0
    42 
    49 
    43 function CreateTeam()
    50 function CreateTeam()
    44 
    51 
    45 	currTeam = ""
    52         currTeam = ""
    46 	lastTeam = ""
    53         lastTeam = ""
    47 	z = 0
    54         z = 0
    48 
    55 
    49 	for i = 0, (numhhs-1) do
    56         for i = 0, (numhhs-1) do
    50 
    57 
    51 		currTeam = GetHogTeamName(hhs[i])
    58                 currTeam = GetHogTeamName(hhs[i])
    52 
    59 
    53 		if currTeam == lastTeam then
    60                 if currTeam == lastTeam then
    54 			z = z + 1
    61                         z = z + 1
    55 		else
    62                 else
    56 			z = 1		
    63                         z = 1
    57 		end
    64                 end
    58 
    65 
    59 		if z == 1 then
    66                 if z == 1 then
    60 
    67 
    61 			SetHogName(hhs[i],"Soldier")
    68                         SetHogName(hhs[i],"Soldier")
    62 			SetHogHat(hhs[i], "Vega")
    69                         SetHogHat(hhs[i], "Vega")
    63 			SetHealth(hhs[i],200)
    70                         SetHealth(hhs[i],200)
    64 
    71 
    65 		elseif z == 2 then
    72                 elseif z == 2 then
    66 
    73 
    67 			SetHogHat(hhs[i], "Glasses")
    74                         SetHogHat(hhs[i], "Glasses")
    68 			SetHogName(hhs[i],"Engineer")
    75                         SetHogName(hhs[i],"Engineer")
    69 
    76 
    70 		elseif z == 3 then
    77                 elseif z == 3 then
    71 
    78 
    72 			SetHogName(hhs[i],"Ninja")			
    79                         SetHogName(hhs[i],"Ninja")
    73 			SetHogHat(hhs[i], "NinjaFull")
    80                         SetHogHat(hhs[i], "NinjaFull")
    74 			SetHealth(hhs[i],80)
    81                         SetHealth(hhs[i],80)
    75 
    82 
    76 		elseif z == 4 then
    83                 elseif z == 4 then
    77 
    84 
    78 			SetHogName(hhs[i],"Demo")			
    85                         SetHogName(hhs[i],"Demo")
    79 			SetHogHat(hhs[i], "Skull")
    86                         SetHogHat(hhs[i], "Skull")
    80 			SetHealth(hhs[i],200)
    87                         SetHealth(hhs[i],200)
    81 
    88 
    82 		elseif z == 5 then
    89                 elseif z == 5 then
    83 
    90 
    84 			SetHogName(hhs[i],"Sniper")			
    91                         SetHogName(hhs[i],"Sniper")
    85 			SetHogHat(hhs[i], "Sniper")
    92                         SetHogHat(hhs[i], "Sniper")
    86 			SetHealth(hhs[i],120)
    93                         SetHealth(hhs[i],120)
    87 
    94 
    88 		elseif z == 6 then
    95                 elseif z == 6 then
    89 
    96 
    90 			SetHogName(hhs[i],"Saint")			
    97                         SetHogName(hhs[i],"Saint")
    91 			SetHogHat(hhs[i], "angel")
    98                         SetHogHat(hhs[i], "angel")
    92 			SetHealth(hhs[i],300)
    99                         SetHealth(hhs[i],300)
    93 
   100 
    94 		elseif z == 7 then
   101                 elseif z == 7 then
    95 
   102 
    96 			SetHogName(hhs[i],"Pyro")			
   103                         SetHogName(hhs[i],"Pyro")
    97 			SetHogHat(hhs[i], "Gasmask")
   104                         SetHogHat(hhs[i], "Gasmask")
    98 			SetHealth(hhs[i],150)
   105                         SetHealth(hhs[i],150)
    99 		
   106 
   100 		elseif z == 8 then
   107                 elseif z == 8 then
   101 		
   108 
   102 			SetHogName(hhs[i],"Loon")			
   109                         SetHogName(hhs[i],"Loon")
   103 			SetHogHat(hhs[i], "clown")
   110                         SetHogHat(hhs[i], "clown")
   104 			SetHealth(hhs[i],100)
   111                         SetHealth(hhs[i],100)
   105 
   112 
   106 		end
   113                 end
   107 
   114 
   108 		lastTeam = GetHogTeamName(hhs[i])
   115                 lastTeam = GetHogTeamName(hhs[i])
   109 
   116 
   110 	end	
   117         end
   111 
   118 
   112 end
   119 end
   113 
   120 
   114 function ResetAllAmmo()
   121 function ResetAllAmmo()
   115 
   122 
   116 	AddAmmo(CurrentHedgehog, amBazooka, 0)
   123         AddAmmo(CurrentHedgehog, amBazooka, 0)
   117 	AddAmmo(CurrentHedgehog, amGrenade, 0)
   124         AddAmmo(CurrentHedgehog, amGrenade, 0)
   118 	AddAmmo(CurrentHedgehog, amShotgun, 0)
   125         AddAmmo(CurrentHedgehog, amShotgun, 0)
   119 	
   126 
   120 	AddAmmo(CurrentHedgehog, amGirder, 0)
   127         AddAmmo(CurrentHedgehog, amGirder, 0)
   121 	AddAmmo(CurrentHedgehog, amBlowTorch, 0)
   128         AddAmmo(CurrentHedgehog, amBlowTorch, 0)
   122 	AddAmmo(CurrentHedgehog, amPickHammer, 0)
   129         AddAmmo(CurrentHedgehog, amPickHammer, 0)
   123 	AddAmmo(CurrentHedgehog, amSwitch, 0)
   130         AddAmmo(CurrentHedgehog, amSwitch, 0)
   124 
   131 
   125 	AddAmmo(CurrentHedgehog, amRope, 0)
   132         AddAmmo(CurrentHedgehog, amRope, 0)
   126 	AddAmmo(CurrentHedgehog, amParachute, 0)
   133         AddAmmo(CurrentHedgehog, amParachute, 0)
   127 	AddAmmo(CurrentHedgehog, amFirePunch, 0)
   134         AddAmmo(CurrentHedgehog, amFirePunch, 0)
   128 
   135 
   129 	AddAmmo(CurrentHedgehog, amDynamite, 0)
   136         AddAmmo(CurrentHedgehog, amDynamite, 0)
   130 	AddAmmo(CurrentHedgehog, amDrill, 0)
   137         AddAmmo(CurrentHedgehog, amDrill, 0)
   131 	AddAmmo(CurrentHedgehog, amMine, 0)
   138         AddAmmo(CurrentHedgehog, amMine, 0)
   132 
   139 
   133 	AddAmmo(CurrentHedgehog, amSniperRifle, 0)
   140         AddAmmo(CurrentHedgehog, amSniperRifle, 0)
   134 	AddAmmo(CurrentHedgehog, amDEagle, 0)
   141         AddAmmo(CurrentHedgehog, amDEagle, 0)
   135 	AddAmmo(CurrentHedgehog, amPortalGun, 0)
   142         AddAmmo(CurrentHedgehog, amPortalGun, 0)
   136 
   143 
   137 	AddAmmo(CurrentHedgehog, amSeduction, 0)
   144         AddAmmo(CurrentHedgehog, amSeduction, 0)
   138 	AddAmmo(CurrentHedgehog, amResurrector, 0)
   145         AddAmmo(CurrentHedgehog, amResurrector, 0)
   139 	AddAmmo(CurrentHedgehog, amInvulnerable, 0)
   146         AddAmmo(CurrentHedgehog, amInvulnerable, 0)
   140 	
   147 
   141 	AddAmmo(CurrentHedgehog, amFlamethrower, 0)
   148         AddAmmo(CurrentHedgehog, amFlamethrower, 0)
   142 	AddAmmo(CurrentHedgehog, amMolotov, 0)
   149         AddAmmo(CurrentHedgehog, amMolotov, 0)
   143 	AddAmmo(CurrentHedgehog, amNapalm, 0)
   150         AddAmmo(CurrentHedgehog, amNapalm, 0)
   144 	
   151 
   145 	AddAmmo(CurrentHedgehog, amBaseballBat, 0)
   152         AddAmmo(CurrentHedgehog, amBaseballBat, 0)
   146 	AddAmmo(CurrentHedgehog, amGasBomb, 0)
   153         AddAmmo(CurrentHedgehog, amGasBomb, 0)
   147 	AddAmmo(CurrentHedgehog, amKamikaze, 0)
   154         AddAmmo(CurrentHedgehog, amKamikaze, 0)
   148 
   155 
   149 end
   156 end
   150 
   157 
   151 function AssignAmmo()
   158 function AssignAmmo()
   152 
   159 
   153 	ResetAllAmmo()	
   160         ResetAllAmmo()
   154 	n = GetHogName(CurrentHedgehog)
   161         n = GetHogName(CurrentHedgehog)
   155 
   162 
   156 	AddAmmo(CurrentHedgehog, amSkip,100)
   163         AddAmmo(CurrentHedgehog, amSkip,100)
   157 
   164 
   158 	if n == "Soldier" then 
   165         if n == "Soldier" then
   159 		AddAmmo(CurrentHedgehog, amBazooka,1)
   166                 AddAmmo(CurrentHedgehog, amBazooka,1)
   160 		AddAmmo(CurrentHedgehog, amGrenade,1)
   167                 AddAmmo(CurrentHedgehog, amGrenade,1)
   161 		AddAmmo(CurrentHedgehog, amShotgun,1)
   168                 AddAmmo(CurrentHedgehog, amShotgun,1)
   162 	elseif n == "Engineer" then
   169         elseif n == "Engineer" then
   163 		AddAmmo(CurrentHedgehog, amGirder, 2)
   170                 AddAmmo(CurrentHedgehog, amGirder, 2)
   164 		AddAmmo(CurrentHedgehog, amBlowTorch, 1)
   171                 AddAmmo(CurrentHedgehog, amBlowTorch, 1)
   165 		AddAmmo(CurrentHedgehog, amPickHammer, 1)	
   172                 AddAmmo(CurrentHedgehog, amPickHammer, 1)
   166 		--AddAmmo(CurrentHedgehog, amSwitch, 2)	
   173         elseif n == "Ninja" then
   167 	elseif n == "Ninja" then
   174                 AddAmmo(CurrentHedgehog, amRope, 100)
   168 		AddAmmo(CurrentHedgehog, amRope, 100)
   175                 AddAmmo(CurrentHedgehog, amParachute, 100)
   169 		AddAmmo(CurrentHedgehog, amParachute, 100)
   176                 AddAmmo(CurrentHedgehog, amFirePunch, 1)
   170 		AddAmmo(CurrentHedgehog, amFirePunch, 1)
   177         elseif n == "Demo" then
   171 	elseif n == "Demo" then
   178                 AddAmmo(CurrentHedgehog, amDynamite, 1)
   172 		AddAmmo(CurrentHedgehog, amDynamite, 1)
   179                 AddAmmo(CurrentHedgehog, amMine, 1)
   173 		AddAmmo(CurrentHedgehog, amMine, 1)
   180                 AddAmmo(CurrentHedgehog, amDrill, 1)
   174 		AddAmmo(CurrentHedgehog, amDrill, 1)
   181         elseif n == "Sniper" then
   175 	elseif n == "Sniper" then
   182                 AddAmmo(CurrentHedgehog, amSniperRifle, 1)
   176 		AddAmmo(CurrentHedgehog, amSniperRifle, 1)
   183                 AddAmmo(CurrentHedgehog, amDEagle, 1)
   177 		AddAmmo(CurrentHedgehog, amDEagle, 1)
   184                 AddAmmo(CurrentHedgehog, amPortalGun, 2)
   178 		AddAmmo(CurrentHedgehog, amPortalGun, 2)
   185         elseif n == "Saint" then
   179 	elseif n == "Saint" then
   186                 AddAmmo(CurrentHedgehog, amSeduction, 100)
   180 		AddAmmo(CurrentHedgehog, amSeduction, 100)
   187                 AddAmmo(CurrentHedgehog, amResurrector, 1)
   181 		AddAmmo(CurrentHedgehog, amResurrector, 1)
   188                 AddAmmo(CurrentHedgehog, amInvulnerable, 1)
   182 		AddAmmo(CurrentHedgehog, amInvulnerable, 1)
   189         elseif n == "Pyro" then
   183 	elseif n == "Pyro" then
   190                 AddAmmo(CurrentHedgehog, amFlamethrower, 1)
   184 		AddAmmo(CurrentHedgehog, amFlamethrower, 1)
   191                 AddAmmo(CurrentHedgehog, amMolotov, 1)
   185 		AddAmmo(CurrentHedgehog, amMolotov, 1)
   192                 AddAmmo(CurrentHedgehog, amNapalm, 1)
   186 		AddAmmo(CurrentHedgehog, amNapalm, 1)
   193         elseif n == "Loon" then
   187 	elseif n == "Loon" then
   194                 AddAmmo(CurrentHedgehog, amBaseballBat, 1)
   188 		AddAmmo(CurrentHedgehog, amBaseballBat, 1)
   195                 AddAmmo(CurrentHedgehog, amGasBomb, 1)
   189 		AddAmmo(CurrentHedgehog, amGasBomb, 1)
   196                 AddAmmo(CurrentHedgehog, amKamikaze, 1)
   190 		AddAmmo(CurrentHedgehog, amKamikaze, 1)
   197         end
   191 	end
       
   192 
   198 
   193 end
   199 end
   194 
   200 
   195 function onGameInit()
   201 function onGameInit()
   196 	GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog
   202         GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog
   197 	Delay = 10
   203         Delay = 10
   198 end
   204 end
   199 
   205 
   200 function onGameStart()
   206 function onGameStart()
   201    	
   207 
   202 	CreateTeam()
   208         CreateTeam()
   203 
   209 
   204 	ShowMission	(
   210         ShowMission     (
   205 				loc("THE SPECIALISTS"),
   211                                 loc("THE SPECIALISTS"),
   206 				loc("a Hedgewars mini-game"),
   212                                 loc("a Hedgewars mini-game"),
   207 
   213 
   208 				loc("Eliminate the enemy specialists.") .. "|" ..
   214                                 loc("Eliminate the enemy specialists.") .. "|" ..
   209 				" " .. "|" ..
   215                                 " " .. "|" ..
   210 
   216 
   211 				loc("Game Modifiers: ") .. "|" ..
   217                                 loc("Game Modifiers: ") .. "|" ..
   212 				loc("Per-Hog Ammo") .. "|" ..				
   218                                 loc("Per-Hog Ammo") .. "|" ..
   213 				loc("Weapons Reset") .. "|" ..				
   219                                 loc("Weapons Reset") .. "|" ..
   214 				loc("Unlimited Attacks") .. "|" ..
   220                                 loc("Unlimited Attacks") .. "|" ..
   215 
   221 
   216 				"", 4, 4000
   222                                 "", 4, 4000
   217 				)
   223                                 )
   218 
   224 
   219 end
   225 end
   220 
   226 
   221 
   227 
   222 function onNewTurn()
   228 function onNewTurn()
   223 	currName = GetHogName(CurrentHedgehog)
   229         currName = GetHogName(CurrentHedgehog)
   224 	lastName = GetHogName(CurrentHedgehog)
   230         lastName = GetHogName(CurrentHedgehog)
   225 	AssignAmmo()
   231         AssignAmmo()
   226 	
   232 
   227 	--AddAmmo(CurrentHedgehog, amSwitch, 1)
   233         ---------------
       
   234         --switch
       
   235         started = false
       
   236         switchStage = 0
       
   237         --AddAmmo(CurrentHedgehog, amSwitch, 1)
   228 	---------------
   238 	---------------
   229 	--switch	
   239 
   230 	started = false
       
   231 	switchStage = 0
       
   232 	---------------
       
   233 end
   240 end
   234 
   241 
   235 function onGameTick()
   242 function onGameTick()
   236 
   243 
   237 	if (CurrentHedgehog ~= nil) then
   244 	if (CurrentHedgehog ~= nil) then
   238 
   245 
   239 		currName = GetHogName(CurrentHedgehog)
   246 		currName = GetHogName(CurrentHedgehog)
   240 		
   247 		
   241 		if currName ~= lastName then
   248 		if (currName ~= lastName) and (switchStage > 100) then
   242 			AddCaption(loc("Switched to ") .. currName .. "!")
   249 			AddCaption(loc("Switched to ") .. currName .. "!")
   243 			AssignAmmo()		
   250 			AssignAmmo()		
   244 		end
   251 		end
   245 
   252 
   246 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then			
   253 		if (TurnTimeLeft > 0) and (TurnTimeLeft ~= TurnTime) and (switchStage < 100) then			
   247 			
   254 			
       
   255 			AddCaption(loc("Prepare yourself") .. ", " .. currName .. "!") 
       
   256 
   248 			switchStage = switchStage + 1	
   257 			switchStage = switchStage + 1	
   249 			
   258 			
   250 			if switchStage == 10 then
   259 			if switchStage == 1 then
   251 				AddAmmo(CurrentHedgehog, amSwitch, 1)
   260 				AddAmmo(CurrentHedgehog, amSwitch, 1)
   252 			elseif switchStage == 20 then
   261 				
       
   262 			elseif switchStage == 2 then
   253 				ParseCommand("setweap " .. string.char(amSwitch))
   263 				ParseCommand("setweap " .. string.char(amSwitch))
   254 			elseif switchStage == 30 then
   264 			elseif switchStage == 3 then
   255 				SetGearMessage(CurrentHedgehog,gmAttack) 
   265 				SetGearMessage(CurrentHedgehog,gmAttack) 
       
   266 			elseif switchStage == 4 then
   256 				switchStage = 110
   267 				switchStage = 110
       
   268 				AddAmmo(CurrentHedgehog, amSwitch, 0)
   257 			end
   269 			end
   258 		end		
   270 		end		
   259 		
   271 		
   260 		--------------------------------------------------------------------------------------
       
   261 
       
   262 		lastName = currName
   272 		lastName = currName
   263 
   273 
   264 	end
   274 	end
   265 
   275 
   266 end
   276 end
   267 
   277 
   268 function onGearAdd(gear)
   278 function onGearAdd(gear)
   269     
   279 
   270 	if GetGearType(gear) == gtHedgehog then
   280         if GetGearType(gear) == gtHedgehog then
   271 		hhs[numhhs] = gear
   281                 hhs[numhhs] = gear
   272 		numhhs = numhhs + 1
   282                 numhhs = numhhs + 1
   273 	end
   283         end
   274 
   284 
   275 end
   285 end
   276 
   286 
   277 function onGearDelete(gear)
   287 function onGearDelete(gear)
   278 --
   288 --
   280 
   290 
   281 function onAmmoStoreInit()
   291 function onAmmoStoreInit()
   282 --
   292 --
   283 end
   293 end
   284 
   294 
   285 
       
   286