author | unc0rr |
Tue, 13 Jan 2009 18:56:14 +0000 | |
changeset 1659 | fd593a5e71fb |
parent 1656 | 209cf0e2fc36 |
child 1743 | ebc54f5fe4e7 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1656
209cf0e2fc36
Finish voicepacks support in engine (not tested though)
unc0rr
parents:
1654
diff
changeset
|
3 |
* Copyright (c) 2004-2009 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 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 |
|
4 | 8 |
* |
183 | 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. |
|
4 | 13 |
* |
183 | 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 |
|
4 | 17 |
*) |
18 |
||
19 |
function CheckNoTeamOrHH: boolean; |
|
351 | 20 |
var Result: boolean; |
4 | 21 |
begin |
602 | 22 |
Result:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil); |
4 | 23 |
{$IFDEF DEBUGFILE} |
24 |
if Result then |
|
25 |
if CurrentTeam = nil then AddFileLog('CONSOLE: CurTeam = nil') |
|
351 | 26 |
else AddFileLog('CONSOLE: CurTeam <> nil, Gear = nil'); |
4 | 27 |
{$ENDIF} |
351 | 28 |
CheckNoTeamOrHH:= Result |
4 | 29 |
end; |
30 |
//////////////////////////////////////////////////////////////////////////////// |
|
31 |
procedure chQuit(var s: shortstring); |
|
1022 | 32 |
const prevGState: TGameState = gsConfirm; |
4 | 33 |
begin |
1022 | 34 |
if GameState <> gsConfirm then |
35 |
begin |
|
36 |
prevGState:= GameState; |
|
37 |
GameState:= gsConfirm |
|
38 |
end else |
|
39 |
GameState:= prevGState |
|
40 |
end; |
|
41 |
||
42 |
procedure chConfirm(var s: shortstring); |
|
43 |
begin |
|
44 |
if GameState = gsConfirm then |
|
45 |
begin |
|
46 |
SendIPC('Q'); |
|
47 |
GameState:= gsExit |
|
48 |
end |
|
4 | 49 |
end; |
50 |
||
205 | 51 |
procedure chCheckProto(var s: shortstring); |
371 | 52 |
var i, c: LongInt; |
205 | 53 |
begin |
54 |
if isDeveloperMode then |
|
55 |
begin |
|
56 |
val(s, i, c); |
|
57 |
if (c <> 0) or (i = 0) then exit; |
|
58 |
TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true); |
|
59 |
TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true) |
|
60 |
end |
|
61 |
end; |
|
62 |
||
4 | 63 |
procedure chAddTeam(var s: shortstring); |
549 | 64 |
var Color: Longword; |
605 | 65 |
ts: shortstring; |
4 | 66 |
begin |
145 | 67 |
if isDeveloperMode then |
68 |
begin |
|
605 | 69 |
SplitBySpace(s, ts); |
549 | 70 |
val(s, Color); |
71 |
TryDo(Color <> 0, 'Error: black team color', true); |
|
351 | 72 |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset
|
73 |
Color:= Color or $FF000000; |
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset
|
74 |
|
549 | 75 |
AddTeam(Color); |
605 | 76 |
CurrentTeam^.TeamName:= ts; |
1654 | 77 |
if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true; |
78 |
||
79 |
CurrentTeam^.voicepack:= AskForVoicepack('Default') |
|
546 | 80 |
end |
4 | 81 |
end; |
82 |
||
83 |
procedure chTeamLocal(var s: shortstring); |
|
84 |
begin |
|
85 |
if not isDeveloperMode then exit; |
|
86 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
|
351 | 87 |
CurrentTeam^.ExtDriven:= true |
4 | 88 |
end; |
89 |
||
90 |
procedure chGrave(var s: shortstring); |
|
91 |
begin |
|
92 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
93 |
if s[1]='"' then Delete(s, 1, 1); |
|
94 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 95 |
CurrentTeam^.GraveName:= s |
4 | 96 |
end; |
97 |
||
98 |
procedure chFort(var s: shortstring); |
|
99 |
begin |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
753
diff
changeset
|
100 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); |
4 | 101 |
if s[1]='"' then Delete(s, 1, 1); |
102 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 103 |
CurrentTeam^.FortName:= s |
4 | 104 |
end; |
105 |
||
1654 | 106 |
procedure chVoicepack(var s: shortstring); |
107 |
begin |
|
108 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true); |
|
109 |
if s[1]='"' then Delete(s, 1, 1); |
|
110 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
111 |
CurrentTeam^.voicepack:= AskForVoicepack(s) |
|
112 |
end; |
|
113 |
||
312 | 114 |
procedure chAddHH(var id: shortstring); |
4 | 115 |
var s: shortstring; |
116 |
Gear: PGear; |
|
117 |
begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
118 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
312 | 119 |
with CurrentTeam^ do |
1242 | 120 |
begin |
121 |
SplitBySpace(id, s); |
|
122 |
CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
|
123 |
val(id, CurrentHedgehog^.BotLevel); |
|
124 |
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
|
125 |
SplitBySpace(s, id); |
|
126 |
val(s, Gear^.Health); |
|
127 |
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
|
128 |
PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; |
|
129 |
CurrentHedgehog^.AmmoStore:= TeamsCount - 1; // FIXME HACK to get ammostores work |
|
130 |
CurrentHedgehog^.Gear:= Gear; |
|
131 |
CurrentHedgehog^.Name:= id; |
|
132 |
inc(HedgehogsNumber) |
|
133 |
end |
|
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 |
if s = '' then |
|
141 |
CurrentHedgehog^.Hat:= 'NoHat' |
|
142 |
else |
|
143 |
CurrentHedgehog^.Hat:= s |
|
4 | 144 |
end; |
145 |
||
604
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
146 |
procedure chSetHHCoords(var x: shortstring); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
147 |
var y: shortstring; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
148 |
t: Longint; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
149 |
begin |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
150 |
if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then exit; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
151 |
SplitBySpace(x, y); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
152 |
val(x, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
153 |
CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
154 |
val(y, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
155 |
CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
156 |
end; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
157 |
|
288 | 158 |
procedure chAddAmmoStore(var descr: shortstring); |
159 |
begin |
|
160 |
AddAmmoStore(descr) |
|
161 |
end; |
|
162 |
||
4 | 163 |
procedure chBind(var id: shortstring); |
164 |
var s: shortstring; |
|
371 | 165 |
b: LongInt; |
4 | 166 |
begin |
167 |
if CurrentTeam = nil then exit; |
|
168 |
SplitBySpace(id, s); |
|
169 |
if s[1]='"' then Delete(s, 1, 1); |
|
170 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
171 |
b:= KeyNameToCode(id); |
|
351 | 172 |
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
173 |
else CurrentTeam^.Binds[b]:= s |
|
4 | 174 |
end; |
175 |
||
176 |
procedure chLeft_p(var s: shortstring); |
|
177 |
begin |
|
178 |
if CheckNoTeamOrHH then exit; |
|
176 | 179 |
bShowFinger:= false; |
351 | 180 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
602 | 181 |
with CurrentHedgehog^.Gear^ do |
4 | 182 |
Message:= Message or gm_Left |
183 |
end; |
|
184 |
||
185 |
procedure chLeft_m(var s: shortstring); |
|
186 |
begin |
|
187 |
if CheckNoTeamOrHH then exit; |
|
351 | 188 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
602 | 189 |
with CurrentHedgehog^.Gear^ do |
4 | 190 |
Message:= Message and not gm_Left |
191 |
end; |
|
192 |
||
193 |
procedure chRight_p(var s: shortstring); |
|
194 |
begin |
|
195 |
if CheckNoTeamOrHH then exit; |
|
176 | 196 |
bShowFinger:= false; |
351 | 197 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
602 | 198 |
with CurrentHedgehog^.Gear^ do |
4 | 199 |
Message:= Message or gm_Right |
200 |
end; |
|
201 |
||
202 |
procedure chRight_m(var s: shortstring); |
|
203 |
begin |
|
204 |
if CheckNoTeamOrHH then exit; |
|
351 | 205 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
602 | 206 |
with CurrentHedgehog^.Gear^ do |
4 | 207 |
Message:= Message and not gm_Right |
208 |
end; |
|
209 |
||
210 |
procedure chUp_p(var s: shortstring); |
|
211 |
begin |
|
212 |
if CheckNoTeamOrHH then exit; |
|
176 | 213 |
bShowFinger:= false; |
351 | 214 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
602 | 215 |
with CurrentHedgehog^.Gear^ do |
4 | 216 |
Message:= Message or gm_Up |
217 |
end; |
|
218 |
||
219 |
procedure chUp_m(var s: shortstring); |
|
220 |
begin |
|
221 |
if CheckNoTeamOrHH then exit; |
|
351 | 222 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
602 | 223 |
with CurrentHedgehog^.Gear^ do |
4 | 224 |
Message:= Message and not gm_Up |
225 |
end; |
|
226 |
||
227 |
procedure chDown_p(var s: shortstring); |
|
228 |
begin |
|
229 |
if CheckNoTeamOrHH then exit; |
|
176 | 230 |
bShowFinger:= false; |
351 | 231 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
602 | 232 |
with CurrentHedgehog^.Gear^ do |
4 | 233 |
Message:= Message or gm_Down |
234 |
end; |
|
235 |
||
236 |
procedure chDown_m(var s: shortstring); |
|
237 |
begin |
|
238 |
if CheckNoTeamOrHH then exit; |
|
351 | 239 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
602 | 240 |
with CurrentHedgehog^.Gear^ do |
4 | 241 |
Message:= Message and not gm_Down |
242 |
end; |
|
243 |
||
1639 | 244 |
procedure chPrecise_p(var s: shortstring); |
245 |
begin |
|
246 |
if CheckNoTeamOrHH then exit; |
|
247 |
bShowFinger:= false; |
|
248 |
if not CurrentTeam^.ExtDriven then SendIPC('Z'); |
|
249 |
with CurrentHedgehog^.Gear^ do |
|
250 |
Message:= Message or gm_Precise |
|
251 |
end; |
|
252 |
||
253 |
procedure chPrecise_m(var s: shortstring); |
|
254 |
begin |
|
255 |
if CheckNoTeamOrHH then exit; |
|
256 |
if not CurrentTeam^.ExtDriven then SendIPC('z'); |
|
257 |
with CurrentHedgehog^.Gear^ do |
|
258 |
Message:= Message and not gm_Precise |
|
259 |
end; |
|
260 |
||
4 | 261 |
procedure chLJump(var s: shortstring); |
262 |
begin |
|
263 |
if CheckNoTeamOrHH then exit; |
|
176 | 264 |
bShowFinger:= false; |
351 | 265 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
602 | 266 |
with CurrentHedgehog^.Gear^ do |
4 | 267 |
Message:= Message or gm_LJump |
268 |
end; |
|
269 |
||
270 |
procedure chHJump(var s: shortstring); |
|
271 |
begin |
|
272 |
if CheckNoTeamOrHH then exit; |
|
176 | 273 |
bShowFinger:= false; |
351 | 274 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
602 | 275 |
with CurrentHedgehog^.Gear^ do |
4 | 276 |
Message:= Message or gm_HJump |
277 |
end; |
|
278 |
||
279 |
procedure chAttack_p(var s: shortstring); |
|
280 |
begin |
|
281 |
if CheckNoTeamOrHH then exit; |
|
176 | 282 |
bShowFinger:= false; |
602 | 283 |
with CurrentHedgehog^.Gear^ do |
4 | 284 |
begin |
351 | 285 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
927
diff
changeset
|
286 |
if ((State and gstHHDriven) <> 0) then |
4 | 287 |
begin |
602 | 288 |
FollowGear:= CurrentHedgehog^.Gear; |
351 | 289 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
4 | 290 |
Message:= Message or gm_Attack |
291 |
end |
|
292 |
end |
|
293 |
end; |
|
294 |
||
295 |
procedure chAttack_m(var s: shortstring); |
|
296 |
begin |
|
297 |
if CheckNoTeamOrHH then exit; |
|
602 | 298 |
with CurrentHedgehog^.Gear^ do |
4 | 299 |
begin |
351 | 300 |
if not CurrentTeam^.ExtDriven and |
95 | 301 |
((Message and gm_Attack) <> 0) then SendIPC('a'); |
302 |
Message:= Message and not gm_Attack |
|
4 | 303 |
end |
304 |
end; |
|
305 |
||
306 |
procedure chSwitch(var s: shortstring); |
|
307 |
begin |
|
308 |
if CheckNoTeamOrHH then exit; |
|
351 | 309 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
602 | 310 |
with CurrentHedgehog^.Gear^ do |
4 | 311 |
Message:= Message or gm_Switch |
312 |
end; |
|
313 |
||
314 |
procedure chNextTurn(var s: shortstring); |
|
315 |
begin |
|
316 |
if AllInactive then |
|
317 |
begin |
|
351 | 318 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
593 | 319 |
TickTrigger(trigTurns); |
4 | 320 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
321 |
end |
|
322 |
end; |
|
323 |
||
324 |
procedure chSay(var s: shortstring); |
|
325 |
begin |
|
1356 | 326 |
SendIPC('s' + s); |
1378 | 327 |
|
328 |
if copy(s, 1, 4) = '/me ' then |
|
1379 | 329 |
s:= '* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) |
1378 | 330 |
else |
331 |
s:= UserNick + ': ' + s; |
|
332 |
||
1356 | 333 |
AddChatString(s) |
4 | 334 |
end; |
335 |
||
336 |
procedure chTimer(var s: shortstring); |
|
337 |
begin |
|
338 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; |
|
176 | 339 |
bShowFinger:= false; |
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
340 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
341 |
with CurrentHedgehog^.Gear^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
342 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
343 |
Message:= Message or gm_Timer; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
344 |
MsgParam:= byte(s[1]) - ord('0') |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
345 |
end |
4 | 346 |
end; |
347 |
||
348 |
procedure chSlot(var s: shortstring); |
|
349 |
var slot: LongWord; |
|
350 |
begin |
|
95 | 351 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 352 |
bShowFinger:= false; |
4 | 353 |
slot:= byte(s[1]) - 49; |
10 | 354 |
if slot > cMaxSlotIndex then exit; |
351 | 355 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
783 | 356 |
with CurrentHedgehog^.Gear^ do |
4 | 357 |
begin |
783 | 358 |
Message:= Message or gm_Slot; |
359 |
MsgParam:= slot |
|
360 |
end |
|
361 |
end; |
|
362 |
||
363 |
procedure chSetWeapon(var s: shortstring); |
|
364 |
begin |
|
365 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
784 | 366 |
|
367 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
|
368 |
||
369 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
370 |
||
783 | 371 |
with CurrentHedgehog^.Gear^ do |
372 |
begin |
|
373 |
Message:= Message or gm_Weapon; |
|
784 | 374 |
MsgParam:= byte(s[1]) |
4 | 375 |
end |
376 |
end; |
|
377 |
||
1035 | 378 |
procedure chTaunt(var s: shortstring); |
379 |
begin |
|
380 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
381 |
||
382 |
if TWave(s[1]) > High(TWave) then exit; |
|
383 |
||
384 |
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
|
385 |
||
386 |
with CurrentHedgehog^.Gear^ do |
|
387 |
begin |
|
388 |
Message:= Message or gm_Animate; |
|
389 |
MsgParam:= byte(s[1]) |
|
390 |
end |
|
391 |
end; |
|
392 |
||
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
393 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 394 |
begin |
395 |
if CheckNoTeamOrHH then exit; |
|
162 | 396 |
if bShowAmmoMenu then |
397 |
begin |
|
398 |
bSelected:= true; |
|
399 |
exit |
|
400 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
401 |
|
602 | 402 |
with CurrentHedgehog^.Gear^, |
403 |
CurrentHedgehog^ do |
|
4 | 404 |
if (State and gstHHChooseTarget) <> 0 then |
405 |
begin |
|
406 |
isCursorVisible:= false; |
|
351 | 407 |
if not CurrentTeam^.ExtDriven then |
4 | 408 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
409 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
410 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
411 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
412 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
413 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
414 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
415 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
416 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
417 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
418 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
419 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 420 |
end; |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
421 |
State:= State and not gstHHChooseTarget; |
351 | 422 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 423 |
Message:= Message or gm_Attack; |
351 | 424 |
end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false) |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
425 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
426 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
427 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
428 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
429 |
doPut(0, 0, false) |
4 | 430 |
end; |
431 |
||
432 |
procedure chCapture(var s: shortstring); |
|
433 |
begin |
|
434 |
flagMakeCapture:= true |
|
435 |
end; |
|
436 |
||
48 | 437 |
procedure chSkip(var s: shortstring); |
438 |
begin |
|
351 | 439 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 440 |
uStats.Skipped; |
917 | 441 |
skipFlag:= true |
48 | 442 |
end; |
443 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
444 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
445 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
446 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
447 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
448 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
449 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
450 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
451 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
452 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
453 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
454 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
455 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
456 |
begin |
80 | 457 |
Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
458 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
459 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
460 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
461 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
462 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
463 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
464 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
465 |
begin |
102 | 466 |
SetRandomSeed(s); |
81 | 467 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
468 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
469 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
470 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
471 |
|
161 | 472 |
procedure chAmmoMenu(var s: shortstring); |
473 |
begin |
|
474 |
if CheckNoTeamOrHH then exit; |
|
475 |
with CurrentTeam^ do |
|
476 |
with Hedgehogs[CurrHedgehog] do |
|
477 |
begin |
|
162 | 478 |
bSelected:= false; |
682 | 479 |
|
161 | 480 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 481 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
482 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 483 |
end |
484 |
end; |
|
485 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
486 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
487 |
var flags: Longword; |
192 | 488 |
{$IFDEF DEBUGFILE} |
489 |
buf: array[byte] of char; |
|
490 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
491 |
begin |
1051
dfdd5dfe97d4
Enable fullscreen switching back, now it's bound on F12
unc0rr
parents:
1035
diff
changeset
|
492 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
493 |
else cFullScreen:= s = '1'; |
192 | 494 |
|
905 | 495 |
{$IFDEF DEBUGFILE} |
496 |
AddFileLog('Prepare to change video parameters...'); |
|
497 |
{$ENDIF} |
|
753 | 498 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
499 |
||
1127 | 500 |
flags:= SDL_OPENGL;// or SDL_RESIZABLE; |
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
501 |
if cFullScreen then |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
502 |
begin |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
503 |
flags:= flags or SDL_FULLSCREEN; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
504 |
cScreenWidth:= cInitWidth; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
505 |
cScreenHeight:= cInitHeight |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
506 |
end |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
507 |
else SDL_WM_SetCaption('Hedgewars', nil); |
905 | 508 |
{$IFDEF DEBUGFILE} |
509 |
AddFileLog('Freeing old primary surface...'); |
|
510 |
{$ENDIF} |
|
1525 | 511 |
if SDLPrimSurface <> nil then SDL_FreeSurface(SDLPrimSurface); |
904 | 512 |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
513 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
904 | 514 |
SDLTry(SDLPrimSurface <> nil, true); |
192 | 515 |
|
905 | 516 |
{$IFDEF DEBUGFILE} |
517 |
AddFileLog('Setting up OpenGL...'); |
|
518 |
{$ENDIF} |
|
753 | 519 |
SetupOpenGL(); |
520 |
||
192 | 521 |
{$IFDEF DEBUGFILE} |
522 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
523 |
{$ENDIF} |
|
351 | 524 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
525 |
end; |
161 | 526 |
|
175 | 527 |
procedure chVol_p(var s: shortstring); |
174 | 528 |
begin |
175 | 529 |
inc(cVolumeDelta, 3) |
174 | 530 |
end; |
531 |
||
175 | 532 |
procedure chVol_m(var s: shortstring); |
174 | 533 |
begin |
175 | 534 |
dec(cVolumeDelta, 3) |
174 | 535 |
end; |
536 |
||
176 | 537 |
procedure chFindhh(var s: shortstring); |
538 |
begin |
|
539 |
if CheckNoTeamOrHH then exit; |
|
540 |
bShowFinger:= true; |
|
602 | 541 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 542 |
end; |
543 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
544 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
545 |
begin |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
546 |
isPaused:= not isPaused; |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
547 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
548 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
549 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
550 |
procedure chRotateMask(var s: shortstring); |
691 | 551 |
const map: array[0..7] of byte = (7,4,0,1,2,3,0,5); |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
552 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
553 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
554 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
555 |
|
589 | 556 |
procedure chAddTrigger(var s: shortstring); |
615 | 557 |
const MAXPARAMS = 16; |
558 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
559 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
560 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
561 |
tmp: shortstring; |
589 | 562 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
563 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
564 |
Delete(s, 1, 1); |
615 | 565 |
|
566 |
i:= 0; |
|
567 |
while (i < MAXPARAMS) and |
|
568 |
(Length(s) > 0) do |
|
569 |
begin |
|
570 |
SplitBySpace(s, tmp); |
|
571 |
val(s, params[i]); |
|
572 |
s:= tmp; |
|
573 |
inc(i) |
|
574 |
end; |
|
575 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
576 |
case c of |
613 | 577 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 578 |
TryDo(i = 7, errmsgWrongNumber, true); |
579 |
AddTriggerSpawner(params[0], params[1], params[2], TGearType(params[3]), params[4], params[5], params[6]); |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
580 |
end; |
613 | 581 |
'C': begin |
615 | 582 |
TryDo(i = 3, errmsgWrongNumber, true); |
583 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
584 |
end; |
|
585 |
'F': begin |
|
586 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
587 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 588 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
589 |
end |
589 | 590 |
end; |
626 | 591 |
|
592 |
procedure chSpeedup_p(var s: shortstring); |
|
593 |
begin |
|
594 |
isSpeed:= true |
|
595 |
end; |
|
596 |
||
597 |
procedure chSpeedup_m(var s: shortstring); |
|
598 |
begin |
|
599 |
isSpeed:= false |
|
600 |
end; |
|
946 | 601 |
|
602 |
procedure chChat(var s: shortstring); |
|
603 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
604 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
605 |
KeyPressChat(27) |
946 | 606 |
end; |
991 | 607 |
|
608 |
procedure chHistory(var s: shortstring); |
|
609 |
begin |
|
610 |
uChat.showAll:= not uChat.showAll |
|
611 |
end; |