author | Wuzzy <almikes@aol.com> |
Thu, 24 Nov 2016 03:53:56 +0100 | |
changeset 12055 | ddf0fee75449 |
parent 10036 | 3be36d2fdca6 |
child 12207 | 2de020695c20 |
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 |
10036 | 49 |
DisableGameFlags(gfInfAttack) |
50 |
EnableGameFlags(gfResetWeps) |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
51 |
-- 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
|
52 |
Goals = loc("Each turn you get one random weapon") |
4551 | 53 |
end |
54 |
||
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
55 |
function onGameStart() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
56 |
-- 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
|
57 |
trackTeams() |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
58 |
-- 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
|
59 |
if MapHasBorder() == false then |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
60 |
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
|
61 |
table.insert(weapons, w) |
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 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
65 |
|
4551 | 66 |
function onAmmoStoreInit() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
67 |
-- Allow skip at all times |
4551 | 68 |
SetAmmo(amSkip, 9, 0, 0, 0) |
69 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
70 |
-- Let utilities be available through crates |
4551 | 71 |
SetAmmo(amParachute, 0, 1, 0, 1) |
72 |
SetAmmo(amGirder, 0, 1, 0, 2) |
|
73 |
SetAmmo(amSwitch, 0, 1, 0, 1) |
|
74 |
SetAmmo(amLowGravity, 0, 1, 0, 1) |
|
75 |
SetAmmo(amExtraDamage, 0, 1, 0, 1) |
|
76 |
SetAmmo(amInvulnerable, 0, 1, 0, 1) |
|
77 |
SetAmmo(amExtraTime, 0, 1, 0, 1) |
|
78 |
SetAmmo(amLaserSight, 0, 1, 0, 1) |
|
79 |
SetAmmo(amVampiric, 0, 1, 0, 1) |
|
80 |
SetAmmo(amJetpack, 0, 1, 0, 1) |
|
81 |
SetAmmo(amPortalGun, 0, 1, 0, 1) |
|
82 |
SetAmmo(amResurrector, 0, 1, 0, 1) |
|
83 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
84 |
-- Allow weapons to be used |
4551 | 85 |
for i, w in pairs(weapons) do |
86 |
SetAmmo(w, 0, 0, 0, 1) |
|
87 |
end |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
88 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
89 |
-- 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
|
90 |
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
|
91 |
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
|
92 |
end |
4551 | 93 |
end |
94 |
||
95 |
function onNewTurn() |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
96 |
-- 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
|
97 |
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
|
98 |
-- 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
|
99 |
runOnGears(reset) |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
100 |
-- 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
|
101 |
setTeamValue(GetHogTeamName(CurrentHedgehog), "ammo", nil) |
4551 | 102 |
end |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
103 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
104 |
function onGearAdd(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
105 |
-- 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
|
106 |
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
|
107 |
trackGear(gear) |
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 |
end |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
110 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
111 |
function onGearDelete(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
112 |
-- 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
|
113 |
trackDeletion(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
114 |
end |