author | unc0rr |
Sun, 25 Nov 2012 01:13:51 +0400 | |
branch | flibqtfrontend |
changeset 8100 | 0e6fadf81a2c |
parent 7777 | e0be9fbc21b4 |
child 8349 | a1dbe148f10f |
permissions | -rw-r--r-- |
4506
37744d5c877e
Finnished up the lua translations by adding training maps, campaign is ignored for now
Henek
parents:
4502
diff
changeset
|
1 |
-- Hedgewars - Knockball for 2+ Players |
3263 | 2 |
|
4506
37744d5c877e
Finnished up the lua translations by adding training maps, campaign is ignored for now
Henek
parents:
4502
diff
changeset
|
3 |
loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
3263 | 4 |
|
5 |
local score = {[0] = 0, [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0} |
|
6 |
||
7 |
local ball = nil |
|
8 |
||
9 |
local started = false |
|
10 |
||
11 |
function onGameInit() |
|
12 |
GameFlags = gfSolidLand + gfInvulnerable + gfDivideTeams |
|
13 |
TurnTime = 20000 |
|
14 |
CaseFreq = 0 |
|
4162 | 15 |
MinesNum = 0 |
3263 | 16 |
Explosives = 0 |
17 |
Delay = 500 |
|
18 |
SuddenDeathTurns = 99999 -- "disable" sudden death |
|
19 |
end |
|
20 |
||
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 | 23 |
started = true |
24 |
end |
|
25 |
||
26 |
function onGameTick() |
|
27 |
if ball ~= nil and GetFollowGear() ~= nil then FollowGear(ball) end |
|
28 |
end |
|
29 |
||
30 |
function onAmmoStoreInit() |
|
3346 | 31 |
SetAmmo(amBaseballBat, 9, 0, 0, 0) |
32 |
SetAmmo(amSkip, 9, 0, 0, 0) |
|
3263 | 33 |
end |
34 |
||
35 |
function onGearAdd(gear) |
|
36 |
if GetGearType(gear) == gtShover then |
|
7777 | 37 |
ball = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtBall, 0, 0, 0, 0) |
3263 | 38 |
if ball ~= nil then |
4517
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4506
diff
changeset
|
39 |
local dx, dy = GetGearVelocity(gear) |
0618b31023dc
added team flag to AddTeam and made AI team allowed to have custom flags. added GetGearVelocity and SetGearVelocity and removed CopyPV2. changed knockball to use use these functions instead.
Henek
parents:
4506
diff
changeset
|
40 |
SetGearVelocity(ball, dx * 2, dy * 2) |
3263 | 41 |
SetState(ball, 0x200) -- temporary - might change! |
42 |
SetTag(ball, 8) -- baseball skin |
|
43 |
FollowGear(ball) |
|
44 |
end |
|
45 |
end |
|
46 |
end |
|
47 |
||
48 |
function onGearDelete(gear) |
|
49 |
if not started then |
|
50 |
return |
|
51 |
end |
|
52 |
if gear == ball then |
|
53 |
ball = nil |
|
54 |
elseif (GetGearType(gear) == gtHedgehog) and CurrentHedgehog ~= nil then |
|
55 |
local clan = GetHogClan(CurrentHedgehog) |
|
56 |
local s |
|
57 |
if clan ~= nil then |
|
58 |
if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then |
|
59 |
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
|
60 |
s = string.format(loc("%s is out and Team %d|scored a point!| |Score:"), GetHogName(gear), clan + 1) |
3263 | 61 |
else |
62 |
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
|
63 |
s = string.format(loc("%s is out and Team %d|scored a penalty!| |Score:"), GetHogName(gear), clan + 1) |
3263 | 64 |
end |
65 |
s = s .. " " .. score[0] |
|
66 |
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
|
67 |
ShowMission(loc("Hedgewars-Knockball"), loc("Not So Friendly Match"), s, -amBaseballBat, 0) |
3263 | 68 |
end |
69 |
end |
|
70 |
end |