author | Wuzzy <Wuzzy2@mail.ru> |
Thu, 03 May 2018 23:00:08 +0200 | |
changeset 13379 | e1aa72e0872e |
parent 13178 | 4d1cf0d76eb7 |
child 13725 | 8e3d2f7d8737 |
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, |
13178
4d1cf0d76eb7
Remove rubber duck from BRW, RW and most weapon schemes for now
Wuzzy <Wuzzy2@mail.ru>
parents:
12961
diff
changeset
|
15 |
amFlamethrower, amSMine, amHammer, amMinigun, amSineGun, |
12961
89930daecaab
Add minigun to scripts. Also add a few missing ammos to BRW and RW
Wuzzy <Wuzzy2@mail.ru>
parents:
12212
diff
changeset
|
16 |
amKnife, amAirMine } |
4551 | 17 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
18 |
-- 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
|
19 |
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
|
20 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
21 |
-- 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
|
22 |
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
|
23 |
-- 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
|
24 |
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
|
25 |
-- 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
|
26 |
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
|
27 |
-- 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
|
28 |
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
|
29 |
-- 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
|
30 |
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
|
31 |
-- 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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
-- 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
|
37 |
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
|
38 |
-- 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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
|
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 |
-- 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
|
44 |
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
|
45 |
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
|
46 |
end |
4551 | 47 |
|
48 |
function onGameInit() |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
49 |
-- Limit flags that can be set, but allow game schemes to be used |
10036 | 50 |
DisableGameFlags(gfInfAttack) |
51 |
EnableGameFlags(gfResetWeps) |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
52 |
-- 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
|
53 |
Goals = loc("Each turn you get one random weapon") |
4551 | 54 |
end |
55 |
||
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
56 |
function onGameStart() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
57 |
-- 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
|
58 |
trackTeams() |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
59 |
-- 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
|
60 |
if MapHasBorder() == false then |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
61 |
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
|
62 |
table.insert(weapons, w) |
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 |
end |
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
66 |
|
4551 | 67 |
function onAmmoStoreInit() |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
68 |
-- Allow skip at all times |
4551 | 69 |
SetAmmo(amSkip, 9, 0, 0, 0) |
70 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
71 |
-- Let utilities be available through crates |
4551 | 72 |
SetAmmo(amParachute, 0, 1, 0, 1) |
73 |
SetAmmo(amGirder, 0, 1, 0, 2) |
|
74 |
SetAmmo(amSwitch, 0, 1, 0, 1) |
|
75 |
SetAmmo(amLowGravity, 0, 1, 0, 1) |
|
76 |
SetAmmo(amExtraDamage, 0, 1, 0, 1) |
|
77 |
SetAmmo(amInvulnerable, 0, 1, 0, 1) |
|
78 |
SetAmmo(amExtraTime, 0, 1, 0, 1) |
|
79 |
SetAmmo(amLaserSight, 0, 1, 0, 1) |
|
80 |
SetAmmo(amVampiric, 0, 1, 0, 1) |
|
81 |
SetAmmo(amJetpack, 0, 1, 0, 1) |
|
82 |
SetAmmo(amPortalGun, 0, 1, 0, 1) |
|
83 |
SetAmmo(amResurrector, 0, 1, 0, 1) |
|
84 |
||
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
85 |
-- Allow weapons to be used |
4551 | 86 |
for i, w in pairs(weapons) do |
87 |
SetAmmo(w, 0, 0, 0, 1) |
|
88 |
end |
|
4590
d9fed5a816e9
added MapHasBorder function for lua and finnished Random Weapons gameplay, might still change though
Henek
parents:
4551
diff
changeset
|
89 |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
90 |
-- 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
|
91 |
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
|
92 |
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
|
93 |
end |
4551 | 94 |
end |
95 |
||
96 |
function onNewTurn() |
|
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
97 |
-- 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
|
98 |
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
|
99 |
-- 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
|
100 |
runOnGears(reset) |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
101 |
-- 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
|
102 |
setTeamValue(GetHogTeamName(CurrentHedgehog), "ammo", nil) |
4551 | 103 |
end |
5138
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
104 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
105 |
function onGearAdd(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
106 |
-- 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
|
107 |
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
|
108 |
trackGear(gear) |
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 |
end |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
111 |
|
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
112 |
function onGearDelete(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
113 |
-- 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
|
114 |
trackDeletion(gear) |
f991f87969ff
now Random Weapons will show the weapon you will get during the other players turns
Henek
parents:
4893
diff
changeset
|
115 |
end |