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