share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
changeset 11728 373150be0356
parent 11727 1c09b8d050ce
child 11729 2d57eed66d41
equal deleted inserted replaced
11727:1c09b8d050ce 11728:373150be0356
    24 ------------------------------------------------------------------------------
    24 ------------------------------------------------------------------------------
    25 -- SCRIPT PARAMETER
    25 -- SCRIPT PARAMETER
    26 ------------------------------------------------------------------------------
    26 ------------------------------------------------------------------------------
    27 -- The script parameter can be used to configure the energy
    27 -- The script parameter can be used to configure the energy
    28 -- of the game. It is a comma-seperated list of key=value pairs, where each
    28 -- of the game. It is a comma-seperated list of key=value pairs, where each
    29 -- key is a word and each value is non-negative integer.
    29 -- key is a word and each value is an negative integer between 0 and 4294967295.
    30 --
    30 --
    31 -- Possible keys:
    31 -- Possible keys:
    32 --- initialenergy: Amount of energy that each team starts with (default: 550)
    32 --- initialenergy: Amount of energy that each team starts with (default: 550)
    33 --- energyperround: Amount of energy that each team gets per round (default: 50)
    33 --- energyperround: Amount of energy that each team gets per round (default: 50)
    34 --- maxenergy: Maximum amount of energy each team can hold (default: 1000)
    34 --- maxenergy: Maximum amount of energy each team can hold (default: 1000).
    35 
    35 
    36 -- Example: “initialenergy=750, maxenergy=2000” starts thee game with 750 energy
    36 -- Example: “initialenergy=750, maxenergy=2000” starts thee game with 750 energy
    37 -- and sets the maximum energy to 2000
    37 -- and sets the maximum energy to 2000
    38 
    38 
    39 ------------------------------------------------------------------------------
    39 ------------------------------------------------------------------------------
   840 					if z == strucClan[i] then
   840 					if z == strucClan[i] then
   841 						increaseGearValue(strucGear[i],"power")
   841 						increaseGearValue(strucGear[i],"power")
   842 						if getGearValue(strucGear[i],"power") == 10 then
   842 						if getGearValue(strucGear[i],"power") == 10 then
   843 							setGearValue(strucGear[i],"power",0)
   843 							setGearValue(strucGear[i],"power",0)
   844 							clanPower[z] = clanPower[z] + 1
   844 							clanPower[z] = clanPower[z] + 1
   845 							if clanPower[z] > conf_maxEnergy then
   845 							if conf_maxEnergy ~= "inf" and clanPower[z] > conf_maxEnergy then
   846 								clanPower[z] = conf_maxEnergy
   846 								clanPower[z] = conf_maxEnergy
   847 							end
   847 							end
   848 						end
   848 						end
   849 	
   849 	
   850 					end
   850 					end
  1496 -- Parses a positive integer
  1496 -- Parses a positive integer
  1497 function parseInt(str, default)
  1497 function parseInt(str, default)
  1498 	if str == nil then return default end
  1498 	if str == nil then return default end
  1499 	local s = string.match(str, "(%d*)")
  1499 	local s = string.match(str, "(%d*)")
  1500 	if s ~= nil then
  1500 	if s ~= nil then
  1501 		return math.max(0, tonumber(s))
  1501 		return math.min(4294967295, math.max(0, tonumber(s)))
  1502 	else
  1502 	else
  1503 		return nil
  1503 		return nil
  1504 	end
  1504 	end
  1505 end
  1505 end
  1506 
  1506 
  1507 -- Parse parameters
  1507 -- Parse parameters
  1508 function onParameters()
  1508 function onParameters()
  1509 	parseParams()
  1509 	parseParams()
  1510 	conf_initialEnergy = parseInt(params["initialenergy"], conf_initialEnergy)
  1510 	conf_initialEnergy = parseInt(params["initialenergy"], conf_initialEnergy)
  1511 	conf_energyPerRound = parseInt(params["energyperround"], conf_energyPerRound)
  1511 	conf_energyPerRound = parseInt(params["energyperround"], conf_energyPerRound)
  1512 	conf_maxEnergy = parseInt(params["maxenergy"], conf_maxEnergy)
  1512 	if params["maxenergy"] == "inf" then
       
  1513 		conf_maxEnergy = "inf"
       
  1514 	else
       
  1515 		conf_maxEnergy = parseInt(params["maxenergy"], conf_maxEnergy)
       
  1516 	end
  1513 end
  1517 end
  1514 
  1518 
  1515 function onGameInit()
  1519 function onGameInit()
  1516 
  1520 
  1517 	Explosives = 0
  1521 	Explosives = 0
  1605 	local clan = GetHogClan(CurrentHedgehog)
  1609 	local clan = GetHogClan(CurrentHedgehog)
  1606 	if clanFirstTurn[clan] then
  1610 	if clanFirstTurn[clan] then
  1607 		clanFirstTurn[clan] = false
  1611 		clanFirstTurn[clan] = false
  1608 	else
  1612 	else
  1609 		clanPower[clan] = clanPower[clan] + conf_energyPerRound
  1613 		clanPower[clan] = clanPower[clan] + conf_energyPerRound
  1610 		if clanPower[clan] > conf_maxEnergy then
  1614 		if conf_maxEnergy ~= "inf" and clanPower[clan] > conf_maxEnergy then
  1611 			clanPower[clan] = conf_maxEnergy
  1615 			clanPower[clan] = conf_maxEnergy
  1612 		end
  1616 		end
  1613 	end
  1617 	end
  1614 	clanUsedExtraTime[clan] = false
  1618 	clanUsedExtraTime[clan] = false
  1615 	clanCratesSpawned[clan] = 0
  1619 	clanCratesSpawned[clan] = 0