author | Wuzzy <almikes@aol.com> |
Sun, 15 Oct 2017 13:15:39 +0200 | |
changeset 12709 | c4ea9f8fb483 |
parent 11899 | dd3cbbde7876 |
child 12819 | b4e20bb485f9 |
permissions | -rw-r--r-- |
9836 | 1 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
9906
93c16a4b0c6a
Only emit roomNameUpdated when it actually is changed
unc0rr
parents:
9902
diff
changeset
|
2 |
HedgewarsScriptLoad("/Scripts/Params.lua") |
9836 | 3 |
|
4 |
local gravity = 100 |
|
9908 | 5 |
local mingravity |
6 |
local maxgravity |
|
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
7 |
local mingravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
8 |
local maxgravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
9 |
local mingravity_low |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
10 |
local maxgravity_low |
9908 | 11 |
local delta = 0 |
12 |
local period |
|
13 |
local periodtimer = 0 |
|
9836 | 14 |
local wdGameTicks = 0 |
15 |
local wdTTL = 0 |
|
9908 | 16 |
local mln = 1000000 |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
17 |
local lowGravityUsed = false |
9836 | 18 |
|
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
19 |
local script2_onNewTurn |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
20 |
local script2_onGameTick20 |
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
21 |
local script2_onGameInit |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
22 |
local script2_onHogAttack |
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
23 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
24 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
25 |
function grav_onNewTurn() |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
26 |
lowGravityUsed = false |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
27 |
if maxgravity_normal == nil then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
28 |
gravity = mingravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
29 |
else |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
30 |
mingravity = mingravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
31 |
maxgravity = maxgravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
32 |
if period > 0 then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
33 |
delta = div(maxgravity_normal - mingravity_normal, period) |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
34 |
end |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
35 |
end |
10738
62659c427e5d
Fix setting gravity multiplied by million for a moment of time on new turn on certain circumstances
unc0rr
parents:
10509
diff
changeset
|
36 |
if delta ~= nil and period == nil then |
62659c427e5d
Fix setting gravity multiplied by million for a moment of time on new turn on certain circumstances
unc0rr
parents:
10509
diff
changeset
|
37 |
SetGravity(gravity) |
62659c427e5d
Fix setting gravity multiplied by million for a moment of time on new turn on certain circumstances
unc0rr
parents:
10509
diff
changeset
|
38 |
else |
62659c427e5d
Fix setting gravity multiplied by million for a moment of time on new turn on certain circumstances
unc0rr
parents:
10509
diff
changeset
|
39 |
SetGravity(div(gravity, mln)) |
62659c427e5d
Fix setting gravity multiplied by million for a moment of time on new turn on certain circumstances
unc0rr
parents:
10509
diff
changeset
|
40 |
end |
62659c427e5d
Fix setting gravity multiplied by million for a moment of time on new turn on certain circumstances
unc0rr
parents:
10509
diff
changeset
|
41 |
|
9836 | 42 |
wdGameTicks = GameTime |
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
43 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
44 |
if script2_onNewTurn ~= nil then |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
45 |
script2_onNewTurn() |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
46 |
end |
9816 | 47 |
end |
48 |
||
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
49 |
function grav_onGameTick20() |
9898
b87695f82d2e
Don't set gravity to normal immediately on turn end, let watchdog do its job if game gets frozen
unc0rr
parents:
9836
diff
changeset
|
50 |
if wdGameTicks + 15000 < GameTime then |
9816 | 51 |
SetGravity(100) |
9908 | 52 |
else |
53 |
if wdTTL ~= TurnTimeLeft then |
|
54 |
wdGameTicks = GameTime |
|
55 |
end |
|
56 |
||
57 |
if delta == nil then |
|
58 |
if periodtimer == 0 then |
|
59 |
periodtimer = period * 2 |
|
10758
0f3a0f117810
Random gravity values interval should include maxgravity
unc0rr
parents:
10738
diff
changeset
|
60 |
SetGravity(div(GetRandom(maxgravity - mingravity + 1) + mingravity, mln)) |
9908 | 61 |
else |
62 |
periodtimer = periodtimer - 1 |
|
63 |
end |
|
64 |
elseif delta == 0 then |
|
65 |
SetGravity(gravity) |
|
66 |
else |
|
67 |
if delta > 0 and gravity + delta > maxgravity then |
|
68 |
gravity = maxgravity |
|
69 |
delta = -delta |
|
10509 | 70 |
elseif delta < 0 and gravity + delta < mingravity then |
9908 | 71 |
gravity = mingravity |
72 |
delta = -delta |
|
73 |
else |
|
74 |
gravity = gravity + delta |
|
75 |
end |
|
76 |
||
77 |
SetGravity(div(gravity, mln)) |
|
78 |
end |
|
9816 | 79 |
end |
9836 | 80 |
|
81 |
wdTTL = TurnTimeLeft |
|
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
82 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
83 |
if script2_onGameTick20 ~= nil then |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
84 |
script2_onGameTick20() |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
85 |
end |
9816 | 86 |
end |
9836 | 87 |
|
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
88 |
function onParameters() |
9906
93c16a4b0c6a
Only emit roomNameUpdated when it actually is changed
unc0rr
parents:
9902
diff
changeset
|
89 |
parseParams() |
9908 | 90 |
|
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
91 |
gravity = tonumber(params["g"]) or gravity |
9908 | 92 |
|
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
93 |
mingravity_normal = gravity |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
94 |
if mingravity_normal > 0 then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
95 |
mingravity_low = div(mingravity_normal, 2) |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
96 |
else |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
97 |
mingravity_low = mingravity_normal * 2 |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
98 |
end |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
99 |
mingravity = mingravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
100 |
if type(tonumber(params["g2"])) == "number" then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
101 |
maxgravity_normal = tonumber(params["g2"]) |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
102 |
if maxgravity_normal > 0 then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
103 |
maxgravity_low = div(maxgravity_normal, 2) |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
104 |
else |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
105 |
maxgravity_low = maxgravity_normal * 2 |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
106 |
end |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
107 |
maxgravity = maxgravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
108 |
end |
9908 | 109 |
period = params["period"] |
110 |
||
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
111 |
if type(mingravity) == "number" and type(maxgravity) == "number" then |
9908 | 112 |
if period ~= nil then |
113 |
period = div(period, 40) |
|
114 |
else |
|
115 |
period = 125 |
|
116 |
end |
|
117 |
||
10509 | 118 |
mingravity = mingravity * mln |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
119 |
mingravity_normal = mingravity_normal * mln |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
120 |
mingravity_low = mingravity_low * mln |
10509 | 121 |
maxgravity = maxgravity * mln |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
122 |
maxgravity_normal = maxgravity_normal * mln |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
123 |
maxgravity_low = maxgravity_low * mln |
10509 | 124 |
|
9908 | 125 |
if mingravity > maxgravity then |
126 |
mingravity, maxgravity = maxgravity, mingravity |
|
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
127 |
mingravity_normal, maxgravity_normal = maxgravity_normal, mingravity_normal |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
128 |
mingravity_low, maxgravity_low = maxgravity_low, mingravity_low |
9908 | 129 |
end |
130 |
||
131 |
gravity = mingravity |
|
132 |
||
133 |
if period > 0 then |
|
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
134 |
delta = div(maxgravity_normal - mingravity_normal, period) |
9908 | 135 |
else |
136 |
period = -period |
|
137 |
delta = nil |
|
138 |
end |
|
139 |
end |
|
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
140 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
141 |
secondScript = params["script2"] |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
142 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
143 |
if secondScript ~= nil then |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
144 |
onParameters = nil |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
145 |
HedgewarsScriptLoad("/Scripts/Multiplayer/" .. secondScript .. ".lua") |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
146 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
147 |
script2_onNewTurn = onNewTurn |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
148 |
script2_onGameTick20 = onGameTick20 |
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
149 |
script2_onGameInit = onGameInit |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
150 |
script2_onHogAttack = onHogAttack |
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
151 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
152 |
if onParameters ~= nil then |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
153 |
onParameters() |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
154 |
end |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
155 |
end |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
156 |
|
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
157 |
onNewTurn = grav_onNewTurn |
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
158 |
onGameTick20 = grav_onGameTick20 |
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
159 |
onGameInit = grav_onGameInit |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
160 |
onHogAttack = grav_onHogAttack |
9836 | 161 |
end |
162 |
||
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
163 |
function grav_onGameInit() |
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
164 |
DisableGameFlags(gfLowGravity) |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
165 |
|
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
166 |
local v, printperiod |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
167 |
if period ~= nil then |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
168 |
local period_ms = period * 40 |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
169 |
if period_ms % 1000 == 0 then |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
170 |
printperiod = string.format(loc("%i s"), div(period_ms, 1000)) |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
171 |
else |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
172 |
printperiod = string.format(loc("%i ms"), period_ms) |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
173 |
end |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
174 |
end |
9908 | 175 |
if delta == nil then |
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
176 |
v = string.format(loc("Crazy Gravity: Gravity randomly changes within a range from %i%% to %i%% with a period of %s"), div(mingravity_normal, mln), div(maxgravity_normal, mln), printperiod) |
9908 | 177 |
elseif period ~= nil then |
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
178 |
v = string.format(loc("Oscillating Gravity: Gravity periodically changes within a range from %i%% to %i%% with a period of %s"), div(mingravity_normal, mln), div(maxgravity_normal, mln), printperiod) |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
179 |
elseif gravity > 100 then |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
180 |
v = string.format(loc("High Gravity: Gravity is %i%%"), gravity) |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
181 |
elseif gravity < 100 then |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
182 |
v = string.format(loc("Low Gravity: Gravity is %i%%"), gravity) |
9908 | 183 |
else |
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
184 |
v = loc("Gravity: 100%") .. "|" .. |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
185 |
loc("Script parameter examples:") .. "|" .. |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
186 |
loc("“g=150”, where 150 is 150% of normal gravity.") .. "|" .. |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
187 |
loc("“g=50, g2=150, period=4000” for gravity changing|from 50 to 150 and back with period of 4000 ms.") .. "|" .. |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
188 |
loc("Set period to negative value for random gravity.") .. "| |" |
9908 | 189 |
end |
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
190 |
Goals = v |
9908 | 191 |
|
11899
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
192 |
if script2_onGameInit ~= nil then |
dd3cbbde7876
Improve mission panel in Gravity script (don't overwrite game modifier texts)
Wuzzy <almikes@aol.com>
parents:
11898
diff
changeset
|
193 |
script2_onGameInit() |
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
194 |
end |
9902 | 195 |
end |
9985
42cd42e44c9a
GravRacer, GravHigh, GravMutant, Grav... uhm... shoppamap? Easy! Gravity script could be combined with any other script now.
unc0rr
parents:
9910
diff
changeset
|
196 |
|
11898
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
197 |
function grav_onHogAttack(ammoType) |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
198 |
if ammoType == amLowGravity then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
199 |
lowGravityUsed = true |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
200 |
if maxgravity_normal == nil then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
201 |
gravity = mingravity_low |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
202 |
else |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
203 |
mingravity = mingravity_low |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
204 |
maxgravity = maxgravity_low |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
205 |
if period > 0 then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
206 |
delta = div(maxgravity_low - mingravity_low, period) |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
207 |
end |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
208 |
end |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
209 |
end |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
210 |
if script2_onHogAttack ~= nil then |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
211 |
script2_onHogAttack() |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
212 |
end |
25a6faa5ac46
Fix low gravity utility not working in Gravity script (fixes #13)
Wuzzy <almikes@aol.com>
parents:
10758
diff
changeset
|
213 |
end |