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