share/hedgewars/Data/Scripts/RopeKnocking.lua
author jpr
Fri, 27 Jan 2023 06:22:22 +0300
changeset 15941 5289ab63853d
parent 15512 0039baa9895e
permissions -rw-r--r--
fix typo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15512
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Locale.lua")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     2
HedgewarsScriptLoad("/Scripts/Utils.lua")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     3
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     4
local hhs = {}
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     5
local deadHogs = {}
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     6
local missionWon = nil
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     7
local endTimer = 1000
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     8
local hogsKilled = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
     9
local totalEnemies = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    10
local finishTime
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    11
local playerFail = false
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    12
local ropeGear = nil
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    13
local endGameCalled = false
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    14
local missionEndHandled = false
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    15
local valkyriesTimer = -1
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    16
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    17
local valkyriesDuration = 20000
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    18
local timeBonus = 6000
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    19
local killBonus = 6000
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    20
local playValkyries = false
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    21
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    22
local extraTime
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    23
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    24
local playerTeamName
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    25
local missionName = loc("Rope-knocking Challenge")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    26
-- Mission type:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    27
-- 0 = none (no special handling)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    28
-- 1 = challenge (saves mission vars)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    29
local missionType = 1
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    30
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    31
local function getKillScore()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    32
	return div(hogsKilled * killBonus, totalEnemies)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    33
