share/hedgewars/Data/Maps/ClimbHome/map.lua
author nemo
Mon, 22 Dec 2014 18:08:42 -0500
changeset 10697 fb38a9468862
parent 10645 b8c73bacb31e
child 10810 931dd8f42763
permissions -rw-r--r--
scaling is not safe in multi at all using a team add. will use the first real team instead.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Locale.lua")
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     2
HedgewarsScriptLoad("/Scripts/Utils.lua")
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     3
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     4
local hTag = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     5
local hTagHeight = 33000
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     6
local tTag = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     7
local rTag = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     8
local startTime = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
     9
local MaxHeight = 32640
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    10
local RecordHeight = 33000
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    11
local RecordHeightHogName = nil
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    12
local Fire = {}
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    13
--local BoomFire = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    14
local HH = {}
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    15
local totalHedgehogs = 0
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    16
local deadHedgehogs = 0
10632
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
    17
local currTeam = ''
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
    18
local teams = {}
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    19
local teamScoreStats = {}
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    20
local teamBests = {}
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    21
local MrMine -- in honour of sparkle's first arrival in the cabin
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    22
local YouWon = false
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    23
local YouLost = false
10580
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
    24
local HogsAreInvulnerable = false
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    25
local WaterRise = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    26
local Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    27
local CakeTries = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    28
local Stars = {}
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    29
local tauntNoo = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    30
local jokeAwardNavy = nil
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    31
local jokeAwardSpeed = nil
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    32
local jokeAwardDamage = nil
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    33
local recordBroken = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    34
local ready = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    35
local showWaterStats = false -- uses the AI team to draw water height.
10697
fb38a9468862 scaling is not safe in multi at all using a team add. will use the first real team instead.
nemo
parents: 10645
diff changeset
    36
local scaleGraph = false
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    37
local dummyHog = nil
10592
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
    38
local dummySkip = 0
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    39
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    40
function onGameInit()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    41
    -- Ensure people get same map for same theme
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    42
    TurnTime = 999999999
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    43
    CaseFreq = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    44
    Explosives = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    45
    MineDudPercent = 0
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    46
    EnableGameFlags(gfOneClanMode)
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    47
    DisableGameFlags(gfBottomBorder+gfBorder)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    48
    --This reduced startup time by only about 15% and looked ugly
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    49
    --EnableGameFlags(gfDisableLandObjects) 
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    50
    -- force seed instead.  Some themes will still be easier, but at least you won't luck out on the same theme
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    51
    Seed = ClimbHome
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    52
    if showWaterStats then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    53
        AddTeam(" ", 0x545C9D, "Simple", "Island", "Default")
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    54
    elseif scaleGraph then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    55
        AddTeam(" ", 0x050505, "Simple", "Island", "Default")
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    56
    end
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    57
    if showWaterStats or scaleGraph then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    58
        dummyHog = AddHog(" ", 0, 1, "NoHat")
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    59
        HH[dummyHog] = nil
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    60
        totalHedgehogs = totalHedgehogs - 1
10697
fb38a9468862 scaling is not safe in multi at all using a team add. will use the first real team instead.
nemo
parents: 10645
diff changeset
    61
        if not showWaterStats then
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    62
            SendStat(siClanHealth, tostring(32640), " ")
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    63
        end
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    64
        SendStat(siClanHealth, tostring(32640), " ")
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    65
    end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    66
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    67
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    68
function onGearAdd(gear)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    69
    if GetGearType(gear) == gtHedgehog then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    70
        HH[gear] = 1
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    71
        totalHedgehogs = totalHedgehogs + 1
