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