end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    34
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    35
local function protectEnemies()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    36
	-- Protect enemy hogs
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    37
	for i=1, totalEnemies do
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    38
		if hhs[i] and GetHealth(hhs[i]) then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    39
			SetEffect(hhs[i], heInvulnerable, 1)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    40
			SetEffect(hhs[i], heResurrectable, 1)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    41
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    42
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    43
end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    44
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    45
local function killStr(killed, total, score)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    46
	if total == 16 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    47
		return string.format(loc("You have killed %d of 16 hedgehogs (+%d points)."), killed, score)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    48
	else
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    49
		return string.format(loc("You have killed %d of %d hedgehogs (+%d points)."), killed, total, score)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    50
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    51
end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    52
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    53
local function gameOver()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    54
	StopMusicSound(sndRideOfTheValkyries)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    55
	valkyriesTimer = -1
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    56
	missionWon = false
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    57
	SendStat(siGameResult, loc("Challenge over!"))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    58
	local score = getKillScore()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    59
	SendStat(siCustomAchievement, killStr(hogsKilled, totalEnemies, score))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    60
	SendStat(siPointType, "!POINTS")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    61
	SendStat(siPlayerKills, tostring(score), playerTeamName)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    62
	protectEnemies()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    63
	if not endGameCalled then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    64
		EndGame()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    65
		endGameCalled = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    66
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    67
	if missionType == 1 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    68
		-- Update highscore
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    69
		updateChallengeRecord("Highscore", score)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    70
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    71
end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    72
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    73
local function victory(onVictory)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    74
	missionWon = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    75
	local e = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    76
	if extraTime then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    77
		e = extraTime
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    78
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    79
	local totalTime = TurnTime + e * totalEnemies
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    80
	local completeTime = (totalTime - finishTime) / 1000
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    81
	ShowMission(missionName, loc("Challenge completed!"), loc("Congratulations!") .. "|" .. string.format(loc("Completion time: %.2fs"), completeTime), 0, 0)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    82
	PlaySound(sndHomerun)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    83
	-- Protect player hog
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    84
	if hhs[0] and GetHealth(hhs[0]) then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    85
		SetEffect(hhs[0], heInvulnerable, 1)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    86
		SetEffect(hhs[0], heResurrectable, 1)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    87
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    88
	SendStat(siGameResult, loc("Challenge completed!"))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    89
	local hogScore = getKillScore()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    90
	local timeScore = div(finishTime * timeBonus, totalTime)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    91
	local score = hogScore + timeScore
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    92
	SendStat(siCustomAchievement, killStr(hogsKilled, totalEnemies, hogScore))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    93
	SendStat(siCustomAchievement, string.format(loc("You have completed this challenge in %.2f s (+%d points)."), completeTime, timeScore))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    94
	SendStat(siPointType, "!POINTS")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    95
	SendStat(siPlayerKills, tostring(score), playerTeamName)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    96
	SetTeamLabel(playerTeamName, tostring(score))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    97
	SetTurnTimeLeft(MAX_TURN_TIME)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    98
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
    99
	if missionType == 1 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   100
		-- Update highscore
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   101
		updateChallengeRecord("Highscore", score)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   102
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   103
	if onVictory then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   104
		onVictory()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   105
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   106
end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   107
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   108
local function knockTaunt()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   109
	local r = math.random(0,23)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   110
	local taunt
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   111
	if r == 0 then taunt =		loc("%s has been knocked out.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   112
	elseif r == 1 then taunt =	loc("%s hit the ground.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   113
	elseif r == 2 then taunt =	loc("%s splatted.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   114
	elseif r == 3 then taunt =	loc("%s was smashed.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   115
	elseif r == 4 then taunt =	loc("%s felt unstable.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   116
	elseif r == 5 then taunt =	loc("%s exploded.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   117
	elseif r == 6 then taunt =	loc("%s fell from a high cliff.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   118
	elseif r == 7 then taunt =	loc("%s goes the way of the lemming.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   119
	elseif r == 8 then taunt =	loc("%s was knocked away.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   120
	elseif r == 9 then taunt =	loc("%s was really unlucky.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   121
	elseif r == 10 then taunt =	loc("%s felt victim to rope-knocking.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   122
	elseif r == 11 then taunt =	loc("%s had no chance.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   123
	elseif r == 12 then taunt =	loc("%s was a good target.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   124
	elseif r == 13 then taunt =	loc("%s spawned at a really bad position.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   125
	elseif r == 14 then taunt =	loc("%s was doomed from the beginning.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   126
	elseif r == 15 then taunt =	loc("%s has fallen victim to gravity.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   127
	elseif r == 16 then taunt =	loc("%s hates Newton.")		-- Isaac Newton
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   128
	elseif r == 17 then taunt =	loc("%s had it coming.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   129
	elseif r == 18 then taunt =	loc("%s is eliminated!")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   130
	elseif r == 19 then taunt =	loc("%s fell too fast.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   131
	elseif r == 20 then taunt =	loc("%s flew like a rock.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   132
	elseif r == 21 then taunt =	loc("%s stumbled.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   133
	elseif r == 22 then taunt =	loc("%s was shoved away.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   134
	elseif r == 23 then taunt =	loc("%s didn't expect that.")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   135
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   136
	return taunt
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   137
end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   138
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   139
local function declareEnemyKilled(gear, onVictory)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   140
	if deadHogs[gear] or playerFail then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   141
		return
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   142
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   143
	deadHogs[gear] = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   144
	hogsKilled = hogsKilled + 1
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   145
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   146
	-- Award extra time, if available
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   147
	if extraTime and extraTime ~= 0 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   148
		SetTurnTimeLeft(TurnTimeLeft + extraTime)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   149
		AddCaption(string.format(loc("+%d seconds!"), div(extraTime, 1000)), 0xFFFFFFFF, capgrpMessage2)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   150
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   151
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   152
	SetTeamLabel(playerTeamName, tostring(getKillScore()))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   153
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   154
	if hogsKilled == totalEnemies - 1 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   155
		if playValkyries then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   156
			PlayMusicSound(sndRideOfTheValkyries)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   157
			valkyriesTimer = valkyriesDuration
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   158
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   159
	elseif hogsKilled == totalEnemies then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   160
		finishTime = TurnTimeLeft
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   161
		victory(onVictory)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   162
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   163
end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   164
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   165
--[[
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   166
RopeKnocking function!
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   167
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   168
This creates a rope-knocking challenge.
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   169
The player spawns with one hog and a rope and must kill all other hogs
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   170
by rope-knocking before the time runs out.
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   171
The player wins points for each kill and gets a time bonus for killing
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   172
all enemies.
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   173
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   174
params is a table with all the required parameters.
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   175
Fields of the params table:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   176
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   177
	MANDATORY:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   178
	- map: Map name
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   179
	- theme: Theme name
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   180
	- turnTime: Turn time
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   181
	- playerTeam: Player team info:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   182
		{
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   183
			x, y: Start position
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   184
			faceLeft: If true, hog faces left
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   185
		}
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   186
	- enemyTeams: Table of enemy team tables. each enemy team table has this format:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   187
		{
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   188
			name: Team name
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   189
			flag: Flag
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   190
			hogs: Hogs table:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   191
			{
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   192
				x, y: Position
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   193
				faceLeft: If true, hog faces left
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   194
				hat: Hat name
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   195
				name: Hog name
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   196
			}
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   197
		}
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   198
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   199
	OPTIONAL:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   200
	- missionName: Mission name
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   201
	- missionType:
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   202
		0: None/other: No special handling
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   203
		1: Challenge: Will save mission variables at end (default)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   204
	- killBonus: Score for killing all hogs (one hog scores ca. (killBonus/<number of enemies)) (default: 6000)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   205
	- timeBonus: Maximum theoretically possible time bonus (default: 6000)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   206
	- gameFlags: List of game flags, if you want to set your own
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   207
	- extraTime: Extra time awarded for each kill, in milliseconds (default: 0)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   208
	- valkyries: If true, play "Ride of the Valkyries" at final enemy (default: false)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   209
	- onGameInit: Custom onGameInit callback
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   210
	- onGameStart: Custom onGameStart callback
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   211
	- onVictory: Function that is called when the mission is won.
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   212
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   213
	Hint: Use onGameInit and onGameStart to place custom gears and girders
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   214
	Hint: Use onVictory to save campaign variables if using this in a campaign
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   215
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   216
]]
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   217
function RopeKnocking(params)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   218
	if params.missionName then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   219
		missionName = params.missionName
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   220
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   221
	if params.extraTime then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   222
		extraTime = params.extraTime
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   223
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   224
	if params.valkyries then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   225
		playValkyries = params.valkyries
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   226
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   227
	if params.missionType then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   228
		missionType = params.missionType
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   229
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   230
	if params.killBonus then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   231
		killBonus = params.killBonus
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   232
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   233
	if params.timeBonus then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   234
		timeBonus = params.timeBonus
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   235
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   236
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   237
	_G.onGameInit = function()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   238
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   239
		if params.gameFlags then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   240
			for g=1, #params.gameFlags do
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   241
				EnableGameFlags(params.gameFlags[g])
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   242
			end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   243
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   244
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   245
		EnableGameFlags(gfBorder, gfSolidLand)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   246
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   247
		TurnTime = params.turnTime
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   248
		Delay = 500
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   249
		Map = params.map
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   250
		Theme = params.theme
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   251
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   252
		-- Disable Sudden Death
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   253
		WaterRise = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   254
		HealthDecrease = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   255
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   256
		CaseFreq = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   257
		MinesNum = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   258
		Explosives = 0
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   259
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   260
		-- Player team
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   261
		playerTeamName = AddMissionTeam(-1)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   262
		hhs[0] = AddMissionHog(1)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   263
		SetGearPosition(hhs[0], params.playerTeam.x, params.playerTeam.y)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   264
		if params.playerTeam.faceLeft == true then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   265
			HogTurnLeft(hhs[0], true)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   266
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   267
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   268
		-- Enemy teams
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   269
		for t=1, #params.enemyTeams do
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   270
			local team = params.enemyTeams[t]
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   271
			params.enemyTeams[t].name = AddTeam(team.name, -2, "Simple", "Tank", "Default_qau", team.flag)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   272
			for h=1, #team.hogs do
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   273
				local hogData = team.hogs[h]
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   274
				local name = hogData.name
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   275
				local hat = hogData.hat
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   276
				if not hat then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   277
					hat = "NoHat"
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   278
				end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   279
				local hog = AddHog(name, 0, 1, hat)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   280
				SetGearPosition(hog, hogData.x, hogData.y)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   281
				if hogData.faceLeft == true then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   282
					HogTurnLeft(hog, true)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   283
				end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   284
				table.insert(hhs, hog)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   285
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   286
				totalEnemies = totalEnemies + 1
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   287
			end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   288
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   289
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   290
		if params.onGameInit then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   291
			params.onGameInit()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   292
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   293
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   294
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   295
	_G.onGameStart = function()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   296
		SendHealthStatsOff()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   297
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   298
		local timeTxt = ""
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   299
		local displayTime = 4000
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   300
		if extraTime and extraTime ~= 0 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   301
			timeTxt = string.format(loc("For each kill you win %d seconds."), div(extraTime, 1000))
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   302
			displayTime = 5000
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   303
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   304
		local recordInfo = getReadableChallengeRecord("Highscore")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   305
		if recordInfo == nil then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   306
			recordInfo = ""
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   307
		else
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   308
			recordInfo = "|" .. recordInfo
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   309
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   310
		ShowMission(
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   311
			missionName,
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   312
			loc("Challenge"),
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   313
			loc("Use the rope to knock your enemies to their doom.") .. "|" ..
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   314
			loc("Finish this challenge as fast as possible to earn bonus points.") .. "|" ..
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   315
			timeTxt .. recordInfo, -amRope, displayTime)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   316
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   317
		SetTeamLabel(playerTeamName, "0")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   318
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   319
		if params.onGameStart then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   320
			params.onGameStart()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   321
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   322
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   323
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   324
	_G.onGameTick = function()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   325
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   326
		if (TurnTimeLeft == 1) and (missionWon == nil) then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   327
			PlaySound(sndBoring, CurrentHedgehog)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   328
			gameOver()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   329
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   330
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   331
		if missionWon ~= nil then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   332
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   333
			endTimer = endTimer - 1
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   334
			if endTimer == 1 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   335
				if not endGameCalled then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   336
					EndGame()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   337
					endGameCalled = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   338
				end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   339
			end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   340
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   341
			if not missionEndHandled then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   342
				if missionWon == true then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   343
					AddCaption(loc("Victory!"), 0xFFFFFFFF, capgrpGameState)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   344
					if missionType == 1 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   345
						SaveMissionVar("Won", "true")
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   346
					end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   347
				else
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   348
					AddCaption(loc("Challenge over!"), 0xFFFFFFFF, capgrpGameState)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   349
				end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   350
				missionEndHandled = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   351
			end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   352
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   353
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   354
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   355
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   356
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   357
	_G.onGameTick20 = function()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   358
		if (valkyriesTimer > 0) then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   359
			valkyriesTimer = valkyriesTimer - 20
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   360
			if valkyriesTimer <= 0 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   361
				StopMusicSound(sndRideOfTheValkyries)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   362
			end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   363
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   364
		local drown = (hhs[0]) and (band(GetState(hhs[0]), gstDrowning) ~= 0)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   365
		if drown and missionWon == nil then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   366
			-- Player hog drowns
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   367
			playerFail = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   368
			return
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   369
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   370
		for i=1, totalEnemies do
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   371
			local hog = hhs[i]
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   372
			drown = (hog) and (not deadHogs[hog]) and (band(GetState(hhs[i]), gstDrowning) ~= 0)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   373
			if drown then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   374
				declareEnemyKilled(hog, params.onVictory)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   375
			end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   376
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   377
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   378
		if ropeGear and not missionWon and band(GetState(ropeGear), gstCollision) ~= 0 then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   379
			-- Hide mission on first rope attach
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   380
			HideMission()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   381
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   382
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   383
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   384
	_G.onGearDamage = function(gear, damage)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   385
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   386
		if gear == hhs[0] then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   387
			-- Player hog hurts itself
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   388
			playerFail = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   389
			StopMusicSound(sndRideOfTheValkyries)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   390
			valkyriesTimer = -1
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   391
			protectEnemies()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   392
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   393
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   394
		if gear ~= hhs[0] and GetGearType(gear) == gtHedgehog and not deadHogs[gear] and missionWon == nil and playerFail == false then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   395
			-- Enemy hog took damage
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   396
			AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   397
			DeleteGear(gear)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   398
			PlaySound(sndExplosion)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   399
			AddCaption(string.format(knockTaunt(), GetHogName(gear)), 0xFFFFFFFF, capgrpMessage)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   400
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   401
			declareEnemyKilled(gear, params.onVictory)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   402
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   403
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   404
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   405
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   406
	_G.onGearAdd = function(gear)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   407
		if GetGearType(gear) == gtRope then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   408
			ropeGear = gear
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   409
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   410
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   411
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   412
	_G.onGearDelete = function(gear)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   413
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   414
		if (gear == hhs[0]) and (missionWon == nil) then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   415
			playerFail = true
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   416
			gameOver()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   417
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   418
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   419
		if GetGearType(gear) == gtHedgehog and gear ~= hhs[0] and not deadHogs[gear] then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   420
			declareEnemyKilled(gear, params.onVictory)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   421
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   422
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   423
		if GetGearType(gear) == gtRope then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   424
			ropeGear = nil
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   425
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   426
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   427
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   428
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   429
	if params.onAmmoStoreInit then
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   430
		_G.onAmmoStoreInit = params.onAmmoStoreInit
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   431
	else
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   432
		_G.onAmmoStoreInit = function()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   433
			SetAmmo(amRope, 9, 0, 0, 0)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   434
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   435
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   436
		_G.onNewTurn = function()
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   437
			SetWeapon(amRope)
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   438
		end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   439
	end
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   440
0039baa9895e Add RopeKnocking library (generalized ropeknock challenges)
Wuzzy <Wuzzy2@mail.ru>
parents:
diff changeset
   441
end