10632
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
    72
        teams[GetHogTeamName(gear)] = 1
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    73
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    74
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    75
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    76
function onGearDelete(gear)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    77
    if gear == MrMine then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    78
        AddCaption("Once you set off the proximity trigger, Mr. Mine is not your friend",0xffffff,0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    79
        MrMine = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    80
    elseif gear == Cake then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    81
        Cake = nil
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    82
    elseif GetGearType(gear) == gtHedgehog then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    83
        HH[gear] = nil
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    84
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    85
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    86
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    87
function onGameStart()
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    88
    if showWaterStats or scaleGraph then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    89
        DeleteGear(dummyHog)
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    90
    end
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    91
    --SetClanColor(ClansCount-1, 0x0000ffff) appears to be broken
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    92
    SendHealthStatsOff()
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    93
    ShowMission(loc("Climb Home"),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    94
                loc("Rope to safety"),
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
    95
                loc("You are far from home, and the water is rising, climb up as high as you can!|Your score will be based on your height."),
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    96
                -amRope, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    97
    local x = 1818
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    98
    for h,i in pairs(HH) do
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
    99
        if h ~= nil then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   100
            -- SetGearPosition(h,x,32549)
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   101
            SetGearPosition(h,x,108)
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   102
            SetHealth(h,1)
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   103
            if x < 1978 then x = x+32 else x = 1818 end
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   104
            if GetEffect(h,heInvulnerable) == 0 then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   105
                SetEffect(h,heInvulnerable,1)
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   106
            else
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   107
                HogsAreInvulnerable = true
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   108
            end
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   109
            SetState(h,bor(GetState(h),gstInvisible))
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   110
        end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   111
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   112
-- 1925,263 - Mr. Mine position
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   113
    MrMine = AddGear(1925,263,gtMine,0,0,0,0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   114
end
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   115
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   116
function onAmmoStoreInit()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   117
    SetAmmo(amRope, 9, 0, 0, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   118
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   119
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   120
function onNewTurn()
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   121
    ready = false
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   122
    startTime = GameTime
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   123
    --disable to preserve highest over multiple turns
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   124
    --will need to change water check too ofc
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   125
    MaxHeight = 32640
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   126
    hTagHeight = 33000
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   127
    SetWaterLine(32768)
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   128
    YouWon = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   129
    YouLost = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   130
    tauntNoo = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   131
    recordBroken = false
10632
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   132
    currTeam = GetHogTeamName(CurrentHedgehog)
10592
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   133
    if CurrentHedgehog ~= nil then
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   134
        if CurrentHedgehog ~= dummyHog then
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   135
            SetGearPosition(CurrentHedgehog, 1951,32640)
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   136
            if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   137
            AddVisualGear(1951,32640,vgtExplosion,0,false)
10592
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   138
            SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible)))
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   139
            SetWeapon(amRope)
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   140
            ready = true
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   141
        else
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   142
            dummySkip = GameTime+1
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   143
        end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   144
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   145
    for f,i in pairs(Fire) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   146
        DeleteGear(f)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   147
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   148
    for s,i in pairs(Stars) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   149
        DeleteVisualGear(s)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   150
        Stars[s] = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   151
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   152
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   153
    if CurrentHedgehog ~= dummyHog then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   154
        for i = 0,12 do
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   155
            flame = AddGear(2000+i*2,308, gtFlame, gsttmpFlag,  0, 0, 0)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   156
            SetTag(flame, 999999+i)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   157
            Fire[flame]=1
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   158
        end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   159
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   160
    if Cake ~= nil then DeleteGear(Cake) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   161
    CakeTries = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   162
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   163
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   164
--function onGearDelete(gear)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   165
--    if gear == WaterRise and MaxHeight > 500 and CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   166
--        WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   167
--    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   168
--end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   169
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   170
function FireBoom(x,y,d) -- going to add for rockets too
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   171
    AddVisualGear(x,y,vgtExplosion,0,false)
10580
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   172
    -- should approximate circle by removing corners
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   173
    --if BoomFire == nil then BoomFire = {} end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   174
    for i = 0,50 do
10580
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   175
	fx = GetRandom(d)-div(d,2)
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   176
	fy = GetRandom(d)-div(d,2)
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   177
	if fx<0 then
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   178
	   fdx = -5000-GetRandom(3000)
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   179
	else
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   180
	   fdx = 5000+GetRandom(3000)
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   181
	end
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   182
	if fy<0 then
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   183
	   fdy = -5000-GetRandom(3000)
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   184
	else
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   185
	   fdy = 5000+GetRandom(3000)
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   186
	end
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   187
        flame = AddGear(x+fx, y+fy, gtFlame, gsttmpFlag,  fdx, fdy, 0)
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   188
        SetTag(flame, 999999+i)
10589
98ea597e5cd9 expose FlightTime to lua, disable in-air flame harming moving hogs ☹ aaaand override that in ClimbHome ☺
nemo
parents: 10587
diff changeset
   189
        SetFlightTime(flame, 0)
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   190
        Fire[flame]=1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   191
--        BoomFire[flame]=1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   192
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   193
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   194
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   195
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   196
function onGameTick20()
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   197
    local x,y;
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   198
    if math.random(20) == 1 then AddVisualGear(2012,56,vgtSmoke,0,false) end
10592
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   199
    if CurrentHedgehog == dummyHog and dummySkip ~= 0 and dummySkip < GameTime then
10585
eaccc445c473 Should prevent desync hopefully. Thanks unc0rr
nemo
parents: 10581
diff changeset
   200
        ParseCommand("/skip")
10592
2da35f88db23 stricter skip
nemo
parents: 10589
diff changeset
   201
        dummySkip = 0
10585
eaccc445c473 Should prevent desync hopefully. Thanks unc0rr
nemo
parents: 10581
diff changeset
   202
    end
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   203
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   204
    --if BoomFire ~= nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   205
    --    for f,i in pairs(BoomFire) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   206
    --        if band(GetState(f),gstCollision~=0) then DeleteGear(f) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   207
    --    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   208
    --    BoomFire = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   209
    --end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   210
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   211
    for s,i in pairs(Stars) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   212
        g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(s)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   213
        if g1 > WaterLine + 500 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   214
            DeleteVisualGear(s)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   215
            Stars[s] = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   216
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   217
        --else  wasn't really visible, pointless.
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   218
        --    g5 = g5+1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   219
        --    if g5 > 360 then g5 = 0 end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   220
        --    SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   221
        --end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   222
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   223
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   224
    if CurrentHedgehog ~= nil then x,y = GetGearPosition(CurrentHedgehog) end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   225
    if Cake ~= nil and CurrentHedgehog ~= nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   226
        local cx,cy = GetGearPosition(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   227
        if y < cy-1500 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   228
            DeleteGear(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   229
            Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   230
        end
10587
1dac23b5fe3b delay cake boom until it has walked a little bit. also fix accidental drowning of watergods in last commit
nemo
parents: 10585
diff changeset
   231
10645
b8c73bacb31e Fix in-flight colouring of land spray, make it use tint when added to land too (lua might find that handy), tweak climbhome cake delay slightly
nemo
parents: 10632
diff changeset
   232
        if Cake ~= nil and GetHealth(Cake) < 999980 and gearIsInCircle(CurrentHedgehog,cx,cy,450) then
10580
17560eb73b4c Reset max team health after script may have screwed with it on start. Maybe a script max health reset function could be useful too. Set climbhome hogs to invulnerable while not their turn if needed to avoid accidental mine/dead hog damage. Tweak cake fire boom a bit.
nemo
parents: 10413
diff changeset
   233
            FireBoom(cx,cy,200) -- todo animate
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   234
            DeleteGear(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   235
            Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   236
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   237
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   238
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   239
    if CurrentHedgehog ~= nil and TurnTimeLeft > 0 and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   240
        if MaxHeight < 32000 and MaxHeight > 286 and WaterLine > 286  then SetWaterLine(WaterLine-2) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   241
        if y > 0 and y < 30000 and MaxHeight > 286 and math.random(y) < 500 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   242
            local s = AddVisualGear(0, 0, vgtStraightShot, 0, true)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   243
            local c = div(250000,y)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   244
            if c > 255 then c = 255 end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   245
            c = c * 0x10000 + 0xFF0000FF
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   246
            SetVisualGearValues(s,
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   247
                math.random(2048), -5000, 0, -1-(1/y*1000), 
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   248
                math.random(360),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   249
                0,
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   250
                999999999, -- frameticks
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   251
                171, -- star
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   252
                0, c)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   253
                --,  0xFFCC00FF) -- could be fun to make colour shift as you rise...
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   254
            Stars[s] = 1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   255
        end    
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   256
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   257
    
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   258
    if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   259
        for f,i in pairs(Fire) do -- takes too long to fall otherwise
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   260
            DeleteGear(f)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   261
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   262
        if Cake ~= nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   263
            DeleteGear(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   264
            Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   265
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   266
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   267
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   268
    if CurrentHedgehog ~= nil and TurnTimeLeft > 0 then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   269
        local vx, vy = GetGearVelocity(CurrentHedgehog)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   270
	local distanceFromWater = WaterLine - y
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   271
	
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   272
        --[[ check joke awards ]]
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   273
        -- navy award: when distance from main map is over 1000
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   274
        local navyDistance = 1250
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   275
        if x < -navyDistance or x > LAND_WIDTH+navyDistance then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   276
            local awarded = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   277
            local dist = 0
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   278
            if jokeAwardNavy == nil then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   279
                awarded = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   280
            else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   281
                if x < 0 then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   282
                    dist = math.abs(x)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   283
                else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   284
                    dist = x - LAND_WIDTH
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   285
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   286
                if dist > jokeAwardNavy.distance then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   287
                    awarded = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   288
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   289
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   290
            if awarded == true then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   291
                jokeAwardNavy = {
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   292
                    hogName = GetHogName(CurrentHedgehog),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   293
                    teamName = GetHogTeamName(CurrentHedgehog),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   294
                    distance = dist
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   295
                }
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   296
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   297
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   298
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   299
        -- Speed award for largest distance from water
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   300
        if distanceFromWater > 3000 and WaterLine < 32000 then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   301
            local awarded = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   302
            if jokeAwardSpeed == nil or distanceFromWater > jokeAwardSpeed.distance then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   303
                awarded = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   304
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   305
            if awarded == true then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   306
                jokeAwardSpeed = {
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   307
                    hogName = GetHogName(CurrentHedgehog),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   308
                    teamName = GetHogTeamName(CurrentHedgehog),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   309
                    distance = distanceFromWater
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   310
                }
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   311
            end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   312
        end
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   313
            if isSinglePlayer then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   314
                if distanceFromWater < 0 and not YouLost and not YouWon then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   315
                    makeSinglePlayerLoserStats()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   316
                    YouLost = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   317
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   318
                if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   319
                    local finishTime = (GameTime-startTime)/1000
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   320
                    local roundedFinishTime = math.ceil(math.floor(finishTime+0.5))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   321
                    AddCaption(loc("Victory!"))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   322
                    ShowMission(loc("Climb Home"),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   323
                                loc("Made it!"),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   324
                                string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   325
                                -amRope, 0)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   326
                    PlaySound(sndVictory,CurrentHedgehog)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   327
                    SetState(CurrentHedgehog, gstWinner)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   328
                    SendStat(siGameResult, loc("You have beaten the challenge!"))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   329
                    SendStat(siGraphTitle, loc("Your height over time"))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   330
                    SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), loc(GetHogName(CurrentHedgehog)), finishTime))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   331
                    SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."),loc(GetHogName(CurrentHedgehog)), getActualHeight(RecordHeight)))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   332
                    SendStat(siPointType, loc("seconds"))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   333
                    SendStat(siPlayerKills, tostring(roundedFinishTime), loc(GetHogTeamName(CurrentHedgehog)))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   334
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   335
                    EndGame()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   336
                    YouWon = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   337
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   338
            elseif distanceFromWater < 0 and not YouLost then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   339
                makeMultiPlayerLoserStat(CurrentHedgehog)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   340
                deadHedgehogs = deadHedgehogs + 1
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   341
                YouLost = true
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   342
                if deadHedgehogs >= totalHedgehogs then
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   343
                    makeFinalMultiPlayerStats()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   344
                    EndGame()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   345
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   346
            end
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   347
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   348
        if GameTime % 500 == 0 then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   349
            --if isSinglePlayer and MaxHeight < 32000 and WaterRise == nil then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   350
            --    WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   351
            --end
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   352
            if showWaterStats == true then
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   353
	        SendStat(siClanHealth, tostring(getActualHeight(WaterLine)), " ")
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   354
            end
10632
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   355
	    for t,i in pairs(teams) do
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   356
                if currTeam == t then
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   357
                    SendStat(siClanHealth, tostring(getActualHeight(y)), t)
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   358
                else
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   359
                    SendStat(siClanHealth, '0', t)
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   360
                end
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   361
            end
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   362
    
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   363
            -- play taunts
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   364
            if not YouWon and not YouLost then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   365
                local nooDistance = 500
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   366
                if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   367
                    if (tauntNoo == false and distanceFromWater > 80) then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   368
                        PlaySound(sndNooo, CurrentHedgehog)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   369
                        tauntNoo = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   370
                    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   371
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   372
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   373
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   374
            if CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then 
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   375
                -- doing this just after the start the first time to take advantage of randomness sources
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   376
                -- Pick a clear y to start with
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   377
                if y > 31000 then cy = 24585 elseif
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   378
                   y > 28000 then cy = 21500 elseif
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   379
                   y > 24000 then cy = 19000 elseif
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   380
                   y > 21500 then cy = 16000 elseif
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   381
                   y > 19000 then cy = 12265 elseif
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   382
                   y > 16000 then cy =  8800 elseif
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   383
                   y > 12000 then cy =  5700 else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   384
                   cy = 400 end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   385
                Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   386
                SetHealth(Cake,999999)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   387
                CakeTries = CakeTries + 1 
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   388
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   389
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   390
            if (y > 286) or (y < 286 and MaxHeight > 286) then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   391
                if y < MaxHeight and y > 286 then MaxHeight = y end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   392
                if y < 286 then MaxHeight = 286 end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   393
                if MaxHeight < hTagHeight then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   394
                    hTagHeight = MaxHeight
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   395
                    if hTag ~= nil then DeleteVisualGear(hTag) end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   396
                    hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   397
                    local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   398
                    -- snagged from space invasion
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   399
                    SetVisualGearValues (
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   400
                            hTag,        --id
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   401
                            -(ScreenWidth/2) + 40, --xoffset
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   402
                            ScreenHeight - 60, --yoffset
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   403
                            0,          --dx
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   404
                            0,          --dy
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   405
                            1.1,        --zoom
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   406
                            1,          --~= 0 means align to screen
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   407
                            g7,         --frameticks
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   408
            -- 116px off bottom for lowest rock, 286 or so off top for position of chair
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   409
            -- 32650 is "0"
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   410
                            32640-hTagHeight,    --value
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   411
                            99999999999,--timer
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   412
                            GetClanColor(GetHogClan(CurrentHedgehog))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   413
                            )
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   414
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   415
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   416
                if MaxHeight < RecordHeight then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   417
                    RecordHeight = MaxHeight
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   418
                    local oldName = RecordHeightHogName
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   419
                    RecordHeightHogName = GetHogName(CurrentHedgehog)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   420
                    if oldName == nil then recordBroken = true end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   421
                    if not isSinglePlayer and RecordHeight > 1500 and not recordBroken then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   422
                        recordBroken = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   423
                        AddCaption(string.format(loc("%s has passed the best height of %s!"), RecordHeightHogName, oldName))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   424
                    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   425
                    if not isSinglePlayer then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   426
                        if rTag ~= nil then DeleteVisualGear(rTag) end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   427
                        rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   428
                        local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   429
                        -- snagged from space invasion
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   430
                        SetVisualGearValues (
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   431
                            rTag,        --id
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   432
                            -(ScreenWidth/2) + 100, --xoffset
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   433
                            ScreenHeight - 60, --yoffset
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   434
                            0,          --dx
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   435
                            0,          --dy
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   436
                            1.1,        --zoom
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   437
                            1,          --~= 0 means align to screen
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   438
                            g7,         --frameticks
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   439
            -- 116px off bottom for lowest rock, 286 or so off top for position of chair
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   440
            -- 32650 is "0"
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   441
                            getActualHeight(RecordHeight),    --value
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   442
                            99999999999,--timer
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   443
                            GetClanColor(GetHogClan(CurrentHedgehog))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   444
                            )
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   445
                    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   446
                end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   447
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   448
            if MaxHeight > 286 then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   449
                if tTag ~= nil then DeleteVisualGear(tTag) end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   450
                tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   451
                local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tTag)
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   452
                -- snagged from space invasion
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   453
                SetVisualGearValues (
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   454
                    tTag,        --id
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   455
                    -(ScreenWidth/2) + 40, --xoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   456
                    ScreenHeight - 100, --yoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   457
                    0,          --dx
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   458
                    0,          --dy
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   459
                    1.1,        --zoom
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   460
                    1,          --~= 0 means align to screen
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   461
                    g7,         --frameticks
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   462
                    (GameTime-startTime)/1000,    --value
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   463
                    99999999999,--timer
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   464
                    0xffffffff
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   465
                    )
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   466
            end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   467
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   468
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   469
end
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   470
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   471
function onGearDamage(gear, damage)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   472
    if GetGearType(gear) == gtHedgehog and not YouLost and not YouWon then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   473
        -- Joke award for largest damage to hog
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   474
        local qualifyDamage = 50
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   475
        if (damage >= qualifyDamage) then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   476
            local awarded = false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   477
            if jokeAwardDamage == nil or damage > jokeAwardDamage.damage then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   478
                awarded = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   479
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   480
            if awarded == true then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   481
                jokeAwardDamage = {
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   482
                    hogName = GetHogName(CurrentHedgehog),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   483
                    teamName = GetHogTeamName(CurrentHedgehog),
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   484
                    damage = damage
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   485
                }
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   486
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   487
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   488
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   489
        if isSinglePlayer then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   490
            makeSinglePlayerLoserStats()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   491
        else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   492
            deadHedgehogs = deadHedgehogs + 1
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   493
            if deadHedgehogs >= totalHedgehogs then
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   494
                makeFinalMultiPlayerStats()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   495
                EndGame()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   496
            end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   497
            makeMultiPlayerLoserStat(gear)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   498
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   499
        YouLost = true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   500
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   501
end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   502
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   503
function makeLoserComment()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   504
    local m
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   505
    if isSinglePlayer then m = 10 else m = 6 end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   506
    local r = math.random(1,m)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   507
    if r == 1 then text = loc("%s never got the ninja diploma.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   508
    elseif r == 2 then text = loc("You have to move upwards, not downwards, %s!")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   509
    elseif r == 3 then text = loc("%s never wanted to reach for the sky in the first place.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   510
    elseif r == 4 then text = loc("%s should try the rope training mission first.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   511
    elseif r == 5 then text = loc("%s skipped ninja classes.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   512
    elseif r == 6 then text = loc("%s doesn’t really know how to handle a rope properly.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   513
    elseif r == 7 then text = loc("Better luck next time!")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   514
    elseif r == 8 then text = loc("It was all just bad luck!")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   515
    elseif r == 9 then text = loc("Well, that escalated quickly!")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   516
    elseif r == 10 then text = loc("What? Is it over already?") end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   517
    return text
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   518
end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   519
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   520
function makeSinglePlayerLoserStats()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   521
    local actualHeight = getActualHeight(RecordHeight)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   522
    SendStat(siGameResult, loc("You lose!"))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   523
    SendStat(siGraphTitle, loc("Your height over time"))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   524
    local text
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   525
    if actualHeight > 30000 then text = loc("%s was damn close to home.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   526
    elseif actualHeight > 28000 then text = loc("%s was close to home.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   527
    elseif actualHeight > 24265 then text = loc("%s was good, but not good enough.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   528
    elseif actualHeight > 16177 then text = loc("%s managed to pass half of the distance towards home.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   529
    elseif actualHeight > 8088 then text = loc("%s went over a quarter of the way towards home.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   530
    elseif actualHeight > 5100 then text = loc("%s still had a long way to go.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   531
    elseif actualHeight > 2000 then text = loc("%s made it past the hogosphere.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   532
    elseif actualHeight > 1500  then text = loc("%s barely made it past the hogosphere.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   533
    else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   534
        text = makeLoserComment()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   535
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   536
    if actualHeight > 1500 then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   537
        SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, actualHeight))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   538
    else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   539
        SendStat(siCustomAchievement, string.format(text, RecordHeightHogName))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   540
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   541
    SendStat(siPlayerKills, actualHeight, loc(GetHogTeamName(CurrentHedgehog)))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   542
    EndGame()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   543
end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   544
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   545
function makeMultiPlayerLoserStat(gear)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   546
    local teamName = GetHogTeamName(gear)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   547
    local actualHeight = getActualHeight(MaxHeight)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   548
    if teamBests[teamName] == nil then teamBests[teamName] = actualHeight end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   549
    if teamBests[teamName] < actualHeight then teamBests[teamName] = actualHeight end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   550
    if teamScoreStats[teamName] == nil then teamScoreStats[teamName] = {} end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   551
    table.insert(teamScoreStats[teamName], actualHeight)
10598
9dd0f41d3244 This should probably fix multiplayer desync, but is the result of fiddling while pretty sick/feverish so, needs testing, and the water/scaling stuff is disabled.
nemo
parents: 10593
diff changeset
   552
    --SendStat(siClanHealth, tostring(teamBests[teamName]), teamName)
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   553
end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   554
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   555
function makeFinalMultiPlayerStats()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   556
    local ranking = {}
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   557
    for k,v in pairs(teamBests) do
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   558
        table.insert(ranking, {name=k, score=v})
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   559
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   560
    local comp = function(table1, table2)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   561
        if table1.score < table2.score then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   562
            return true
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   563
        else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   564
            return false
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   565
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   566
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   567
    table.sort(ranking, comp)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   568
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   569
    local winner = ranking[#ranking]
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   570
    local loser = ranking[1]
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   571
    SendStat(siGameResult, string.format(loc("%s wins!"), winner.name))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   572
    SendStat(siGraphTitle, string.format(loc("Team’s best heights per round")))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   573
    
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   574
    if winner.score < 1500 then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   575
        SendStat(siCustomAchievement, string.format(loc("This round’s award for ulitmate disappointment goes to: Everyone!")))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   576
    else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   577
        if winner.score > 30000 then text = loc("%s (%s) reached for the sky and beyond with a height of %d!")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   578
        elseif winner.score > 24750 then text = loc("%s (%s) was certainly not afraid of heights: Peak height of %d!")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   579
        elseif winner.score > 16500 then text = loc("%s (%s) does not have to feel ashamed for their best height of %d.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   580
        elseif winner.score > 8250 then text = loc("%s (%s) reached a decent peak height of %d.")
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   581
        else text = loc("%s (%s) reached a peak height of %d.") end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   582
        SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, winner.name, winner.score))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   583
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   584
        if loser.score < 1500 then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   585
            text = makeLoserComment()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   586
            SendStat(siCustomAchievement, string.format(text, loser.name))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   587
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   588
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   589
    checkAwards()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   590
    for i = #ranking, 1, -1 do
10632
5ae7ba0b2849 pretty sure the other teams need stats at 0 for the graph to look right
nemo
parents: 10598
diff changeset
   591
	SendStat(siPointType, loc("points"))
10581
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   592
        SendStat(siPlayerKills, tostring(ranking[i].score), ranking[i].name)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   593
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   594
end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   595
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   596
function checkAwards()
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   597
    if jokeAwardNavy ~= nil then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   598
        if isSinglePlayer then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   599
            SendStat(siCustomAchievement, string.format(loc("The Navy greets %s for managing to get in a distance of %d away from the mainland!"), jokeAwardNavy.hogName, jokeAwardNavy.distance))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   600
        else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   601
            SendStat(siCustomAchievement, string.format(loc("Greetings from the Navy, %s (%s), for being a distance of %d away from the mainland!"), jokeAwardNavy.hogName, jokeAwardNavy.teamName, jokeAwardNavy.distance))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   602
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   603
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   604
    if jokeAwardSpeed ~= nil then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   605
        if isSinglePlayer then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   606
            SendStat(siCustomAchievement, string.format(loc("Your hedgehog was panicly afraid of the water and decided to go in a safe distance of %d from it."), jokeAwardSpeed.distance))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   607
        else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   608
            SendStat(siCustomAchievement, string.format(loc("%s (%s) was panicly afraid of the water and decided to get in a safe distance of %d from it."), jokeAwardSpeed.hogName, jokeAwardSpeed.teamName, jokeAwardSpeed.distance))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   609
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   610
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   611
    if jokeAwardDamage ~= nil then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   612
        if isSinglePlayer then
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   613
            SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. You mutilated your poor hedgehog hog with %d damage."), jokeAwardDamage.damage))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   614
        else
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   615
            SendStat(siCustomAchievement, string.format(loc("Ouch! That must have hurt. %s (%s) hit the ground with %d damage points."), jokeAwardDamage.hogName, jokeAwardDamage.teamName, jokeAwardDamage.damage))
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   616
        end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   617
    end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   618
end
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   619
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   620
function getActualHeight(height)
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   621
    return 32640-height
f0b4c14a3c62 Wuzzy's changes to climbhome w/ some tweaks by me
nemo
parents: 10580
diff changeset
   622
end