author | unc0rr |
Thu, 30 Apr 2009 20:16:58 +0000 | |
changeset 2019 | b3f1eda8865f |
parent 2017 | 7845c77c8d31 |
child 2022 | 9bbf8af42ace |
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 |
|
1850 | 367 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
784 | 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; |
|
1850 | 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 |
||
2017 | 393 |
procedure chHogSay(var s: shortstring); |
394 |
var Gear: PGear; |
|
395 |
text: shortstring; |
|
396 |
begin |
|
397 |
text:= copy(s, 2, Length(s)-1); |
|
398 |
if CheckNoTeamOrHH or ((CurrentHedgehog^.Gear^.State and gstHHDriven) = 0) then |
|
399 |
begin |
|
400 |
chSay(text); |
|
401 |
exit |
|
402 |
end; |
|
403 |
||
404 |
if not CurrentTeam^.ExtDriven then SendIPC('h' + s); |
|
405 |
if byte(s[1]) < 4 then |
|
406 |
begin |
|
407 |
Gear:= AddGear(0, 0, gtSpeechBubble, 0, _0, _0, 0); |
|
408 |
Gear^.Text:= text; |
|
409 |
Gear^.Hedgehog:= CurrentHedgehog; |
|
410 |
Gear^.State:= byte(s[1]); |
|
411 |
end |
|
412 |
else |
|
413 |
begin |
|
414 |
// If I knew how to add a gear without it becoming immediately active, I'd |
|
415 |
// just create/attach the hedgehog SpeechGear here, then activate it where |
|
416 |
// SpeechType/SpeechText are activated |
|
417 |
SpeechType:= byte(s[1]); |
|
418 |
SpeechText:= text |
|
419 |
end; |
|
420 |
end; |
|
421 |
||
1821
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
422 |
procedure chNewGrave; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
423 |
begin |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
424 |
if CheckNoTeamOrHH then exit; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
425 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
426 |
if not CurrentTeam^.ExtDriven then SendIPC('g'); |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
427 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
428 |
AddGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), gtGrave, 0, _0, _0, 0) |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
429 |
end; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
430 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
431 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 432 |
begin |
433 |
if CheckNoTeamOrHH then exit; |
|
162 | 434 |
if bShowAmmoMenu then |
435 |
begin |
|
436 |
bSelected:= true; |
|
437 |
exit |
|
438 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
439 |
|
602 | 440 |
with CurrentHedgehog^.Gear^, |
441 |
CurrentHedgehog^ do |
|
4 | 442 |
if (State and gstHHChooseTarget) <> 0 then |
443 |
begin |
|
444 |
isCursorVisible:= false; |
|
351 | 445 |
if not CurrentTeam^.ExtDriven then |
4 | 446 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
447 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
448 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
449 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
450 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
451 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
452 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
453 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
454 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
455 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
456 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
457 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 458 |
end; |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
459 |
State:= State and not gstHHChooseTarget; |
351 | 460 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 461 |
Message:= Message or gm_Attack; |
351 | 462 |
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
|
463 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
464 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
465 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
466 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
467 |
doPut(0, 0, false) |
4 | 468 |
end; |
469 |
||
470 |
procedure chCapture(var s: shortstring); |
|
471 |
begin |
|
472 |
flagMakeCapture:= true |
|
473 |
end; |
|
474 |
||
48 | 475 |
procedure chSkip(var s: shortstring); |
476 |
begin |
|
351 | 477 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 478 |
uStats.Skipped; |
917 | 479 |
skipFlag:= true |
48 | 480 |
end; |
481 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
482 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
483 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
484 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
485 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
486 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
487 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
488 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
489 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
490 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
491 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
492 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
493 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
494 |
begin |
80 | 495 |
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
|
496 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
497 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
498 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
499 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
500 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
501 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
502 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
503 |
begin |
102 | 504 |
SetRandomSeed(s); |
81 | 505 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
506 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
507 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
508 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
509 |
|
161 | 510 |
procedure chAmmoMenu(var s: shortstring); |
511 |
begin |
|
512 |
if CheckNoTeamOrHH then exit; |
|
513 |
with CurrentTeam^ do |
|
514 |
with Hedgehogs[CurrHedgehog] do |
|
515 |
begin |
|
162 | 516 |
bSelected:= false; |
682 | 517 |
|
161 | 518 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 519 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
520 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 521 |
end |
522 |
end; |
|
523 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
524 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
525 |
var flags: Longword; |
192 | 526 |
{$IFDEF DEBUGFILE} |
527 |
buf: array[byte] of char; |
|
528 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
529 |
begin |
1051
dfdd5dfe97d4
Enable fullscreen switching back, now it's bound on F12
unc0rr
parents:
1035
diff
changeset
|
530 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
531 |
else cFullScreen:= s = '1'; |
192 | 532 |
|
905 | 533 |
{$IFDEF DEBUGFILE} |
534 |
AddFileLog('Prepare to change video parameters...'); |
|
535 |
{$ENDIF} |
|
753 | 536 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
537 |
||
1127 | 538 |
flags:= SDL_OPENGL;// or SDL_RESIZABLE; |
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
539 |
if cFullScreen then |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
540 |
begin |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
541 |
flags:= flags or SDL_FULLSCREEN; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
542 |
cScreenWidth:= cInitWidth; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
543 |
cScreenHeight:= cInitHeight |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
544 |
end |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
545 |
else SDL_WM_SetCaption('Hedgewars', nil); |
905 | 546 |
{$IFDEF DEBUGFILE} |
547 |
AddFileLog('Freeing old primary surface...'); |
|
548 |
{$ENDIF} |
|
1525 | 549 |
if SDLPrimSurface <> nil then SDL_FreeSurface(SDLPrimSurface); |
904 | 550 |
|
1836 | 551 |
{$IFDEF DARWIN} |
552 |
{Fix for the Mac titlebar bug} |
|
553 |
flags:= flags or SDL_NOFRAME; |
|
554 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
555 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
904 | 556 |
SDLTry(SDLPrimSurface <> nil, true); |
192 | 557 |
|
905 | 558 |
{$IFDEF DEBUGFILE} |
559 |
AddFileLog('Setting up OpenGL...'); |
|
560 |
{$ENDIF} |
|
753 | 561 |
SetupOpenGL(); |
562 |
||
192 | 563 |
{$IFDEF DEBUGFILE} |
564 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
565 |
{$ENDIF} |
|
351 | 566 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
567 |
end; |
161 | 568 |
|
175 | 569 |
procedure chVol_p(var s: shortstring); |
174 | 570 |
begin |
175 | 571 |
inc(cVolumeDelta, 3) |
174 | 572 |
end; |
573 |
||
175 | 574 |
procedure chVol_m(var s: shortstring); |
174 | 575 |
begin |
175 | 576 |
dec(cVolumeDelta, 3) |
174 | 577 |
end; |
578 |
||
176 | 579 |
procedure chFindhh(var s: shortstring); |
580 |
begin |
|
581 |
if CheckNoTeamOrHH then exit; |
|
582 |
bShowFinger:= true; |
|
602 | 583 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 584 |
end; |
585 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
586 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
587 |
begin |
1743 | 588 |
if gameType <> gmtNet then |
589 |
isPaused:= not isPaused; |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
590 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
591 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
592 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
593 |
procedure chRotateMask(var s: shortstring); |
691 | 594 |
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
|
595 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
596 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
597 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
598 |
|
589 | 599 |
procedure chAddTrigger(var s: shortstring); |
615 | 600 |
const MAXPARAMS = 16; |
601 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
602 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
603 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
604 |
tmp: shortstring; |
589 | 605 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
606 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
607 |
Delete(s, 1, 1); |
615 | 608 |
|
609 |
i:= 0; |
|
610 |
while (i < MAXPARAMS) and |
|
611 |
(Length(s) > 0) do |
|
612 |
begin |
|
613 |
SplitBySpace(s, tmp); |
|
614 |
val(s, params[i]); |
|
615 |
s:= tmp; |
|
616 |
inc(i) |
|
617 |
end; |
|
618 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
619 |
case c of |
613 | 620 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 621 |
TryDo(i = 7, errmsgWrongNumber, true); |
622 |
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
|
623 |
end; |
613 | 624 |
'C': begin |
615 | 625 |
TryDo(i = 3, errmsgWrongNumber, true); |
626 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
627 |
end; |
|
628 |
'F': begin |
|
629 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
630 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 631 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
632 |
end |
589 | 633 |
end; |
626 | 634 |
|
635 |
procedure chSpeedup_p(var s: shortstring); |
|
636 |
begin |
|
637 |
isSpeed:= true |
|
638 |
end; |
|
639 |
||
640 |
procedure chSpeedup_m(var s: shortstring); |
|
641 |
begin |
|
642 |
isSpeed:= false |
|
643 |
end; |
|
946 | 644 |
|
645 |
procedure chChat(var s: shortstring); |
|
646 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
647 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
648 |
KeyPressChat(27) |
946 | 649 |
end; |
991 | 650 |
|
651 |
procedure chHistory(var s: shortstring); |
|
652 |
begin |
|
653 |
uChat.showAll:= not uChat.showAll |
|
654 |
end; |