share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua
author szczur
Wed, 29 May 2013 13:03:23 -0400
changeset 9079 387e440093b7
parent 8057 93e16240f178
child 9083 6d2efdca5da2
permissions -rw-r--r--
polish translation update
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
8043
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7996
diff changeset
    55
HedgewarsScriptLoad("/Scripts/Locale.lua")
da083f8d95e6 We need custom script loading function in lua now
unc0rr
parents: 7996
diff changeset
    56
HedgewarsScriptLoad("/Scripts/Tracker.lua")
7889
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()
7996
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   212
    setAIHints()
7889
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   213
    kill_reward= numhhs*10
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   214
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   215
    if CurrentHedgehog == mutant then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   216
        mt_hurt=true
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   217
        disease= mutant_base_disease - numhhs
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   218
    else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   219
        mt_hurt=false
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   220
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   221
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   222
    setGearValue(CurrentHedgehog, "Alive", true)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   223
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   224
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   225
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   226
function countBodies()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   227
        if killsCounter == 2 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   228
            AddCaption(loc("DOUBLE KILL"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   229
        elseif killsCounter == 3 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   230
            AddCaption(loc("MEGA KILL"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   231
            PlaySound(sndRegret)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   232
        elseif killsCounter == 4 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   233
            AddCaption(loc("ULTRA KILL"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   234
        elseif killsCounter == 5 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   235
            AddCaption(loc("MONSTER KILL"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   236
            PlaySound(sndIllGetYou)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   237
        elseif killsCounter == 6 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   238
            AddCaption(loc("LUDICROUS KILL"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   239
            PlaySound(sndNutter)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   240
        elseif killsCounter == 7 then
8045
ef403e6bddae mutatis mutandis
koda
parents: 7996
diff changeset
   241
            AddCaption(loc("HOLY SHYTE!"))
7889
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   242
            PlaySound(sndLaugh)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   243
        elseif killsCounter > 8 then
7938
nemo
parents: 7936
diff changeset
   244
            AddCaption(loc("INSANITY"))
7889
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   245
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   246
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   247
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   248
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   249
function onGameTick()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   250
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   251
    if circleFrame > -1 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   252
        for i = 0, #hhs do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   253
            if circles[hhs[i]] ~= nil and hhs[i]~= nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   254
                hhx, hhy = GetGearPosition(hhs[i])
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   255
                X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint = GetVisualGearValues(circles[hhs[i]])
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   256
                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
   257
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   258
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   259
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   260
        circleFrame = circleFrame + 0.06
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   261
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   262
        if circleFrame >= 25 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   263
            for i = 0, #hhs do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   264
                if circles[hhs[i]] ~= nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   265
                    DeleteVisualGear(circles[hhs[i]])
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   266
                    circles[hhs[i]] = nil
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
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   271
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   272
    if TurnTimeLeft==0 and mt_hurt then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   273
        mt_hurt = false
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   274
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   275
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   276
    if mt_hurt and mutant~=nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   277
        timer = timer + 1
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   278
            if timer > disease_timer then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   279
                timer = 0
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   280
                SetHealth(mutant, GetHealth(mutant)-disease )
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   281
                AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   282
                    if GetHealth(mutant)<=0 then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   283
                        SetHealth(mutant,0)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   284
                        mt_hurt= false
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   285
                        setGearValue(mutant,"SelfDestruct",true)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   286
                        TurnTimeLeft = 0
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
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   291
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   292
function saveStuff(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   293
    setGearValue(gear,"Name",GetHogName(gear))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   294
    setGearValue(gear,"Hat",GetHogHat(gear))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   295
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   296
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   297
function armageddon(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   298
    SetState(gear, gstLoser)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   299
    SetEffect(gear, heResurrectable, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   300
    SetHealth(gear, 0)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   301
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   302
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   303
function updateScore()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   304
local showScore = ""
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   305
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   306
    for i=0, TeamsCount-1 do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   307
        if teams[i]~= nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   308
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   309
            local curr_score = getTeamValue(teams[i], "Score")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   310
            showScore = showScore .. teams[i] .. ": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   311
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   312
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   313
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   314
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   315
    ShowMission(loc("Score"),
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   316
                "-------",
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   317
                showScore, 0, 200)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   318
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   319
    HideMission()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   320
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   321
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   322
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   323
function checkScore()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   324
local showScore = ""
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   325
local lowest_score_team = nil
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   326
local min_score=nil
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   327
local winTeam = nil
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   328
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   329
local only_low_score = true
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   330
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   331
    for i=0, TeamsCount-1 do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   332
        if teams[i]~=nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   333
            local curr_score = getTeamValue(teams[i], "Score")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   334
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   335
            runOnHogsInTeam(removeFeeder, teams[i])
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   336
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   337
            showScore = showScore .. teams[i] ..": " .. curr_score .. " (deaths: " .. getTeamValue(teams[i], "DeadHogs") .. ") " .. "|"
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   338
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   339
            if curr_score >= winScore then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   340
                gameOver = true
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   341
                winTeam = teams[i]
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   342
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   343
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   344
            if min_score==nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   345
                min_score= curr_score
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   346
                lowest_score_team = teams[i]
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   347
            else
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 curr_score == min_score then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   350
                        if getTeamValue(teams[i], "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   351
                            only_low_score = false
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   352
                        else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   353
                            if getTeamValue(teams[i], "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   354
                                lowest_score_team = teams[i]
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   355
                            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   356
                            only_low_score = true
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   357
                        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   358
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   359
                    else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   360
                        min_score= curr_score
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   361
                        lowest_score_team = teams[i]
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   362
                        only_low_score = true
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
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   368
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   369
    if gameOver then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   370
        TurnTimeLeft = 0
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   371
        for i=0, #teams do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   372
            if teams[i]~=winTeam then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   373
                runOnHogsInTeam(armageddon, teams[i])
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   374
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   375
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   376
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   377
    ShowMission(    loc("WINNER IS ") .. winTeam,
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   378
                    "~~~~~~~~~~~~~~~~~~~~~~~~~",
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   379
                    showScore, 0, 200)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   380
    else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   381
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   382
    if only_low_score then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   383
        runOnHogsInTeam(setFeeder, lowest_score_team)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   384
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   385
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   386
    ShowMission(    loc("Score"),
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   387
                    loc("-------"),
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   388
                    showScore, 0, 200)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   389
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   390
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   391
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   392
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   393
function backToNormal(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   394
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   395
    SetHogName(gear, getGearValue(gear,"Name"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   396
    SetHogHat(gear, 'NoHat')
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   397
    SetHogHat(gear, getGearValue(gear,"Hat"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   398
    setGearValue(mutant,"SelfDestruct",false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   399
    mt_hurt=false
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   400
    mutant=nil
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   401
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   402
7996
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   403
function setAIHints()
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   404
    for i = 0, #hhs do
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   405
        if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant then
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   406
            SetGearAIHints(hhs[i], aihUsual)
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   407
        else
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   408
            SetGearAIHints(hhs[i], aihDoesntMatter)
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   409
        end
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   410
    end
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   411
end
66e8ac9c2274 Try to beat AI in Mutant!
unc0rr
parents: 7938
diff changeset
   412
7889
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   413
function removeFeeder(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   414
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   415
    if gear~=nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   416
        setGearValue(gear,"Feeder",false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   417
        if gear~= mutant then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   418
            SetHogName(gear, getGearValue(gear,"Name") )
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   419
            SetHogHat(gear, 'NoHat')
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   420
            SetHogHat(gear, getGearValue(gear,"Hat"))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   421
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   422
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   423
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   424
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   425
function setFeeder(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   426
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   427
    if gear~= mutant and gear~= nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   428
        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
   429
        SetHogHat(gear, 'poke_slowpoke')
7889
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   430
        setGearValue(gear,"Feeder", true)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   431
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   432
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   433
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   434
function setMutantStuff(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   435
    mutant = gear
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   436
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   437
    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
   438
    SetHogHat(gear,'WhySoSerious')
7889
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   439
    SetHealth(gear, ( mutant_base_health + numhhs*25) )
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   440
    SetEffect(gear, hePoisoned, 1)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   441
    setGearValue(mutant,"SelfDestruct",false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   442
    setGearValue(gear, "Feeder", false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   443
7936
9f44e39d856c Script typos
nemo
parents: 7894
diff changeset
   444
    AddCaption(getGearValue(gear, "Name") .. loc(" HAS MUTATED"))
7889
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   445
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   446
    TurnTimeLeft=0
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   447
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   448
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   449
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   450
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   451
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   452
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   453
    PlaySound(sndSuddenDeath)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   454
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   455
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   456
function teamScan()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   457
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   458
        for i=0, TeamsCount-1 do --nil filling
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   459
        teams[i]=nil
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   460
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   461
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   462
        for i=0, #hhs do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   463
            for j=0, TeamsCount-1 do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   464
                if teams[j] ==nil and hhs[i]~=nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   465
                teams[j] = GetHogTeamName(hhs[i])
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   466
                setTeamValue(teams[j],"Score",0)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   467
                setTeamValue(teams[j], "DeadHogs",0)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   468
                break
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   469
                end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   470
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   471
                if teams[j] == GetHogTeamName(hhs[i]) then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   472
                    break
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   473
                end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   474
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   475
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   476
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   477
        ---***---
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   478
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   479
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   480
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   481
function onGearDamage(gear, dmg)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   482
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   483
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   484
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   485
function set_Mutant_and_Score(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   486
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   487
local curr_team = GetHogTeamName(CurrentHedgehog)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   488
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   489
    if gear == CurrentHedgehog then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   490
        if CurrentHedgehog == mutant then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   491
            PlaySound(sndHomerun)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   492
            if getGearValue(gear, "SelfDestruct")==false then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   493
                decreaseTeamValue(curr_team,"Score")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   494
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   495
            backToNormal(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   496
        else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   497
            decreaseTeamValue(curr_team,"Score")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   498
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   499
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   500
    else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   501
            if gear == mutant then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   502
                    backToNormal(mutant)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   503
                    if curr_team ~=GetHogTeamName(gear) then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   504
                            if  getGearValue(CurrentHedgehog, "Alive") then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   505
                            setMutantStuff(CurrentHedgehog)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   506
                            setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   507
                            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   508
                    else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   509
                        setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   510
                    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   511
            else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   512
                if mutant==nil then
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 getGearValue(CurrentHedgehog, "Alive") then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   515
                                    setMutantStuff(CurrentHedgehog)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   516
                                    setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   517
                            else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   518
                                increaseTeamValue(curr_team,"Score")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   519
                            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   520
                        else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   521
                            setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   522
                        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   523
                else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   524
                    if curr_team ~=GetHogTeamName(gear) then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   525
                        if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   526
                            SetHealth(CurrentHedgehog, GetHealth(CurrentHedgehog)+kill_reward)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   527
                            AddCaption("+" .. kill_reward .. loc(" HP") )
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   528
                            increaseTeamValue(curr_team,"Score")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   529
                        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   530
                        if getGearValue(CurrentHedgehog,"Feeder") then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   531
                            increaseTeamValue(curr_team,"Score")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   532
                        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   533
                    else
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   534
                        setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   535
                    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   536
                end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   537
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   538
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   539
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   540
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   541
function onGearResurrect(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   542
if not gameOver then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   543
    if GetGearType(gear) == gtHedgehog then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   544
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   545
        increaseTeamValue(GetHogTeamName(gear), "DeadHogs")
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   546
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   547
        if gear==CurrentHedgehog then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   548
            setGearValue(CurrentHedgehog, "Alive", false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   549
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   550
        set_Mutant_and_Score(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   551
        if gear~=CurrentHedgehog then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   552
            killsCounter = killsCounter + 1
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   553
            countBodies()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   554
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   555
        AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   556
        PlaySound(sndWhack)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   557
        updateScore()
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   558
    end
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 onGearAdd(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   563
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   564
    -- Catch hedgehogs for the tracker
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   565
    if GetGearType(gear) == gtHedgehog then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   566
        trackGear(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   567
        hhs[numhhs] = gear
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   568
        numhhs = numhhs + 1
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   569
        SetEffect(gear, heResurrectable, 1)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   570
    end
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 checkEmptyTeam (teamName)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   574
    for i=0 , #hhs do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   575
        if hhs[i]~=nil then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   576
            if teamName == GetHogTeamName(hhs[i]) then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   577
                return false
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   578
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   579
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   580
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   581
    return true
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   582
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   583
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   584
function onGearDelete(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   585
    -- Remove hogs that are gone
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   586
    if GetGearType(gear) == gtHedgehog then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   587
        numhhs = numhhs - 1
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   588
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   589
        local found
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   590
        for i=0, #hhs do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   591
            if hhs[i] == gear then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   592
                found = i
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   593
                break
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   594
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   595
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   596
        for i = found, #hhs - 1 do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   597
            hhs[i] = hhs[i + 1]
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   598
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   599
        hhs[#hhs] = nil
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   600
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   601
        local t_name = GetHogTeamName(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   602
        if checkEmptyTeam(t_name) then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   603
            for i = 0, TeamsCount - 1 do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   604
                if teams[i] == t_name then
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   605
                    found = i
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   606
                    break
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   607
                end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   608
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   609
            for i = found, TeamsCount - 2 do
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   610
                teams[i] = teams[i + 1]
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   611
            end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   612
            teams[TeamsCount - 1] = nil
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   613
            TeamsCount = TeamsCount - 1
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   614
        end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   615
        AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   616
        trackDeletion(gear)
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   617
    end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   618
end
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   619
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   620
--[[
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   621
S T A R R I N G
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   622
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   623
    prof - Coding, implementing and evangelism
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   624
    vos  - Initial idea and script improvements
57b117d441b9 consistent line endings
nemo
parents: 7879
diff changeset
   625
--]]