author | Wuzzy <almikes@aol.com> |
Fri, 25 Nov 2016 13:38:24 +0100 | |
changeset 12084 | 8f222872d432 |
parent 12082 | ce3860c82c8b |
child 12086 | ed40d46c9e59 |
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 |
|
9093 | 3 |
HedgewarsScriptLoad("/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 |
|
12084
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12082
diff
changeset
|
18 |
-- Disable Sudden Death |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12082
diff
changeset
|
19 |
WaterRise = 0 |
8f222872d432
Disable SD for a couple of scripts and mission maps
Wuzzy <almikes@aol.com>
parents:
12082
diff
changeset
|
20 |
HealthDecrease = 0 |
3263 | 21 |
end |
22 |
||
23 |
function onGameStart() |
|
12082
ce3860c82c8b
Rewrite 2nd line of mission panel of most missions for consistency
Wuzzy <almikes@aol.com>
parents:
11202
diff
changeset
|
24 |
ShowMission(loc("Knockball"), loc("Not So Friendly Match"), loc("Bat balls at your enemies and|push them into the sea!"), -amBaseballBat, 0) |
3263 | 25 |
started = true |
26 |
end |
|
27 |
||
28 |
function onGameTick() |
|
29 |
if ball ~= nil and GetFollowGear() ~= nil then FollowGear(ball) end |
|
30 |
end |
|
31 |
||
32 |
function onAmmoStoreInit() |
|
3346 | 33 |
SetAmmo(amBaseballBat, 9, 0, 0, 0) |
34 |
SetAmmo(amSkip, 9, 0, 0, 0) |
|
3263 | 35 |
end |
36 |
||
37 |
function onGearAdd(gear) |
|
38 |
if GetGearType(gear) == gtShover then |
|
7777 | 39 |
ball = AddGear(GetX(CurrentHedgehog), GetY(CurrentHedgehog), gtBall, 0, 0, 0, 0) |
3263 | 40 |
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
|
41 |
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
|
42 |
SetGearVelocity(ball, dx * 2, dy * 2) |
3263 | 43 |
SetState(ball, 0x200) -- temporary - might change! |
44 |
SetTag(ball, 8) -- baseball skin |
|
45 |
FollowGear(ball) |
|
46 |
end |
|
47 |
end |
|
48 |
end |
|
49 |
||
50 |
function onGearDelete(gear) |
|
51 |
if not started then |
|
52 |
return |
|
53 |
end |
|
54 |
if gear == ball then |
|
55 |
ball = nil |
|
56 |
elseif (GetGearType(gear) == gtHedgehog) and CurrentHedgehog ~= nil then |
|
57 |
local clan = GetHogClan(CurrentHedgehog) |
|
58 |
local s |
|
59 |
if clan ~= nil then |
|
60 |
if GetHogClan(CurrentHedgehog) ~= GetHogClan(gear) then |
|
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 point!| |Score:"), GetHogName(gear), clan + 1) |
3263 | 63 |
else |
64 |
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
|
65 |
s = string.format(loc("%s is out and Team %d|scored a penalty!| |Score:"), GetHogName(gear), clan + 1) |
3263 | 66 |
end |
67 |
s = s .. " " .. score[0] |
|
68 |
for i = 1, ClansCount - 1 do s = s .. " - " .. score[i] end |
|
12082
ce3860c82c8b
Rewrite 2nd line of mission panel of most missions for consistency
Wuzzy <almikes@aol.com>
parents:
11202
diff
changeset
|
69 |
ShowMission(loc("Knockball"), loc("Not So Friendly Match"), s, -amBaseballBat, 0) |
3263 | 70 |
end |
71 |
end |
|
72 |
end |
|
11202
cc308446f90d
preselect baseball bat in Knockball and Basketball
sheepluva
parents:
9093
diff
changeset
|
73 |
|
cc308446f90d
preselect baseball bat in Knockball and Basketball
sheepluva
parents:
9093
diff
changeset
|
74 |
function onNewTurn() |
cc308446f90d
preselect baseball bat in Knockball and Basketball
sheepluva
parents:
9093
diff
changeset
|
75 |
SetWeapon(amBaseballBat) |
cc308446f90d
preselect baseball bat in Knockball and Basketball
sheepluva
parents:
9093
diff
changeset
|
76 |
end |