share/hedgewars/Data/Scripts/Multiplayer/Highlander.lua
changeset 13275 7ed4ab32f351
parent 12956 89930daecaab
child 13450 f38b72d64157
equal deleted inserted replaced
13274:e381f5260b45 13275:7ed4ab32f351
   138 local utiltot = 0
   138 local utiltot = 0
   139 
   139 
   140 local someHog = nil -- just for looking up the weps
   140 local someHog = nil -- just for looking up the weps
   141 
   141 
   142 -- Script parameter stuff
   142 -- Script parameter stuff
   143 local mode = nil
   143 
   144 
   144 --[[ Loyal Highlander.
   145 -- If true, killing hogs of your own clan doesn't give you their weapons.
   145 If true, killing hogs of your own clan doesn't give you their weapons.
   146 -- Otherwise, killing any hog gives you their weapons.
   146 Otherwise, killing any hog gives you their weapons. ]]
   147 local loyal = false
   147 local loyal = false
       
   148 
       
   149 
       
   150 --[[ Multiple weapon usages.
       
   151 This is a bit tricky to explain.
       
   152 First, remind yourselves that hogs can never hold more than 1 of the same ammo type.
       
   153 
       
   154 This param changes how ammo will be restocked after killing a hog if you
       
   155 already owned this ammo.
       
   156 Basically this is about if you can use the same weapon multiple times in a
       
   157 turn by killing enemies in a clever way.
       
   158 We need to distinguish between your current inventory and the “reset inventory”,
       
   159 that is, the state to which your inventory will get reset in the next turn.
       
   160 
       
   161 No Multi-Use (default):
       
   162     If you kill a hog who owns a weapon you currently have in your reset inventory,
       
   163     but not your inventory, you DO NOT get this weapon again.
       
   164 
       
   165 Multi-Use:
       
   166     If you kill a hog who owns a weapon you currently have in your reset inventory,
       
   167     but not your inventory, you DO get this weapon.
       
   168 
       
   169 Example 1:
       
   170     You have a ballgun, and use it to kill a hog who also owns a ballgun.
       
   171     No Multi-Use: You will NOT get another ballgun, since it's in your
       
   172                   reset inventory.
       
   173     Multi-Use: You get another ballgun.
       
   174 
       
   175 Example 2:
       
   176     You have a grenade and a bazooka in your inventory. You use the bazooka
       
   177     to kill a hedgehog who owns a grenade.
       
   178     In both ammo limit modes, you do NOT win any ammo since you already have
       
   179     a grenade in your inventory (not just your reset inventory), and the
       
   180     rule “no more than 1 ammo per type” applies.
       
   181 ]]
       
   182 local multiUse = false
   148 
   183 
   149 function onParameters()
   184 function onParameters()
   150     parseParams()
   185     parseParams()
   151     mode = params["mode"]
   186     multiUse = params["multiuse"] == "true"
   152     loyal = params["loyal"] == "true"
   187     loyal = params["loyal"] == "true"
   153 end
   188 end
   154 
   189 
   155 function CheckForWeaponSwap()
   190 function CheckForWeaponSwap()
   156 	if GetCurAmmoType() ~= lastWep then
   191 	if GetCurAmmoType() ~= lastWep then
   243             color = GetClanColor(GetHogClan(CurrentHedgehog))
   278             color = GetClanColor(GetHogClan(CurrentHedgehog))
   244         end
   279         end
   245 
   280 
   246         for w,c in pairs(wepArray) do
   281         for w,c in pairs(wepArray) do
   247 			val = getGearValue(gear,w)
   282 			val = getGearValue(gear,w)
   248 			if val ~= 0 and (mode == "orig" or (wepArray[w] ~= 9 and getGearValue(CurrentHedgehog, w) == 0))  then
   283 			if val ~= 0 and (multiUse or (wepArray[w] ~= 9 and getGearValue(CurrentHedgehog, w) == 0))  then
   249 				setGearValue(CurrentHedgehog, w, val)
   284 				setGearValue(CurrentHedgehog, w, val)
   250 
   285 
   251 				-- if you are using multi-shot weapon, gimme one more
   286 				-- if you are using multi-shot weapon, gimme one more
   252 				if (GetCurAmmoType() == w) and (shotsFired ~= 0) then
   287 				if (GetCurAmmoType() == w) and (shotsFired ~= 0) then
   253 					AddAmmo(CurrentHedgehog, w, val+1)
   288 					AddAmmo(CurrentHedgehog, w, val+1)
   290 		Goals = loc("Loyal Highlander: Eliminate enemy hogs to take their weapons") .. "|"
   325 		Goals = loc("Loyal Highlander: Eliminate enemy hogs to take their weapons") .. "|"
   291 	else
   326 	else
   292 		Goals = loc("Highlander: Eliminate hogs to take their weapons") .. "|"
   327 		Goals = loc("Highlander: Eliminate hogs to take their weapons") .. "|"
   293 	end
   328 	end
   294 	Goals = Goals .. loc("Replenishment: Weapons are restocked on turn start of a new hog") .. "|" ..
   329 	Goals = Goals .. loc("Replenishment: Weapons are restocked on turn start of a new hog") .. "|" ..
   295 	loc("Ammo Limit: Hogs can’t have more than 1 ammo per type")
   330 	loc("Ammo Limit: Hogs can’t have more than 1 ammo per type") .. "|"
       
   331 	if multiUse then
       
   332 		Goals = Goals .. loc("Multi-Use: You can take and use the same ammo type multiple times in a turn")
       
   333 	else
       
   334 		Goals = Goals .. loc("No Multi-Use: Once you used an ammo, you can’t take it again in this turn")
       
   335 	end
   296 end
   336 end
   297 
   337 
   298 function onGameStart()
   338 function onGameStart()
   299     utilChoices[amSkip] = 0
   339     utilChoices[amSkip] = 0
   300     local c = 0
   340     local c = 0