author | koda |
Mon, 25 Jul 2011 01:18:51 +0200 | |
changeset 5453 | ea6f7631df4a |
parent 5352 | 7f57d0c7816a |
child 5385 | a864a0aeed96 |
child 5523 | 9ac5acc4f3e5 |
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 |
|
5247 | 29 |
uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions; |
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); |
5247 | 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]); |
5247 | 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 |
|
5352
7f57d0c7816a
Fix random weapons with per-hog ammo, fix ammo store loadout number in scripting for per-clan and per-hog ammo, add an advanced script hook into parsecommand to override values, add check for empty map in chSetMap, load script earlier in game params from frontend
nemo
parents:
5247
diff
changeset
|
448 |
if isDeveloperMode and (s <> '') then |
4413 | 449 |
begin |
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5026
diff
changeset
|
450 |
UserPathz[ptMapCurrent]:= UserPathz[ptMaps] + '/' + s; |
4413 | 451 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
452 |
InitStepsFlags:= InitStepsFlags or cifMap |
|
453 |
end |
|
454 |
end; |
|
455 |
||
456 |
procedure chSetTheme(var s: shortstring); |
|
457 |
begin |
|
458 |
if isDeveloperMode then |
|
459 |
begin |
|
5238
46ddaf14509d
Enable ~/.hedgewars/Data (or platform equivalent) to override/extend pretty much everything in system Data dir. Obviously desyncing can occur, so this is at user's own risk. Should simplify map etc install. Needs testing.
nemo
parents:
5026
diff
changeset
|
460 |
UserPathz[ptCurrTheme]:= UserPathz[ptThemes] + '/' + s; |
4413 | 461 |
Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; |
4611 | 462 |
Theme:= s; |
4413 | 463 |
InitStepsFlags:= InitStepsFlags or cifTheme |
464 |
end |
|
465 |
end; |
|
466 |
||
467 |
procedure chSetSeed(var s: shortstring); |
|
468 |
begin |
|
469 |
if isDeveloperMode then |
|
470 |
begin |
|
471 |
SetRandomSeed(s); |
|
472 |
cSeed:= s; |
|
473 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
|
474 |
end |
|
475 |
end; |
|
476 |
||
477 |
procedure chAmmoMenu(var s: shortstring); |
|
478 |
begin |
|
479 |
s:= s; // avoid compiler hint |
|
480 |
if CheckNoTeamOrHH then |
|
481 |
bShowAmmoMenu:= true |
|
482 |
else |
|
483 |
begin |
|
484 |
with CurrentTeam^ do |
|
485 |
with Hedgehogs[CurrHedgehog] do |
|
486 |
begin |
|
487 |
bSelected:= false; |
|
488 |
||
489 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
|
490 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or |
|
491 |
((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) or |
|
492 |
((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
493 |
end; |
|
494 |
end |
|
495 |
end; |
|
496 |
||
497 |
procedure chVol_p(var s: shortstring); |
|
498 |
begin |
|
499 |
s:= s; // avoid compiler hint |
|
500 |
inc(cVolumeDelta, 3) |
|
501 |
end; |
|
502 |
||
503 |
procedure chVol_m(var s: shortstring); |
|
504 |
begin |
|
505 |
s:= s; // avoid compiler hint |
|
506 |
dec(cVolumeDelta, 3) |
|
507 |
end; |
|
508 |
||
509 |
procedure chFindhh(var s: shortstring); |
|
510 |
begin |
|
511 |
s:= s; // avoid compiler hint |
|
512 |
if CheckNoTeamOrHH or isPaused then exit; |
|
5247 | 513 |
|
514 |
if FollowGear <> nil then |
|
515 |
begin |
|
516 |
AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume); |
|
517 |
autoCameraOn:= false |
|
518 |
end |
|
519 |
else begin |
|
520 |
AddCaption('Auto Camera On', $CCCCCC, capgrpVolume); |
|
521 |
bShowFinger:= true; |
|
522 |
FollowGear:= CurrentHedgehog^.Gear; |
|
523 |
autoCameraOn:= true |
|
524 |
end |
|
4413 | 525 |
end; |
526 |
||
527 |
procedure chPause(var s: shortstring); |
|
528 |
begin |
|
529 |
s:= s; // avoid compiler hint |
|
530 |
if gameType <> gmtNet then |
|
531 |
isPaused:= not isPaused; |
|
532 |
SDL_ShowCursor(ord(isPaused)) |
|
533 |
end; |
|
534 |
||
535 |
procedure chRotateMask(var s: shortstring); |
|
536 |
begin |
|
537 |
s:= s; // avoid compiler hint |
|
538 |
if ((GameFlags and gfInvulnerable) = 0) then cTagsMask:= cTagsMasks[cTagsMask] else cTagsMask:= cTagsMasksNoHealth[cTagsMask]; |
|
539 |
end; |
|
540 |
||
541 |
procedure chSpeedup_p(var s: shortstring); |
|
542 |
begin |
|
543 |
s:= s; // avoid compiler hint |
|
544 |
isSpeed:= true |
|
545 |
end; |
|
546 |
||
547 |
procedure chSpeedup_m(var s: shortstring); |
|
548 |
begin |
|
549 |
s:= s; // avoid compiler hint |
|
550 |
isSpeed:= false |
|
551 |
end; |
|
552 |
||
553 |
procedure chZoomIn(var s: shortstring); |
|
554 |
begin |
|
555 |
s:= s; // avoid compiler hint |
|
556 |
if ZoomValue < cMinZoomLevel then |
|
557 |
ZoomValue:= ZoomValue + cZoomDelta; |
|
558 |
end; |
|
559 |
||
560 |
procedure chZoomOut(var s: shortstring); |
|
561 |
begin |
|
562 |
s:= s; // avoid compiler hint |
|
563 |
if ZoomValue > cMaxZoomLevel then |
|
564 |
ZoomValue:= ZoomValue - cZoomDelta; |
|
565 |
end; |
|
566 |
||
567 |
procedure chZoomReset(var s: shortstring); |
|
568 |
begin |
|
569 |
s:= s; // avoid compiler hint |
|
570 |
ZoomValue:= cDefaultZoomLevel; |
|
571 |
end; |
|
572 |
||
573 |
||
574 |
procedure initModule; |
|
575 |
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
|
576 |
//////// 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
|
577 |
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
|
578 |
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
|
579 |
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
|
580 |
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
|
581 |
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
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
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
|
586 |
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
|
587 |
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
|
588 |
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
|
589 |
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
|
590 |
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
|
591 |
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
|
592 |
//////// End top by freq analysis |
4531
4ea193b0e378
Reenable ReadyTimer using a synced message NEEDS TESTING.
nemo
parents:
4528
diff
changeset
|
593 |
RegisterVariable('gencmd' , vtCommand, @chGenCmd , false); |
4413 | 594 |
RegisterVariable('flag' , vtCommand, @chFlag , false); |
595 |
RegisterVariable('script' , vtCommand, @chScript , false); |
|
596 |
RegisterVariable('proto' , vtCommand, @chCheckProto , true ); |
|
597 |
RegisterVariable('spectate', vtBoolean, @fastUntilLag , false); |
|
598 |
RegisterVariable('capture' , vtCommand, @chCapture , true ); |
|
599 |
RegisterVariable('rotmask' , vtCommand, @chRotateMask , true ); |
|
600 |
RegisterVariable('rdriven' , vtCommand, @chTeamLocal , false); |
|
601 |
RegisterVariable('map' , vtCommand, @chSetMap , false); |
|
602 |
RegisterVariable('theme' , vtCommand, @chSetTheme , false); |
|
603 |
RegisterVariable('seed' , vtCommand, @chSetSeed , false); |
|
604 |
RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false); |
|
605 |
RegisterVariable('mapgen' , vtLongInt, @cMapGen , false); |
|
606 |
RegisterVariable('maze_size',vtLongInt, @cMazeSize , false); |
|
607 |
RegisterVariable('delay' , vtLongInt, @cInactDelay , false); |
|
608 |
RegisterVariable('ready' , vtLongInt, @cReadyDelay , false); |
|
609 |
RegisterVariable('casefreq', vtLongInt, @cCaseFactor , false); |
|
610 |
RegisterVariable('healthprob', vtLongInt, @cHealthCaseProb, false); |
|
611 |
RegisterVariable('hcaseamount', vtLongInt, @cHealthCaseAmount, false); |
|
612 |
RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns , false); |
|
613 |
RegisterVariable('waterrise', vtLongInt, @cWaterRise , false); |
|
614 |
RegisterVariable('healthdec', vtLongInt, @cHealthDecrease, false); |
|
615 |
RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false); |
|
616 |
RegisterVariable('ropepct' , vtLongInt, @cRopePercent , false); |
|
5026 | 617 |
RegisterVariable('getawaytime' , vtLongInt, @cGetAwayTime , false); |
4413 | 618 |
RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false); |
619 |
RegisterVariable('minesnum', vtLongInt, @cLandMines , false); |
|
620 |
RegisterVariable('explosives',vtLongInt,@cExplosives , false); |
|
621 |
RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); |
|
622 |
RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); |
|
623 |
RegisterVariable('minestime',vtLongInt, @cMinesTime , false); |
|
624 |
RegisterVariable('fort' , vtCommand, @chFort , false); |
|
625 |
RegisterVariable('grave' , vtCommand, @chGrave , false); |
|
626 |
RegisterVariable('hat' , vtCommand, @chSetHat , false); |
|
627 |
RegisterVariable('quit' , vtCommand, @chQuit , true ); |
|
4744
ecc2c757d0df
general uKey refactor in preparaiton of two new shortcuts
koda
parents:
4661
diff
changeset
|
628 |
RegisterVariable('forcequit', vtCommand, @chForceQuit , true ); |
4413 | 629 |
RegisterVariable('confirm' , vtCommand, @chConfirm , true ); |
4751 | 630 |
RegisterVariable('halt', vtCommand, @chHalt , true ); |
4413 | 631 |
RegisterVariable('+speedup', vtCommand, @chSpeedup_p , true ); |
632 |
RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); |
|
633 |
RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); |
|
634 |
RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); |
|
635 |
RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); |
|
636 |
RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); |
|
637 |
RegisterVariable('+precise', vtCommand, @chPrecise_p , false); |
|
638 |
RegisterVariable('-precise', vtCommand, @chPrecise_m , false); |
|
639 |
RegisterVariable('switch' , vtCommand, @chSwitch , false); |
|
640 |
RegisterVariable('timer' , vtCommand, @chTimer , false); |
|
641 |
RegisterVariable('taunt' , vtCommand, @chTaunt , false); |
|
642 |
RegisterVariable('put' , vtCommand, @chPut , false); |
|
643 |
RegisterVariable('+volup' , vtCommand, @chVol_p , true ); |
|
644 |
RegisterVariable('-volup' , vtCommand, @chVol_m , true ); |
|
645 |
RegisterVariable('+voldown', vtCommand, @chVol_m , true ); |
|
646 |
RegisterVariable('-voldown', vtCommand, @chVol_p , true ); |
|
647 |
RegisterVariable('findhh' , vtCommand, @chFindhh , true ); |
|
648 |
RegisterVariable('pause' , vtCommand, @chPause , true ); |
|
649 |
RegisterVariable('+cur_u' , vtCommand, @chCurU_p , true ); |
|
650 |
RegisterVariable('-cur_u' , vtCommand, @chCurU_m , true ); |
|
651 |
RegisterVariable('+cur_d' , vtCommand, @chCurD_p , true ); |
|
652 |
RegisterVariable('-cur_d' , vtCommand, @chCurD_m , true ); |
|
653 |
RegisterVariable('+cur_l' , vtCommand, @chCurL_p , true ); |
|
654 |
RegisterVariable('-cur_l' , vtCommand, @chCurL_m , true ); |
|
655 |
RegisterVariable('+cur_r' , vtCommand, @chCurR_p , true ); |
|
656 |
RegisterVariable('-cur_r' , vtCommand, @chCurR_m , true ); |
|
657 |
end; |
|
658 |
||
659 |
procedure freeModule; |
|
660 |
begin |
|
661 |
end; |
|
662 |
||
663 |
end. |