share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua
author unc0rr
Tue, 30 Oct 2012 00:16:42 +0400
changeset 7879 c5be4be37f4b
parent 7878 2be6c9b89797
child 7889 57b117d441b9
permissions -rw-r--r--
Change messages a bit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7878
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     1
local MUTANT_VERSION = "v0.9.4"
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     2
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     3
--[[                  ___                   ___
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     4
                    (   )                 (   )
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     5
___ .-. .-. ___  ___ | |_    .---. ___ .-. | |_
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     6
(   )   '   (   )(   (   __) / .-, (   )   (   __)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     7
|  .-.  .-. | |  | | | |   (__) ; ||  .-. .| |
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     8
| |  | |  | | |  | | | | ___ .'`  || |  | || | ___
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
     9
| |  | |  | | |  | | | |(   / .'| || |  | || |(   )
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    10
| |  | |  | | |  | | | | | | /  | || |  | || | | |
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    11
| |  | |  | | |  ; ' | ' | ; |  ; || |  | || ' | |
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    12
| |  | |  | ' `-'  / ' `-' ' `-'  || |  | |' `-' ;
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    13
(___)(___)(___'.__.'   `.__.`.__.'_(___)(___)`.__.
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    14
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    15
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    16
----  IMPORTANT!
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    17
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    18
----  You should save (press Ctrl+S) this script to:
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    19
----  Program Files\Hedgewars\share\hedgewars\Data\Scripts\Multiplayer\Mutant.lua
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    20
----     or (on Linux):
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    21
----  ~/.hedgewars/Data/Scripts/Multiplayer/Mutant.lua
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    22
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    23
----  (or wherever scripts like Highlander.lua, Racer.lua are on your system)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    24
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    25
----  Also, if you didn't have Mutant script yet, you need to restart Hedgewars for it to find the script file.
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    26
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    27
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    28
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    29
----  GAME RULES
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    30
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    31
----  Recommended settings:
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    32
----    * one hedgehog per team
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    33
----    * 'Small' one-island map
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    34
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    35
----  First one to kill anyone becomes Mutant. Mutant has super-weapons
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    36
----  and a lot of health, which however depletes if he doesn't frag fast.
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    37
----  Goal of Mutant is to use his weapons to hold his status for as long
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    38
----  as he can.
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    39
----  Goal of others is to hunt the Mutant down. The one who kills Mutant,
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    40
----  becomes Mutant himself.
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    41
----  The player with least points (or most deaths) is Bottom Feeder. He
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    42
----  can gain points by killing anyone. Other normal players only get points
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    43
----  for killing Mutant.
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    44
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    45
----  Points:
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    46
----    +2 for becoming a Mutant
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    47
----    +1 to a Mutant for killing anyone
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    48
----    +1 to a Bottom Feeder for killing anyone
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    49
----    -1 to anyone for a suicide
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    50
----   other kills don't give you points.
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    51
----
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    52
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    53
--]]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    54
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    55
loadfile(GetDataPath() .. "Scripts/Locale.lua")()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    56
loadfile(GetDataPath() .. "Scripts/Tracker.lua")()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    57
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    58
--[[
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    59
    MUTANT SCRIPT
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    60
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    61
    To Do:  -Clean-up this fucking piece of code
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    62
            -Debug
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    63
            -Find a girlfriend
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    64
            -Fix Sheepluva's hat  +[p]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    65
            -Cookies
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    66
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    67
-----------------------]]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    68
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    69
local hhs = {}
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    70
local numhhs = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    71
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    72
local gameOver=false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    73
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    74
local mutant = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    75
local mutant_base_health = 200
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    76
local mutant_base_disease = 25
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    77
local disease_timer = 2000
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    78
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    79
local kill_reward = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    80
local mt_hurt=false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    81
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    82
local killsCounter = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    83
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    84
local team_fire_punishment = 3
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    85
local mutant_kill_reward = 2
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    86
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    87
local hh_weapons = { amBazooka, amGrenade, amShotgun, amMine}
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    88
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    89
local mt_weapons = {amWatermelon, amHellishBomb, amBallgun, amRCPlane, amTeleport}
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    90
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    91
local disease=0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    92
local timer=0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    93
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    94
local winScore = 15
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    95
local hogsLimit = 1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    96
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    97
local teams = {}
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    98
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
    99
local circles = {}
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   100
local circleFrame = -1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   101
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   102
function onGameInit()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   103
    TurnTime = 20000
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   104
    WaterRise = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   105
    GameFlags = GameFlags + gfResetWeps + gfPerHogAmmo
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   106
    HealthCaseProb=0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   107
    HealthCaseAmount=0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   108
    MinesTime=1000
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   109
    CaseFreq = 2
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   110
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   111
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   112
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   113
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   114
function limitHogs(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   115
    cnthhs = cnthhs + 1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   116
        if cnthhs > 1 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   117
            hogLimitHit = true
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   118
            SetEffect(gear, heResurrectable, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   119
            SetHealth(gear, 0)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   120
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   121
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   122
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   123
function onGameStart()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   124
    trackTeams()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   125
    teamScan()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   126
    runOnHogs(saveStuff)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   127
    --local str = "/say " .. MUTANT_VERSION
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   128
    --ParseCommand(str)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   129
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   130
    hogLimitHit = false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   131
    for i=0 , TeamsCount - 1 do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   132
        cnthhs = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   133
        runOnHogsInTeam(limitHogs, teams[i])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   134
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   135
    if hogLimitHit then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   136
        AddCaption(loc("ONE HOG PER TEAM! KILLING EXCESS HEDGES"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   137
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   138
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   139
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   140
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   141
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   142
function giveWeapons(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   143
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   144
    if gear == mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   145
        AddAmmo(gear, amRope)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   146
        for i=1, #mt_weapons do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   147
            AddAmmo(gear, mt_weapons[i])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   148
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   149
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   150
    else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   151
        for i=1, #hh_weapons do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   152
            AddAmmo(gear,hh_weapons[i])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   153
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   154
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   155
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   156
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   157
function onAmmoStoreInit()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   158
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   159
    SetAmmo(amSkip, 9, 0, 0, 0)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   160
    SetAmmo(amRope,0,1,0,5)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   161
    SetAmmo(amSnowball,0,1,0,1)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   162
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   163
    for i=1, #hh_weapons do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   164
        SetAmmo(hh_weapons[i], 0, 0, 0, 1)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   165
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   166
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   167
    for i=1, #mt_weapons do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   168
        SetAmmo(mt_weapons[i], 0, 3, 0, 1)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   169
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   170
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   171
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   172
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   173
function drawCircles()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   174
    for i = 0, #hhs do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   175
        if circles[hhs[i]] ~= nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   176
            DeleteVisualGear(circles[hhs[i]])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   177
            circles[hhs[i]] = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   178
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   179
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   180
        if hhs[i] ~= CurrentHedgehog then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   181
            if mutant == nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   182
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   183
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   184
            elseif CurrentHedgehog == mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   185
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   186
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   187
            elseif getGearValue(CurrentHedgehog, "Feeder") and hhs[i] ~= mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   188
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   189
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   190
            elseif hhs[i] == mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   191
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   192
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   193
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   194
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   195
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   196
    circleFrame = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   197
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   198
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   199
function onNewTurn()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   200
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   201
    trackTeams()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   202
    killsCounter = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   203
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   204
    if mutant == nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   205
        AddCaption( loc("FIRST BLOOD MUTATES") )
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   206
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   207
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   208
    checkScore()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   209
    giveWeapons(CurrentHedgehog)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   210
    drawCircles()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   211
    kill_reward= numhhs*10
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   212
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   213
    if CurrentHedgehog == mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   214
        mt_hurt=true
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   215
        disease= mutant_base_disease - numhhs
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   216
    else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   217
        mt_hurt=false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   218
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   219
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   220
    setGearValue(CurrentHedgehog, "Alive", true)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   221
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   222
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   223
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   224
function countBodies()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   225
        if killsCounter == 2 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   226
            AddCaption(loc("DOUBLE KILL"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   227
        elseif killsCounter == 3 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   228
            AddCaption(loc("MEGA KILL"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   229
            PlaySound(sndRegret)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   230
        elseif killsCounter == 4 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   231
            AddCaption(loc("ULTRA KILL"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   232
        elseif killsCounter == 5 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   233
            AddCaption(loc("MONSTER KILL"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   234
            PlaySound(sndIllGetYou)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   235
        elseif killsCounter == 6 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   236
            AddCaption(loc("LUDICROUS KILL"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   237
            PlaySound(sndNutter)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   238
        elseif killsCounter == 7 then
7879
c5be4be37f4b Change messages a bit
unc0rr
parents: 7878
diff changeset
   239
            AddCaption(loc("HOLY SHIT!"))
7878
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   240
            PlaySound(sndLaugh)
7879
c5be4be37f4b Change messages a bit
unc0rr
parents: 7878
diff changeset
   241
        elseif killsCounter > 8 then
c5be4be37f4b Change messages a bit
unc0rr
parents: 7878
diff changeset
   242
            AddCaption(loc("FAG"))
7878
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   243
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   244
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   245
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   246
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   247
function onGameTick()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   248
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   249
    if circleFrame > -1 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   250
        for i = 0, #hhs do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   251
            if circles[hhs[i]] ~= nil and hhs[i]~= nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   252
                hhx, hhy = GetGearPosition(hhs[i])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   253
                X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint = GetVisualGearValues(circles[hhs[i]])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   254
                SetVisualGearValues(circles[hhs[i]], hhx + 1, hhy - 3, 0, 0, 0, 0, 0, 40 - (circleFrame % 25), Timer, Tint)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   255
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   256
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   257
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   258
        circleFrame = circleFrame + 0.06
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   259
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   260
        if circleFrame >= 25 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   261
            for i = 0, #hhs do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   262
                if circles[hhs[i]] ~= nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   263
                    DeleteVisualGear(circles[hhs[i]])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   264
                    circles[hhs[i]] = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   265
                end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   266
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   267
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   268
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   269
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   270
    if TurnTimeLeft==0 and mt_hurt then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   271
        mt_hurt = false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   272
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   273
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   274
    if mt_hurt and mutant~=nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   275
        timer = timer + 1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   276
            if timer > disease_timer then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   277
                timer = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   278
                SetHealth(mutant, GetHealth(mutant)-disease )
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   279
                AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   280
                    if GetHealth(mutant)<=0 then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   281
                        SetHealth(mutant,0)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   282
                        mt_hurt= false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   283
                        setGearValue(mutant,"SelfDestruct",true)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   284
                        TurnTimeLeft = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   285
                    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   286
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   287
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   288
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   289
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   290
function saveStuff(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   291
    setGearValue(gear,"Name",GetHogName(gear))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   292
    setGearValue(gear,"Hat",GetHogHat(gear))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   293
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   294
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   295
function armageddon(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   296
    SetState(gear, gstLoser)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   297
    SetEffect(gear, heResurrectable, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   298
    SetHealth(gear, 0)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   299
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   300
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   301
function updateScore()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   302
local showScore = ""
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   303
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   304
    for i=0, TeamsCount-1 do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   305
        if teams[i]~= nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   306
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   307
            local curr_score = getTeamValue(teams[i], "Score")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   308
            showScore = showScore .. teams[i] .. ": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   309
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   310
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   311
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   312
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   313
    ShowMission(loc("Score"),
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   314
                "-------",
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   315
                showScore, 0, 200)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   316
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   317
    HideMission()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   318
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   319
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   320
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   321
function checkScore()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   322
local showScore = ""
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   323
local lowest_score_team = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   324
local min_score=nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   325
local winTeam = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   326
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   327
local only_low_score = true
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   328
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   329
    for i=0, TeamsCount-1 do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   330
        if teams[i]~=nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   331
            local curr_score = getTeamValue(teams[i], "Score")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   332
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   333
            runOnHogsInTeam(removeFeeder, teams[i])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   334
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   335
            showScore = showScore .. teams[i] ..": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   336
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   337
            if curr_score >= winScore then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   338
                gameOver = true
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   339
                winTeam = teams[i]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   340
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   341
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   342
            if min_score==nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   343
                min_score= curr_score
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   344
                lowest_score_team = teams[i]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   345
            else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   346
                if curr_score <= min_score then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   347
                    if curr_score == min_score then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   348
                        if getTeamValue(teams[i], "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   349
                            only_low_score = false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   350
                        else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   351
                            if getTeamValue(teams[i], "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   352
                                lowest_score_team = teams[i]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   353
                            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   354
                            only_low_score = true
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   355
                        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   356
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   357
                    else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   358
                        min_score= curr_score
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   359
                        lowest_score_team = teams[i]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   360
                        only_low_score = true
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   361
                    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   362
                end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   363
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   364
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   365
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   366
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   367
    if gameOver then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   368
        TurnTimeLeft = 0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   369
        for i=0, #teams do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   370
            if teams[i]~=winTeam then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   371
                runOnHogsInTeam(armageddon, teams[i])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   372
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   373
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   374
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   375
    ShowMission(    loc("WINNER IS ") .. winTeam,
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   376
                    "~~~~~~~~~~~~~~~~~~~~~~~~~",
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   377
                    showScore, 0, 200)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   378
    else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   379
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   380
    if only_low_score then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   381
        runOnHogsInTeam(setFeeder, lowest_score_team)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   382
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   383
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   384
    ShowMission(    loc("Score"),
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   385
                    loc("-------"),
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   386
                    showScore, 0, 200)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   387
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   388
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   389
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   390
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   391
function backToNormal(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   392
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   393
    SetHogName(gear, getGearValue(gear,"Name"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   394
    SetHogHat(gear, 'NoHat')
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   395
    SetHogHat(gear, getGearValue(gear,"Hat"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   396
    setGearValue(mutant,"SelfDestruct",false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   397
    mt_hurt=false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   398
    mutant=nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   399
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   400
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   401
function removeFeeder(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   402
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   403
    if gear~=nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   404
        setGearValue(gear,"Feeder",false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   405
        if gear~= mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   406
            SetHogName(gear, getGearValue(gear,"Name") )
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   407
            SetHogHat(gear, 'NoHat')
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   408
            SetHogHat(gear, getGearValue(gear,"Hat"))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   409
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   410
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   411
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   412
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   413
function setFeeder(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   414
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   415
    if gear~= mutant and gear~= nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   416
        SetHogName(gear,"BOTTOM FEEDER")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   417
        SetHogHat(gear, 'Poke_Slowpoke')
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   418
        setGearValue(gear,"Feeder", true)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   419
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   420
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   421
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   422
function setMutantStuff(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   423
    mutant = gear
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   424
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   425
    SetHogName(gear,"MUTANT")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   426
    SetHogHat(gear,'whysoserious')
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   427
    SetHealth(gear, ( mutant_base_health + numhhs*25) )
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   428
    SetEffect(gear, hePoisoned, 1)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   429
    setGearValue(mutant,"SelfDestruct",false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   430
    setGearValue(gear, "Feeder", false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   431
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   432
    AddCaption(getGearValue(gear, "Name") .. loc(" HAS MUTATED" ))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   433
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   434
    TurnTimeLeft=0
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   435
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   436
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   437
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   438
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   439
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   440
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   441
    PlaySound(sndSuddenDeath)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   442
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   443
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   444
function teamScan()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   445
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   446
        for i=0, TeamsCount-1 do --nil filling
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   447
        teams[i]=nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   448
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   449
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   450
        for i=0, #hhs do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   451
            for j=0, TeamsCount-1 do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   452
                if teams[j] ==nil and hhs[i]~=nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   453
                teams[j] = GetHogTeamName(hhs[i])
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   454
                setTeamValue(teams[j],"Score",0)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   455
                setTeamValue(teams[j], "DeadHogs",0)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   456
                break
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   457
                end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   458
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   459
                if teams[j] == GetHogTeamName(hhs[i]) then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   460
                    break
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   461
                end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   462
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   463
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   464
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   465
        ---***---
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   466
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   467
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   468
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   469
function onGearDamage(gear, dmg)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   470
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   471
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   472
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   473
function set_Mutant_and_Score(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   474
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   475
local curr_team = GetHogTeamName(CurrentHedgehog)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   476
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   477
    if gear == CurrentHedgehog then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   478
        if CurrentHedgehog == mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   479
            PlaySound(sndHomerun)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   480
            if getGearValue(gear, "SelfDestruct")==false then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   481
                decreaseTeamValue(curr_team,"Score")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   482
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   483
            backToNormal(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   484
        else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   485
            decreaseTeamValue(curr_team,"Score")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   486
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   487
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   488
    else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   489
            if gear == mutant then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   490
                    backToNormal(mutant)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   491
                    if curr_team ~=GetHogTeamName(gear) then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   492
                            if  getGearValue(CurrentHedgehog, "Alive") then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   493
                            setMutantStuff(CurrentHedgehog)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   494
                            setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   495
                            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   496
                    else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   497
                        setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   498
                    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   499
            else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   500
                if mutant==nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   501
                        if curr_team ~=GetHogTeamName(gear) then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   502
                            if getGearValue(CurrentHedgehog, "Alive") then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   503
                                    setMutantStuff(CurrentHedgehog)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   504
                                    setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   505
                            else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   506
                                increaseTeamValue(curr_team,"Score")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   507
                            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   508
                        else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   509
                            setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   510
                        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   511
                else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   512
                    if curr_team ~=GetHogTeamName(gear) then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   513
                        if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   514
                            SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+kill_reward)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   515
                            AddCaption("+" .. kill_reward .. loc(" HP") )
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   516
                            increaseTeamValue(curr_team,"Score")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   517
                        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   518
                        if getGearValue(CurrentHedgehog,"Feeder") then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   519
                            increaseTeamValue(curr_team,"Score")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   520
                        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   521
                    else
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   522
                        setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   523
                    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   524
                end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   525
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   526
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   527
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   528
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   529
function onGearResurrect(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   530
if not gameOver then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   531
    if GetGearType(gear) == gtHedgehog then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   532
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   533
        increaseTeamValue(GetHogTeamName(gear), "DeadHogs")
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   534
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   535
        if gear==CurrentHedgehog then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   536
            setGearValue(CurrentHedgehog, "Alive", false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   537
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   538
        set_Mutant_and_Score(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   539
        if gear~=CurrentHedgehog then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   540
            killsCounter = killsCounter + 1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   541
            countBodies()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   542
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   543
        AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   544
        PlaySound(sndWhack)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   545
        updateScore()
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   546
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   547
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   548
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   549
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   550
function onGearAdd(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   551
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   552
    -- Catch hedgehogs for the tracker
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   553
    if GetGearType(gear) == gtHedgehog then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   554
        trackGear(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   555
        hhs[numhhs] = gear
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   556
        numhhs = numhhs + 1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   557
        SetEffect(gear, heResurrectable, 1)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   558
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   559
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   560
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   561
function checkEmptyTeam (teamName)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   562
    for i=0 , #hhs do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   563
        if hhs[i]~=nil then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   564
            if teamName == GetHogTeamName(hhs[i]) then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   565
                return false
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   566
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   567
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   568
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   569
    return true
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   570
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   571
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   572
function onGearDelete(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   573
    -- Remove hogs that are gone
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   574
    if GetGearType(gear) == gtHedgehog then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   575
        numhhs = numhhs - 1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   576
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   577
        local found
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   578
        for i=0, #hhs do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   579
            if hhs[i] == gear then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   580
                found = i
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   581
                break
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   582
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   583
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   584
        for i = found, #hhs - 1 do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   585
            hhs[i] = hhs[i + 1]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   586
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   587
        hhs[#hhs] = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   588
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   589
        local t_name = GetHogTeamName(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   590
        if checkEmptyTeam(t_name) then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   591
            for i = 0, TeamsCount - 1 do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   592
                if teams[i] == t_name then
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   593
                    found = i
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   594
                    break
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   595
                end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   596
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   597
            for i = found, TeamsCount - 2 do
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   598
                teams[i] = teams[i + 1]
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   599
            end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   600
            teams[TeamsCount - 1] = nil
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   601
            TeamsCount = TeamsCount - 1
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   602
        end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   603
        AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   604
        trackDeletion(gear)
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   605
    end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   606
end
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   607
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   608
--[[
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   609
S T A R R I N G
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   610
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   611
    prof - Coding, implementing and evangelism
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   612
    vos  - Initial idea and script improvements
2be6c9b89797 Mutant script
unc0rr
parents:
diff changeset
   613
--]]