author | unc0rr |
Tue, 20 Sep 2011 00:00:22 +0400 | |
branch | 0.9.15 |
changeset 4781 | 39412dd371a7 |
parent 4751 | 849740a91d36 |
child 4845 | 9a0f5377c529 |
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); |
|
4744
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 |
|
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 |
|
309 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));{$ENDIF} |
|
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 |
{$IFDEF DEBUGFILE} |
|
351 |
AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks)); |
|
352 |
{$ENDIF} |
|
353 |
end; |
|
354 |
||
355 |
procedure chTimer(var s: shortstring); |
|
356 |
begin |
|
357 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit; |
|
358 |
||
359 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
|
360 |
bShowFinger:= false; |
|
361 |
with CurrentHedgehog^.Gear^ do |
|
362 |
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
|
363 |
Message:= Message or (gmTimer and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
364 |
MsgParam:= byte(s[1]) - ord('0'); |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
365 |
ScriptCall('onTimer'); |
4413 | 366 |
end |
367 |
end; |
|
368 |
||
369 |
procedure chSlot(var s: shortstring); |
|
370 |
var slot: LongWord; |
|
371 |
begin |
|
372 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
373 |
slot:= byte(s[1]) - 49; |
|
374 |
if slot > cMaxSlotIndex then exit; |
|
375 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
|
376 |
bShowFinger:= false; |
|
377 |
with CurrentHedgehog^.Gear^ do |
|
378 |
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
|
379 |
Message:= Message or (gmSlot and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
380 |
MsgParam:= slot; |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
381 |
ScriptCall('onSlot'); |
4413 | 382 |
end |
383 |
end; |
|
384 |
||
385 |
procedure chSetWeapon(var s: shortstring); |
|
386 |
begin |
|
387 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
388 |
||
389 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
|
390 |
||
391 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
392 |
||
393 |
with CurrentHedgehog^.Gear^ do |
|
394 |
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
|
395 |
Message:= Message or (gmWeapon and InputMask); |
4413 | 396 |
MsgParam:= byte(s[1]); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
397 |
ScriptCall('onSetWeapon'); |
4413 | 398 |
end; |
399 |
end; |
|
400 |
||
401 |
procedure chTaunt(var s: shortstring); |
|
402 |
begin |
|
403 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
404 |
||
405 |
if TWave(s[1]) > High(TWave) then exit; |
|
406 |
||
407 |
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
|
408 |
||
409 |
with CurrentHedgehog^.Gear^ do |
|
410 |
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
|
411 |
Message:= Message or (gmAnimate and InputMask); |
4661
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
412 |
MsgParam:= byte(s[1]) ; |
f5d858e4b634
Whole ton of script callbacks on commands. Poor engine.
mikade
parents:
4611
diff
changeset
|
413 |
ScriptCall('onTaunt'); |
4413 | 414 |
end |
415 |
end; |
|
416 |
||
417 |
procedure chPut(var s: shortstring); |
|
418 |
begin |
|
419 |
s:= s; // avoid compiler hint |
|
420 |
doPut(0, 0, false); |
|
421 |
end; |
|
422 |
||
423 |
procedure chCapture(var s: shortstring); |
|
424 |
begin |
|
425 |
s:= s; // avoid compiler hint |
|
426 |
flagMakeCapture:= true |
|
427 |
end; |
|
428 |
||
429 |
procedure chSetMap(var s: shortstring); |
|
430 |
begin |
|
431 |
if isDeveloperMode then |
|
432 |
begin |
|
433 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
|
434 |
InitStepsFlags:= InitStepsFlags or cifMap |
|
435 |
end |
|
436 |
end; |
|
437 |
||
438 |
procedure chSetTheme(var s: shortstring); |
|
439 |
begin |
|
440 |
if isDeveloperMode then |
|
441 |
begin |
|
442 |
Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; |
|
4611 | 443 |
Theme:= s; |
4413 | 444 |
InitStepsFlags:= InitStepsFlags or cifTheme |
445 |
end |
|
446 |
end; |
|
447 |
||
448 |
procedure chSetSeed(var s: shortstring); |
|
449 |
begin |
|
450 |
if isDeveloperMode then |
|
451 |
begin |
|
452 |
SetRandomSeed(s); |
|
453 |
cSeed:= s; |
|
454 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
|
455 |
end |
|
456 |
end; |
|
457 |
||
458 |
procedure chAmmoMenu(var s: shortstring); |
|
459 |
begin |
|
460 |
s:= s; // avoid compiler hint |
|
461 |
if CheckNoTeamOrHH then |
|
462 |
bShowAmmoMenu:= true |
|
463 |
else |
|
464 |
begin |
|
465 |
with CurrentTeam^ do |
|
466 |
with Hedgehogs[CurrHedgehog] do |
|
467 |
begin |
|
468 |
bSelected:= false; |
|
469 |
||
470 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
|
471 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or |
|
472 |
((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) or |
|
473 |
((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
474 |
end; |
|
475 |
end |
|
476 |
end; |
|
477 |
||
478 |
procedure chVol_p(var s: shortstring); |
|
479 |
begin |
|
480 |
s:= s; // avoid compiler hint |
|
481 |
inc(cVolumeDelta, 3) |
|
482 |
end; |
|
483 |
||
484 |
procedure chVol_m(var s: shortstring); |
|
485 |
begin |
|
486 |
s:= s; // avoid compiler hint |
|
487 |
dec(cVolumeDelta, 3) |
|
488 |
end; |
|
489 |
||
490 |
procedure chFindhh(var s: shortstring); |
|
491 |
begin |
|
492 |
s:= s; // avoid compiler hint |
|
493 |
if CheckNoTeamOrHH or isPaused then exit; |
|
494 |
bShowFinger:= true; |
|
495 |
FollowGear:= CurrentHedgehog^.Gear |
|
496 |
end; |
|
497 |
||
498 |
procedure chPause(var s: shortstring); |
|
499 |
begin |
|
500 |
s:= s; // avoid compiler hint |
|
501 |
if gameType <> gmtNet then |
|
502 |
isPaused:= not isPaused; |
|
503 |
SDL_ShowCursor(ord(isPaused)) |
|
504 |
end; |
|
505 |
||
506 |
procedure chRotateMask(var s: shortstring); |
|
507 |
begin |
|
508 |
s:= s; // avoid compiler hint |
|
509 |
if ((GameFlags and gfInvulnerable) = 0) then cTagsMask:= cTagsMasks[cTagsMask] else cTagsMask:= cTagsMasksNoHealth[cTagsMask]; |
|
510 |
end; |
|
511 |
||
512 |
procedure chSpeedup_p(var s: shortstring); |
|
513 |
begin |
|
514 |
s:= s; // avoid compiler hint |
|
515 |
isSpeed:= true |
|
516 |
end; |
|
517 |
||
518 |
procedure chSpeedup_m(var s: shortstring); |
|
519 |
begin |
|
520 |
s:= s; // avoid compiler hint |
|
521 |
isSpeed:= false |
|
522 |
end; |
|
523 |
||
524 |
procedure chZoomIn(var s: shortstring); |
|
525 |
begin |
|
526 |
s:= s; // avoid compiler hint |
|
527 |
if ZoomValue < cMinZoomLevel then |
|
528 |
ZoomValue:= ZoomValue + cZoomDelta; |
|
529 |
end; |
|
530 |
||
531 |
procedure chZoomOut(var s: shortstring); |
|
532 |
begin |
|
533 |
s:= s; // avoid compiler hint |
|
534 |
if ZoomValue > cMaxZoomLevel then |
|
535 |
ZoomValue:= ZoomValue - cZoomDelta; |
|
536 |
end; |
|
537 |
||
538 |
procedure chZoomReset(var s: shortstring); |
|
539 |
begin |
|
540 |
s:= s; // avoid compiler hint |
|
541 |
ZoomValue:= cDefaultZoomLevel; |
|
542 |
end; |
|
543 |
||
544 |
||
545 |
procedure initModule; |
|
546 |
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
|
547 |
//////// 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
|
548 |
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
|
549 |
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
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
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
|
554 |
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
|
555 |
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
|
556 |
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
|
557 |
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
|
558 |
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
|
559 |
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
|
560 |
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
|
561 |
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
|
562 |
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
|
563 |
//////// End top by freq analysis |
4531
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
564 |
RegisterVariable('gencmd' , vtCommand, @chGenCmd , false); |
4413 | 565 |
RegisterVariable('flag' , vtCommand, @chFlag , false); |
566 |
RegisterVariable('script' , vtCommand, @chScript , false); |
|
567 |
RegisterVariable('proto' , vtCommand, @chCheckProto , true ); |
|
568 |
RegisterVariable('spectate', vtBoolean, @fastUntilLag , false); |
|
569 |
RegisterVariable('capture' , vtCommand, @chCapture , true ); |
|
570 |
RegisterVariable('rotmask' , vtCommand, @chRotateMask , true ); |
|
571 |
RegisterVariable('rdriven' , vtCommand, @chTeamLocal , false); |
|
572 |
RegisterVariable('map' , vtCommand, @chSetMap , false); |
|
573 |
RegisterVariable('theme' , vtCommand, @chSetTheme , false); |
|
574 |
RegisterVariable('seed' , vtCommand, @chSetSeed , false); |
|
575 |
RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false); |
|
576 |
RegisterVariable('mapgen' , vtLongInt, @cMapGen , false); |
|
577 |
RegisterVariable('maze_size',vtLongInt, @cMazeSize , false); |
|
578 |
RegisterVariable('delay' , vtLongInt, @cInactDelay , false); |
|
579 |
RegisterVariable('ready' , vtLongInt, @cReadyDelay , false); |
|
580 |
RegisterVariable('casefreq', vtLongInt, @cCaseFactor , false); |
|
581 |
RegisterVariable('healthprob', vtLongInt, @cHealthCaseProb, false); |
|
582 |
RegisterVariable('hcaseamount', vtLongInt, @cHealthCaseAmount, false); |
|
583 |
RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns , false); |
|
584 |
RegisterVariable('waterrise', vtLongInt, @cWaterRise , false); |
|
585 |
RegisterVariable('healthdec', vtLongInt, @cHealthDecrease, false); |
|
586 |
RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false); |
|
587 |
RegisterVariable('ropepct' , vtLongInt, @cRopePercent , false); |
|
588 |
RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false); |
|
589 |
RegisterVariable('minesnum', vtLongInt, @cLandMines , false); |
|
590 |
RegisterVariable('explosives',vtLongInt,@cExplosives , false); |
|
591 |
RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); |
|
592 |
RegisterVariable('trflags' , vtLongInt, @TrainingFlags , false); |
|
593 |
RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); |
|
594 |
RegisterVariable('minestime',vtLongInt, @cMinesTime , false); |
|
595 |
RegisterVariable('fort' , vtCommand, @chFort , false); |
|
596 |
RegisterVariable('grave' , vtCommand, @chGrave , false); |
|
597 |
RegisterVariable('hat' , vtCommand, @chSetHat , false); |
|
598 |
RegisterVariable('quit' , vtCommand, @chQuit , true ); |
|
4744
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
599 |
RegisterVariable('forcequit', vtCommand, @chForceQuit , true ); |
4413 | 600 |
RegisterVariable('confirm' , vtCommand, @chConfirm , true ); |
4751 | 601 |
RegisterVariable('halt', vtCommand, @chHalt , true ); |
4413 | 602 |
RegisterVariable('+speedup', vtCommand, @chSpeedup_p , true ); |
603 |
RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); |
|
604 |
RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); |
|
605 |
RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); |
|
606 |
RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); |
|
607 |
RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); |
|
608 |
RegisterVariable('+precise', vtCommand, @chPrecise_p , false); |
|
609 |
RegisterVariable('-precise', vtCommand, @chPrecise_m , false); |
|
610 |
RegisterVariable('switch' , vtCommand, @chSwitch , false); |
|
611 |
RegisterVariable('timer' , vtCommand, @chTimer , false); |
|
612 |
RegisterVariable('taunt' , vtCommand, @chTaunt , false); |
|
613 |
RegisterVariable('put' , vtCommand, @chPut , false); |
|
614 |
RegisterVariable('+volup' , vtCommand, @chVol_p , true ); |
|
615 |
RegisterVariable('-volup' , vtCommand, @chVol_m , true ); |
|
616 |
RegisterVariable('+voldown', vtCommand, @chVol_m , true ); |
|
617 |
RegisterVariable('-voldown', vtCommand, @chVol_p , true ); |
|
618 |
RegisterVariable('findhh' , vtCommand, @chFindhh , true ); |
|
619 |
RegisterVariable('pause' , vtCommand, @chPause , true ); |
|
620 |
RegisterVariable('+cur_u' , vtCommand, @chCurU_p , true ); |
|
621 |
RegisterVariable('-cur_u' , vtCommand, @chCurU_m , true ); |
|
622 |
RegisterVariable('+cur_d' , vtCommand, @chCurD_p , true ); |
|
623 |
RegisterVariable('-cur_d' , vtCommand, @chCurD_m , true ); |
|
624 |
RegisterVariable('+cur_l' , vtCommand, @chCurL_p , true ); |
|
625 |
RegisterVariable('-cur_l' , vtCommand, @chCurL_m , true ); |
|
626 |
RegisterVariable('+cur_r' , vtCommand, @chCurR_p , true ); |
|
627 |
RegisterVariable('-cur_r' , vtCommand, @chCurR_m , true ); |
|
628 |
end; |
|
629 |
||
630 |
procedure freeModule; |
|
631 |
begin |
|
632 |
end; |
|
633 |
||
634 |
end. |