share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua
changeset 14269 6f3f59266c4c
parent 13774 e874bfe563c7
child 14270 2b54c956813e
equal deleted inserted replaced
14268:29d614a5c9eb 14269:6f3f59266c4c
    30             -Fix Sheepluva's hat  +[p]
    30             -Fix Sheepluva's hat  +[p]
    31             -Cookies
    31             -Cookies
    32 -----------------------]]
    32 -----------------------]]
    33 
    33 
    34 local hhs = {}
    34 local hhs = {}
       
    35 local crates = {}
    35 local numhhs = 0
    36 local numhhs = 0
    36 local meh = false
    37 local meh = false
    37 
    38 
    38 local gameOver=false
    39 local gameOver=false
    39 
    40 
   101 local mutantHat = "WhySoSerious"
   102 local mutantHat = "WhySoSerious"
   102 local feederHat = "poke_slowpoke"
   103 local feederHat = "poke_slowpoke"
   103 
   104 
   104 function rules()
   105 function rules()
   105 
   106 
   106 	local ruleSet = loc("Hedgehogs will be revived after their death.") .. "|" ..
   107     local ruleSet = loc("Hedgehogs will be revived after their death.") .. "|" ..
   107 	string.format(loc("Mines explode after %d s."), div(MinesTime, 1000)) .. "|" ..
   108     string.format(loc("Mines explode after %d s."), div(MinesTime, 1000)) .. "|" ..
   108 	loc("The first hedgehog to kill someone becomes the Mutant.") .. "|" ..
   109     loc("The first hedgehog to kill someone becomes the Mutant.") .. "|" ..
   109 	loc("The Mutant has super weapons and a lot of health.") .. "|" ..
   110     loc("The Mutant has super weapons and a lot of health.") .. "|" ..
   110 	loc("The Mutant loses health quickly, but gains health by killing.") .. "|" ..
   111     loc("The Mutant loses health quickly, but gains health by killing.") .. "|" ..
   111 	" |" ..
   112     " |" ..
   112 	loc("Score points by killing other hedgehogs.") .. "|" ..
   113     loc("Score points by killing other hedgehogs.") .. "|" ..
   113 	loc("The hedgehog with least points (or most deaths) becomes the Bottom Feeder.") .. "|" ..
   114     loc("The hedgehog with least points (or most deaths) becomes the Bottom Feeder.") .. "|" ..
   114 	loc("The score and deaths are shown next to the team bar.") .. "|" ..
   115     loc("The score and deaths are shown next to the team bar.") .. "|" ..
   115 	string.format(loc("Goal: Score %d points or more to win!"), winScore) .. "|" ..
   116     string.format(loc("Goal: Score %d points or more to win!"), winScore) .. "|" ..
   116         " |" ..
   117         " |" ..
   117 	loc("Scoring: ") .. "|" ..
   118     loc("Scoring: ") .. "|" ..
   118 	loc("+2 for becoming the Mutant") .. "|" ..
   119     loc("+2 for becoming the Mutant") .. "|" ..
   119 	loc("+1 to the Mutant for killing anyone") .. "|" ..
   120     loc("+1 to the Mutant for killing anyone") .. "|" ..
   120 	loc("+1 to the Bottom Feeder for killing anyone") .. "|" ..
   121     loc("+1 to the Bottom Feeder for killing anyone") .. "|" ..
   121 	loc("-1 to anyone for a suicide")
   122     loc("-1 to anyone for a suicide")
   122 
   123 
   123 	return ruleSet
   124     return ruleSet
   124 
   125 
   125 end
   126 end
   126 
   127 
   127 function showStartingInfo()
   128 function showStartingInfo()
   128 
   129 
   129 	ShowMission(loc("Mutant"), loc("A Hedgewars tag game"), rules(), 1, 5000)
   130     ShowMission(loc("Mutant"), loc("A Hedgewars tag game"), rules(), 1, 5000)
   130 
   131 
   131 end
   132 end
   132 
   133 
   133 function onGameInit()
   134 function onGameInit()
   134     TurnTime = 20000
   135     TurnTime = 20000
   509     if only_low_score then
   510     if only_low_score then
   510         runOnHogsInTeam(setFeeder, lowest_score_team)
   511         runOnHogsInTeam(setFeeder, lowest_score_team)
   511     end
   512     end
   512 
   513 
   513     if meh == false then
   514     if meh == false then
   514 		meh = true
   515         meh = true
   515 	end
   516     end
   516 
   517 
   517     end
   518     end
   518 end
   519 end
   519 
   520 
   520 function backToNormal(gear)
   521 function backToNormal(gear)
   530     for i = 0, #hhs do
   531     for i = 0, #hhs do
   531         if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then
   532         if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then
   532             SetGearAIHints(hhs[i], aihUsualProcessing)
   533             SetGearAIHints(hhs[i], aihUsualProcessing)
   533         else
   534         else
   534             SetGearAIHints(hhs[i], aihDoesntMatter)
   535             SetGearAIHints(hhs[i], aihDoesntMatter)
       
   536         end
       
   537     end
       
   538     for i = 0, #crates do
       
   539         if CurrentHedgehog == mutant and crate[i] != nil  then
       
   540             SetGearAIHints(crates[i], aihDoesntMatter)
       
   541         else
       
   542             SetGearAIHints(crates[i], aihUsualProcessing)
   535         end
   543         end
   536     end
   544     end
   537 end
   545 end
   538 
   546 
   539 function removeFeeder(gear)
   547 function removeFeeder(gear)
   694     end
   702     end
   695 end
   703 end
   696 end
   704 end
   697 
   705 
   698 function onGearDamage(gear, damage)
   706 function onGearDamage(gear, damage)
   699 	if not gameOver and GetGearType(gear) == gtHedgehog then
   707     if not gameOver and GetGearType(gear) == gtHedgehog then
   700 		totalDamage = totalDamage + damage
   708         totalDamage = totalDamage + damage
   701 	end
   709     end
   702 end
   710 end
   703 
   711 
   704 function onSkipTurn()
   712 function onSkipTurn()
   705 	-- Record skips for achievement
   713     -- Record skips for achievement
   706 	local team = GetHogTeamName(CurrentHedgehog)
   714     local team = GetHogTeamName(CurrentHedgehog)
   707 	increaseTeamValue(team, "Skips")
   715     increaseTeamValue(team, "Skips")
   708 	if(getTeamValue(team, "Skips") > recordSkips) then
   716     if(getTeamValue(team, "Skips") > recordSkips) then
   709 		recordSkips = getTeamValue(team, "Skips")
   717         recordSkips = getTeamValue(team, "Skips")
   710 		recordSkipsHogName = getGearValue(CurrentHedgehog, "Name")
   718         recordSkipsHogName = getGearValue(CurrentHedgehog, "Name")
   711 		recordSkipsTeamName = team
   719         recordSkipsTeamName = team
   712 	end
   720     end
   713 end
   721 end
   714 
   722 
   715 function onGearAdd(gear)
   723 function onGearAdd(gear)
   716 
   724 
   717     -- Catch hedgehogs for the tracker
   725     -- Catch hedgehogs for the tracker
   718     if GetGearType(gear) == gtHedgehog then
   726     if GetGearType(gear) == gtHedgehog then
   719         trackGear(gear)
   727         trackGear(gear)
   720         hhs[numhhs] = gear
   728         hhs[numhhs] = gear
   721         numhhs = numhhs + 1
   729         numhhs = numhhs + 1
   722         SetEffect(gear, heResurrectable, 1)
   730         SetEffect(gear, heResurrectable, 1)
       
   731     elseif GetGearType(gear) == gtCase then
       
   732         crates[#crates] = gear
   723     elseif GetGearType(gear) == gtATFinishGame then
   733     elseif GetGearType(gear) == gtATFinishGame then
   724         if not gameOver then
   734         if not gameOver then
   725             local winner = createEndGameStats()
   735             local winner = createEndGameStats()
   726             if winner then
   736             if winner then
   727                 SendStat(siGameResult, string.format(loc("%s wins!"), winner))
   737                 SendStat(siGameResult, string.format(loc("%s wins!"), winner))
   773         if getGearValue(gear, "excess") ~= true and band(GetState(gear), gstDrowning) == 0 then
   783         if getGearValue(gear, "excess") ~= true and band(GetState(gear), gstDrowning) == 0 then
   774             AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   784             AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
   775         end
   785         end
   776         trackDeletion(gear)
   786         trackDeletion(gear)
   777     elseif GetGearType(gear) == gtCase then
   787     elseif GetGearType(gear) == gtCase then
       
   788         crates[gear] = nil
   778         -- Check if a crate has been collected
   789         -- Check if a crate has been collected
   779         if band(GetGearMessage(gear), gmDestroy) ~= 0 and CurrentHedgehog ~= nil then
   790         if band(GetGearMessage(gear), gmDestroy) ~= 0 and CurrentHedgehog ~= nil then
   780             -- Update crate collection achievement
   791             -- Update crate collection achievement
   781             increaseTeamValue(GetHogTeamName(CurrentHedgehog), "Crates")
   792             increaseTeamValue(GetHogTeamName(CurrentHedgehog), "Crates")
   782             if(getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") > recordCrates) then
   793             if(getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") > recordCrates) then