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