65 |
69 |
66 procedure chConfirm(var s: shortstring); |
70 procedure chConfirm(var s: shortstring); |
67 begin |
71 begin |
68 s:= s; // avoid compiler hint |
72 s:= s; // avoid compiler hint |
69 if GameState = gsConfirm then |
73 if GameState = gsConfirm then |
70 begin |
74 begin |
71 SendIPC('Q'); |
75 SendIPC(_S'Q'); |
72 GameState:= gsExit |
76 GameState:= gsExit |
73 end |
77 end |
74 else |
78 else |
75 ParseCommand('chat team', true); |
79 ParseCommand('chat team', true); |
76 end; |
80 end; |
77 |
81 |
78 procedure chHalt (var s: shortstring); |
82 procedure chHalt (var s: shortstring); |
79 begin |
83 begin |
80 s:= s; // avoid compiler hint |
84 s:= s; // avoid compiler hint |
81 SendIPC('H'); |
85 SendIPC(_S'H'); |
82 GameState:= gsExit |
86 GameState:= gsExit |
83 end; |
87 end; |
84 |
88 |
85 procedure chCheckProto(var s: shortstring); |
89 procedure chCheckProto(var s: shortstring); |
86 var i, c: LongInt; |
90 var i, c: LongInt; |
87 begin |
91 begin |
88 if isDeveloperMode then |
92 if isDeveloperMode then |
89 begin |
93 begin |
90 val(s, i, c); |
94 val(s, i, c); |
91 if (c <> 0) or (i = 0) then exit; |
|
92 TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
95 TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
93 TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
96 TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); |
94 end |
97 end |
95 end; |
98 end; |
96 |
99 |
97 procedure chTeamLocal(var s: shortstring); |
100 procedure chTeamLocal(var s: shortstring); |
98 begin |
101 begin |
99 s:= s; // avoid compiler hint |
102 s:= s; // avoid compiler hint |
100 if not isDeveloperMode then exit; |
103 if not isDeveloperMode then |
101 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
104 exit; |
|
105 if CurrentTeam = nil then |
|
106 OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
102 CurrentTeam^.ExtDriven:= true |
107 CurrentTeam^.ExtDriven:= true |
103 end; |
108 end; |
104 |
109 |
105 procedure chGrave(var s: shortstring); |
110 procedure chGrave(var s: shortstring); |
106 begin |
111 begin |
107 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
112 if CurrentTeam = nil then |
108 if s[1]='"' then Delete(s, 1, 1); |
113 OutError(errmsgIncorrectUse + ' "/grave"', true); |
109 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
114 if s[1]='"' then |
|
115 Delete(s, 1, 1); |
|
116 if s[byte(s[0])]='"' then |
|
117 Delete(s, byte(s[0]), 1); |
110 CurrentTeam^.GraveName:= s |
118 CurrentTeam^.GraveName:= s |
111 end; |
119 end; |
112 |
120 |
113 procedure chFort(var s: shortstring); |
121 procedure chFort(var s: shortstring); |
114 begin |
122 begin |
115 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); |
123 if CurrentTeam = nil then |
116 if s[1]='"' then Delete(s, 1, 1); |
124 OutError(errmsgIncorrectUse + ' "/fort"', true); |
117 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
125 if s[1]='"' then |
|
126 Delete(s, 1, 1); |
|
127 if s[byte(s[0])]='"' then |
|
128 Delete(s, byte(s[0]), 1); |
118 CurrentTeam^.FortName:= s |
129 CurrentTeam^.FortName:= s |
119 end; |
130 end; |
120 |
131 |
121 procedure chFlag(var s: shortstring); |
132 procedure chFlag(var s: shortstring); |
122 begin |
133 begin |
123 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/flag"', true); |
134 if CurrentTeam = nil then |
124 if s[1]='"' then Delete(s, 1, 1); |
135 OutError(errmsgIncorrectUse + ' "/flag"', true); |
125 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
136 if s[1]='"' then |
|
137 Delete(s, 1, 1); |
|
138 if s[byte(s[0])]='"' then |
|
139 Delete(s, byte(s[0]), 1); |
126 CurrentTeam^.flag:= s |
140 CurrentTeam^.flag:= s |
127 end; |
141 end; |
128 |
142 |
129 procedure chScript(var s: shortstring); |
143 procedure chScript(var s: shortstring); |
130 begin |
144 begin |
131 if s[1]='"' then Delete(s, 1, 1); |
145 if s[1]='"' then |
132 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
146 Delete(s, 1, 1); |
|
147 if s[byte(s[0])]='"' then |
|
148 Delete(s, byte(s[0]), 1); |
133 cScriptName:= s; |
149 cScriptName:= s; |
134 ScriptLoad(s) |
150 ScriptLoad(s) |
135 end; |
151 end; |
136 |
152 |
137 procedure chSetHat(var s: shortstring); |
153 procedure chSetHat(var s: shortstring); |
138 begin |
154 begin |
139 if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
155 if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
140 with CurrentTeam^ do |
156 with CurrentTeam^ do |
141 begin |
157 begin |
142 if not CurrentHedgehog^.King then |
158 if not CurrentHedgehog^.King then |
143 if (s = '') or |
159 if (s = '') |
144 (((GameFlags and gfKing) <> 0) and (s = 'crown')) or |
160 or (((GameFlags and gfKing) <> 0) and (s = 'crown')) |
145 ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then |
161 or ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then |
146 CurrentHedgehog^.Hat:= 'NoHat' |
162 CurrentHedgehog^.Hat:= 'NoHat' |
147 else |
163 else |
148 CurrentHedgehog^.Hat:= s |
164 CurrentHedgehog^.Hat:= s |
149 end; |
165 end; |
150 end; |
166 end; |
198 end; |
214 end; |
199 |
215 |
200 procedure chLeft_p(var s: shortstring); |
216 procedure chLeft_p(var s: shortstring); |
201 begin |
217 begin |
202 s:= s; // avoid compiler hint |
218 s:= s; // avoid compiler hint |
203 if CheckNoTeamOrHH or isPaused then exit; |
219 if CheckNoTeamOrHH or isPaused then |
204 if not CurrentTeam^.ExtDriven then SendIPC('L'); |
220 exit; |
|
221 if not isExternalSource then |
|
222 SendIPC(_S'L'); |
205 bShowFinger:= false; |
223 bShowFinger:= false; |
206 with CurrentHedgehog^.Gear^ do |
224 with CurrentHedgehog^.Gear^ do |
207 Message:= Message or (gmLeft and InputMask); |
225 Message:= Message or (gmLeft and InputMask); |
208 ScriptCall('onLeft'); |
226 ScriptCall('onLeft'); |
209 end; |
227 end; |
210 |
228 |
211 procedure chLeft_m(var s: shortstring); |
229 procedure chLeft_m(var s: shortstring); |
212 begin |
230 begin |
213 s:= s; // avoid compiler hint |
231 s:= s; // avoid compiler hint |
214 if CheckNoTeamOrHH then exit; |
232 if CheckNoTeamOrHH then |
215 if not CurrentTeam^.ExtDriven then SendIPC('l'); |
233 exit; |
216 with CurrentHedgehog^.Gear^ do |
234 if not isExternalSource then |
217 Message:= Message and not (gmLeft and InputMask); |
235 SendIPC(_S'l'); |
|
236 with CurrentHedgehog^.Gear^ do |
|
237 Message:= Message and (not (gmLeft and InputMask)); |
218 ScriptCall('onLeftUp'); |
238 ScriptCall('onLeftUp'); |
219 end; |
239 end; |
220 |
240 |
221 procedure chRight_p(var s: shortstring); |
241 procedure chRight_p(var s: shortstring); |
222 begin |
242 begin |
223 s:= s; // avoid compiler hint |
243 s:= s; // avoid compiler hint |
224 if CheckNoTeamOrHH or isPaused then exit; |
244 if CheckNoTeamOrHH or isPaused then |
225 if not CurrentTeam^.ExtDriven then SendIPC('R'); |
245 exit; |
|
246 if not isExternalSource then |
|
247 SendIPC(_S'R'); |
226 bShowFinger:= false; |
248 bShowFinger:= false; |
227 with CurrentHedgehog^.Gear^ do |
249 with CurrentHedgehog^.Gear^ do |
228 Message:= Message or (gmRight and InputMask); |
250 Message:= Message or (gmRight and InputMask); |
229 ScriptCall('onRight'); |
251 ScriptCall('onRight'); |
230 end; |
252 end; |
231 |
253 |
232 procedure chRight_m(var s: shortstring); |
254 procedure chRight_m(var s: shortstring); |
233 begin |
255 begin |
234 s:= s; // avoid compiler hint |
256 s:= s; // avoid compiler hint |
235 if CheckNoTeamOrHH then exit; |
257 if CheckNoTeamOrHH then |
236 if not CurrentTeam^.ExtDriven then SendIPC('r'); |
258 exit; |
237 with CurrentHedgehog^.Gear^ do |
259 if not isExternalSource then |
238 Message:= Message and not (gmRight and InputMask); |
260 SendIPC(_S'r'); |
|
261 with CurrentHedgehog^.Gear^ do |
|
262 Message:= Message and (not (gmRight and InputMask)); |
239 ScriptCall('onRightUp'); |
263 ScriptCall('onRightUp'); |
240 end; |
264 end; |
241 |
265 |
242 procedure chUp_p(var s: shortstring); |
266 procedure chUp_p(var s: shortstring); |
243 begin |
267 begin |
244 s:= s; // avoid compiler hint |
268 s:= s; // avoid compiler hint |
245 if CheckNoTeamOrHH or isPaused then exit; |
269 if CheckNoTeamOrHH or isPaused then |
246 if not CurrentTeam^.ExtDriven then SendIPC('U'); |
270 exit; |
|
271 if not isExternalSource then |
|
272 SendIPC(_S'U'); |
247 bShowFinger:= false; |
273 bShowFinger:= false; |
248 with CurrentHedgehog^.Gear^ do |
274 with CurrentHedgehog^.Gear^ do |
249 Message:= Message or (gmUp and InputMask); |
275 Message:= Message or (gmUp and InputMask); |
250 ScriptCall('onUp'); |
276 ScriptCall('onUp'); |
251 end; |
277 end; |
252 |
278 |
253 procedure chUp_m(var s: shortstring); |
279 procedure chUp_m(var s: shortstring); |
254 begin |
280 begin |
255 s:= s; // avoid compiler hint |
281 s:= s; // avoid compiler hint |
256 if CheckNoTeamOrHH then exit; |
282 if CheckNoTeamOrHH then |
257 if not CurrentTeam^.ExtDriven then SendIPC('u'); |
283 exit; |
258 with CurrentHedgehog^.Gear^ do |
284 if not isExternalSource then |
259 Message:= Message and not (gmUp and InputMask); |
285 SendIPC(_S'u'); |
|
286 with CurrentHedgehog^.Gear^ do |
|
287 Message:= Message and (not (gmUp and InputMask)); |
260 ScriptCall('onUpUp'); |
288 ScriptCall('onUpUp'); |
261 end; |
289 end; |
262 |
290 |
263 procedure chDown_p(var s: shortstring); |
291 procedure chDown_p(var s: shortstring); |
264 begin |
292 begin |
265 s:= s; // avoid compiler hint |
293 s:= s; // avoid compiler hint |
266 if CheckNoTeamOrHH or isPaused then exit; |
294 if CheckNoTeamOrHH or isPaused then |
267 if not CurrentTeam^.ExtDriven then SendIPC('D'); |
295 exit; |
|
296 if not isExternalSource then |
|
297 SendIPC(_S'D'); |
268 bShowFinger:= false; |
298 bShowFinger:= false; |
269 with CurrentHedgehog^.Gear^ do |
299 with CurrentHedgehog^.Gear^ do |
270 Message:= Message or (gmDown and InputMask); |
300 Message:= Message or (gmDown and InputMask); |
271 ScriptCall('onDown'); |
301 ScriptCall('onDown'); |
272 end; |
302 end; |
273 |
303 |
274 procedure chDown_m(var s: shortstring); |
304 procedure chDown_m(var s: shortstring); |
275 begin |
305 begin |
276 s:= s; // avoid compiler hint |
306 s:= s; // avoid compiler hint |
277 if CheckNoTeamOrHH then exit; |
307 if CheckNoTeamOrHH then |
278 if not CurrentTeam^.ExtDriven then SendIPC('d'); |
308 exit; |
279 with CurrentHedgehog^.Gear^ do |
309 if not isExternalSource then |
280 Message:= Message and not (gmDown and InputMask); |
310 SendIPC(_S'd'); |
|
311 with CurrentHedgehog^.Gear^ do |
|
312 Message:= Message and (not (gmDown and InputMask)); |
281 ScriptCall('onDownUp'); |
313 ScriptCall('onDownUp'); |
282 end; |
314 end; |
283 |
315 |
284 procedure chPrecise_p(var s: shortstring); |
316 procedure chPrecise_p(var s: shortstring); |
285 begin |
317 begin |
286 s:= s; // avoid compiler hint |
318 s:= s; // avoid compiler hint |
287 if CheckNoTeamOrHH or isPaused then exit; |
319 if CheckNoTeamOrHH or isPaused then |
288 if not CurrentTeam^.ExtDriven then SendIPC('Z'); |
320 exit; |
|
321 if not isExternalSource then |
|
322 SendIPC(_S'Z'); |
289 bShowFinger:= false; |
323 bShowFinger:= false; |
290 with CurrentHedgehog^.Gear^ do |
324 with CurrentHedgehog^.Gear^ do |
291 Message:= Message or (gmPrecise and InputMask); |
325 Message:= Message or (gmPrecise and InputMask); |
292 ScriptCall('onPrecise'); |
326 ScriptCall('onPrecise'); |
293 end; |
327 end; |
294 |
328 |
295 procedure chPrecise_m(var s: shortstring); |
329 procedure chPrecise_m(var s: shortstring); |
296 begin |
330 begin |
297 s:= s; // avoid compiler hint |
331 s:= s; // avoid compiler hint |
298 if CheckNoTeamOrHH then exit; |
332 if CheckNoTeamOrHH then |
299 if not CurrentTeam^.ExtDriven then SendIPC('z'); |
333 exit; |
300 with CurrentHedgehog^.Gear^ do |
334 if not isExternalSource then |
301 Message:= Message and not (gmPrecise and InputMask); |
335 SendIPC(_S'z'); |
|
336 with CurrentHedgehog^.Gear^ do |
|
337 Message:= Message and (not (gmPrecise and InputMask)); |
302 ScriptCall('onPreciseUp'); |
338 ScriptCall('onPreciseUp'); |
303 end; |
339 end; |
304 |
340 |
305 procedure chLJump(var s: shortstring); |
341 procedure chLJump(var s: shortstring); |
306 begin |
342 begin |
307 s:= s; // avoid compiler hint |
343 s:= s; // avoid compiler hint |
308 if CheckNoTeamOrHH or isPaused then exit; |
344 if CheckNoTeamOrHH or isPaused then |
309 if not CurrentTeam^.ExtDriven then SendIPC('j'); |
345 exit; |
|
346 if not isExternalSource then |
|
347 SendIPC(_S'j'); |
310 bShowFinger:= false; |
348 bShowFinger:= false; |
311 with CurrentHedgehog^.Gear^ do |
349 with CurrentHedgehog^.Gear^ do |
312 Message:= Message or (gmLJump and InputMask); |
350 Message:= Message or (gmLJump and InputMask); |
313 ScriptCall('onLJump'); |
351 ScriptCall('onLJump'); |
314 end; |
352 end; |
315 |
353 |
316 procedure chHJump(var s: shortstring); |
354 procedure chHJump(var s: shortstring); |
317 begin |
355 begin |
318 s:= s; // avoid compiler hint |
356 s:= s; // avoid compiler hint |
319 if CheckNoTeamOrHH or isPaused then exit; |
357 if CheckNoTeamOrHH or isPaused then |
320 if not CurrentTeam^.ExtDriven then SendIPC('J'); |
358 exit; |
|
359 if not isExternalSource then |
|
360 SendIPC(_S'J'); |
321 bShowFinger:= false; |
361 bShowFinger:= false; |
322 with CurrentHedgehog^.Gear^ do |
362 with CurrentHedgehog^.Gear^ do |
323 Message:= Message or (gmHJump and InputMask); |
363 Message:= Message or (gmHJump and InputMask); |
324 ScriptCall('onHJump'); |
364 ScriptCall('onHJump'); |
325 end; |
365 end; |
326 |
366 |
327 procedure chAttack_p(var s: shortstring); |
367 procedure chAttack_p(var s: shortstring); |
328 begin |
368 begin |
329 s:= s; // avoid compiler hint |
369 s:= s; // avoid compiler hint |
330 if CheckNoTeamOrHH or isPaused then exit; |
370 if CheckNoTeamOrHH or isPaused then |
|
371 exit; |
331 bShowFinger:= false; |
372 bShowFinger:= false; |
332 with CurrentHedgehog^.Gear^ do |
373 with CurrentHedgehog^.Gear^ do |
333 begin |
374 begin |
334 AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State)); |
375 AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State)); |
335 if ((State and gstHHDriven) <> 0) then |
376 if ((State and gstHHDriven) <> 0) then |
336 begin |
377 begin |
337 FollowGear:= CurrentHedgehog^.Gear; |
378 FollowGear:= CurrentHedgehog^.Gear; |
338 if not CurrentTeam^.ExtDriven then SendIPC('A'); |
379 if not isExternalSource then |
|
380 SendIPC(_S'A'); |
339 Message:= Message or (gmAttack and InputMask); |
381 Message:= Message or (gmAttack and InputMask); |
340 ScriptCall('onAttack'); |
382 ScriptCall('onAttack'); |
341 end |
383 end |
342 end |
384 end |
343 end; |
385 end; |
344 |
386 |
345 procedure chAttack_m(var s: shortstring); |
387 procedure chAttack_m(var s: shortstring); |
346 begin |
388 begin |
347 s:= s; // avoid compiler hint |
389 s:= s; // avoid compiler hint |
348 if CheckNoTeamOrHH then exit; |
390 if CheckNoTeamOrHH then |
349 with CurrentHedgehog^.Gear^ do |
391 exit; |
350 begin |
392 with CurrentHedgehog^.Gear^ do |
351 if not CurrentTeam^.ExtDriven and |
393 begin |
352 ((Message and gmAttack) <> 0) then SendIPC('a'); |
394 if not isExternalSource and |
353 Message:= Message and not (gmAttack and InputMask); |
395 ((Message and gmAttack) <> 0) then |
|
396 SendIPC(_S'a'); |
|
397 Message:= Message and (not (gmAttack and InputMask)); |
354 ScriptCall('onAttackUp'); |
398 ScriptCall('onAttackUp'); |
355 end |
399 end |
356 end; |
400 end; |
357 |
401 |
358 procedure chSwitch(var s: shortstring); |
402 procedure chSwitch(var s: shortstring); |
359 begin |
403 begin |
360 s:= s; // avoid compiler hint |
404 s:= s; // avoid compiler hint |
361 if CheckNoTeamOrHH or isPaused then exit; |
405 if CheckNoTeamOrHH or isPaused then |
362 if not CurrentTeam^.ExtDriven then SendIPC('S'); |
406 exit; |
|
407 if not isExternalSource then |
|
408 SendIPC(_S'S'); |
363 bShowFinger:= false; |
409 bShowFinger:= false; |
364 with CurrentHedgehog^.Gear^ do |
410 with CurrentHedgehog^.Gear^ do |
365 Message:= Message or (gmSwitch and InputMask); |
411 Message:= Message or (gmSwitch and InputMask); |
366 ScriptCall('onSwitch'); |
412 ScriptCall('onSwitch'); |
367 end; |
413 end; |
368 |
414 |
369 procedure chNextTurn(var s: shortstring); |
415 procedure chNextTurn(var s: shortstring); |
|
416 var gi: PGear; |
370 begin |
417 begin |
371 s:= s; // avoid compiler hint |
418 s:= s; // avoid compiler hint |
|
419 |
372 TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
420 TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
373 |
421 |
374 if not CurrentTeam^.ExtDriven then SendIPC('N'); |
422 CheckSum:= CheckSum xor GameTicks; |
375 AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks)); |
423 gi := GearsList; |
|
424 while gi <> nil do |
|
425 begin |
|
426 with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac; |
|
427 AddRandomness(CheckSum); |
|
428 gi := gi^.NextGear |
|
429 end; |
|
430 |
|
431 if not isExternalSource then |
|
432 begin |
|
433 s[0]:= #5; |
|
434 s[1]:= 'N'; |
|
435 SDLNet_Write32(CheckSum, @s[2]); |
|
436 SendIPC(s) |
|
437 end |
|
438 else |
|
439 TryDo(CurrentTeam^.hasGone or (CheckSum = lastTurnChecksum), 'Desync detected', true); |
|
440 |
|
441 AddFileLog('Next turn: time '+inttostr(GameTicks)); |
376 end; |
442 end; |
377 |
443 |
378 procedure chTimer(var s: shortstring); |
444 procedure chTimer(var s: shortstring); |
379 begin |
445 begin |
380 if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit; |
446 if CheckNoTeamOrHH then |
381 |
447 exit; |
382 if not CurrentTeam^.ExtDriven then SendIPC(s); |
448 |
|
449 TryDo((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true); |
|
450 |
|
451 if not isExternalSource then |
|
452 SendIPC(s); |
383 bShowFinger:= false; |
453 bShowFinger:= false; |
384 with CurrentHedgehog^.Gear^ do |
454 with CurrentHedgehog^.Gear^ do |
385 begin |
455 begin |
386 Message:= Message or (gmTimer and InputMask); |
456 Message:= Message or (gmTimer and InputMask); |
387 MsgParam:= byte(s[1]) - ord('0'); |
457 MsgParam:= byte(s[1]) - ord('0'); |
388 ScriptCall('onTimer'); |
458 ScriptCall('onTimer', MsgParam); |
389 end |
459 end |
390 end; |
460 end; |
391 |
461 |
392 procedure chSlot(var s: shortstring); |
462 procedure chSlot(var s: shortstring); |
393 var slot: LongWord; |
463 var slot: LongWord; |
394 begin |
464 ss: shortstring; |
395 if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
465 begin |
|
466 if (s[0] <> #1) or CheckNoTeamOrHH then |
|
467 exit; |
396 slot:= byte(s[1]) - 49; |
468 slot:= byte(s[1]) - 49; |
397 if slot > cMaxSlotIndex then exit; |
469 if slot > cMaxSlotIndex then |
398 if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
470 exit; |
|
471 if not isExternalSource then |
|
472 begin |
|
473 ss[0]:= #1; |
|
474 ss[1]:= char(byte(s[1]) + 79); |
|
475 SendIPC(ss); |
|
476 end; |
399 bShowFinger:= false; |
477 bShowFinger:= false; |
400 with CurrentHedgehog^.Gear^ do |
478 with CurrentHedgehog^.Gear^ do |
401 begin |
479 begin |
402 Message:= Message or (gmSlot and InputMask); |
480 Message:= Message or (gmSlot and InputMask); |
403 MsgParam:= slot; |
481 MsgParam:= slot; |
404 ScriptCall('onSlot'); |
482 ScriptCall('onSlot', MsgParam); |
405 end |
483 end |
406 end; |
484 end; |
407 |
485 |
408 procedure chSetWeapon(var s: shortstring); |
486 procedure chSetWeapon(var s: shortstring); |
409 begin |
487 begin |
410 if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
488 if CheckNoTeamOrHH then |
411 |
489 exit; |
412 if TAmmoType(s[1]) > High(TAmmoType) then exit; |
490 |
413 |
491 TryDo((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true); |
414 if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
492 |
|
493 if not isExternalSource then |
|
494 SendIPC('w' + s); |
415 |
495 |
416 with CurrentHedgehog^.Gear^ do |
496 with CurrentHedgehog^.Gear^ do |
417 begin |
497 begin |
418 Message:= Message or (gmWeapon and InputMask); |
498 Message:= Message or (gmWeapon and InputMask); |
419 MsgParam:= byte(s[1]); |
499 MsgParam:= byte(s[1]); |
420 ScriptCall('onSetWeapon'); |
500 ScriptCall('onSetWeapon', MsgParam); |
421 end; |
501 end; |
422 end; |
502 end; |
423 |
503 |
424 procedure chTaunt(var s: shortstring); |
504 procedure chTaunt(var s: shortstring); |
425 begin |
505 begin |
426 if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
506 if (s[0] <> #1) or CheckNoTeamOrHH then |
427 |
507 exit; |
428 if TWave(s[1]) > High(TWave) then exit; |
508 |
429 |
509 if TWave(s[1]) > High(TWave) then |
430 if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
510 exit; |
|
511 |
|
512 if not isExternalSource then |
|
513 SendIPC('t' + s); |
431 |
514 |
432 with CurrentHedgehog^.Gear^ do |
515 with CurrentHedgehog^.Gear^ do |
433 begin |
516 begin |
434 Message:= Message or (gmAnimate and InputMask); |
517 Message:= Message or (gmAnimate and InputMask); |
435 MsgParam:= byte(s[1]) ; |
518 MsgParam:= byte(s[1]) ; |
436 ScriptCall('onTaunt'); |
519 ScriptCall('onTaunt', MsgParam); |
437 end |
520 end |
438 end; |
521 end; |
439 |
522 |
440 procedure chPut(var s: shortstring); |
523 procedure chPut(var s: shortstring); |
441 begin |
524 begin |
580 begin |
695 begin |
581 s:= s; // avoid compiler hint |
696 s:= s; // avoid compiler hint |
582 ZoomValue:= cDefaultZoomLevel; |
697 ZoomValue:= cDefaultZoomLevel; |
583 end; |
698 end; |
584 |
699 |
|
700 procedure chMapGen(var s: shortstring); |
|
701 begin |
|
702 cMapGen:= StrToInt(s) |
|
703 end; |
|
704 |
|
705 procedure chTemplateFilter(var s: shortstring); |
|
706 begin |
|
707 cTemplateFilter:= StrToInt(s) |
|
708 end; |
|
709 |
|
710 procedure chInactDelay(var s: shortstring); |
|
711 begin |
|
712 cInactDelay:= StrToInt(s) |
|
713 end; |
|
714 |
|
715 procedure chReadyDelay(var s: shortstring); |
|
716 begin |
|
717 cReadyDelay:= StrToInt(s) |
|
718 end; |
|
719 |
|
720 procedure chCaseFactor(var s: shortstring); |
|
721 begin |
|
722 cCaseFactor:= StrToInt(s) |
|
723 end; |
|
724 |
|
725 procedure chHealthCaseProb(var s: shortstring); |
|
726 begin |
|
727 cHealthCaseProb:= StrToInt(s) |
|
728 end; |
|
729 |
|
730 procedure chHealthCaseAmount(var s: shortstring); |
|
731 begin |
|
732 cHealthCaseAmount:= StrToInt(s) |
|
733 end; |
|
734 |
|
735 procedure chSuddenDTurns(var s: shortstring); |
|
736 begin |
|
737 cSuddenDTurns:= StrToInt(s) |
|
738 end; |
|
739 |
|
740 procedure chWaterRise(var s: shortstring); |
|
741 begin |
|
742 cWaterRise:= StrToInt(s) |
|
743 end; |
|
744 |
|
745 procedure chHealthDecrease(var s: shortstring); |
|
746 begin |
|
747 cHealthDecrease:= StrToInt(s) |
|
748 end; |
|
749 |
|
750 procedure chDamagePercent(var s: shortstring); |
|
751 begin |
|
752 cDamagePercent:= StrToInt(s) |
|
753 end; |
|
754 |
|
755 procedure chRopePercent(var s: shortstring); |
|
756 begin |
|
757 cRopePercent:= StrToInt(s) |
|
758 end; |
|
759 |
|
760 procedure chGetAwayTime(var s: shortstring); |
|
761 begin |
|
762 cGetAwayTime:= StrToInt(s) |
|
763 end; |
|
764 |
|
765 procedure chMineDudPercent(var s: shortstring); |
|
766 begin |
|
767 cMineDudPercent:= StrToInt(s) |
|
768 end; |
|
769 |
|
770 procedure chLandMines(var s: shortstring); |
|
771 begin |
|
772 cLandMines:= StrToInt(s) |
|
773 end; |
|
774 |
|
775 procedure chExplosives(var s: shortstring); |
|
776 begin |
|
777 cExplosives:= StrToInt(s) |
|
778 end; |
|
779 |
|
780 procedure chGameFlags(var s: shortstring); |
|
781 begin |
|
782 GameFlags:= StrToInt(s); |
|
783 if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo) |
|
784 end; |
|
785 |
|
786 procedure chHedgehogTurnTime(var s: shortstring); |
|
787 begin |
|
788 cHedgehogTurnTime:= StrToInt(s) |
|
789 end; |
|
790 |
|
791 procedure chMinesTime(var s: shortstring); |
|
792 begin |
|
793 cMinesTime:= StrToInt(s) |
|
794 end; |
|
795 |
|
796 procedure chFastUntilLag(var s: shortstring); |
|
797 begin |
|
798 fastUntilLag:= StrToInt(s) <> 0 |
|
799 end; |
|
800 |
|
801 procedure chCampVar(var s:shortstring); |
|
802 begin |
|
803 CampaignVariable := s; |
|
804 end; |
585 |
805 |
586 procedure initModule; |
806 procedure initModule; |
587 begin |
807 begin |
588 //////// Begin top sorted by freq analysis not including chatmsg |
808 //////// Begin top sorted by freq analysis not including chatmsg |
589 RegisterVariable('+right' , vtCommand, @chRight_p , false); |
809 RegisterVariable('+right' , @chRight_p , false, true); |
590 RegisterVariable('-right' , vtCommand, @chRight_m , false); |
810 RegisterVariable('-right' , @chRight_m , false, true); |
591 RegisterVariable('+up' , vtCommand, @chUp_p , false); |
811 RegisterVariable('+up' , @chUp_p , false, true); |
592 RegisterVariable('-up' , vtCommand, @chUp_m , false); |
812 RegisterVariable('-up' , @chUp_m , false, true); |
593 RegisterVariable('+left' , vtCommand, @chLeft_p , false); |
813 RegisterVariable('+left' , @chLeft_p , false, true); |
594 RegisterVariable('-left' , vtCommand, @chLeft_m , false); |
814 RegisterVariable('-left' , @chLeft_m , false, true); |
595 RegisterVariable('+attack' , vtCommand, @chAttack_p , false); |
815 RegisterVariable('+attack' , @chAttack_p , false); |
596 RegisterVariable('+down' , vtCommand, @chDown_p , false); |
816 RegisterVariable('+down' , @chDown_p , false, true); |
597 RegisterVariable('-down' , vtCommand, @chDown_m , false); |
817 RegisterVariable('-down' , @chDown_m , false, true); |
598 RegisterVariable('hjump' , vtCommand, @chHJump , false); |
818 RegisterVariable('hjump' , @chHJump , false, true); |
599 RegisterVariable('ljump' , vtCommand, @chLJump , false); |
819 RegisterVariable('ljump' , @chLJump , false, true); |
600 RegisterVariable('nextturn', vtCommand, @chNextTurn , false); |
820 RegisterVariable('nextturn', @chNextTurn , false); |
601 RegisterVariable('-attack' , vtCommand, @chAttack_m , false); |
821 RegisterVariable('-attack' , @chAttack_m , false); |
602 RegisterVariable('slot' , vtCommand, @chSlot , false); |
822 RegisterVariable('slot' , @chSlot , false); |
603 RegisterVariable('setweap' , vtCommand, @chSetWeapon , false); |
823 RegisterVariable('setweap' , @chSetWeapon , false, true); |
604 //////// End top by freq analysis |
824 //////// End top by freq analysis |
605 RegisterVariable('gencmd' , vtCommand, @chGenCmd , false); |
825 RegisterVariable('gencmd' , @chGenCmd , false); |
606 RegisterVariable('flag' , vtCommand, @chFlag , false); |
826 RegisterVariable('flag' , @chFlag , false); |
607 RegisterVariable('script' , vtCommand, @chScript , false); |
827 RegisterVariable('script' , @chScript , false); |
608 RegisterVariable('proto' , vtCommand, @chCheckProto , true ); |
828 RegisterVariable('proto' , @chCheckProto , true ); |
609 RegisterVariable('spectate', vtBoolean, @fastUntilLag , false); |
829 RegisterVariable('spectate', @chFastUntilLag , false); |
610 RegisterVariable('capture' , vtCommand, @chCapture , true ); |
830 RegisterVariable('capture' , @chCapture , true ); |
611 RegisterVariable('rotmask' , vtCommand, @chRotateMask , true ); |
831 RegisterVariable('rotmask' , @chRotateMask , true ); |
612 RegisterVariable('rdriven' , vtCommand, @chTeamLocal , false); |
832 RegisterVariable('rdriven' , @chTeamLocal , false); |
613 RegisterVariable('map' , vtCommand, @chSetMap , false); |
833 RegisterVariable('map' , @chSetMap , false); |
614 RegisterVariable('theme' , vtCommand, @chSetTheme , false); |
834 RegisterVariable('theme' , @chSetTheme , false); |
615 RegisterVariable('seed' , vtCommand, @chSetSeed , false); |
835 RegisterVariable('seed' , @chSetSeed , false); |
616 RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false); |
836 RegisterVariable('template_filter', @chTemplateFilter, false); |
617 RegisterVariable('mapgen' , vtLongInt, @cMapGen , false); |
837 RegisterVariable('mapgen' , @chMapGen , false); |
618 RegisterVariable('maze_size',vtLongInt, @cTemplateFilter, false); |
838 RegisterVariable('maze_size',@chTemplateFilter, false); |
619 RegisterVariable('delay' , vtLongInt, @cInactDelay , false); |
839 RegisterVariable('delay' , @chInactDelay , false); |
620 RegisterVariable('ready' , vtLongInt, @cReadyDelay , false); |
840 RegisterVariable('ready' , @chReadyDelay , false); |
621 RegisterVariable('casefreq', vtLongInt, @cCaseFactor , false); |
841 RegisterVariable('casefreq', @chCaseFactor , false); |
622 RegisterVariable('healthprob', vtLongInt, @cHealthCaseProb, false); |
842 RegisterVariable('healthprob', @chHealthCaseProb, false); |
623 RegisterVariable('hcaseamount', vtLongInt, @cHealthCaseAmount, false); |
843 RegisterVariable('hcaseamount', @chHealthCaseAmount, false); |
624 RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns , false); |
844 RegisterVariable('sd_turns', @chSuddenDTurns , false); |
625 RegisterVariable('waterrise', vtLongInt, @cWaterRise , false); |
845 RegisterVariable('waterrise', @chWaterRise , false); |
626 RegisterVariable('healthdec', vtLongInt, @cHealthDecrease, false); |
846 RegisterVariable('healthdec', @chHealthDecrease, false); |
627 RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false); |
847 RegisterVariable('damagepct',@chDamagePercent , false); |
628 RegisterVariable('ropepct' , vtLongInt, @cRopePercent , false); |
848 RegisterVariable('ropepct' , @chRopePercent , false); |
629 RegisterVariable('getawaytime' , vtLongInt, @cGetAwayTime , false); |
849 RegisterVariable('getawaytime' , @chGetAwayTime , false); |
630 RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false); |
850 RegisterVariable('minedudpct',@chMineDudPercent, false); |
631 RegisterVariable('minesnum', vtLongInt, @cLandMines , false); |
851 RegisterVariable('minesnum', @chLandMines , false); |
632 RegisterVariable('explosives',vtLongInt,@cExplosives , false); |
852 RegisterVariable('explosives',@chExplosives , false); |
633 RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); |
853 RegisterVariable('gmflags' , @chGameFlags , false); |
634 RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); |
854 RegisterVariable('turntime', @chHedgehogTurnTime, false); |
635 RegisterVariable('minestime',vtLongInt, @cMinesTime , false); |
855 RegisterVariable('minestime',@chMinesTime , false); |
636 RegisterVariable('fort' , vtCommand, @chFort , false); |
856 RegisterVariable('fort' , @chFort , false); |
637 RegisterVariable('grave' , vtCommand, @chGrave , false); |
857 RegisterVariable('grave' , @chGrave , false); |
638 RegisterVariable('hat' , vtCommand, @chSetHat , false); |
858 RegisterVariable('hat' , @chSetHat , false); |
639 RegisterVariable('quit' , vtCommand, @chQuit , true ); |
859 RegisterVariable('quit' , @chQuit , true ); |
640 RegisterVariable('forcequit', vtCommand, @chForceQuit , true ); |
860 RegisterVariable('forcequit', @chForceQuit , true ); |
641 RegisterVariable('confirm' , vtCommand, @chConfirm , true ); |
861 RegisterVariable('confirm' , @chConfirm , true ); |
642 RegisterVariable('halt', vtCommand, @chHalt , true ); |
862 RegisterVariable('halt', @chHalt , true ); |
643 RegisterVariable('+speedup', vtCommand, @chSpeedup_p , true ); |
863 RegisterVariable('+speedup', @chSpeedup_p , true ); |
644 RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); |
864 RegisterVariable('-speedup', @chSpeedup_m , true ); |
645 RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); |
865 RegisterVariable('zoomin' , @chZoomIn , true ); |
646 RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); |
866 RegisterVariable('zoomout' , @chZoomOut , true ); |
647 RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); |
867 RegisterVariable('zoomreset',@chZoomReset , true ); |
648 RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); |
868 RegisterVariable('ammomenu', @chAmmoMenu , true); |
649 RegisterVariable('+precise', vtCommand, @chPrecise_p , false); |
869 RegisterVariable('+precise', @chPrecise_p , false, true); |
650 RegisterVariable('-precise', vtCommand, @chPrecise_m , false); |
870 RegisterVariable('-precise', @chPrecise_m , false, true); |
651 RegisterVariable('switch' , vtCommand, @chSwitch , false); |
871 RegisterVariable('switch' , @chSwitch , false); |
652 RegisterVariable('timer' , vtCommand, @chTimer , false); |
872 RegisterVariable('timer' , @chTimer , false, true); |
653 RegisterVariable('taunt' , vtCommand, @chTaunt , false); |
873 RegisterVariable('taunt' , @chTaunt , false); |
654 RegisterVariable('put' , vtCommand, @chPut , false); |
874 RegisterVariable('put' , @chPut , false); |
655 RegisterVariable('+volup' , vtCommand, @chVol_p , true ); |
875 RegisterVariable('+volup' , @chVol_p , true ); |
656 RegisterVariable('-volup' , vtCommand, @chVol_m , true ); |
876 RegisterVariable('-volup' , @chVol_m , true ); |
657 RegisterVariable('+voldown', vtCommand, @chVol_m , true ); |
877 RegisterVariable('+voldown', @chVol_m , true ); |
658 RegisterVariable('-voldown', vtCommand, @chVol_p , true ); |
878 RegisterVariable('-voldown', @chVol_p , true ); |
659 RegisterVariable('findhh' , vtCommand, @chFindhh , true ); |
879 RegisterVariable('findhh' , @chFindhh , true ); |
660 RegisterVariable('pause' , vtCommand, @chPause , true ); |
880 RegisterVariable('pause' , @chPause , true ); |
661 RegisterVariable('+cur_u' , vtCommand, @chCurU_p , true ); |
881 RegisterVariable('+cur_u' , @chCurU_p , true ); |
662 RegisterVariable('-cur_u' , vtCommand, @chCurU_m , true ); |
882 RegisterVariable('-cur_u' , @chCurU_m , true ); |
663 RegisterVariable('+cur_d' , vtCommand, @chCurD_p , true ); |
883 RegisterVariable('+cur_d' , @chCurD_p , true ); |
664 RegisterVariable('-cur_d' , vtCommand, @chCurD_m , true ); |
884 RegisterVariable('-cur_d' , @chCurD_m , true ); |
665 RegisterVariable('+cur_l' , vtCommand, @chCurL_p , true ); |
885 RegisterVariable('+cur_l' , @chCurL_p , true ); |
666 RegisterVariable('-cur_l' , vtCommand, @chCurL_m , true ); |
886 RegisterVariable('-cur_l' , @chCurL_m , true ); |
667 RegisterVariable('+cur_r' , vtCommand, @chCurR_p , true ); |
887 RegisterVariable('+cur_r' , @chCurR_p , true ); |
668 RegisterVariable('-cur_r' , vtCommand, @chCurR_m , true ); |
888 RegisterVariable('-cur_r' , @chCurR_m , true ); |
|
889 RegisterVariable('campvar' , @chCampVar , true ); |
|
890 RegisterVariable('record' , @chRecord , true ); |
669 end; |
891 end; |
670 |
892 |
671 procedure freeModule; |
893 procedure freeModule; |
672 begin |
894 begin |
673 end; |
895 end; |