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