share/hedgewars/Data/Maps/ClimbHome/map.lua
author nemo
Sat, 29 Nov 2014 15:30:33 -0500
changeset 10580 17560eb73b4c
parent 10413 afd746a538ef
child 10581 f0b4c14a3c62
permissions -rw-r--r--
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.
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
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    11
local Fire = {}
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    12
--local BoomFire = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    13
local HH = {}
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    14
local MrMine -- in honour of sparkle's first arrival in the cabin
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    15
local YouWon = 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
    16
local HogsAreInvulnerable = false
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    17
local WaterRise = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    18
local Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    19
local CakeTries = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    20
local Stars = {}
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    21
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    22
function onGameInit()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    23
    -- Ensure people get same map for same theme
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    24
    TurnTime = 999999999
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    25
    CaseFreq = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    26
    Explosives = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    27
    MineDudPercent = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    28
    DisableGameFlags(gfBottomBorder+gfBorder)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    29
    --This reduced startup time by only about 15% and looked ugly
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    30
    --EnableGameFlags(gfDisableLandObjects) 
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    31
    -- 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
    32
    Seed = ClimbHome
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    33
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    34
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    35
function onGearAdd(gear)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    36
    if GetGearType(gear) == gtHedgehog then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    37
        HH[gear] = 1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    38
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    39
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    40
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    41
function onGearDelete(gear)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    42
    if gear == MrMine then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    43
        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
    44
        MrMine = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    45
    elseif gear == Cake then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    46
        Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    47
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    48
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    49
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    50
function onGameStart()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    51
    ShowMission(loc("Climb Home"),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    52
                loc("Rope to safety"),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    53
                loc("You are far from home, and the water is rising, climb up as high as you can!"),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    54
                -amRope, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    55
    local x = 1818
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    56
    for h,i in pairs(HH) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    57
       -- SetGearPosition(h,x,32549)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    58
        SetGearPosition(h,x,108)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    59
        SetHealth(h,1)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    60
        if x < 1978 then x = x+32 else x = 1818 end
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
    61
	if GetEffect(h,heInvulnerable) == 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
    62
	    SetEffect(h,heInvulnerable,1)
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
    63
	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
    64
	    HogsAreInvulnerable = true
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
    65
	end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    66
        SetState(h,bor(GetState(h),gstInvisible))
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    67
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    68
-- 1925,263 - Mr. Mine position
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    69
    MrMine = AddGear(1925,263,gtMine,0,0,0,0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    70
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    71
function onAmmoStoreInit()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    72
    SetAmmo(amRope, 9, 0, 0, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    73
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    74
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    75
function onNewTurn()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    76
    startTime = GameTime
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    77
    --disable to preserve highest over multiple turns
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    78
    --will need to change water check too ofc
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    79
    MaxHeight = 32640
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    80
    hTagHeight = 33000
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    81
    SetWaterLine(32768)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    82
    if CurrentHedgehog ~= nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    83
        SetGearPosition(CurrentHedgehog, 1951,32640)
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
    84
	if not HogsAreInvulnerable 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
    85
	    SetEffect(CurrentHedgehog,heInvulnerable,0)
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
    86
	end
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    87
        AddVisualGear(19531,32640,vgtExplosion,0,false)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    88
        SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible)))
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    89
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    90
    for f,i in pairs(Fire) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    91
        DeleteGear(f)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    92
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    93
    for s,i in pairs(Stars) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    94
        DeleteVisualGear(s)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    95
        Stars[s] = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    96
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    97
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    98
    for i = 0,12 do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
    99
        flame = AddGear(2000+i*2,308, gtFlame, gsttmpFlag,  0, 0, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   100
        SetTag(flame, 999999+i)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   101
        Fire[flame]=1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   102
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   103
    if Cake ~= nil then DeleteGear(Cake) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   104
    CakeTries = 0
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   105
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   106
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   107
--function onGearDelete(gear)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   108
--    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
   109
--        WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   110
--    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   111
--end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   112
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   113
function FireBoom(x,y,d) -- going to add for rockets too
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   114
    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
   115
    -- should approximate circle by removing corners
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   116
    if BoomFire == nil then BoomFire = {} end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   117
    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
   118
	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
   119
	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
   120
	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
   121
	   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
   122
	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
   123
	   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
   124
	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
   125
	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
   126
	   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
   127
	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
   128
	   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
   129
	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
   130
        flame = AddGear(x+fx, y+fy, gtFlame, gsttmpFlag,  fdx, fdy, 0)
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   131
        SetTag(flame, 999999+i)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   132
        Fire[flame]=1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   133
--        BoomFire[flame]=1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   134
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   135
end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   136
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   137
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   138
function onGameTick20()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   139
    if math.random(20) == 1 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   140
        AddVisualGear(2012,56,vgtSmoke,0,false)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   141
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   142
    --if BoomFire ~= nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   143
    --    for f,i in pairs(BoomFire) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   144
    --        if band(GetState(f),gstCollision~=0) then DeleteGear(f) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   145
    --    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   146
    --    BoomFire = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   147
    --end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   148
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   149
    for s,i in pairs(Stars) do
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   150
        g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(s)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   151
        if g1 > WaterLine + 500 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   152
            DeleteVisualGear(s)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   153
            Stars[s] = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   154
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   155
        --else  wasn't really visible, pointless.
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   156
        --    g5 = g5+1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   157
        --    if g5 > 360 then g5 = 0 end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   158
        --    SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   159
        --end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   160
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   161
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   162
    if Cake ~= nil and CurrentHedgehog ~= nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   163
        local cx,cy = GetGearPosition(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   164
        local x,y = GetGearPosition(CurrentHedgehog)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   165
        if y < cy-1500 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   166
            DeleteGear(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   167
            Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   168
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   169
        if 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
   170
            FireBoom(cx,cy,200) -- todo animate
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   171
            DeleteGear(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   172
            Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   173
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   174
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   175
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   176
    if CurrentHedgehog ~= nil and TurnTimeLeft > 0 and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   177
        if MaxHeight < 32000 and MaxHeight > 286 and WaterLine > 286  then SetWaterLine(WaterLine-2) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   178
        local x,y = GetGearPosition(CurrentHedgehog)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   179
        if y > 0 and y < 30000 and MaxHeight > 286 and math.random(y) < 500 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   180
            local s = AddVisualGear(0, 0, vgtStraightShot, 0, true)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   181
            local c = div(250000,y)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   182
            if c > 255 then c = 255 end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   183
            c = c * 0x10000 + 0xFF0000FF
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   184
            SetVisualGearValues(s,
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   185
                math.random(2048), -5000, 0, -1-(1/y*1000), 
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   186
                math.random(360),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   187
                0,
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   188
                999999999, -- frameticks
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   189
                171, -- star
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   190
                0, c)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   191
                --,  0xFFCC00FF) -- could be fun to make colour shift as you rise...
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   192
            Stars[s] = 1
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   193
        end    
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   194
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   195
    
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   196
    if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   197
        for f,i in pairs(Fire) do -- takes too long to fall otherwise
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   198
            DeleteGear(f)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   199
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   200
        if Cake ~= nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   201
            DeleteGear(Cake)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   202
            Cake = nil
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   203
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   204
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   205
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   206
    if GameTime % 500 == 0 and CurrentHedgehog ~= nil and TurnTimeLeft > 0 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   207
        --if isSinglePlayer and MaxHeight < 32000 and WaterRise == nil then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   208
        --    WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   209
        --end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   210
        if isSinglePlayer and not YouWon and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   211
            ShowMission(loc("Climb Home"),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   212
                        loc("Made it!"),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   213
                        string.format(loc("AHHh, home sweet home.  Made it in %d seconds."),(GameTime-startTime)/1000),
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   214
                        -amRope, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   215
            PlaySound(sndVictory,CurrentHedgehog)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   216
            EndGame()
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   217
            YouWon = true
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   218
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   219
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   220
        local x,y = GetGearPosition(CurrentHedgehog)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   221
        if CakeTries < 10 and y < 32600 and y > 3000 and Cake == nil and band(GetState(CurrentHedgehog),gstHHDriven) ~= 0 then 
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   222
            -- doing this just after the start the first time to take advantage of randomness sources
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   223
            -- there's a small chance it'll jiggle the camera though, so trying not to do it too often
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   224
            -- Pick a clear y to start with
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   225
            if y > 31000 then cy = 24585 elseif
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   226
               y > 28000 then cy = 21500 elseif
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   227
               y > 24000 then cy = 19000 elseif
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   228
               y > 21500 then cy = 16000 elseif
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   229
               y > 19000 then cy = 12265 elseif
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   230
               y > 16000 then cy =  8800 elseif
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   231
               y > 12000 then cy =  5700 else
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   232
               cy = 400 end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   233
            Cake = AddGear(GetRandom(2048), cy, gtCake, 0, 0, 0, 0)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   234
            SetHealth(Cake,999999)
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
   235
            CakeTries = CakeTries + 1 
10413
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   236
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   237
        if (y > 286) or (y < 286 and MaxHeight > 286) then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   238
            if y < MaxHeight and y > 286 then MaxHeight = y end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   239
            if y < 286 then MaxHeight = 286 end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   240
            if MaxHeight < hTagHeight then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   241
                hTagHeight = MaxHeight
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   242
                if hTag ~= nil then DeleteVisualGear(hTag) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   243
                hTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   244
                local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   245
                -- snagged from space invasion
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   246
                SetVisualGearValues (
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   247
                        hTag,        --id
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   248
                        -(ScreenWidth/2) + 40, --xoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   249
                        ScreenHeight - 60, --yoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   250
                        0,          --dx
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   251
                        0,          --dy
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   252
                        1.1,        --zoom
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   253
                        1,          --~= 0 means align to screen
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   254
                        g7,         --frameticks
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   255
        -- 116px off bottom for lowest rock, 286 or so off top for position of chair
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   256
        -- 32650 is "0"
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   257
                        32640-hTagHeight,    --value
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   258
                        99999999999,--timer
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   259
                        GetClanColor(GetHogClan(CurrentHedgehog))
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   260
                        )
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   261
            end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   262
            if MaxHeight < RecordHeight then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   263
                RecordHeight = MaxHeight
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   264
                if rTag ~= nil then DeleteVisualGear(rTag) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   265
                rTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   266
                local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(hTag)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   267
                -- snagged from space invasion
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   268
                SetVisualGearValues (
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   269
                        rTag,        --id
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   270
                        -(ScreenWidth/2) + 100, --xoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   271
                        ScreenHeight - 60, --yoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   272
                        0,          --dx
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   273
                        0,          --dy
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   274
                        1.1,        --zoom
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   275
                        1,          --~= 0 means align to screen
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   276
                        g7,         --frameticks
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   277
        -- 116px off bottom for lowest rock, 286 or so off top for position of chair
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   278
        -- 32650 is "0"
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   279
                        32640-RecordHeight,    --value
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   280
                        99999999999,--timer
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   281
                        GetClanColor(GetHogClan(CurrentHedgehog))
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   282
                        )
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   283
            end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   284
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   285
        if MaxHeight > 286 then
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   286
            if tTag ~= nil then DeleteVisualGear(tTag) end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   287
            tTag = AddVisualGear(0, 0, vgtHealthTag, 0, true)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   288
            local g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tTag)
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   289
            -- snagged from space invasion
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   290
            SetVisualGearValues (
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   291
                    tTag,        --id
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   292
                    -(ScreenWidth/2) + 40, --xoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   293
                    ScreenHeight - 100, --yoffset
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   294
                    0,          --dx
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   295
                    0,          --dy
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   296
                    1.1,        --zoom
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   297
                    1,          --~= 0 means align to screen
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   298
                    g7,         --frameticks
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   299
                    (GameTime-startTime)/1000,    --value
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   300
                    99999999999,--timer
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   301
                    0xffffffff
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   302
                    )
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   303
        end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   304
    end
afd746a538ef climb home training/multiplayer
nemo
parents:
diff changeset
   305
end