author | unc0rr |
Tue, 24 Dec 2013 22:16:07 +0400 | |
changeset 9836 | 00cbbb195f11 |
parent 8043 | da083f8d95e6 |
child 10036 | 3be36d2fdca6 |
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) |
8043 | 4 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
4590
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 |
8043 | 7 |
HedgewarsScriptLoad("/Scripts/Tracker.lua") |
5138
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 |
5141
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
21 |
function assignAmmo(hog) |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
22 |
-- Get name of the current team |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
23 |
local name = GetHogTeamName(hog) |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
24 |
-- Get whither the team has been processed |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
25 |
local processed = getTeamValue(name, "processed") |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
26 |
-- If it has not, process it |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
27 |
if processed == nil or not processed then |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
28 |
-- Get the ammo for this hog's team |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
29 |
local ammo = getTeamValue(name, "ammo") |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
30 |
-- If there is no ammo, get a random one from the list and store it |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
31 |
if ammo == nil then |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
32 |
ammo = weapons[GetRandom(table.maxn(weapons)) + 1] |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
33 |
setTeamValue(name, "ammo", ammo) |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
34 |
end |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
35 |
-- Add the ammo for the hog |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
36 |
AddAmmo(hog, ammo) |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
37 |
-- Mark as processed |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
38 |
setTeamValue(name, "processed", true) |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
39 |
end |
5141
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
40 |
end |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
41 |
|
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
42 |
-- Mark team as not processed |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
43 |
function reset(hog) |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
44 |
setTeamValue(GetHogTeamName(hog), "processed", false) |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
45 |
end |
4551 | 46 |
|
47 |
function onGameInit() |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
48 |
-- Limit flags that can be set, but allow game schemes to be used |
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5141
diff
changeset
|
49 |
GameFlags = band(bor(GameFlags, gfResetWeps), bnot(gfInfAttack)) |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
50 |
-- 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
|
51 |
Goals = loc("Each turn you get one random weapon") |
4551 | 52 |
end |
53 |
||
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
54 |
function onGameStart() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
55 |
-- 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
|
56 |
trackTeams() |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
57 |
-- 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
|
58 |
if MapHasBorder() == false then |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
59 |
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
|
60 |
table.insert(weapons, w) |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
61 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
62 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
63 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
64 |
|
4551 | 65 |
function onAmmoStoreInit() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
66 |
-- Allow skip at all times |
4551 | 67 |
SetAmmo(amSkip, 9, 0, 0, 0) |
68 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
69 |
-- Let utilities be available through crates |
4551 | 70 |
SetAmmo(amParachute, 0, 1, 0, 1) |
71 |
SetAmmo(amGirder, 0, 1, 0, 2) |
|
72 |
SetAmmo(amSwitch, 0, 1, 0, 1) |
|
73 |
SetAmmo(amLowGravity, 0, 1, 0, 1) |
|
74 |
SetAmmo(amExtraDamage, 0, 1, 0, 1) |
|
75 |
SetAmmo(amInvulnerable, 0, 1, 0, 1) |
|
76 |
SetAmmo(amExtraTime, 0, 1, 0, 1) |
|
77 |
SetAmmo(amLaserSight, 0, 1, 0, 1) |
|
78 |
SetAmmo(amVampiric, 0, 1, 0, 1) |
|
79 |
SetAmmo(amJetpack, 0, 1, 0, 1) |
|
80 |
SetAmmo(amPortalGun, 0, 1, 0, 1) |
|
81 |
SetAmmo(amResurrector, 0, 1, 0, 1) |
|
82 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
83 |
-- Allow weapons to be used |
4551 | 84 |
for i, w in pairs(weapons) do |
85 |
SetAmmo(w, 0, 0, 0, 1) |
|
86 |
end |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
87 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
88 |
-- 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
|
89 |
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
|
90 |
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
|
91 |
end |
4551 | 92 |
end |
93 |
||
94 |
function onNewTurn() |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
95 |
-- Give every team their weapons, so one can plan during anothers turn |
5141
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
96 |
runOnGears(assignAmmo) |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
97 |
-- Mark all teams as not processed |
2fb6555011d3
cleared up Random Weapons and implemented remembering of weapons in Balanced Random Weapons too, also seems to work
Henek
parents:
5138
diff
changeset
|
98 |
runOnGears(reset) |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
99 |
-- 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
|
100 |
setTeamValue(GetHogTeamName(CurrentHedgehog), "ammo", nil) |
4551 | 101 |
end |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
102 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
103 |
function onGearAdd(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
104 |
-- 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
|
105 |
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
|
106 |
trackGear(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
107 |
end |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
108 |
end |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
109 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
110 |
function onGearDelete(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
111 |
-- 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
|
112 |
trackDeletion(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
113 |
end |