share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua
changeset 9083 6d2efdca5da2
parent 8057 93e16240f178
child 10017 de822cd3df3a
child 10036 3be36d2fdca6
equal deleted inserted replaced
9082:d971f88c71c0 9083:6d2efdca5da2
     1 local MUTANT_VERSION = "v0.9.4"
     1 local MUTANT_VERSION = "v0.9.5"
     2 
     2 
     3 --[[                  ___                   ___
     3 --[[                  ___                   ___
     4                     (   )                 (   )
     4                     (   )                 (   )
     5 ___ .-. .-. ___  ___ | |_    .---. ___ .-. | |_
     5 ___ .-. .-. ___  ___ | |_    .---. ___ .-. | |_
     6 (   )   '   (   )(   (   __) / .-, (   )   (   __)
     6 (   )   '   (   )(   (   __) / .-, (   )   (   __)
    11 | |  | |  | | |  ; ' | ' | ; |  ; || |  | || ' | |
    11 | |  | |  | | |  ; ' | ' | ; |  ; || |  | || ' | |
    12 | |  | |  | ' `-'  / ' `-' ' `-'  || |  | |' `-' ;
    12 | |  | |  | ' `-'  / ' `-' ' `-'  || |  | |' `-' ;
    13 (___)(___)(___'.__.'   `.__.`.__.'_(___)(___)`.__.
    13 (___)(___)(___'.__.'   `.__.`.__.'_(___)(___)`.__.
    14 
    14 
    15 
    15 
    16 ----  IMPORTANT!
       
    17 ----
       
    18 ----  You should save (press Ctrl+S) this script to:
       
    19 ----  Program Files\Hedgewars\share\hedgewars\Data\Scripts\Multiplayer\Mutant.lua
       
    20 ----     or (on Linux):
       
    21 ----  ~/.hedgewars/Data/Scripts/Multiplayer/Mutant.lua
       
    22 ----
       
    23 ----  (or wherever scripts like Highlander.lua, Racer.lua are on your system)
       
    24 ----
       
    25 ----  Also, if you didn't have Mutant script yet, you need to restart Hedgewars for it to find the script file.
       
    26 ----
       
    27 
       
    28 
       
    29 ----  GAME RULES
       
    30 ----
       
    31 ----  Recommended settings:
    16 ----  Recommended settings:
    32 ----    * one hedgehog per team
    17 ----    * one hedgehog per team
    33 ----    * 'Small' one-island map
    18 ----    * 'Small' one-island map
    34 ----
       
    35 ----  First one to kill anyone becomes Mutant. Mutant has super-weapons
       
    36 ----  and a lot of health, which however depletes if he doesn't frag fast.
       
    37 ----  Goal of Mutant is to use his weapons to hold his status for as long
       
    38 ----  as he can.
       
    39 ----  Goal of others is to hunt the Mutant down. The one who kills Mutant,
       
    40 ----  becomes Mutant himself.
       
    41 ----  The player with least points (or most deaths) is Bottom Feeder. He
       
    42 ----  can gain points by killing anyone. Other normal players only get points
       
    43 ----  for killing Mutant.
       
    44 ----
       
    45 ----  Points:
       
    46 ----    +2 for becoming a Mutant
       
    47 ----    +1 to a Mutant for killing anyone
       
    48 ----    +1 to a Bottom Feeder for killing anyone
       
    49 ----    -1 to anyone for a suicide
       
    50 ----   other kills don't give you points.
       
    51 ----
       
    52 
    19 
    53 --]]
    20 --]]
    54 
    21 
    55 HedgewarsScriptLoad("/Scripts/Locale.lua")
    22 HedgewarsScriptLoad("/Scripts/Locale.lua")
    56 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    23 HedgewarsScriptLoad("/Scripts/Tracker.lua")
    61     To Do:  -Clean-up this fucking piece of code
    28     To Do:  -Clean-up this fucking piece of code
    62             -Debug
    29             -Debug
    63             -Find a girlfriend
    30             -Find a girlfriend
    64             -Fix Sheepluva's hat  +[p]
    31             -Fix Sheepluva's hat  +[p]
    65             -Cookies
    32             -Cookies
    66 
       
    67 -----------------------]]
    33 -----------------------]]
    68 
    34 
    69 local hhs = {}
    35 local hhs = {}
    70 local numhhs = 0
    36 local numhhs = 0
       
    37 local meh = false
    71 
    38 
    72 local gameOver=false
    39 local gameOver=false
    73 
    40 
    74 local mutant = nil
    41 local mutant = nil
    75 local mutant_base_health = 200
    42 local mutant_base_health = 200
    96 
    63 
    97 local teams = {}
    64 local teams = {}
    98 
    65 
    99 local circles = {}
    66 local circles = {}
   100 local circleFrame = -1
    67 local circleFrame = -1
       
    68 
       
    69 function showStartingInfo()
       
    70 
       
    71 	ruleSet = loc("RULES") .. ": " ..
       
    72 	" |" .. --" |" ..
       
    73 	loc("The first player to kill someone becomes the Mutant.") .. "|" ..
       
    74 	loc("The Mutant has super-weapons and a lot of health.") .. "|" ..
       
    75 	loc("The Mutant loses health quickly if he doesn't keep scoring kills.") .. "|" ..
       
    76 	" |" ..
       
    77 	loc("Normal players can only score points by killing the mutant.") .. "|" ..
       
    78 	" |" .. "" ..
       
    79 	loc("The player with least points (or most deaths) becomes the Bottom Feeder.") .. "|" ..
       
    80 	loc("The Bottom Feeder can score points by killing anyone.") .. "|" ..
       
    81 	" |" ..
       
    82 	loc("POINTS") .. ": " ..
       
    83 	" |" ..
       
    84 	loc("+2 for becoming a Mutant") .. "|" ..
       
    85 	loc("+1 to a Mutant for killing anyone") .. "|" ..
       
    86 	loc("+1 to a Bottom Feeder for killing anyone") .. "|" ..
       
    87 	loc("-1 to anyone for a suicide") .. "|" ..
       
    88 	loc("Other kills don't give you points.")
       
    89 
       
    90 	ShowMission(loc("Mutant"),
       
    91                 loc("a Hedgewars tag game"),
       
    92                 ruleSet, 0, 5000)
       
    93 
       
    94 end
   101 
    95 
   102 function onGameInit()
    96 function onGameInit()
   103     TurnTime = 20000
    97     TurnTime = 20000
   104     WaterRise = 0
    98     WaterRise = 0
   105     GameFlags = GameFlags + gfResetWeps + gfPerHogAmmo
    99     GameFlags = GameFlags + gfResetWeps + gfPerHogAmmo
   106     HealthCaseProb=0
   100     HealthCaseProb=0
   107     HealthCaseAmount=0
   101     HealthCaseAmount=0
   108     MinesTime=1000
   102     MinesTime=1000
   109     CaseFreq = 2
   103     CaseFreq = 2
   110 
       
   111 end
   104 end
   112 
   105 
   113 
   106 
   114 function limitHogs(gear)
   107 function limitHogs(gear)
   115     cnthhs = cnthhs + 1
   108     cnthhs = cnthhs + 1
   134         runOnHogsInTeam(limitHogs, teams[i])
   127         runOnHogsInTeam(limitHogs, teams[i])
   135     end
   128     end
   136     if hogLimitHit then
   129     if hogLimitHit then
   137         AddCaption(loc("ONE HOG PER TEAM! KILLING EXCESS HEDGES"))
   130         AddCaption(loc("ONE HOG PER TEAM! KILLING EXCESS HEDGES"))
   138     end
   131     end
       
   132     showStartingInfo()
   139 end
   133 end
   140 
   134 
   141 
   135 
   142 
   136 
   143 function giveWeapons(gear)
   137 function giveWeapons(gear)
   144 
       
   145     if gear == mutant then
   138     if gear == mutant then
   146         AddAmmo(gear, amRope)
   139         AddAmmo(gear, amRope)
   147         for i=1, #mt_weapons do
   140         for i=1, #mt_weapons do
   148             AddAmmo(gear, mt_weapons[i])
   141             AddAmmo(gear, mt_weapons[i])
   149         end
   142         end
   241             AddCaption(loc("HOLY SHYTE!"))
   234             AddCaption(loc("HOLY SHYTE!"))
   242             PlaySound(sndLaugh)
   235             PlaySound(sndLaugh)
   243         elseif killsCounter > 8 then
   236         elseif killsCounter > 8 then
   244             AddCaption(loc("INSANITY"))
   237             AddCaption(loc("INSANITY"))
   245         end
   238         end
   246 
       
   247 end
   239 end
   248 
   240 
   249 function onGameTick()
   241 function onGameTick()
   250 
   242 
   251     if circleFrame > -1 then
   243     if circleFrame > -1 then
   285                         setGearValue(mutant,"SelfDestruct",true)
   277                         setGearValue(mutant,"SelfDestruct",true)
   286                         TurnTimeLeft = 0
   278                         TurnTimeLeft = 0
   287                     end
   279                     end
   288             end
   280             end
   289     end
   281     end
       
   282 
   290 end
   283 end
   291 
   284 
   292 function saveStuff(gear)
   285 function saveStuff(gear)
   293     setGearValue(gear,"Name",GetHogName(gear))
   286     setGearValue(gear,"Name",GetHogName(gear))
   294     setGearValue(gear,"Hat",GetHogHat(gear))
   287     setGearValue(gear,"Hat",GetHogHat(gear))
   299     SetEffect(gear, heResurrectable, false)
   292     SetEffect(gear, heResurrectable, false)
   300     SetHealth(gear, 0)
   293     SetHealth(gear, 0)
   301 end
   294 end
   302 
   295 
   303 function updateScore()
   296 function updateScore()
   304 local showScore = ""
   297 
       
   298     local showScore = ""
   305 
   299 
   306     for i=0, TeamsCount-1 do
   300     for i=0, TeamsCount-1 do
   307         if teams[i]~= nil then
   301         if teams[i]~= nil then
   308 
   302 
   309             local curr_score = getTeamValue(teams[i], "Score")
   303             local curr_score = getTeamValue(teams[i], "Score")
   381 
   375 
   382     if only_low_score then
   376     if only_low_score then
   383         runOnHogsInTeam(setFeeder, lowest_score_team)
   377         runOnHogsInTeam(setFeeder, lowest_score_team)
   384     end
   378     end
   385 
   379 
   386     ShowMission(    loc("Score"),
   380     if meh == false then
       
   381 		meh = true
       
   382 	else
       
   383 		ShowMission(    loc("Score"),
   387                     loc("-------"),
   384                     loc("-------"),
   388                     showScore, 0, 200)
   385                     showScore, 0, 200)
       
   386 	end
   389 
   387 
   390     end
   388     end
   391 end
   389 end
   392 
   390 
   393 function backToNormal(gear)
   391 function backToNormal(gear)
   394 
       
   395     SetHogName(gear, getGearValue(gear,"Name"))
   392     SetHogName(gear, getGearValue(gear,"Name"))
   396     SetHogHat(gear, 'NoHat')
   393     SetHogHat(gear, 'NoHat')
   397     SetHogHat(gear, getGearValue(gear,"Hat"))
   394     SetHogHat(gear, getGearValue(gear,"Hat"))
   398     setGearValue(mutant,"SelfDestruct",false)
   395     setGearValue(mutant,"SelfDestruct",false)
   399     mt_hurt=false
   396     mt_hurt=false
   409         end
   406         end
   410     end
   407     end
   411 end
   408 end
   412 
   409 
   413 function removeFeeder(gear)
   410 function removeFeeder(gear)
   414 
       
   415     if gear~=nil then
   411     if gear~=nil then
   416         setGearValue(gear,"Feeder",false)
   412         setGearValue(gear,"Feeder",false)
   417         if gear~= mutant then
   413         if gear~= mutant then
   418             SetHogName(gear, getGearValue(gear,"Name") )
   414             SetHogName(gear, getGearValue(gear,"Name") )
   419             SetHogHat(gear, 'NoHat')
   415             SetHogHat(gear, 'NoHat')
   421         end
   417         end
   422     end
   418     end
   423 end
   419 end
   424 
   420 
   425 function setFeeder(gear)
   421 function setFeeder(gear)
   426 
       
   427     if gear~= mutant and gear~= nil then
   422     if gear~= mutant and gear~= nil then
   428         SetHogName(gear,"BOTTOM FEEDER")
   423         SetHogName(gear,"BOTTOM FEEDER")
   429         SetHogHat(gear, 'poke_slowpoke')
   424         SetHogHat(gear, 'poke_slowpoke')
   430         setGearValue(gear,"Feeder", true)
   425         setGearValue(gear,"Feeder", true)
   431     end
   426     end
   473                 end
   468                 end
   474             end
   469             end
   475         end
   470         end
   476 
   471 
   477         ---***---
   472         ---***---
   478 end
       
   479 
       
   480 
       
   481 function onGearDamage(gear, dmg)
       
   482 
       
   483 end
   473 end
   484 
   474 
   485 function set_Mutant_and_Score(gear)
   475 function set_Mutant_and_Score(gear)
   486 
   476 
   487 local curr_team = GetHogTeamName(CurrentHedgehog)
   477 local curr_team = GetHogTeamName(CurrentHedgehog)
   617     end
   607     end
   618 end
   608 end
   619 
   609 
   620 --[[
   610 --[[
   621 S T A R R I N G
   611 S T A R R I N G
   622 
       
   623     prof - Coding, implementing and evangelism
   612     prof - Coding, implementing and evangelism
   624     vos  - Initial idea and script improvements
   613     vos  - Initial idea and script improvements
       
   614     mikade - Moving the `how to play` into the game so that people know `how to play`, and whitespace :D
   625 --]]
   615 --]]