share/hedgewars/Data/Scripts/Multiplayer/Battalion.lua
changeset 12987 ba99ecc53cf0
parent 12986 1c38d4370943
child 13029 905449169319
equal deleted inserted replaced
12986:1c38d4370943 12987:ba99ecc53cf0
   245 
   245 
   246 local mode = 'default' -- Which game type to play
   246 local mode = 'default' -- Which game type to play
   247 local modeExplicit = false -- Whether the mode was set in script param
   247 local modeExplicit = false -- Whether the mode was set in script param
   248 local luck = 100 -- Multiplier for bonuses like crates
   248 local luck = 100 -- Multiplier for bonuses like crates
   249 local strength = 1 -- Multiplier for more weapons
   249 local strength = 1 -- Multiplier for more weapons
   250 local mutate = false -- Whether or not to mutate the hogs
   250 local useVariantHats = true -- Whether to overwrite the hog hats to those of their variants
       
   251                             -- In King Mode, crowns are always enforced regardless of this setting
       
   252 local useVariantNames = false -- Whether to overwrite the hog names to those of their variants
   251 
   253 
   252 local highHasBonusWeps = false -- whether or not a hog got bonus weapons on current turn
   254 local highHasBonusWeps = false -- whether or not a hog got bonus weapons on current turn
   253 local highHasBonusHelp = false -- whether or not a hog got bonus helpers on current turn
   255 local highHasBonusHelp = false -- whether or not a hog got bonus helpers on current turn
   254 local highPickupCount = 1
   256 local highPickupCount = 1
   255 local highPickupSDCount = 2
   257 local highPickupSDCount = 2
   631   ##############################################################################
   633   ##############################################################################
   632   ### HOG SETUP  FUNCTIONS                                                   ###
   634   ### HOG SETUP  FUNCTIONS                                                   ###
   633   ##############################################################################
   635   ##############################################################################
   634 ]]--
   636 ]]--
   635 
   637 
   636 function MutateHog(hog)
   638 -- Overwrite hog hat to that of its variant
       
   639 function SetHogVariantHat(hog)
   637   local var = getHogInfo(hog, 'variant')
   640   local var = getHogInfo(hog, 'variant')
   638 
   641   SetHogHat(hog, variants[var]["hat"])
       
   642 end
       
   643 
       
   644 -- Give a crown if the hog is a king.
       
   645 -- Strip the hog from its crown if
       
   646 -- it is not a king.
       
   647 function SetHogVariantHatKingMode(hog)
       
   648   local var = getHogInfo(hog, 'variant')
       
   649   if var == "King" then
       
   650     SetHogHat(hog, variants[var]["hat"])
       
   651   elseif GetHogHat(hog) == "crown" then
       
   652     SetHogHat(hog, "NoHat")
       
   653   end
       
   654 end
       
   655 
       
   656 -- Overwrite hog name to that of its variant
       
   657 function SetHogVariantName(hog)
       
   658   local var = getHogInfo(hog, 'variant')
   639   SetHogName(hog, variants[var]["name"])
   659   SetHogName(hog, variants[var]["name"])
   640   SetHogHat(hog, variants[var]["hat"])
       
   641 end
   660 end
   642 
   661 
   643 function GetRandomVariant()
   662 function GetRandomVariant()
   644   local maxNum = 0
   663   local maxNum = 0
   645 
   664 
  1479     if mode == "default" or mode == "king" or mode == "points" or mode == "highland" then
  1498     if mode == "default" or mode == "king" or mode == "points" or mode == "highland" then
  1480        modeExplicit = true
  1499        modeExplicit = true
  1481     end
  1500     end
  1482   end
  1501   end
  1483 
  1502 
       
  1503   if params['mutatenames'] ~= nil then
       
  1504     useVariantNames = params['mutatenames']
       
  1505   end
  1484   if params['mutate'] ~= nil then
  1506   if params['mutate'] ~= nil then
  1485     mutate = params['mutate']
  1507     useVariantHats = params['mutate']
  1486   end
  1508   end
  1487 
  1509 
  1488   if params['strength'] ~= nil and tonumber(params['strength']) > 0 then
  1510   if params['strength'] ~= nil and tonumber(params['strength']) > 0 then
  1489     strength = tonumber(params['strength'])
  1511     strength = tonumber(params['strength'])
  1490     -- Highland
  1512     -- Highland
  1603   runOnGears(setHogInfo)
  1625   runOnGears(setHogInfo)
  1604   
  1626   
  1605   if mode ~= 'points' then
  1627   if mode ~= 'points' then
  1606     runOnGears(setHogVariant)
  1628     runOnGears(setHogVariant)
  1607     runOnGears(setupHogTurn)
  1629     runOnGears(setupHogTurn)
  1608     if mutate ~= false and mutate ~= 'false' then
  1630     if useVariantNames ~= false and useVariantNames ~= 'false' then
  1609       runOnGears(MutateHog)
  1631       runOnGears(SetHogVariantName)
       
  1632     end
       
  1633     if useVariantHats ~= false and useVariantHats ~= 'false' then
       
  1634         runOnGears(SetHogVariantHat)
       
  1635     elseif mode == 'king' then
       
  1636         -- If variant hats are disabled but we're in King Mode,
       
  1637         -- we still change *some* hats to make sure only kings
       
  1638         -- wear crows. Otherwise, you don't know who's the king!
       
  1639         runOnGears(SetHogVariantHatKingMode)
  1610     end
  1640     end
  1611   end
  1641   end
  1612 
  1642 
  1613   if mode == 'points' then
  1643   if mode == 'points' then
  1614     for key, val in pairs(teamNames) do
  1644     for key, val in pairs(teamNames) do