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