share/hedgewars/Data/Scripts/Multiplayer/The_Specialists.lua
changeset 14522 2fd8f4cd3aa4
parent 14521 f5487302d53b
child 14523 a97216ff1c51
equal deleted inserted replaced
14521:f5487302d53b 14522:2fd8f4cd3aa4
     1 ----------------------------------
     1 ----------------------------------
     2 -- THE SPECIALISTS MODE 0.7
     2 -- THE SPECIALISTS
     3 -- by mikade
     3 -- original style by mikade
     4 ----------------------------------
     4 ----------------------------------
     5 
     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 -- version 0.3
       
    21 ----------------
       
    22 -- added switching on start
       
    23 -- removed switch from engineer weaponset
       
    24 
       
    25 ----------------
       
    26 -- version 0.4
       
    27 ----------------
       
    28 -- Attempted to:
       
    29 -- fix potential switch explit
       
    30 -- improve user feedback on start
       
    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 
       
    38 ----------------
       
    39 -- version 0.6
       
    40 ----------------
       
    41 -- for the meanwhile, don't drop any crates except health crates
       
    42 
       
    43 ----------------
       
    44 -- version 0.7
       
    45 ----------------
       
    46 -- perhogadmsdf :D :D :D :D
       
    47 
       
    48 --------------------
     6 --------------------
    49 --TO DO
     7 -- TODO
    50 --------------------
     8 --------------------
    51 
       
    52 -- balance hog health, maybe
       
    53 -- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
     9 -- add proper gameflag checking, maybe (so that we can throw in a .cfg and let the users break everything)
       
    10 
    54 
    11 
    55 HedgewarsScriptLoad("/Scripts/Locale.lua")
    12 HedgewarsScriptLoad("/Scripts/Locale.lua")
    56 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    13 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    57 HedgewarsScriptLoad("/Scripts/Params.lua")
    14 HedgewarsScriptLoad("/Scripts/Params.lua")
    58 
    15 
    59 -- S=(S)oldier D=(D)emo E=(E)ngineer N=(N)inja P=(P)yro C=(C)lown H=(H)olyman[saint] X=Sniper [running out of letters, but X-out or X-hair or something]
    16 --[[
       
    17 Specialist letters:
       
    18 
       
    19   S=[S]oldier
       
    20   E=[E]ngineer
       
    21   N=[N]inja
       
    22   D=[D]emo
       
    23   X=Sniper
       
    24   H=Saint ([H]oly)
       
    25   P=[P]yro
       
    26   C=Loon ([C]lown)
       
    27 ]]
    60 -- default team values
    28 -- default team values
    61 local currTeamIdx = 0;
    29 local currTeamIdx = 0;
    62 local teamRoles = 
    30 local teamRoles = {
    63         {
    31 	{'S','E','N','D','X','H','P','C'},
    64             {'S','E','N','D','X','H','P','C'},
    32 	{'S','E','N','D','X','H','P','C'},
    65             {'S','E','N','D','X','H','P','C'},
    33 	{'S','E','N','D','X','H','P','C'},
    66             {'S','E','N','D','X','H','P','C'},
    34 	{'S','E','N','D','X','H','P','C'},
    67             {'S','E','N','D','X','H','P','C'},
    35 	{'S','E','N','D','X','H','P','C'},
    68             {'S','E','N','D','X','H','P','C'},
    36 	{'S','E','N','D','X','H','P','C'},
    69             {'S','E','N','D','X','H','P','C'},
    37 	{'S','E','N','D','X','H','P','C'},
    70             {'S','E','N','D','X','H','P','C'},
    38 	{'S','E','N','D','X','H','P','C'}
    71             {'S','E','N','D','X','H','P','C'}
    39 };
    72         };
       
    73 
    40 
    74 local numhhs = 0
    41 local numhhs = 0
    75 local hhs = {}
    42 local hhs = {}
    76 
    43 
    77 local started = false
    44 local started = false
    78 
    45 
    79 function onParameters()
    46 function onParameters()
    80 	parseParams()
    47 	parseParams()
    81 	for i = 1, 8 do
    48 	for i = 1, 8 do
    82         if params['t'..i] ~= nil then
    49 		if params['t'..i] ~= nil then
    83             for j = 1, 8 do
    50 			for j = 1, 8 do
    84                 if string.len(params['t'..i]) >= j  then
    51 				if string.len(params['t'..i]) >= j  then
    85                     teamRoles[i][j] = string.upper(string.sub(params['t'..i],j,j));
    52 					teamRoles[i][j] = string.upper(string.sub(params['t'..i],j,j));
    86                 end
    53 				end
    87             end
    54 			end
    88         end
    55 		end
    89     end
    56 	end
    90 end
    57 end
    91 
    58 
    92 function onNewAmmoStore(groupIndex, hogIndex)
    59 function onNewAmmoStore(groupIndex, hogIndex)
    93 
    60 
    94 	SetAmmo(amSkip, 9, 0, 0, 0)
    61 	SetAmmo(amSkip, 9, 0, 0, 0)
    95     groupIndex = groupIndex + 1
    62 	groupIndex = groupIndex + 1
    96     hogIndex = hogIndex + 1
    63 	hogIndex = hogIndex + 1
    97 
    64 
    98     if teamRoles[groupIndex][hogIndex] == 'S' then
    65 	if teamRoles[groupIndex][hogIndex] == 'S' then
    99 		SetAmmo(amBazooka, 1, 0, 0, 0)
    66 		SetAmmo(amBazooka, 1, 0, 0, 0)
   100 		SetAmmo(amGrenade, 1, 0, 0, 0)
    67 		SetAmmo(amGrenade, 1, 0, 0, 0)
   101 		SetAmmo(amShotgun, 1, 0, 0, 0)
    68 		SetAmmo(amShotgun, 1, 0, 0, 0)
   102     elseif teamRoles[groupIndex][hogIndex] == 'E' then
    69 	elseif teamRoles[groupIndex][hogIndex] == 'E' then
   103 		SetAmmo(amGirder, 2, 0, 0, 0)
    70 		SetAmmo(amGirder, 2, 0, 0, 0)
   104 		SetAmmo(amBlowTorch, 1, 0, 0, 0)
    71 		SetAmmo(amBlowTorch, 1, 0, 0, 0)
   105 		SetAmmo(amPickHammer, 1, 0, 0, 0)
    72 		SetAmmo(amPickHammer, 1, 0, 0, 0)
   106     elseif teamRoles[groupIndex][hogIndex] == 'N' then
    73 	elseif teamRoles[groupIndex][hogIndex] == 'N' then
   107 		SetAmmo(amRope, 9, 0, 0, 0)
    74 		SetAmmo(amRope, 9, 0, 0, 0)
   108 		SetAmmo(amParachute, 9, 0, 0, 0)
    75 		SetAmmo(amParachute, 9, 0, 0, 0)
   109 		SetAmmo(amFirePunch, 1, 0, 0, 0)
    76 		SetAmmo(amFirePunch, 1, 0, 0, 0)
   110     elseif teamRoles[groupIndex][hogIndex] == 'D' then
    77 	elseif teamRoles[groupIndex][hogIndex] == 'D' then
   111 		SetAmmo(amDynamite, 1, 0, 0, 0)
    78 		SetAmmo(amDynamite, 1, 0, 0, 0)
   112 		SetAmmo(amMine, 1, 0, 0, 0)
    79 		SetAmmo(amMine, 1, 0, 0, 0)
   113 		SetAmmo(amDrill, 1, 0, 0, 0)
    80 		SetAmmo(amDrill, 1, 0, 0, 0)
   114     elseif teamRoles[groupIndex][hogIndex] == 'X' then
    81 	elseif teamRoles[groupIndex][hogIndex] == 'X' then
   115 		SetAmmo(amSniperRifle, 1, 0, 0, 0)
    82 		SetAmmo(amSniperRifle, 1, 0, 0, 0)
   116 		SetAmmo(amDEagle, 1, 0, 0, 0)
    83 		SetAmmo(amDEagle, 1, 0, 0, 0)
   117 		SetAmmo(amPortalGun, 2, 0, 0, 0)
    84 		SetAmmo(amPortalGun, 2, 0, 0, 0)
   118     elseif teamRoles[groupIndex][hogIndex] == 'H' then
    85 	elseif teamRoles[groupIndex][hogIndex] == 'H' then
   119 		SetAmmo(amSeduction, 9, 0, 0, 0)
    86 		SetAmmo(amSeduction, 9, 0, 0, 0)
   120 		SetAmmo(amResurrector, 1, 0, 0, 0)
    87 		SetAmmo(amResurrector, 1, 0, 0, 0)
   121 		SetAmmo(amInvulnerable, 1, 0, 0, 0)
    88 		SetAmmo(amInvulnerable, 1, 0, 0, 0)
   122         SetAmmo(amLowGravity, 1, 0, 0, 0)
    89 		SetAmmo(amLowGravity, 1, 0, 0, 0)
   123     elseif teamRoles[groupIndex][hogIndex] == 'P' then
    90 	elseif teamRoles[groupIndex][hogIndex] == 'P' then
   124 		SetAmmo(amFlamethrower, 1, 0, 0, 0)
    91 		SetAmmo(amFlamethrower, 1, 0, 0, 0)
   125 		SetAmmo(amMolotov, 1, 0, 0, 0)
    92 		SetAmmo(amMolotov, 1, 0, 0, 0)
   126 		SetAmmo(amNapalm, 1, 0, 0, 0)
    93 		SetAmmo(amNapalm, 1, 0, 0, 0)
   127     elseif teamRoles[groupIndex][hogIndex] == 'C' then
    94 	elseif teamRoles[groupIndex][hogIndex] == 'C' then
   128 		SetAmmo(amBaseballBat, 1, 0, 0, 0)
    95 		SetAmmo(amBaseballBat, 1, 0, 0, 0)
   129 		SetAmmo(amGasBomb, 1, 0, 0, 0)
    96 		SetAmmo(amGasBomb, 1, 0, 0, 0)
   130 		SetAmmo(amKamikaze, 1, 0, 0, 0)
    97 		SetAmmo(amKamikaze, 1, 0, 0, 0)
   131 	end
    98 	end
   132 
    99 
   138 	lastTeam = ""
   105 	lastTeam = ""
   139 	z = 0
   106 	z = 0
   140 
   107 
   141 	for i = 0, (numhhs-1) do
   108 	for i = 0, (numhhs-1) do
   142 
   109 
   143 			currTeam = GetHogTeamName(hhs[i])
   110 		currTeam = GetHogTeamName(hhs[i])
   144 
   111 
   145 			if currTeam == lastTeam then
   112 		if currTeam == lastTeam then
   146 					z = z + 1
   113 			z = z + 1
   147 			else
   114 		else
   148 					z = 1
   115 			z = 1
   149                     currTeamIdx = currTeamIdx + 1;
   116 			currTeamIdx = currTeamIdx + 1;
   150 			end
   117 		end
   151 
   118 
   152 			if teamRoles[currTeamIdx][z] == 'S' then
   119 		if teamRoles[currTeamIdx][z] == 'S' then
   153 
   120 
   154 					SetHogName(hhs[i],loc("Soldier"))
   121 			SetHogName(hhs[i],loc("Soldier"))
   155 					SetHogHat(hhs[i], "sf_vega")
   122 			SetHogHat(hhs[i], "sf_vega")
   156 					SetHealth(hhs[i],200)
   123 			SetHealth(hhs[i],200)
   157 
   124 
   158 			elseif teamRoles[currTeamIdx][z] == 'E' then
   125 		elseif teamRoles[currTeamIdx][z] == 'E' then
   159 
   126 
   160 					SetHogHat(hhs[i], "Glasses")
   127 			SetHogHat(hhs[i], "Glasses")
   161 					SetHogName(hhs[i],loc("Engineer"))
   128 			SetHogName(hhs[i],loc("Engineer"))
   162 
   129 
   163 			elseif teamRoles[currTeamIdx][z] == 'N' then
   130 		elseif teamRoles[currTeamIdx][z] == 'N' then
   164 
   131 
   165 					SetHogName(hhs[i],loc("Ninja"))
   132 			SetHogName(hhs[i],loc("Ninja"))
   166 					SetHogHat(hhs[i], "NinjaFull")
   133 			SetHogHat(hhs[i], "NinjaFull")
   167 					SetHealth(hhs[i],80)
   134 			SetHealth(hhs[i],80)
   168 
   135 
   169 			elseif teamRoles[currTeamIdx][z] == 'D' then
   136 		elseif teamRoles[currTeamIdx][z] == 'D' then
   170 
   137 
   171 					SetHogName(hhs[i],loc("Demo"))
   138 			SetHogName(hhs[i],loc("Demo"))
   172 					SetHogHat(hhs[i], "Skull")
   139 			SetHogHat(hhs[i], "Skull")
   173 					SetHealth(hhs[i],200)
   140 			SetHealth(hhs[i],200)
   174 
   141 
   175 			elseif teamRoles[currTeamIdx][z] == 'X' then
   142 		elseif teamRoles[currTeamIdx][z] == 'X' then
   176 
   143 
   177 					SetHogName(hhs[i],loc("Sniper"))
   144 			SetHogName(hhs[i],loc("Sniper"))
   178 					SetHogHat(hhs[i], "Sniper")
   145 			SetHogHat(hhs[i], "Sniper")
   179 					SetHealth(hhs[i],120)
   146 			SetHealth(hhs[i],120)
   180 
   147 
   181 			elseif teamRoles[currTeamIdx][z] == 'H' then
   148 		elseif teamRoles[currTeamIdx][z] == 'H' then
   182 
   149 
   183 					SetHogName(hhs[i],loc("Saint"))
   150 			SetHogName(hhs[i],loc("Saint"))
   184 					SetHogHat(hhs[i], "angel")
   151 			SetHogHat(hhs[i], "angel")
   185 					SetHealth(hhs[i],300)
   152 			SetHealth(hhs[i],300)
   186 
   153 
   187 			elseif teamRoles[currTeamIdx][z] == 'P' then
   154 		elseif teamRoles[currTeamIdx][z] == 'P' then
   188 
   155 
   189 					SetHogName(hhs[i],loc("Pyro"))
   156 			SetHogName(hhs[i],loc("Pyro"))
   190 					SetHogHat(hhs[i], "Gasmask")
   157 			SetHogHat(hhs[i], "Gasmask")
   191 					SetHealth(hhs[i],150)
   158 			SetHealth(hhs[i],150)
   192 
   159 
   193 			elseif teamRoles[currTeamIdx][z] == 'C' then
   160 		elseif teamRoles[currTeamIdx][z] == 'C' then
   194 
   161 
   195 					SetHogName(hhs[i],loc("Loon"))
   162 			SetHogName(hhs[i],loc("Loon"))
   196 					SetHogHat(hhs[i], "clown")
   163 			SetHogHat(hhs[i], "clown")
   197 					SetHealth(hhs[i],100)
   164 			SetHealth(hhs[i],100)
   198 
   165 
   199 			end
   166 		end
   200 
   167 
   201 			lastTeam = GetHogTeamName(hhs[i])
   168 		lastTeam = GetHogTeamName(hhs[i])
   202 
   169 
   203 	end
   170 	end
   204 
   171 
   205 end
   172 end
   206 
   173 
   212 
   179 
   213 function onGameStart()
   180 function onGameStart()
   214 
   181 
   215 	CreateTeam()
   182 	CreateTeam()
   216 
   183 
   217 	ShowMission     (
   184 	ShowMission(
   218                                 loc("THE SPECIALISTS"),
   185 		loc("THE SPECIALISTS"),
   219                                 loc("a Hedgewars mini-game"),
   186 		loc("a Hedgewars mini-game"),
   220 
   187 		loc("Eliminate the enemy specialists.") .. "|" ..
   221                                 loc("Eliminate the enemy specialists.") .. "|" ..
   188 		" " .. "|" ..
   222                                 " " .. "|" ..
   189 		loc("Game Modifiers: ") .. "|" ..
   223 
   190 		loc("Per-Hog Ammo") .. "|" ..
   224                                 loc("Game Modifiers: ") .. "|" ..
   191 		loc("Weapons Reset") .. "|" ..
   225                                 loc("Per-Hog Ammo") .. "|" ..
   192 		loc("Unlimited Attacks") .. "|" ..
   226                                 loc("Weapons Reset") .. "|" ..
   193 		"", 4, 4000
   227                                 loc("Unlimited Attacks") .. "|" ..
   194 	)
   228 
       
   229                                 "", 4, 4000
       
   230                                 )
       
   231 
   195 
   232 	trackTeams()
   196 	trackTeams()
   233 
   197 
   234 end
   198 end
   235 
   199 
   241 
   205 
   242 end
   206 end
   243 
   207 
   244 function onGearAdd(gear)
   208 function onGearAdd(gear)
   245 
   209 
   246     if GetGearType(gear) == gtHedgehog then
   210 	if GetGearType(gear) == gtHedgehog then
   247 		hhs[numhhs] = gear
   211 		hhs[numhhs] = gear
   248 		numhhs = numhhs + 1
   212 		numhhs = numhhs + 1
   249 	elseif (GetGearType(gear) == gtMine) and (started == true) then
   213 	elseif (GetGearType(gear) == gtMine) and (started == true) then
   250 		SetTimer(gear,5000)
   214 		SetTimer(gear,5000)
   251 	end
   215 	end