share/hedgewars/Data/Maps/Knockball/map.lua
author Henek
Fri, 10 Dec 2010 23:58:15 +0100
changeset 4502 759c1a3bb156
parent 4350 cdb3d7a39fa2
child 4506 37744d5c877e
permissions -rw-r--r--
lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4502
759c1a3bb156 lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents: 4350
diff changeset
     1
loadfile(GetDataPath() .. "Scripts/Locale.lua")()
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
     2
4502
759c1a3bb156 lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents: 4350
diff changeset
     3
-- Hedgewars - Knockball for 2+ Players
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
     4
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
     5
local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0}
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
     6
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
     7
local ball = nil
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
     8
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
     9
local started = false
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    10
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    11
function onGameInit()
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    12
	GameFlags = gfSolidLand + gfInvulnerable + gfDivideTeams
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    13
	TurnTime = 20000
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    14
	CaseFreq = 0
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 3465
diff changeset
    15
	MinesNum = 0
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    16
	Explosives = 0
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    17
	Delay = 500
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    18
	SuddenDeathTurns = 99999 -- "disable" sudden death
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    19
end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    20
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    21
function onGameStart()
4502
759c1a3bb156 lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents: 4350
diff changeset
    22
	ShowMission(loc("Hedgewars-Knockball"), loc("Not So Friendly Match"), loc("Bat balls at your enemies and|push them into the sea!"), -amBaseballBat, 0)
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    23
	started = true
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    24
end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    25
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    26
function onGameTick()
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    27
	if ball ~= nil and GetFollowGear() ~= nil then FollowGear(ball) end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    28
end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    29
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    30
function onAmmoStoreInit()
3346
967fd96f7373 Engine/Frontend:
smxx
parents: 3266
diff changeset
    31
	SetAmmo(amBaseballBat, 9, 0, 0, 0)
967fd96f7373 Engine/Frontend:
smxx
parents: 3266
diff changeset
    32
	SetAmmo(amSkip, 9, 0, 0, 0)
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    33
end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    34
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    35
function onGearAdd(gear)
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    36
	if GetGearType(gear) == gtShover then
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    37
		ball = AddGear(GetX(gear), GetY(gear), gtBall, 0, 0, 0, 0)
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    38
		if ball ~= nil then
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    39
			CopyPV2(gear, ball)
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    40
			SetState(ball, 0x200) -- temporary - might change!
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    41
			SetTag(ball, 8) -- baseball skin
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    42
			FollowGear(ball)
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    43
		end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    44
	end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    45
end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    46
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    47
function onGearDelete(gear)
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    48
	if not started then
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    49
		return
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    50
	end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    51
	if gear == ball then
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    52
		ball = nil
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    53
	elseif (GetGearType(gear) == gtHedgehog) and CurrentHedgehog ~= nil then
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    54
		local clan = GetHogClan(CurrentHedgehog)
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    55
		local s
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    56
		if clan ~= nil then
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    57
			if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    58
				score[clan] = score[clan] + 1
4502
759c1a3bb156 lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents: 4350
diff changeset
    59
				s = string.format(loc("%s is out and Team %d|scored a point!| |Score:"), GetHogName(gear), clan + 1)
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    60
			else
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    61
				score[clan] = score[clan] - 1
4502
759c1a3bb156 lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents: 4350
diff changeset
    62
				s = string.format(loc("%s is out and Team %d|scored a penalty!| |Score:"), GetHogName(gear), clan + 1)
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    63
			end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    64
			s = s .. " " .. score[0]
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    65
			for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end
4502
759c1a3bb156 lua access to data dir by GetDataPath and made a new scripting translation system with Locale.lua as library and .lua files under Locale. Updated maps Basketball and Knockball to this new system.
Henek
parents: 4350
diff changeset
    66
			ShowMission(loc("Hedgewars-Knockball"), loc("Not So Friendly Match"), s, -amBaseballBat, 0)
3263
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    67
		end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    68
	end
fd1588933051 Fix line endings. Again.
nemo
parents: 3257
diff changeset
    69
end