share/hedgewars/Data/Scripts/Multiplayer/Mutant.lua
author Wuzzy <Wuzzy2@mail.ru>
Mon, 16 Sep 2019 17:33:49 +0200
changeset 15431 8504fee3b601
parent 15290 96fbf9bb960a
child 15483 19e987301674
permissions -rw-r--r--
Racer: Fix weird water splashes after waypoint placement Does not affect official racer, as only waypoint placement is touched. The reason was that the air attack gear sometimes was not deleted fast enough so it might occassionally drop some air bombs (these are deleted now). Also, the airplane position was set to water level, which caused another water splash.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     1
--[[                  ___                   ___
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     2
                    (   )                 (   )
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     3
___ .-. .-. ___  ___ | |_    .---. ___ .-. | |_
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     4
(   )   '   (   )(   (   __) / .-, (   )   (   __)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     5
|  .-.  .-. | |  | | | |   (__) ; ||  .-. .| |
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     6
| |  | |  | | |  | | | | ___ .'`  || |  | || | ___
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     7
| |  | |  | | |  | | | |(   / .'| || |  | || |(   )
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     8
| |  | |  | | |  | | | | | | /  | || |  | || | | |
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
     9
| |  | |  | | |  ; ' | ' | ; |  ; || |  | || ' | |
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    10
| |  | |  | ' `-'  / ' `-' ' `-'  || |  | |' `-' ;
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    11
(___)(___)(___'.__.'   `.__.`.__.'_(___)(___)`.__.
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    12
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    13
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    14
----  Recommended settings:
14290
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
    15
----    * one hedgehog per team (forced by game)
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
    16
----    * one team per clan
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    17
----    * 'Small' one-island map
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    18
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    19
--]]
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    20
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    21
HedgewarsScriptLoad("/Scripts/Locale.lua")
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    22
HedgewarsScriptLoad("/Scripts/Tracker.lua")
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    23
HedgewarsScriptLoad("/Scripts/Params.lua")
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    24
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    25
--[[
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    26
    MUTANT SCRIPT
14290
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
    27
]]
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    28
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    29
local hhs = {}
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
    30
local crates = {}
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    31
local numhhs = 0
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    32
local meh = false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    33
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    34
local gameOver=false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    35
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    36
local mutant = nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    37
local mutant_base_health = 200
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    38
local mutant_base_disease = 25
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    39
local disease_timer = 2000
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    40
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    41
local kill_reward = nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    42
local mt_hurt=false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    43
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    44
local killsCounter = 0
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    45
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    46
local team_fire_punishment = 3
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    47
local mutant_kill_reward = 2
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    48
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    49
local hh_weapons = { amBazooka, amGrenade, amShotgun, amMine}
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    50
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    51
local mt_weapons = {amWatermelon, amHellishBomb, amBallgun, amRCPlane, amTeleport}
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    52
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    53
local disease=0
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    54
local timer=0
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    55
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    56
local winScore = 15
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    57
local hogsLimit = 1
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    58
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
    59
local teamsDead = {}
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
    60
local teamsDeleted = {}
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
    61
local hogLimitHit = false
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
    62
local cnthhs
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    63
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    64
local circles = {}
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    65
local circleFrame = -1
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    66
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    67
-- Variables for custom achievements
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    68
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    69
-- Most kills in 1 turn
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    70
local recordKills = 0
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    71
local recordKillsHogName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    72
local recordKillsTeamName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    73
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    74
-- Most suicides
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    75
local recordSuicides = 0
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    76
local recordSuicidesHogName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    77
local recordSuicidesTeamName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    78
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    79
-- Most skips
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    80
local recordSkips = 0
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    81
local recordSkipsHogName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    82
local recordSkipsTeamName = nil
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
    83
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
    84
-- Most crates collected
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    85
local recordCrates = 0
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    86
local recordCratesHogName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    87
local recordCratesTeamName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    88
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    89
-- Most deaths
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    90
local recordDeaths = 0
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    91
local recordDeathsHogName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    92
local recordDeathsTeamName = nil
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    93
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    94
-- Total killed hedgehogs
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    95
local totalKills = 0
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    96
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    97
-- Total damage
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    98
local totalDamage = 0
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
    99
12988
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   100
local mutantHat = "WhySoSerious"
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   101
local feederHat = "poke_slowpoke"
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   102
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   103
function rules()
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   104
14290
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   105
    local mineStr
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   106
    if MinesTime < 0 then
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   107
        mineStr = loc("Mines time: 0s-5s")
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   108
    else
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   109
        mineStr = string.format(loc("Mines explode after %d s."), div(MinesTime, 1000))
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   110
    end
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   111
    local ruleSet = loc("Hedgehogs will be revived after their death.") .. "|" ..
14290
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   112
    mineStr .. "|" ..
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   113
    loc("The first hedgehog to kill someone becomes the Mutant.") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   114
    loc("The Mutant has super weapons and a lot of health.") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   115
    loc("The Mutant loses health quickly, but gains health by killing.") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   116
    " |" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   117
    loc("Score points by killing other hedgehogs.") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   118
    loc("The hedgehog with least points (or most deaths) becomes the Bottom Feeder.") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   119
    loc("The score and deaths are shown next to the team bar.") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   120
    string.format(loc("Goal: Score %d points or more to win!"), winScore) .. "|" ..
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   121
        " |" ..
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   122
    loc("Scoring: ") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   123
    loc("+2 for becoming the Mutant") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   124
    loc("+1 to the Mutant for killing anyone") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   125
    loc("+1 to the Bottom Feeder for killing anyone") .. "|" ..
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   126
    loc("-1 to anyone for a suicide")
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   127
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   128
    return ruleSet
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   129
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   130
end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   131
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   132
function showStartingInfo()
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   133
15090
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15010
diff changeset
   134
    ShowMission(loc("Mutant"), loc("A Hedgewars tag game"), rules(), -amWatermelon, 5000)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   135
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   136
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   137
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   138
function onGameInit()
14290
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   139
    -- Sudden Death would be weird
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   140
    WaterRise = 0
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   141
    HealthDecrease = 0
14290
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   142
    -- Weapons must be reset for the Mutant mechanic to work
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   143
    EnableGameFlags(gfResetWeps)
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   144
    -- King Mode messes with game too much
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   145
    DisableGameFlags(gfKing)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   146
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   147
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   148
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   149
function limitHogsTeam(gear)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   150
    cnthhs = cnthhs + 1
13108
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   151
    if cnthhs > 1 then
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   152
        hogLimitHit = true
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   153
        SetEffect(gear, heResurrectable, 0)
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   154
        setGearValue(gear, "excess", true)
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   155
        DeleteGear(gear)
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   156
    end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   157
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   158
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   159
function limitHogsClan(gear)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   160
    hogLimitHit = true
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   161
    SetEffect(gear, heResurrectable, 0)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   162
    setGearValue(gear, "excess", true)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   163
    DeleteGear(gear)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   164
end
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   165
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   166
function onGameStart()
13798
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   167
    if ClansCount >= 2 then
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   168
        SendHealthStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   169
        SendAchievementsStatsOff()
e874bfe563c7 Make sure scripts don't break w/ only 1 clan
Wuzzy <Wuzzy2@mail.ru>
parents: 13685
diff changeset
   170
    end
12335
8f693d25be2f Show traditional winning animation in Mutant again
Wuzzy <almikes@aol.com>
parents: 12288
diff changeset
   171
    SendRankingStatsOff()
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   172
    trackTeams()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   173
    teamScan()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   174
    runOnHogs(saveStuff)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   175
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   176
    -- Enforce team and hog limits
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   177
    hogLimitHit = false
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   178
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   179
    -- Rule 1: One team per clan
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   180
    if TeamsCount > ClansCount then
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   181
        local usedClans = {}
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   182
        for i=0, TeamsCount - 1 do
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   183
            local teamName = GetTeamName(i)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   184
            local clanNumber = GetTeamClan(teamName)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   185
            if not usedClans[clanNumber] then
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   186
                usedClans[clanNumber] = true
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   187
            else
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   188
                runOnHogsInTeam(limitHogsClan, teamName)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   189
                teamsDeleted[teamName] = true
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   190
                setTeamValue(teamName, "Score", getTeamValue(teamName, "Score") -99999)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   191
            end
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   192
        end
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   193
    end
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   194
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   195
    -- Rule 2: One hog per team
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   196
    for i=0 , TeamsCount - 1 do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   197
        cnthhs = 0
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   198
        runOnHogsInTeam(limitHogsTeam, GetTeamName(i))
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   199
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   200
    if hogLimitHit then
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   201
        -- TODO: Update warning message to include excess teams as well
13108
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   202
        WriteLnToChat(loc("Only one hog per team allowed! Excess hogs will be removed."))
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   203
    end
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   204
    trackTeams()
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   205
    showStartingInfo()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   206
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   207
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   208
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   209
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   210
function giveWeapons(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   211
    if gear == mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   212
        AddAmmo(gear, amRope)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   213
        for i=1, #mt_weapons do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   214
            AddAmmo(gear, mt_weapons[i])
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   215
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   216
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   217
    else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   218
        for i=1, #hh_weapons do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   219
            AddAmmo(gear,hh_weapons[i])
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   220
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   221
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   222
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   223
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   224
function onAmmoStoreInit()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   225
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   226
    SetAmmo(amSkip, 9, 0, 0, 0)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   227
    SetAmmo(amRope,0,1,0,5)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   228
    SetAmmo(amSnowball,0,1,0,1)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   229
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   230
    for i=1, #hh_weapons do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   231
        SetAmmo(hh_weapons[i], 0, 0, 0, 1)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   232
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   233
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   234
    for i=1, #mt_weapons do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   235
        SetAmmo(mt_weapons[i], 0, 3, 0, 1)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   236
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   237
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   238
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   239
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   240
function drawCircles()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   241
    for i = 0, #hhs do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   242
        if circles[hhs[i]] ~= nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   243
            DeleteVisualGear(circles[hhs[i]])
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   244
            circles[hhs[i]] = nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   245
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   246
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   247
        if hhs[i] ~= CurrentHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   248
            if mutant == nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   249
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   250
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   251
            elseif CurrentHedgehog == mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   252
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   253
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   254
            elseif getGearValue(CurrentHedgehog, "Feeder") and hhs[i] ~= mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   255
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   256
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 3, 0xaa000070)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   257
            elseif hhs[i] == mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   258
                circles[hhs[i]] = AddVisualGear(0, 0, vgtCircle, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   259
                SetVisualGearValues(circles[hhs[i]], 0, 0, 0, 0, 0, 0, 0, 22, 5, 0xff000080)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   260
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   261
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   262
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   263
    circleFrame = 0
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   264
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   265
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   266
function onNewTurn()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   267
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   268
    killsCounter = 0
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   269
14290
47af42f7ca8b Add Mutant game scheme, and adapt Mutant for the newly unlocked settings
Wuzzy <Wuzzy2@mail.ru>
parents: 14287
diff changeset
   270
    if mutant == nil and TotalRounds >= 0 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   271
        AddCaption( loc("First killer will mutate"), capcolDefault, capgrpGameState )
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   272
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   273
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   274
    checkScore()
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   275
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   276
    for i=0, TeamsCount-1 do
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   277
        local teamName = GetTeamName(i)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   278
        if not teamsDeleted[teamName] then
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   279
            SendStat(siClanHealth, getTeamValue(teamName, "Score"), teamName)
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   280
        end
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   281
    end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   282
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   283
    giveWeapons(CurrentHedgehog)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   284
    drawCircles()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   285
    setAIHints()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   286
    kill_reward= numhhs*10
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   287
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   288
    if CurrentHedgehog == mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   289
        mt_hurt=true
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   290
        disease= mutant_base_disease - numhhs
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   291
    else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   292
        mt_hurt=false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   293
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   294
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   295
    setGearValue(CurrentHedgehog, "Alive", true)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   296
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   297
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   298
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   299
function countBodies()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   300
        if killsCounter == 2 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   301
            AddCaption(loc("Double kill!"), capcolDefault, capgrpGameState )
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   302
        elseif killsCounter == 3 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   303
            AddCaption(loc("Mega kill!"), capcolDefault, capgrpGameState )
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   304
            PlaySound(sndRegret)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   305
        elseif killsCounter == 4 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   306
            AddCaption(loc("Ultra kill!"), capcolDefault, capgrpGameState )
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   307
        elseif killsCounter == 5 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   308
            AddCaption(loc("Monster kill!"), capcolDefault, capgrpGameState )
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   309
            PlaySound(sndIllGetYou)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   310
        elseif killsCounter == 6 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   311
            AddCaption(loc("Ludicrous kill!"), capcolDefault, capgrpGameState )
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   312
            PlaySound(sndNutter)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   313
        elseif killsCounter == 7 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   314
            AddCaption(loc("Holy shit!"), capcolDefault, capgrpGameState )
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   315
            PlaySound(sndLaugh)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   316
        elseif killsCounter > 8 then
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   317
            AddCaption(loc("Insanity!"), capcolDefault, capgrpGameState )
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   318
        end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   319
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   320
        if killsCounter > recordKills then
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   321
            recordKills = killsCounter
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   322
            recordKillsHogName = getGearValue(CurrentHedgehog, "Name")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   323
            recordKillsTeamName = GetHogTeamName(CurrentHedgehog)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   324
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   325
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   326
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   327
function onGameTick()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   328
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   329
    if circleFrame > -1 then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   330
        for i = 0, #hhs do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   331
            if circles[hhs[i]] ~= nil and hhs[i]~= nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   332
                hhx, hhy = GetGearPosition(hhs[i])
13685
09ea1faf97ca Remove calls to GetVisualGearValues where it's not needed
Wuzzy <Wuzzy2@mail.ru>
parents: 13643
diff changeset
   333
                SetVisualGearValues(circles[hhs[i]], hhx + 1, hhy - 3, 0, 0, 0, 0, 0, 40 - (circleFrame % 25))
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   334
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   335
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   336
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   337
        circleFrame = circleFrame + 0.06
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   338
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   339
        if circleFrame >= 25 then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   340
            for i = 0, #hhs do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   341
                if circles[hhs[i]] ~= nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   342
                    DeleteVisualGear(circles[hhs[i]])
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   343
                    circles[hhs[i]] = nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   344
                end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   345
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   346
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   347
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   348
14346
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   349
    if (TurnTimeLeft==0 or band(GetState(mutant), gstHHDriven) == 0) and mt_hurt then
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   350
        mt_hurt = false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   351
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   352
14346
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   353
    -- Mutant's disease
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   354
    -- Hurt Mutant during its turn time
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   355
    -- Mutant's health is safe in ready phase
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   356
    if mt_hurt and mutant~=nil and ReadyTimeLeft == 0 then
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   357
        timer = timer + 1
14346
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   358
        if timer > disease_timer then
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   359
            timer = 0
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   360
            local h = GetHealth(mutant)-disease
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   361
            SetHealth(mutant, h)
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   362
            -- Low health warning
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   363
            if h <= 75 then
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   364
                PlaySound(sndPoisonMoan, mutant)
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   365
            elseif h <= 150 then
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   366
                PlaySound(sndPoisonCough, mutant)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   367
            end
14346
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   368
            local tag = AddVisualGear(GetX(mutant), GetY(mutant)-5, vgtHealthTag, disease, true)
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   369
            SetVisualGearValues(tag, nil, nil, nil, nil, nil, nil, nil, nil, nil, GetClanColor(GetHogClan(mutant)))
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   370
            if GetHealth(mutant)<=0 then
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   371
                SetHealth(mutant,0)
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   372
                mt_hurt= false
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   373
                setGearValue(mutant,"SelfDestruct",true)
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   374
                EndTurn()
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   375
            end
bd2bbd607f5e Mutant: Don't reduce mutant health in ready phase. Play poison hurt sound as health warning
Wuzzy <Wuzzy2@mail.ru>
parents: 14290
diff changeset
   376
        end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   377
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   378
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   379
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   380
12988
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   381
--[[
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   382
Forces the special mutant/feeder names and hats only to be
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   383
taken by those who deserved it.
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   384
Names and hats will be changed (and ridiculed) if neccesary.
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   385
]]
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   386
function exposeIdentityTheft(gear)
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   387
    local lon = string.lower(GetHogName(gear)) -- lowercase origina name
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   388
    local name, hat
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   389
    -- Change name if hog uses a reserved one
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   390
    if lon == "mutant" or lon == string.lower(loc("Mutant")) then
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   391
       SetHogName(gear, loc("Identity Thief"))
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   392
       SetHogHat(gear, "Disguise")
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   393
    elseif lon == "bottom feeder" or lon == string.lower(loc("Bottom Feeder")) then
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   394
       -- Word play on "Bottom Feeder". Someone who is low on cotton. :D
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   395
       -- Either translate literally or make up your ow word play
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   396
       SetHogName(gear, loc("Cotton Needer"))
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   397
       SetHogHat(gear, "StrawHat")
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   398
    end
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   399
    -- Strip hog off its special hat
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   400
    if GetHogHat(gear) == mutantHat or GetHogHat(gear) == feederHat then
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   401
       SetHogHat(gear, "NoHat")
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   402
    end
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   403
end
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   404
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   405
function saveStuff(gear)
12988
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   406
    exposeIdentityTheft(gear)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   407
    setGearValue(gear,"Name",GetHogName(gear))
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   408
    setGearValue(gear,"Hat",GetHogHat(gear))
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   409
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   410
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   411
function armageddon(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   412
    SetState(gear, gstLoser)
13108
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   413
    SetEffect(gear, heResurrectable, 0)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   414
    SetHealth(gear, 0)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   415
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   416
13019
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12988
diff changeset
   417
function renderScores()
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   418
    for i=0, TeamsCount-1 do
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   419
        local name = GetTeamName(i)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   420
        SetTeamLabel(name, string.format(loc("%d | %d"), getTeamValue(name, "Score"), getTeamValue(name, "DeadHogs")))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   421
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   422
end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   423
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   424
function createEndGameStats()
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   425
    SendStat(siGraphTitle, loc("Score graph"))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   426
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   427
    local teamsSorted = {}
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   428
    for i=0, TeamsCount-1, 1 do
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   429
        teamsSorted[i+1] = GetTeamName(i)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   430
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   431
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   432
    -- Achievements stuff
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   433
    local achievements = 0
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   434
    --- Most kills per turn
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   435
    if recordKills >= 3 then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   436
        SendStat(siMaxStepKills, string.format("%d %s (%s)", recordKills, recordKillsHogName, recordKillsTeamName))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   437
        achievements = achievements + 1
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   438
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   439
    --- Most crates collected
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   440
    if recordCrates >= 5 then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   441
        SendStat(siCustomAchievement, string.format(loc("%s (%s) was the greediest hedgehog and collected %d crates."), recordCratesHogName, recordCratesTeamName, recordCrates))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   442
        achievements = achievements + 1
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   443
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   444
    --- Most suicides
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   445
    if recordSuicides >= 5 then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   446
        SendStat(siCustomAchievement, string.format(loc("%s (%s) hate life and suicided %d times."), recordSuicidesHogName, recordSuicidesTeamName, recordSuicides))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   447
        achievements = achievements + 1
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   448
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   449
    --- Most deaths
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   450
    if recordDeaths >= 5 then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   451
        SendStat(siCustomAchievement, string.format(loc("Poor %s (%s) died %d times."), recordDeathsHogName, recordDeathsTeamName, recordDeaths))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   452
        achievements = achievements + 1
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   453
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   454
    --- Most skips
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   455
    if recordSkips >= 3 then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   456
        SendStat(siMaxTurnSkips, string.format("%d %s (%s)", recordSkips, recordSkipsHogName, recordSkipsTeamName))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   457
        achievements = achievements + 1
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   458
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   459
    --- Total damage
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   460
    if totalDamage >= 900 then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   461
        SendStat(siCustomAchievement, string.format(loc("%d damage was dealt in this game."), totalDamage))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   462
        achievements = achievements + 1
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   463
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   464
    --- Total kills
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   465
    if totalKills >= 20 or (achievements <= 0 and totalKills >= 1) then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   466
        SendStat(siKilledHHs, tostring(totalKills))
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   467
        achievements = achievements + 1
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   468
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   469
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   470
    -- Score and stats stuff
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   471
    local showScore = ""
15010
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   472
    local rank = 0
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   473
    local rankPlus = 1
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   474
    local prevScore
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   475
    table.sort(teamsSorted, function(team1, team2) return getTeamValue(team1, "Score") > getTeamValue(team2, "Score") end)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   476
    for i=1, TeamsCount do
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   477
        local score = getTeamValue(teamsSorted[i], "Score")
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   478
        local deaths = getTeamValue(teamsSorted[i], "DeadHogs")
15010
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   479
        if i == 1 or score < prevScore then
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   480
            rank = rank + rankPlus
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   481
            rankPlus = 1
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   482
            prevScore = score
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   483
        else
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   484
            rankPlus = rankPlus + 1
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   485
        end
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   486
        SendStat(siPointType, "!POINTS")
5188ecbf726f Rank tied teams properly in Control, CTF and Mutant
Wuzzy <Wuzzy2@mail.ru>
parents: 14599
diff changeset
   487
        SendStat(siTeamRank, rank)
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   488
        SendStat(siPlayerKills, score, teamsSorted[i])
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   489
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   490
        showScore = showScore .. string.format(loc("%s: %d (deaths: %d)"), teamsSorted[i], score, deaths) .. "|"
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   491
    end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   492
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   493
    if getTeamValue(teamsSorted[1], "Score") == getTeamValue(teamsSorted[2], "Score") then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   494
        -- The first two teams have the same score! Round is drawn.
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   495
        return nil
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   496
    else
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   497
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   498
    ShowMission(loc("Mutant"),
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   499
        loc("Final result"),
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   500
        string.format(loc("Winner: %s"), teamsSorted[1]) .. "| |" .. loc("Scores:") .. " |" ..
15090
e16f906224fd Change mission panel icons for a couple of game styles
Wuzzy <Wuzzy2@mail.ru>
parents: 15010
diff changeset
   501
        showScore, 4, 15000)
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   502
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   503
        -- return winning team
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   504
        return teamsSorted[1]
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   505
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   506
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   507
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   508
function checkScore()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   509
local lowest_score_team = nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   510
local min_score=nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   511
local winTeam = nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   512
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   513
local only_low_score = true
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   514
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   515
    for i=0, TeamsCount-1 do
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   516
        local teamName = GetTeamName(i)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   517
        if not teamsDead[teamName] then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   518
            local curr_score = getTeamValue(teamName, "Score")
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   519
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   520
            runOnHogsInTeam(removeFeeder, teamName)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   521
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   522
            if curr_score >= winScore then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   523
                gameOver = true
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   524
                winTeam = teamName
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   525
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   526
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   527
            if min_score==nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   528
                min_score= curr_score
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   529
                lowest_score_team = teamName
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   530
            else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   531
                if curr_score <= min_score then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   532
                    if curr_score == min_score then
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   533
                        if getTeamValue(teamName, "DeadHogs") == getTeamValue(lowest_score_team, "DeadHogs") then
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   534
                            only_low_score = false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   535
                        else
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   536
                            if getTeamValue(teamName, "DeadHogs") > getTeamValue(lowest_score_team, "DeadHogs") then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   537
                                lowest_score_team = teamName
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   538
                            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   539
                            only_low_score = true
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   540
                        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   541
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   542
                    else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   543
                        min_score= curr_score
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   544
                        lowest_score_team = teamName
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   545
                        only_low_score = true
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   546
                    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   547
                end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   548
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   549
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   550
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   551
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   552
    if gameOver then
12341
c73521104fac Mutant: Fix “Boring” taunt being played when becoming the mutant
Wuzzy <almikes@aol.com>
parents: 12335
diff changeset
   553
        EndTurn(true)
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   554
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   555
        for i=0, TeamsCount-1 do
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   556
            local teamName = GetTeamName(i)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   557
            if teamName~=winTeam then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   558
                runOnHogsInTeam(armageddon, teamName)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   559
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   560
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   561
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   562
        createEndGameStats()
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   563
    else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   564
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   565
    if only_low_score then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   566
        runOnHogsInTeam(setFeeder, lowest_score_team)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   567
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   568
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   569
    if meh == false then
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   570
        meh = true
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   571
    end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   572
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   573
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   574
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   575
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   576
function backToNormal(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   577
    SetHogName(gear, getGearValue(gear,"Name"))
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   578
    SetHogHat(gear, 'NoHat')
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   579
    SetHogHat(gear, getGearValue(gear,"Hat"))
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   580
    setGearValue(mutant,"SelfDestruct",false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   581
    mt_hurt=false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   582
    mutant=nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   583
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   584
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   585
function setAIHints()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   586
    for i = 0, #hhs do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   587
        if mutant == nil or hhs[i] == mutant or CurrentHedgehog == mutant or getGearValue(CurrentHedgehog, "Feeder") then
13036
434bcdd9562c Fix inconsistent name of SetGearAIHints
Wuzzy <Wuzzy2@mail.ru>
parents: 13019
diff changeset
   588
            SetGearAIHints(hhs[i], aihUsualProcessing)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   589
        else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   590
            SetGearAIHints(hhs[i], aihDoesntMatter)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   591
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   592
    end
14287
9b5a8147386f I think this is correct way to use iterate over it as a hashmap. don't have much lua practice
nemo
parents: 14286
diff changeset
   593
    for k,v in pairs(crates) do
9b5a8147386f I think this is correct way to use iterate over it as a hashmap. don't have much lua practice
nemo
parents: 14286
diff changeset
   594
        if CurrentHedgehog == mutant and v ~= nil  then
9b5a8147386f I think this is correct way to use iterate over it as a hashmap. don't have much lua practice
nemo
parents: 14286
diff changeset
   595
            SetGearAIHints(v, aihDoesntMatter)
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   596
        else
14287
9b5a8147386f I think this is correct way to use iterate over it as a hashmap. don't have much lua practice
nemo
parents: 14286
diff changeset
   597
            SetGearAIHints(v, aihUsualProcessing)
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   598
        end
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   599
    end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   600
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   601
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   602
function removeFeeder(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   603
    if gear~=nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   604
        setGearValue(gear,"Feeder",false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   605
        if gear~= mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   606
            SetHogName(gear, getGearValue(gear,"Name") )
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   607
            SetHogHat(gear, 'NoHat')
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   608
            SetHogHat(gear, getGearValue(gear,"Hat"))
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   609
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   610
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   611
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   612
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   613
function setFeeder(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   614
    if gear~= mutant and gear~= nil then
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   615
        SetHogName(gear, loc("Bottom Feeder"))
12988
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   616
        SetHogHat(gear, feederHat)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   617
        setGearValue(gear,"Feeder", true)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   618
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   619
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   620
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   621
function setMutantStuff(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   622
    mutant = gear
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   623
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   624
    SetHogName(gear, loc("Mutant"))
12988
a15413d896c3 Mutant: Force special mutant/feeder hat+name to be only hold by those who deserved it
Wuzzy <Wuzzy2@mail.ru>
parents: 12940
diff changeset
   625
    SetHogHat(gear, mutantHat)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   626
    SetHealth(gear, ( mutant_base_health + numhhs*25) )
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   627
    SetEffect(gear, hePoisoned, 1)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   628
    setGearValue(mutant,"SelfDestruct",false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   629
    setGearValue(gear, "Feeder", false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   630
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   631
    AddCaption(string.format(loc("%s has mutated! +2 points"), getGearValue(gear, "Name")), GetClanColor(GetHogClan(gear)), capgrpMessage)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   632
12430
c461a224ec09 Mutant: Fix turn skip of next hog after mutating when TurnTimeLeft = 0
Wuzzy <almikes@aol.com>
parents: 12341
diff changeset
   633
    if TurnTimeLeft > 0 then
c461a224ec09 Mutant: Fix turn skip of next hog after mutating when TurnTimeLeft = 0
Wuzzy <almikes@aol.com>
parents: 12341
diff changeset
   634
        EndTurn(true)
c461a224ec09 Mutant: Fix turn skip of next hog after mutating when TurnTimeLeft = 0
Wuzzy <almikes@aol.com>
parents: 12341
diff changeset
   635
    end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   636
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   637
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   638
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   639
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   640
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   641
    AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   642
    PlaySound(sndSuddenDeath)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   643
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   644
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   645
function teamScan()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   646
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   647
        for j=0, TeamsCount-1 do
15290
96fbf9bb960a Mutant: Remove excess teams if a clan has more than one team
Wuzzy <Wuzzy2@mail.ru>
parents: 15090
diff changeset
   648
            local teamName = GetTeamName(j)
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   649
            teamsDead[teamName] = false
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   650
            setTeamValue(teamName, "Score",0)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   651
            setTeamValue(teamName, "Suicides",0)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   652
            setTeamValue(teamName, "Skips",0)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   653
            setTeamValue(teamName, "Crates",0)
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   654
            setTeamValue(teamName, "DeadHogs",0)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   655
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   656
13019
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12988
diff changeset
   657
        renderScores()
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12988
diff changeset
   658
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   659
        ---***---
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   660
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   661
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   662
function set_Mutant_and_Score(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   663
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   664
local curr_team = GetHogTeamName(CurrentHedgehog)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   665
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   666
    if gear == CurrentHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   667
        if CurrentHedgehog == mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   668
            PlaySound(sndHomerun)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   669
            if getGearValue(gear, "SelfDestruct")==false then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   670
                decreaseTeamValue(curr_team,"Score")
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   671
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   672
            backToNormal(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   673
        else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   674
            decreaseTeamValue(curr_team,"Score")
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   675
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   676
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   677
    else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   678
            if gear == mutant then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   679
                    backToNormal(mutant)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   680
                    if curr_team ~=GetHogTeamName(gear) then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   681
                            if  getGearValue(CurrentHedgehog, "Alive") then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   682
                            setMutantStuff(CurrentHedgehog)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   683
                            setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   684
                            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   685
                    else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   686
                        setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   687
                        increaseTeamValue(curr_team,"Suicides")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   688
                        if(getTeamValue(curr_team, "Suicides") > recordSuicides) then
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   689
                            recordSuicides = getTeamValue(curr_team, "Suicides")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   690
                            recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   691
                            recordSuicidesTeamName = curr_team
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   692
                        end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   693
                        AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   694
                    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   695
            else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   696
                if mutant==nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   697
                        if curr_team ~=GetHogTeamName(gear) then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   698
                            if getGearValue(CurrentHedgehog, "Alive") then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   699
                                    setMutantStuff(CurrentHedgehog)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   700
                                    setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") + mutant_kill_reward))
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   701
                            else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   702
                                increaseTeamValue(curr_team,"Score")
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   703
                            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   704
                        else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   705
                            setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   706
                            increaseTeamValue(curr_team,"Suicides")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   707
                            if(getTeamValue(curr_team, "Suicides") > recordSuicides) then
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   708
                                recordSuicides = getTeamValue(curr_team, "Suicides")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   709
                                recordSuicidesHogName = getGearValue(CurrentHedgehog, "Name")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   710
                                recordSuicidesTeamName = curr_team
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   711
                            end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   712
                            AddCaption(loc("-1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   713
                        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   714
                else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   715
                    if curr_team ~=GetHogTeamName(gear) then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   716
                        if CurrentHedgehog==mutant and getGearValue(mutant,"SelfDestruct")==false then
12940
39b7b3ed619e Add healing visual effect + heal msg in scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 12430
diff changeset
   717
                            HealHog(CurrentHedgehog, kill_reward)
12288
a5a7d0c6d3f3 Fix incorrect Mutant score message color
Wuzzy <almikes@aol.com>
parents: 11909
diff changeset
   718
                            AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   719
                            increaseTeamValue(curr_team,"Score")
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   720
                        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   721
                        if getGearValue(CurrentHedgehog,"Feeder") then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   722
                            increaseTeamValue(curr_team,"Score")
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   723
                            AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   724
                        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   725
                    else
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   726
                        setTeamValue(curr_team,"Score",(getTeamValue(curr_team,"Score") - team_fire_punishment))
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   727
                        AddCaption(loc("+1 point"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpMessage)
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   728
                    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   729
                end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   730
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   731
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   732
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   733
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   734
function onGearResurrect(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   735
if not gameOver then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   736
    if GetGearType(gear) == gtHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   737
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   738
        increaseTeamValue(GetHogTeamName(gear), "DeadHogs")
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   739
        totalKills = totalKills + 1
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   740
        if(getTeamValue(GetHogTeamName(gear), "DeadHogs") > recordDeaths) then
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   741
            recordDeaths = getTeamValue(GetHogTeamName(gear), "DeadHogs")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   742
            recordDeathsHogName = getGearValue(gear, "Name")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   743
            recordDeathsTeamName = GetHogTeamName(gear)
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   744
        end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   745
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   746
        if gear==CurrentHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   747
            setGearValue(CurrentHedgehog, "Alive", false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   748
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   749
        set_Mutant_and_Score(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   750
        if gear~=CurrentHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   751
            killsCounter = killsCounter + 1
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   752
            countBodies()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   753
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   754
        AddVisualGear(GetX(gear), GetY(gear), vgtSmokeRing, 0, false)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   755
        PlaySound(sndWhack)
13019
880662cf41ee Add team score next to team bars for CTF_Blizard, Control, CTF, Mutant, Space Invasion
Wuzzy <Wuzzy2@mail.ru>
parents: 12988
diff changeset
   756
        renderScores()
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   757
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   758
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   759
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   760
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   761
function onGearDamage(gear, damage)
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   762
    if not gameOver and GetGearType(gear) == gtHedgehog then
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   763
        totalDamage = totalDamage + damage
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   764
    end
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   765
end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   766
13172
159004144897 Use onSkipTurn in scripts to detect turn skips
Wuzzy <Wuzzy2@mail.ru>
parents: 13108
diff changeset
   767
function onSkipTurn()
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   768
    -- Record skips for achievement
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   769
    local team = GetHogTeamName(CurrentHedgehog)
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   770
    increaseTeamValue(team, "Skips")
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   771
    if(getTeamValue(team, "Skips") > recordSkips) then
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   772
        recordSkips = getTeamValue(team, "Skips")
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   773
        recordSkipsHogName = getGearValue(CurrentHedgehog, "Name")
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   774
        recordSkipsTeamName = team
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   775
    end
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   776
end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   777
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   778
function onGearAdd(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   779
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   780
    -- Catch hedgehogs for the tracker
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   781
    if GetGearType(gear) == gtHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   782
        trackGear(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   783
        hhs[numhhs] = gear
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   784
        numhhs = numhhs + 1
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   785
        SetEffect(gear, heResurrectable, 1)
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   786
    elseif GetGearType(gear) == gtCase then
14287
9b5a8147386f I think this is correct way to use iterate over it as a hashmap. don't have much lua practice
nemo
parents: 14286
diff changeset
   787
        crates[gear] = gear
13219
b229b3259a76 Mutant: Fix graph title on game draw
Wuzzy <Wuzzy2@mail.ru>
parents: 13172
diff changeset
   788
    elseif GetGearType(gear) == gtATFinishGame then
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   789
        if not gameOver then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   790
            local winner = createEndGameStats()
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   791
            if winner then
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   792
                SendStat(siGameResult, string.format(loc("%s wins!"), winner))
13643
690cc84e9fd6 Use capcolDefault in Lua scripts
Wuzzy <Wuzzy2@mail.ru>
parents: 13220
diff changeset
   793
                AddCaption(string.format(loc("%s wins!"), winner), capcolDefault, capgrpGameState)
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   794
            end
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   795
            gameOver = true
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   796
        end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   797
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   798
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   799
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   800
function checkEmptyTeam (teamName)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   801
    for i=0 , #hhs do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   802
        if hhs[i]~=nil then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   803
            if teamName == GetHogTeamName(hhs[i]) then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   804
                return false
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   805
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   806
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   807
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   808
    return true
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   809
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   810
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   811
function onGearDelete(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   812
    -- Remove hogs that are gone
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   813
    if GetGearType(gear) == gtHedgehog then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   814
        numhhs = numhhs - 1
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   815
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   816
        local found
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   817
        for i=0, #hhs do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   818
            if hhs[i] == gear then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   819
                found = i
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   820
                break
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   821
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   822
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   823
        for i = found, #hhs - 1 do
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   824
            hhs[i] = hhs[i + 1]
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   825
        end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   826
        hhs[#hhs] = nil
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   827
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   828
        local t_name = GetHogTeamName(gear)
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   829
        if checkEmptyTeam(t_name) then
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   830
            for i = 0, TeamsCount - 1 do
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   831
                if GetTeamName(i) == t_name then
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   832
                    found = i
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   833
                    teamsDead[t_name] = true
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   834
                    break
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   835
                end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   836
            end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   837
        end
13220
1c390781f72f Mutant: When game ends prematurely due to missing land, declare highest-scoring team the winner
Wuzzy <Wuzzy2@mail.ru>
parents: 13219
diff changeset
   838
        if getGearValue(gear, "excess") ~= true and band(GetState(gear), gstDrowning) == 0 then
13108
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   839
            AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
f3f8d017f994 Mutant: Faster excess hog removal
Wuzzy <Wuzzy2@mail.ru>
parents: 13105
diff changeset
   840
        end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   841
        trackDeletion(gear)
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   842
    elseif GetGearType(gear) == gtCase then
14285
6f3f59266c4c flag crates since waste of time for mutant.
nemo
parents: 13798
diff changeset
   843
        crates[gear] = nil
11909
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   844
        -- Check if a crate has been collected
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   845
        if band(GetGearMessage(gear), gmDestroy) ~= 0 and CurrentHedgehog ~= nil then
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   846
            -- Update crate collection achievement
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   847
            increaseTeamValue(GetHogTeamName(CurrentHedgehog), "Crates")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   848
            if(getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates") > recordCrates) then
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   849
                recordCrates = getTeamValue(GetHogTeamName(CurrentHedgehog), "Crates")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   850
                recordCratesHogName = getGearValue(CurrentHedgehog, "Name")
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   851
                recordCratesTeamName = GetHogTeamName(CurrentHedgehog)
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   852
            end
1d2e89be3eb6 Update Mutant script
Wuzzy <almikes@aol.com>
parents: 11237
diff changeset
   853
        end
11015
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   854
    end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   855
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   856
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   857
function onParameters()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   858
    parseParams()
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   859
    winScore = tonumber(params["winscore"]) or winScore
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   860
end
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   861
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   862
--[[
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   863
S T A R R I N G
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   864
    prof - Coding, implementing and evangelism
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   865
    vos  - Initial idea and script improvements
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   866
    mikade - Moving the `how to play` into the game so that people know `how to play`, and whitespace :D
7a905f0070ce CRLF purge
nemo
parents: 10872
diff changeset
   867
--]]