author | Henek |
Mon, 11 Apr 2011 00:35:53 +0200 | |
changeset 5138 | f991f87969ff |
parent 4893 | 353781305c07 |
child 5141 | 2fb6555011d3 |
permissions | -rw-r--r-- |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
1 |
-- Random Weapons, example for gameplay scripts |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
2 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
3 |
-- Load the library for localisation ("loc" function) |
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
4 |
loadfile(GetDataPath() .. "Scripts/Locale.lua")() |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
5 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
6 |
-- Load the gear tracker |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
7 |
loadfile(GetDataPath() .. "Scripts/Tracker.lua")() |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
8 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
9 |
-- List of available weapons |
4551 | 10 |
local weapons = { amGrenade, amClusterBomb, amBazooka, amBee, amShotgun, |
11 |
amMine, amDEagle, amDynamite, amFirePunch, amWhip, amPickHammer, |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
12 |
amBaseballBat, amTeleport, amMortar, amCake, amSeduction, |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
13 |
amWatermelon, amHellishBomb, amDrill, amBallgun, amRCPlane, |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
14 |
amSniperRifle, amMolotov, amBirdy, amBlowTorch, amGasBomb, |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
15 |
amFlamethrower, amSMine, amHammer } |
4551 | 16 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
17 |
-- List of weapons that attack from the air |
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
18 |
local airweapons = { amAirAttack, amMineStrike, amNapalm, amDrillStrike } |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
19 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
20 |
-- Function that assigns the team their weapon |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
21 |
-- Due to the fact that the gameplay uses reset weapons and no inf attack there is no point in limiting the ammo count |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
22 |
function assignWeapon(hog) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
23 |
-- Get the ammo for this hog's team |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
24 |
local ammo = getTeamValue(GetHogTeamName(hog), "ammo") |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
25 |
-- If there is no ammo, get a random one from the list and store it |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
26 |
if ammo == nil then |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
27 |
ammo = weapons[GetRandom(table.maxn(weapons)) + 1] |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
28 |
setTeamValue(GetHogTeamName(hog), "ammo", ammo) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
29 |
end |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
30 |
-- Add the ammo for the hog |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
31 |
AddAmmo(hog, ammo) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
32 |
end |
4551 | 33 |
|
34 |
function onGameInit() |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
35 |
-- Limit flags that can be set, but allow game schemes to be used |
4551 | 36 |
GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfInfAttack + gfPerHogAmmo)) |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
37 |
-- Set a custom game goal that will show together with the scheme ones |
4893
353781305c07
make Random Weapons and No Jumping use the new custom goal function
Henek
parents:
4590
diff
changeset
|
38 |
Goals = loc("Each turn you get one random weapon") |
4551 | 39 |
end |
40 |
||
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
41 |
function onGameStart() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
42 |
-- Initialize the tracking of hogs and teams |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
43 |
trackTeams() |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
44 |
-- Add air weapons to the game if the border is not active |
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
45 |
if MapHasBorder() == false then |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
46 |
for i, w in pairs(airweapons) do |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
47 |
table.insert(weapons, w) |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
48 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
49 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
50 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
51 |
|
4551 | 52 |
function onAmmoStoreInit() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
53 |
-- Allow skip at all times |
4551 | 54 |
SetAmmo(amSkip, 9, 0, 0, 0) |
55 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
56 |
-- Let utilities be available through crates |
4551 | 57 |
SetAmmo(amParachute, 0, 1, 0, 1) |
58 |
SetAmmo(amGirder, 0, 1, 0, 2) |
|
59 |
SetAmmo(amSwitch, 0, 1, 0, 1) |
|
60 |
SetAmmo(amLowGravity, 0, 1, 0, 1) |
|
61 |
SetAmmo(amExtraDamage, 0, 1, 0, 1) |
|
62 |
SetAmmo(amInvulnerable, 0, 1, 0, 1) |
|
63 |
SetAmmo(amExtraTime, 0, 1, 0, 1) |
|
64 |
SetAmmo(amLaserSight, 0, 1, 0, 1) |
|
65 |
SetAmmo(amVampiric, 0, 1, 0, 1) |
|
66 |
SetAmmo(amJetpack, 0, 1, 0, 1) |
|
67 |
SetAmmo(amPortalGun, 0, 1, 0, 1) |
|
68 |
SetAmmo(amResurrector, 0, 1, 0, 1) |
|
69 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
70 |
-- Allow weapons to be used |
4551 | 71 |
for i, w in pairs(weapons) do |
72 |
SetAmmo(w, 0, 0, 0, 1) |
|
73 |
end |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
74 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
75 |
-- Allow air weapons to be used |
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
76 |
for i, w in pairs(airweapons) do |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
77 |
SetAmmo(w, 0, 0, 0, 1) |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
78 |
end |
4551 | 79 |
end |
80 |
||
81 |
function onNewTurn() |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
82 |
-- Give every team their weapons, so one can plan during anothers turn |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
83 |
runOnGears(assignWeapon) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
84 |
-- Set the current teams weapons to nil so they will get new after the turn has ended |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
85 |
setTeamValue(GetHogTeamName(CurrentHedgehog), "ammo", nil) |
4551 | 86 |
end |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
87 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
88 |
function onGearAdd(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
89 |
-- Catch hedgehogs for the tracker |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
90 |
if GetGearType(gear) == gtHedgehog then |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
91 |
trackGear(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
92 |
end |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
93 |
end |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
94 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
95 |
function onGearDelete(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
96 |
-- Remove hogs that are gone |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
97 |
trackDeletion(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
98 |
end |