share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
changeset 5277 09beef0752ab
child 5362 5f0c46e78e50
equal deleted inserted replaced
5276:562070d3f978 5277:09beef0752ab
       
     1 ----------------------------------
       
     2 -- THE SPECIALISTS MODE 0.2
       
     3 -- by mikade
       
     4 ----------------------------------
       
     5 
       
     6 -- version history
       
     7 -----------------
       
     8 -- version 0.1
       
     9 -----------------
       
    10 -- concept test
       
    11 
       
    12 ----------------
       
    13 -- version 0.2
       
    14 ----------------
       
    15 -- added gfRandomOrder to gameflags
       
    16 -- removed some deprecated variables/methods
       
    17 -- fixed lack of portal reset
       
    18 
       
    19 --------------------
       
    20 --TO DO
       
    21 --------------------
       
    22 
       
    23 -- add proper gameflag checking, maybe
       
    24 -- set crate drops etc.
       
    25 -- assuming place hog mode + gfinfattack doesn't get the fix: somehow end turn after teleport
       
    26 
       
    27 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
    28 
       
    29 local numhhs = 0 
       
    30 local hhs = {} 
       
    31 
       
    32 local currName 
       
    33 local lastName
       
    34 
       
    35 function CreateTeam()
       
    36 
       
    37 	currTeam = ""
       
    38 	lastTeam = ""
       
    39 	z = 0
       
    40 
       
    41 	for i = 0, (numhhs-1) do
       
    42 
       
    43 		currTeam = GetHogTeamName(hhs[i])
       
    44 
       
    45 		if currTeam == lastTeam then
       
    46 			z = z + 1
       
    47 		else
       
    48 			z = 1		
       
    49 		end
       
    50 
       
    51 		if z == 1 then
       
    52 
       
    53 			SetHogName(hhs[i],"Soldier")
       
    54 			SetHogHat(hhs[i], "Vega")
       
    55 			SetHealth(hhs[i],200)
       
    56 
       
    57 		elseif z == 2 then
       
    58 
       
    59 			SetHogHat(hhs[i], "Glasses")
       
    60 			SetHogName(hhs[i],"Engineer")
       
    61 
       
    62 		elseif z == 3 then
       
    63 
       
    64 			SetHogName(hhs[i],"Ninja")			
       
    65 			SetHogHat(hhs[i], "NinjaFull")
       
    66 			SetHealth(hhs[i],80)
       
    67 
       
    68 		elseif z == 4 then
       
    69 
       
    70 			SetHogName(hhs[i],"Demo")			
       
    71 			SetHogHat(hhs[i], "Skull")
       
    72 			SetHealth(hhs[i],200)
       
    73 
       
    74 		elseif z == 5 then
       
    75 
       
    76 			SetHogName(hhs[i],"Sniper")			
       
    77 			SetHogHat(hhs[i], "Sniper")
       
    78 			SetHealth(hhs[i],120)
       
    79 
       
    80 		elseif z == 6 then
       
    81 
       
    82 			SetHogName(hhs[i],"Saint")			
       
    83 			SetHogHat(hhs[i], "angel")
       
    84 			SetHealth(hhs[i],300)
       
    85 
       
    86 		elseif z == 7 then
       
    87 
       
    88 			SetHogName(hhs[i],"Pyro")			
       
    89 			SetHogHat(hhs[i], "Gasmask")
       
    90 			SetHealth(hhs[i],150)
       
    91 		
       
    92 		elseif z == 8 then
       
    93 		
       
    94 			SetHogName(hhs[i],"Loon")			
       
    95 			SetHogHat(hhs[i], "clown")
       
    96 			SetHealth(hhs[i],100)
       
    97 
       
    98 		end
       
    99 
       
   100 		lastTeam = GetHogTeamName(hhs[i])
       
   101 
       
   102 	end	
       
   103 
       
   104 end
       
   105 
       
   106 function ResetAllAmmo()
       
   107 
       
   108 	AddAmmo(CurrentHedgehog, amBazooka, 0)
       
   109 	AddAmmo(CurrentHedgehog, amGrenade, 0)
       
   110 	AddAmmo(CurrentHedgehog, amShotgun, 0)
       
   111 	
       
   112 	AddAmmo(CurrentHedgehog, amGirder, 0)
       
   113 	AddAmmo(CurrentHedgehog, amBlowTorch, 0)
       
   114 	AddAmmo(CurrentHedgehog, amPickHammer, 0)
       
   115 	AddAmmo(CurrentHedgehog, amSwitch, 0)
       
   116 
       
   117 	AddAmmo(CurrentHedgehog, amRope, 0)
       
   118 	AddAmmo(CurrentHedgehog, amParachute, 0)
       
   119 	AddAmmo(CurrentHedgehog, amFirePunch, 0)
       
   120 
       
   121 	AddAmmo(CurrentHedgehog, amDynamite, 0)
       
   122 	AddAmmo(CurrentHedgehog, amDrill, 0)
       
   123 	AddAmmo(CurrentHedgehog, amMine, 0)
       
   124 
       
   125 	AddAmmo(CurrentHedgehog, amSniperRifle, 0)
       
   126 	AddAmmo(CurrentHedgehog, amDEagle, 0)
       
   127 	AddAmmo(CurrentHedgehog, amPortalGun, 0)
       
   128 
       
   129 	AddAmmo(CurrentHedgehog, amSeduction, 0)
       
   130 	AddAmmo(CurrentHedgehog, amResurrector, 0)
       
   131 	AddAmmo(CurrentHedgehog, amInvulnerable, 0)
       
   132 	
       
   133 	AddAmmo(CurrentHedgehog, amFlamethrower, 0)
       
   134 	AddAmmo(CurrentHedgehog, amMolotov, 0)
       
   135 	AddAmmo(CurrentHedgehog, amNapalm, 0)
       
   136 	
       
   137 	AddAmmo(CurrentHedgehog, amBaseballBat, 0)
       
   138 	AddAmmo(CurrentHedgehog, amGasBomb, 0)
       
   139 	AddAmmo(CurrentHedgehog, amKamikaze, 0)
       
   140 
       
   141 end
       
   142 
       
   143 function AssignAmmo()
       
   144 
       
   145 	ResetAllAmmo()	
       
   146 	n = GetHogName(CurrentHedgehog)
       
   147 
       
   148 	AddAmmo(CurrentHedgehog, amSkip,100)
       
   149 
       
   150 	if n == "Soldier" then 
       
   151 		AddAmmo(CurrentHedgehog, amBazooka,1)
       
   152 		AddAmmo(CurrentHedgehog, amGrenade,1)
       
   153 		AddAmmo(CurrentHedgehog, amShotgun,1)
       
   154 	elseif n == "Engineer" then
       
   155 		AddAmmo(CurrentHedgehog, amGirder, 2)
       
   156 		AddAmmo(CurrentHedgehog, amBlowTorch, 1)
       
   157 		AddAmmo(CurrentHedgehog, amPickHammer, 1)	
       
   158 		AddAmmo(CurrentHedgehog, amSwitch, 2)	
       
   159 	elseif n == "Ninja" then
       
   160 		AddAmmo(CurrentHedgehog, amRope, 100)
       
   161 		AddAmmo(CurrentHedgehog, amParachute, 100)
       
   162 		AddAmmo(CurrentHedgehog, amFirePunch, 1)
       
   163 	elseif n == "Demo" then
       
   164 		AddAmmo(CurrentHedgehog, amDynamite, 1)
       
   165 		AddAmmo(CurrentHedgehog, amMine, 1)
       
   166 		AddAmmo(CurrentHedgehog, amDrill, 1)
       
   167 	elseif n == "Sniper" then
       
   168 		AddAmmo(CurrentHedgehog, amSniperRifle, 1)
       
   169 		AddAmmo(CurrentHedgehog, amDEagle, 1)
       
   170 		AddAmmo(CurrentHedgehog, amPortalGun, 2)
       
   171 	elseif n == "Saint" then
       
   172 		AddAmmo(CurrentHedgehog, amSeduction, 100)
       
   173 		AddAmmo(CurrentHedgehog, amResurrector, 1)
       
   174 		AddAmmo(CurrentHedgehog, amInvulnerable, 1)
       
   175 	elseif n == "Pyro" then
       
   176 		AddAmmo(CurrentHedgehog, amFlamethrower, 1)
       
   177 		AddAmmo(CurrentHedgehog, amMolotov, 1)
       
   178 		AddAmmo(CurrentHedgehog, amNapalm, 1)
       
   179 	elseif n == "Loon" then
       
   180 		AddAmmo(CurrentHedgehog, amBaseballBat, 1)
       
   181 		AddAmmo(CurrentHedgehog, amGasBomb, 1)
       
   182 		AddAmmo(CurrentHedgehog, amKamikaze, 1)
       
   183 	end
       
   184 
       
   185 end
       
   186 
       
   187 function onGameInit()
       
   188 	GameFlags = gfRandomOrder + gfResetWeps + gfInfAttack + gfPlaceHog
       
   189 	Delay = 10
       
   190 end
       
   191 
       
   192 function onGameStart()
       
   193    	
       
   194 	CreateTeam()
       
   195 
       
   196 	ShowMission	(
       
   197 				loc("THE SPECIALISTS"),
       
   198 				loc("a Hedgewars mini-game"),
       
   199 
       
   200 				loc("Eliminate the enemy specialists.") .. "|" ..
       
   201 				" " .. "|" ..
       
   202 
       
   203 				loc("Game Modifiers: ") .. "|" ..
       
   204 				loc("Per-Hog Ammo") .. "|" ..				
       
   205 				loc("Weapons Reset") .. "|" ..				
       
   206 				loc("Unlimited Attacks") .. "|" ..
       
   207 
       
   208 				"", 4, 4000
       
   209 				)
       
   210 
       
   211 end
       
   212 
       
   213 
       
   214 function onNewTurn()
       
   215 	currName = GetHogName(CurrentHedgehog)
       
   216 	lastName = GetHogName(CurrentHedgehog)
       
   217 	AssignAmmo()
       
   218 	AddAmmo(CurrentHedgehog, amSwitch, 1)
       
   219 end
       
   220 
       
   221 function onGameTick()
       
   222 
       
   223 	if (CurrentHedgehog ~= nil) then
       
   224 
       
   225 		currName = GetHogName(CurrentHedgehog)
       
   226 		
       
   227 		if currName ~= lastName then
       
   228 			AddCaption(loc("Switched to ") .. currName .. "!")
       
   229 			AssignAmmo()		
       
   230 		end
       
   231 
       
   232 		lastName = currName
       
   233 
       
   234 	end
       
   235 
       
   236 end
       
   237 
       
   238 function onGearAdd(gear)
       
   239     
       
   240 	if GetGearType(gear) == gtHedgehog then
       
   241 		hhs[numhhs] = gear
       
   242 		numhhs = numhhs + 1
       
   243 	end
       
   244 
       
   245 end
       
   246 
       
   247 function onGearDelete(gear)
       
   248 --
       
   249 end
       
   250 
       
   251 function onAmmoStoreInit()
       
   252 
       
   253 end
       
   254 
       
   255 
       
   256