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