author | koda |
Tue, 01 Feb 2011 15:30:08 +0100 | |
changeset 4900 | 8ad0e23e6d63 |
parent 4845 | 9a0f5377c529 |
child 4976 | 088d40d8aba2 |
permissions | -rw-r--r-- |
4413 | 1 |
{$INCLUDE "options.inc"} |
2 |
unit uCommandHandlers; |
|
3 |
||
4 |
interface |
|
5 |
||
6 |
procedure initModule; |
|
7 |
procedure freeModule; |
|
8 |
||
9 |
implementation |
|
4437
05192cdbce9b
un-break build (wrong merge in uConsole) and update project file with the new sources
koda
parents:
4413
diff
changeset
|
10 |
uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom; |
4413 | 11 |
|
4531
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
12 |
procedure chGenCmd(var s: shortstring); |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
13 |
begin |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
14 |
case s[1] of |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
15 |
'R': if ReadyTimeLeft > 1 then |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
16 |
begin |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
17 |
ReadyTimeLeft:= 1; |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
18 |
if not CurrentTeam^.ExtDriven then SendIPC('c'+s); |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
19 |
end |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
20 |
end |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
21 |
end; |
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
22 |
|
4413 | 23 |
procedure chQuit(var s: shortstring); |
24 |
const prevGState: TGameState = gsConfirm; |
|
25 |
begin |
|
4751 | 26 |
s:= s; // avoid compiler hint |
27 |
if GameState <> gsConfirm then |
|
28 |
begin |
|
4413 | 29 |
prevGState:= GameState; |
30 |
GameState:= gsConfirm |
|
4751 | 31 |
end else |
32 |
GameState:= prevGState |
|
4413 | 33 |
end; |
34 |
||
4744
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
35 |
procedure chForceQuit(var s: shortstring); |
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
36 |
begin |
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
37 |
s:= s; // avoid compiler hint |
4751 | 38 |
GameState:= gsConfirm; |
39 |
ParseCommand('confirm', true); |
|
4413 | 40 |
end; |
41 |
||
42 |
procedure chConfirm(var s: shortstring); |
|
43 |
begin |
|
4751 | 44 |
s:= s; // avoid compiler hint |
45 |
if GameState = gsConfirm then |
|
4413 | 46 |
begin |
4751 | 47 |
SendIPC('Q'); |
48 |
GameState:= gsExit |
|
4413 | 49 |
end |
50 |
else |
|
51 |
ParseCommand('chat team', true); |
|
52 |
end; |
|
53 |
||
4751 | 54 |
procedure chHalt (var s: shortstring); |
4746
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
55 |
begin |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
56 |
s:= s; // avoid compiler hint |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
57 |
SendIPC('H'); |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
58 |
GameState:= gsExit |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
59 |
end; |
3ae448aebe7e
implemented actions for closing/enging program (needs testing over the net)
koda
parents:
4744
diff
changeset
|
60 |
|
4413 | 61 |
procedure chCheckProto(var s: shortstring); |
62 |
var i, c: LongInt; |
|
63 |
begin |
|
64 |
if isDeveloperMode then |
|
65 |
begin |
|
66 |
val(s, i, c); |
|
67 |
if (c <> 0) or (i = 0) then exit; |
|
68 |
TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true); |
|
69 |
TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true) |
|
70 |
end |
|
71 |
end; |
|
72 |
||
73 |
procedure chTeamLocal(var s: shortstring); |
|
74 |
begin |
|
75 |
s:= s; // avoid compiler hint |
|
76 |
if not isDeveloperMode then exit; |
|
77 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
|
78 |
CurrentTeam^.ExtDriven:= true |
|
79 |
end; |
|
80 |
||
81 |
procedure chGrave(var s: shortstring); |
|
82 |
begin |
|
83 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
84 |
if s[1]='"' then Delete(s, 1, 1); |
|
85 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
86 |
CurrentTeam^.GraveName:= s |
|
87 |
end; |
|
88 |
||
89 |
procedure chFort(var s: shortstring); |
|
90 |
begin |
|
91 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); |
|
92 |
if s[1]='"' then Delete(s, 1, 1); |
|
93 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
94 |
CurrentTeam^.FortName:= s |
|
95 |
end; |
|
96 |
||
97 |
procedure chFlag(var s: shortstring); |
|
98 |
begin |
|
99 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/flag"', true); |
|
100 |
if s[1]='"' then Delete(s, 1, 1); |
|
101 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
102 |
CurrentTeam^.flag:= s |
|
103 |
end; |
|
104 |
||
105 |
procedure chScript(var s: shortstring); |
|
106 |
begin |
|
107 |
if s[1]='"' then Delete(s, 1, 1); |
|
108 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
109 |
ScriptLoad(s) |
|
110 |
end; |
|
111 |
||
112 |
procedure chSetHat(var s: shortstring); |
|
113 |
begin |
|
114 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
|
115 |
with CurrentTeam^ do |
|
116 |
begin |
|
117 |
if not CurrentHedgehog^.King then |
|
118 |
if (s = '') or |
|
119 |
(((GameFlags and gfKing) <> 0) and (s = 'crown')) or |
|
120 |
((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then |
|
121 |
CurrentHedgehog^.Hat:= 'NoHat' |
|
122 |
else |
|
123 |
CurrentHedgehog^.Hat:= s |
|
124 |
end; |
|
125 |
end; |
|
126 |
||
127 |
procedure chCurU_p(var s: shortstring); |
|
128 |
begin |
|
129 |
s:= s; // avoid compiler hint |
|
130 |
CursorMovementY:= -1; |
|
131 |
end; |
|
132 |
||
133 |
procedure chCurU_m(var s: shortstring); |
|
134 |
begin |
|
135 |
s:= s; // avoid compiler hint |
|
136 |
CursorMovementY:= 0; |
|
137 |
end; |
|
138 |
||
139 |
procedure chCurD_p(var s: shortstring); |
|
140 |
begin |
|
141 |
s:= s; // avoid compiler hint |
|
142 |
CursorMovementY:= 1; |
|
143 |
end; |
|
144 |
||
145 |
procedure chCurD_m(var s: shortstring); |
|
146 |
begin |
|
147 |
s:= s; // avoid compiler hint |
|
148 |
CursorMovementY:= 0; |
|
149 |
end; |
|
150 |
||
151 |
procedure chCurL_p(var s: shortstring); |
|
152 |
begin |
|
153 |
s:= s; // avoid compiler hint |
|
154 |
CursorMovementX:= -1; |
|
155 |
end; |
|
156 |
||
157 |
procedure chCurL_m(var s: shortstring); |
|
158 |
begin |
|
159 |
s:= s; // avoid compiler hint |
|
160 |
CursorMovementX:= 0; |
|
161 |
end; |
|
162 |
||
163 |
procedure chCurR_p(var s: shortstring); |
|
164 |
begin |
|
165 |
s:= s; // avoid compiler hint |
|
166 |
CursorMovementX:= 1; |
|
167 |
end; |
|
168 |
||
169 |
procedure chCurR_m(var s: shortstring); |
|
170 |
begin |
|
171 |
s:= s; // avoid compiler hint |
|
172 |
CursorMovementX:= 0; |
|
173 |
end; |
|
174 |
||
175 |
procedure chLeft_p(var s: shortstring); |
|
176 |
begin |
|
177 |
s:= s; // avoid compiler hint |
|
178 |
if CheckNoTeamOrHH or isPaused then exit; |
|
179 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
|
180 |
bShowFinger:= false; |
|
181 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
182 |
Message:= Message or (gmLeft and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
183 |
ScriptCall('onLeft'); |
4413 | 184 |
end; |
185 |
||
186 |
procedure chLeft_m(var s: shortstring); |
|
187 |
begin |
|
188 |
s:= s; // avoid compiler hint |
|
189 |
if CheckNoTeamOrHH then exit; |
|
190 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
|
191 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
192 |
Message:= Message and not (gmLeft and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
193 |
ScriptCall('onLeftUp'); |
4413 | 194 |
end; |
195 |
||
196 |
procedure chRight_p(var s: shortstring); |
|
197 |
begin |
|
198 |
s:= s; // avoid compiler hint |
|
199 |
if CheckNoTeamOrHH or isPaused then exit; |
|
200 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
|
201 |
bShowFinger:= false; |
|
202 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
203 |
Message:= Message or (gmRight and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
204 |
ScriptCall('onRight'); |
4413 | 205 |
end; |
206 |
||
207 |
procedure chRight_m(var s: shortstring); |
|
208 |
begin |
|
209 |
s:= s; // avoid compiler hint |
|
210 |
if CheckNoTeamOrHH then exit; |
|
211 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
|
212 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
213 |
Message:= Message and not (gmRight and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
214 |
ScriptCall('onRightUp'); |
4413 | 215 |
end; |
216 |
||
217 |
procedure chUp_p(var s: shortstring); |
|
218 |
begin |
|
219 |
s:= s; // avoid compiler hint |
|
220 |
if CheckNoTeamOrHH or isPaused then exit; |
|
221 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
|
222 |
bShowFinger:= false; |
|
223 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
224 |
Message:= Message or (gmUp and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
225 |
ScriptCall('onUp'); |
4413 | 226 |
end; |
227 |
||
228 |
procedure chUp_m(var s: shortstring); |
|
229 |
begin |
|
230 |
s:= s; // avoid compiler hint |
|
231 |
if CheckNoTeamOrHH then exit; |
|
232 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
|
233 |
with CurrentHedgehog^.Gear^ do |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
234 |
Message:= Message and not (gmUp and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
235 |
ScriptCall('onUpUp'); |
4413 | 236 |
end; |
237 |
||
238 |
procedure chDown_p(var s: shortstring); |
|
239 |
begin |
|
240 |
s:= s; // avoid compiler hint |
|
241 |
if CheckNoTeamOrHH or isPaused then exit; |
|
242 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
|
243 |
bShowFinger:= false; |
|
244 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
245 |
Message:= Message or (gmDown and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
246 |
ScriptCall('onDown'); |
4413 | 247 |
end; |
248 |
||
249 |
procedure chDown_m(var s: shortstring); |
|
250 |
begin |
|
251 |
s:= s; // avoid compiler hint |
|
252 |
if CheckNoTeamOrHH then exit; |
|
253 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
|
254 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
255 |
Message:= Message and not (gmDown and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
256 |
ScriptCall('onDownUp'); |
4413 | 257 |
end; |
258 |
||
259 |
procedure chPrecise_p(var s: shortstring); |
|
260 |
begin |
|
261 |
s:= s; // avoid compiler hint |
|
262 |
if CheckNoTeamOrHH or isPaused then exit; |
|
263 |
if not CurrentTeam^.ExtDriven then SendIPC('Z'); |
|
264 |
bShowFinger:= false; |
|
265 |
with CurrentHedgehog^.Gear^ do |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
266 |
Message:= Message or (gmPrecise and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
267 |
ScriptCall('onPrecise'); |
4413 | 268 |
end; |
269 |
||
270 |
procedure chPrecise_m(var s: shortstring); |
|
271 |
begin |
|
272 |
s:= s; // avoid compiler hint |
|
273 |
if CheckNoTeamOrHH then exit; |
|
274 |
if not CurrentTeam^.ExtDriven then SendIPC('z'); |
|
275 |
with CurrentHedgehog^.Gear^ do |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
276 |
Message:= Message and not (gmPrecise and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
277 |
ScriptCall('onPreciseUp'); |
4413 | 278 |
end; |
279 |
||
280 |
procedure chLJump(var s: shortstring); |
|
281 |
begin |
|
282 |
s:= s; // avoid compiler hint |
|
283 |
if CheckNoTeamOrHH or isPaused then exit; |
|
284 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
|
285 |
bShowFinger:= false; |
|
286 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
287 |
Message:= Message or (gmLJump and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
288 |
ScriptCall('onLJump'); |
4413 | 289 |
end; |
290 |
||
291 |
procedure chHJump(var s: shortstring); |
|
292 |
begin |
|
293 |
s:= s; // avoid compiler hint |
|
294 |
if CheckNoTeamOrHH or isPaused then exit; |
|
295 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
|
296 |
bShowFinger:= false; |
|
297 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
298 |
Message:= Message or (gmHJump and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
299 |
ScriptCall('onHJump'); |
4413 | 300 |
end; |
301 |
||
302 |
procedure chAttack_p(var s: shortstring); |
|
303 |
begin |
|
304 |
s:= s; // avoid compiler hint |
|
305 |
if CheckNoTeamOrHH or isPaused then exit; |
|
306 |
bShowFinger:= false; |
|
307 |
with CurrentHedgehog^.Gear^ do |
|
308 |
begin |
|
4900 | 309 |
AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State)); |
4413 | 310 |
if ((State and gstHHDriven) <> 0) then |
311 |
begin |
|
312 |
FollowGear:= CurrentHedgehog^.Gear; |
|
313 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
314 |
Message:= Message or (gmAttack and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
315 |
ScriptCall('onAttack'); |
4413 | 316 |
end |
317 |
end |
|
318 |
end; |
|
319 |
||
320 |
procedure chAttack_m(var s: shortstring); |
|
321 |
begin |
|
322 |
s:= s; // avoid compiler hint |
|
323 |
if CheckNoTeamOrHH then exit; |
|
324 |
with CurrentHedgehog^.Gear^ do |
|
325 |
begin |
|
326 |
if not CurrentTeam^.ExtDriven and |
|
327 |
((Message and gmAttack) <> 0) then SendIPC('a'); |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
328 |
Message:= Message and not (gmAttack and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
329 |
ScriptCall('onAttackUp'); |
4413 | 330 |
end |
331 |
end; |
|
332 |
||
333 |
procedure chSwitch(var s: shortstring); |
|
334 |
begin |
|
335 |
s:= s; // avoid compiler hint |
|
336 |
if CheckNoTeamOrHH or isPaused then exit; |
|
337 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
|
338 |
bShowFinger:= false; |
|
339 |
with CurrentHedgehog^.Gear^ do |
|
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
340 |
Message:= Message or (gmSwitch and InputMask); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
341 |
ScriptCall('onSwitch'); |
4413 | 342 |
end; |
343 |
||
344 |
procedure chNextTurn(var s: shortstring); |
|
345 |
begin |
|
346 |
s:= s; // avoid compiler hint |
|
347 |
TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
|
348 |
||
349 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
|
350 |
AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks)); |
|
351 |
end; |
|
352 |
||
353 |
procedure chTimer(var s: shortstring); |
|
354 |
begin |
|
355 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit; |
|
356 |
||
357 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
|
358 |
bShowFinger:= false; |
|
359 |
with CurrentHedgehog^.Gear^ do |
|
360 |
begin |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
361 |
Message:= Message or (gmTimer and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
362 |
MsgParam:= byte(s[1]) - ord('0'); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
363 |
ScriptCall('onTimer'); |
4413 | 364 |
end |
365 |
end; |
|
366 |
||
367 |
procedure chSlot(var s: shortstring); |
|
368 |
var slot: LongWord; |
|
369 |
begin |
|
370 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
371 |
slot:= byte(s[1]) - 49; |
|
372 |
if slot > cMaxSlotIndex then exit; |
|
373 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
|
374 |
bShowFinger:= false; |
|
375 |
with CurrentHedgehog^.Gear^ do |
|
376 |
begin |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
377 |
Message:= Message or (gmSlot and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
378 |
MsgParam:= slot; |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
379 |
ScriptCall('onSlot'); |
4413 | 380 |
end |
381 |
end; |
|
382 |
||
383 |
procedure chSetWeapon(var s: shortstring); |
|
384 |
begin |
|
385 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
386 |
||
387 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
|
388 |
||
389 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
390 |
||
391 |
with CurrentHedgehog^.Gear^ do |
|
392 |
begin |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
393 |
Message:= Message or (gmWeapon and InputMask); |
4413 | 394 |
MsgParam:= byte(s[1]); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
395 |
ScriptCall('onSetWeapon'); |
4413 | 396 |
end; |
397 |
end; |
|
398 |
||
399 |
procedure chTaunt(var s: shortstring); |
|
400 |
begin |
|
401 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
402 |
||
403 |
if TWave(s[1]) > High(TWave) then exit; |
|
404 |
||
405 |
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
|
406 |
||
407 |
with CurrentHedgehog^.Gear^ do |
|
408 |
begin |
|
4522
0f590eefd531
Add an input mask for setting of gear messages. Intended for intercepting user messages. This is totally untested. I don't think it should desync but seriously needs a lot of testing. Esp the doPut behaviour.
nemo
parents:
4437
diff
changeset
|
409 |
Message:= Message or (gmAnimate and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
410 |
MsgParam:= byte(s[1]) ; |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
411 |
ScriptCall('onTaunt'); |
4413 | 412 |
end |
413 |
end; |
|
414 |
||
415 |
procedure chPut(var s: shortstring); |
|
416 |
begin |
|
417 |
s:= s; // avoid compiler hint |
|
418 |
doPut(0, 0, false); |
|
419 |
end; |
|
420 |
||
421 |
procedure chCapture(var s: shortstring); |
|
422 |
begin |
|
423 |
s:= s; // avoid compiler hint |
|
424 |
flagMakeCapture:= true |
|
425 |
end; |
|
426 |
||
427 |
procedure chSetMap(var s: shortstring); |
|
428 |
begin |
|
429 |
if isDeveloperMode then |
|
430 |
begin |
|
431 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
|
432 |
InitStepsFlags:= InitStepsFlags or cifMap |
|
433 |
end |
|
434 |
end; |
|
435 |
||
436 |
procedure chSetTheme(var s: shortstring); |
|
437 |
begin |
|
438 |
if isDeveloperMode then |
|
439 |
begin |
|
440 |
Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; |
|
4611 | 441 |
Theme:= s; |
4413 | 442 |
InitStepsFlags:= InitStepsFlags or cifTheme |
443 |
end |
|
444 |
end; |
|
445 |
||
446 |
procedure chSetSeed(var s: shortstring); |
|
447 |
begin |
|
448 |
if isDeveloperMode then |
|
449 |
begin |
|
450 |
SetRandomSeed(s); |
|
451 |
cSeed:= s; |
|
452 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
|
453 |
end |
|
454 |
end; |
|
455 |
||
456 |
procedure chAmmoMenu(var s: shortstring); |
|
457 |
begin |
|
458 |
s:= s; // avoid compiler hint |
|
459 |
if CheckNoTeamOrHH then |
|
460 |
bShowAmmoMenu:= true |
|
461 |
else |
|
462 |
begin |
|
463 |
with CurrentTeam^ do |
|
464 |
with Hedgehogs[CurrHedgehog] do |
|
465 |
begin |
|
466 |
bSelected:= false; |
|
467 |
||
468 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
|
469 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or |
|
470 |
((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) or |
|
471 |
((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
472 |
end; |
|
473 |
end |
|
474 |
end; |
|
475 |
||
476 |
procedure chVol_p(var s: shortstring); |
|
477 |
begin |
|
478 |
s:= s; // avoid compiler hint |
|
479 |
inc(cVolumeDelta, 3) |
|
480 |
end; |
|
481 |
||
482 |
procedure chVol_m(var s: shortstring); |
|
483 |
begin |
|
484 |
s:= s; // avoid compiler hint |
|
485 |
dec(cVolumeDelta, 3) |
|
486 |
end; |
|
487 |
||
488 |
procedure chFindhh(var s: shortstring); |
|
489 |
begin |
|
490 |
s:= s; // avoid compiler hint |
|
491 |
if CheckNoTeamOrHH or isPaused then exit; |
|
492 |
bShowFinger:= true; |
|
493 |
FollowGear:= CurrentHedgehog^.Gear |
|
494 |
end; |
|
495 |
||
496 |
procedure chPause(var s: shortstring); |
|
497 |
begin |
|
498 |
s:= s; // avoid compiler hint |
|
499 |
if gameType <> gmtNet then |
|
500 |
isPaused:= not isPaused; |
|
501 |
SDL_ShowCursor(ord(isPaused)) |
|
502 |
end; |
|
503 |
||
504 |
procedure chRotateMask(var s: shortstring); |
|
505 |
begin |
|
506 |
s:= s; // avoid compiler hint |
|
507 |
if ((GameFlags and gfInvulnerable) = 0) then cTagsMask:= cTagsMasks[cTagsMask] else cTagsMask:= cTagsMasksNoHealth[cTagsMask]; |
|
508 |
end; |
|
509 |
||
510 |
procedure chSpeedup_p(var s: shortstring); |
|
511 |
begin |
|
512 |
s:= s; // avoid compiler hint |
|
513 |
isSpeed:= true |
|
514 |
end; |
|
515 |
||
516 |
procedure chSpeedup_m(var s: shortstring); |
|
517 |
begin |
|
518 |
s:= s; // avoid compiler hint |
|
519 |
isSpeed:= false |
|
520 |
end; |
|
521 |
||
522 |
procedure chZoomIn(var s: shortstring); |
|
523 |
begin |
|
524 |
s:= s; // avoid compiler hint |
|
525 |
if ZoomValue < cMinZoomLevel then |
|
526 |
ZoomValue:= ZoomValue + cZoomDelta; |
|
527 |
end; |
|
528 |
||
529 |
procedure chZoomOut(var s: shortstring); |
|
530 |
begin |
|
531 |
s:= s; // avoid compiler hint |
|
532 |
if ZoomValue > cMaxZoomLevel then |
|
533 |
ZoomValue:= ZoomValue - cZoomDelta; |
|
534 |
end; |
|
535 |
||
536 |
procedure chZoomReset(var s: shortstring); |
|
537 |
begin |
|
538 |
s:= s; // avoid compiler hint |
|
539 |
ZoomValue:= cDefaultZoomLevel; |
|
540 |
end; |
|
541 |
||
542 |
||
543 |
procedure initModule; |
|
544 |
begin |
|
4528
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
545 |
//////// Begin top sorted by freq analysis not including chatmsg |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
546 |
RegisterVariable('+right' , vtCommand, @chRight_p , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
547 |
RegisterVariable('-right' , vtCommand, @chRight_m , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
548 |
RegisterVariable('+up' , vtCommand, @chUp_p , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
549 |
RegisterVariable('-up' , vtCommand, @chUp_m , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
550 |
RegisterVariable('+left' , vtCommand, @chLeft_p , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
551 |
RegisterVariable('-left' , vtCommand, @chLeft_m , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
552 |
RegisterVariable('+attack' , vtCommand, @chAttack_p , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
553 |
RegisterVariable('+down' , vtCommand, @chDown_p , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
554 |
RegisterVariable('-down' , vtCommand, @chDown_m , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
555 |
RegisterVariable('hjump' , vtCommand, @chHJump , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
556 |
RegisterVariable('ljump' , vtCommand, @chLJump , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
557 |
RegisterVariable('nextturn', vtCommand, @chNextTurn , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
558 |
RegisterVariable('-attack' , vtCommand, @chAttack_m , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
559 |
RegisterVariable('slot' , vtCommand, @chSlot , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
560 |
RegisterVariable('setweap' , vtCommand, @chSetWeapon , false); |
630f4ab0c926
Reorder top registered variables by frequency gathered from 60 or so games of varying length/type. Oh. And add green hair to joker.
nemo
parents:
4522
diff
changeset
|
561 |
//////// End top by freq analysis |
4531
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
562 |
RegisterVariable('gencmd' , vtCommand, @chGenCmd , false); |
4413 | 563 |
RegisterVariable('flag' , vtCommand, @chFlag , false); |
564 |
RegisterVariable('script' , vtCommand, @chScript , false); |
|
565 |
RegisterVariable('proto' , vtCommand, @chCheckProto , true ); |
|
566 |
RegisterVariable('spectate', vtBoolean, @fastUntilLag , false); |
|
567 |
RegisterVariable('capture' , vtCommand, @chCapture , true ); |
|
568 |
RegisterVariable('rotmask' , vtCommand, @chRotateMask , true ); |
|
569 |
RegisterVariable('rdriven' , vtCommand, @chTeamLocal , false); |
|
570 |
RegisterVariable('map' , vtCommand, @chSetMap , false); |
|
571 |
RegisterVariable('theme' , vtCommand, @chSetTheme , false); |
|
572 |
RegisterVariable('seed' , vtCommand, @chSetSeed , false); |
|
573 |
RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false); |
|
574 |
RegisterVariable('mapgen' , vtLongInt, @cMapGen , false); |
|
575 |
RegisterVariable('maze_size',vtLongInt, @cMazeSize , false); |
|
576 |
RegisterVariable('delay' , vtLongInt, @cInactDelay , false); |
|
577 |
RegisterVariable('ready' , vtLongInt, @cReadyDelay , false); |
|
578 |
RegisterVariable('casefreq', vtLongInt, @cCaseFactor , false); |
|
579 |
RegisterVariable('healthprob', vtLongInt, @cHealthCaseProb, false); |
|
580 |
RegisterVariable('hcaseamount', vtLongInt, @cHealthCaseAmount, false); |
|
581 |
RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns , false); |
|
582 |
RegisterVariable('waterrise', vtLongInt, @cWaterRise , false); |
|
583 |
RegisterVariable('healthdec', vtLongInt, @cHealthDecrease, false); |
|
584 |
RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false); |
|
585 |
RegisterVariable('ropepct' , vtLongInt, @cRopePercent , false); |
|
586 |
RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false); |
|
587 |
RegisterVariable('minesnum', vtLongInt, @cLandMines , false); |
|
588 |
RegisterVariable('explosives',vtLongInt,@cExplosives , false); |
|
589 |
RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); |
|
590 |
RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); |
|
591 |
RegisterVariable('minestime',vtLongInt, @cMinesTime , false); |
|
592 |
RegisterVariable('fort' , vtCommand, @chFort , false); |
|
593 |
RegisterVariable('grave' , vtCommand, @chGrave , false); |
|
594 |
RegisterVariable('hat' , vtCommand, @chSetHat , false); |
|
595 |
RegisterVariable('quit' , vtCommand, @chQuit , true ); |
|
4744
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
596 |
RegisterVariable('forcequit', vtCommand, @chForceQuit , true ); |
4413 | 597 |
RegisterVariable('confirm' , vtCommand, @chConfirm , true ); |
4751 | 598 |
RegisterVariable('halt', vtCommand, @chHalt , true ); |
4413 | 599 |
RegisterVariable('+speedup', vtCommand, @chSpeedup_p , true ); |
600 |
RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); |
|
601 |
RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); |
|
602 |
RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); |
|
603 |
RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); |
|
604 |
RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); |
|
605 |
RegisterVariable('+precise', vtCommand, @chPrecise_p , false); |
|
606 |
RegisterVariable('-precise', vtCommand, @chPrecise_m , false); |
|
607 |
RegisterVariable('switch' , vtCommand, @chSwitch , false); |
|
608 |
RegisterVariable('timer' , vtCommand, @chTimer , false); |
|
609 |
RegisterVariable('taunt' , vtCommand, @chTaunt , false); |
|
610 |
RegisterVariable('put' , vtCommand, @chPut , false); |
|
611 |
RegisterVariable('+volup' , vtCommand, @chVol_p , true ); |
|
612 |
RegisterVariable('-volup' , vtCommand, @chVol_m , true ); |
|
613 |
RegisterVariable('+voldown', vtCommand, @chVol_m , true ); |
|
614 |
RegisterVariable('-voldown', vtCommand, @chVol_p , true ); |
|
615 |
RegisterVariable('findhh' , vtCommand, @chFindhh , true ); |
|
616 |
RegisterVariable('pause' , vtCommand, @chPause , true ); |
|
617 |
RegisterVariable('+cur_u' , vtCommand, @chCurU_p , true ); |
|
618 |
RegisterVariable('-cur_u' , vtCommand, @chCurU_m , true ); |
|
619 |
RegisterVariable('+cur_d' , vtCommand, @chCurD_p , true ); |
|
620 |
RegisterVariable('-cur_d' , vtCommand, @chCurD_m , true ); |
|
621 |
RegisterVariable('+cur_l' , vtCommand, @chCurL_p , true ); |
|
622 |
RegisterVariable('-cur_l' , vtCommand, @chCurL_m , true ); |
|
623 |
RegisterVariable('+cur_r' , vtCommand, @chCurR_p , true ); |
|
624 |
RegisterVariable('-cur_r' , vtCommand, @chCurR_m , true ); |
|
625 |
end; |
|
626 |
||
627 |
procedure freeModule; |
|
628 |
begin |
|
629 |
end; |
|
630 |
||
631 |
end. |