author | unc0rr |
Sun, 24 May 2009 15:01:10 +0000 | |
changeset 2111 | 9be70514954c |
parent 2110 | df2a1fe3617a |
child 2114 | 9a8ccc7bc3d8 |
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 |
2079 | 285 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: hedgehog''s 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 |
|
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
316 |
TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); |
2046 | 317 |
|
2045
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
318 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
319 |
TickTrigger(trigTurns); |
b0588498bc3a
- Fix network (my crappy fault, triggered by nemo's patch)
unc0rr
parents:
2042
diff
changeset
|
320 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
4 | 321 |
end; |
322 |
||
323 |
procedure chSay(var s: shortstring); |
|
324 |
begin |
|
1356 | 325 |
SendIPC('s' + s); |
1378 | 326 |
|
327 |
if copy(s, 1, 4) = '/me ' then |
|
1379 | 328 |
s:= '* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) |
1378 | 329 |
else |
330 |
s:= UserNick + ': ' + s; |
|
331 |
||
1356 | 332 |
AddChatString(s) |
4 | 333 |
end; |
334 |
||
335 |
procedure chTimer(var s: shortstring); |
|
336 |
begin |
|
337 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; |
|
176 | 338 |
bShowFinger:= false; |
926
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
339 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
340 |
with CurrentHedgehog^.Gear^ do |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
341 |
begin |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
342 |
Message:= Message or gm_Timer; |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
343 |
MsgParam:= byte(s[1]) - ord('0') |
d231e007452a
Timer as hedgehog message (avoid possible desync in very rare cases)
unc0rr
parents:
917
diff
changeset
|
344 |
end |
4 | 345 |
end; |
346 |
||
347 |
procedure chSlot(var s: shortstring); |
|
348 |
var slot: LongWord; |
|
349 |
begin |
|
95 | 350 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 351 |
bShowFinger:= false; |
4 | 352 |
slot:= byte(s[1]) - 49; |
10 | 353 |
if slot > cMaxSlotIndex then exit; |
351 | 354 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
783 | 355 |
with CurrentHedgehog^.Gear^ do |
4 | 356 |
begin |
783 | 357 |
Message:= Message or gm_Slot; |
358 |
MsgParam:= slot |
|
359 |
end |
|
360 |
end; |
|
361 |
||
362 |
procedure chSetWeapon(var s: shortstring); |
|
363 |
begin |
|
364 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
784 | 365 |
|
1850 | 366 |
if TAmmoType(s[1]) > High(TAmmoType) then exit; |
784 | 367 |
|
368 |
if not CurrentTeam^.ExtDriven then SendIPC('w' + s); |
|
369 |
||
783 | 370 |
with CurrentHedgehog^.Gear^ do |
371 |
begin |
|
372 |
Message:= Message or gm_Weapon; |
|
1850 | 373 |
MsgParam:= byte(s[1]) |
4 | 374 |
end |
375 |
end; |
|
376 |
||
1035 | 377 |
procedure chTaunt(var s: shortstring); |
378 |
begin |
|
379 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
|
380 |
||
381 |
if TWave(s[1]) > High(TWave) then exit; |
|
382 |
||
383 |
if not CurrentTeam^.ExtDriven then SendIPC('t' + s); |
|
384 |
||
385 |
with CurrentHedgehog^.Gear^ do |
|
386 |
begin |
|
387 |
Message:= Message or gm_Animate; |
|
388 |
MsgParam:= byte(s[1]) |
|
389 |
end |
|
390 |
end; |
|
391 |
||
2017 | 392 |
procedure chHogSay(var s: shortstring); |
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
393 |
var Gear: PVisualGear; |
2017 | 394 |
text: shortstring; |
395 |
begin |
|
396 |
text:= copy(s, 2, Length(s)-1); |
|
2110 | 397 |
if CheckNoTeamOrHH |
2111 | 398 |
or ((CurrentHedgehog^.Gear^.State and gstHHDriven) = 0) then |
2017 | 399 |
begin |
400 |
chSay(text); |
|
401 |
exit |
|
402 |
end; |
|
403 |
||
404 |
if not CurrentTeam^.ExtDriven then SendIPC('h' + s); |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
405 |
|
2017 | 406 |
if byte(s[1]) < 4 then |
407 |
begin |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
408 |
Gear:= AddVisualGear(0, 0, vgtSpeechBubble); |
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
409 |
Gear^.Hedgehog:= CurrentHedgehog; |
2017 | 410 |
Gear^.Text:= text; |
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
411 |
Gear^.FrameTicks:= byte(s[1]) |
2017 | 412 |
end |
413 |
else |
|
414 |
begin |
|
2022 | 415 |
SpeechType:= byte(s[1])-3; |
2017 | 416 |
SpeechText:= text |
417 |
end; |
|
2042
905c554d62e6
Move Speech to visual gears. This checkin CRASHES on deletion of visual gear outside the doStep
nemo
parents:
2022
diff
changeset
|
418 |
|
2017 | 419 |
end; |
420 |
||
1821
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
421 |
procedure chNewGrave; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
422 |
begin |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
423 |
if CheckNoTeamOrHH then exit; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
424 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
425 |
if not CurrentTeam^.ExtDriven then SendIPC('g'); |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
426 |
|
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
427 |
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
|
428 |
end; |
6b6cf3389f92
Hedgehog drops a grave on "/newgrave" command. Patch by nemo
unc0rr
parents:
1743
diff
changeset
|
429 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
430 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 431 |
begin |
432 |
if CheckNoTeamOrHH then exit; |
|
162 | 433 |
if bShowAmmoMenu then |
434 |
begin |
|
435 |
bSelected:= true; |
|
436 |
exit |
|
437 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
438 |
|
602 | 439 |
with CurrentHedgehog^.Gear^, |
440 |
CurrentHedgehog^ do |
|
4 | 441 |
if (State and gstHHChooseTarget) <> 0 then |
442 |
begin |
|
443 |
isCursorVisible:= false; |
|
351 | 444 |
if not CurrentTeam^.ExtDriven then |
4 | 445 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
446 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
447 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
448 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
449 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
450 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
451 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
452 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
453 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
454 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
455 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
456 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 457 |
end; |
927
2c1675344a6f
Remove AltSlot and AltAmmo fields of Hedgehog record, as they are not actually needed
unc0rr
parents:
926
diff
changeset
|
458 |
State:= State and not gstHHChooseTarget; |
351 | 459 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 460 |
Message:= Message or gm_Attack; |
351 | 461 |
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
|
462 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
463 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
464 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
465 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
466 |
doPut(0, 0, false) |
4 | 467 |
end; |
468 |
||
469 |
procedure chCapture(var s: shortstring); |
|
470 |
begin |
|
471 |
flagMakeCapture:= true |
|
472 |
end; |
|
473 |
||
48 | 474 |
procedure chSkip(var s: shortstring); |
475 |
begin |
|
351 | 476 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
871 | 477 |
uStats.Skipped; |
917 | 478 |
skipFlag:= true |
48 | 479 |
end; |
480 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
481 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
482 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
483 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
484 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
485 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
486 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
487 |
end |
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 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
490 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
491 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
492 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
493 |
begin |
80 | 494 |
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
|
495 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
496 |
end |
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 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
499 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
500 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
501 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
502 |
begin |
102 | 503 |
SetRandomSeed(s); |
81 | 504 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
505 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
506 |
end |
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 |
|
161 | 509 |
procedure chAmmoMenu(var s: shortstring); |
510 |
begin |
|
511 |
if CheckNoTeamOrHH then exit; |
|
512 |
with CurrentTeam^ do |
|
513 |
with Hedgehogs[CurrHedgehog] do |
|
514 |
begin |
|
162 | 515 |
bSelected:= false; |
682 | 516 |
|
161 | 517 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 518 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
519 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 520 |
end |
521 |
end; |
|
522 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
523 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
524 |
var flags: Longword; |
192 | 525 |
{$IFDEF DEBUGFILE} |
526 |
buf: array[byte] of char; |
|
527 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
528 |
begin |
1051
dfdd5dfe97d4
Enable fullscreen switching back, now it's bound on F12
unc0rr
parents:
1035
diff
changeset
|
529 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
530 |
else cFullScreen:= s = '1'; |
192 | 531 |
|
905 | 532 |
{$IFDEF DEBUGFILE} |
533 |
AddFileLog('Prepare to change video parameters...'); |
|
534 |
{$ENDIF} |
|
753 | 535 |
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
536 |
||
1127 | 537 |
flags:= SDL_OPENGL;// or SDL_RESIZABLE; |
1121
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
538 |
if cFullScreen then |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
539 |
begin |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
540 |
flags:= flags or SDL_FULLSCREEN; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
541 |
cScreenWidth:= cInitWidth; |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
542 |
cScreenHeight:= cInitHeight |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
543 |
end |
d595dc56b4f3
Remember initial resolution settings to use when switching to fullscreen mode
unc0rr
parents:
1120
diff
changeset
|
544 |
else SDL_WM_SetCaption('Hedgewars', nil); |
905 | 545 |
{$IFDEF DEBUGFILE} |
546 |
AddFileLog('Freeing old primary surface...'); |
|
547 |
{$ENDIF} |
|
1525 | 548 |
if SDLPrimSurface <> nil then SDL_FreeSurface(SDLPrimSurface); |
904 | 549 |
|
1836 | 550 |
{$IFDEF DARWIN} |
551 |
{Fix for the Mac titlebar bug} |
|
552 |
flags:= flags or SDL_NOFRAME; |
|
553 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
554 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
904 | 555 |
SDLTry(SDLPrimSurface <> nil, true); |
192 | 556 |
|
905 | 557 |
{$IFDEF DEBUGFILE} |
558 |
AddFileLog('Setting up OpenGL...'); |
|
559 |
{$ENDIF} |
|
753 | 560 |
SetupOpenGL(); |
561 |
||
192 | 562 |
{$IFDEF DEBUGFILE} |
563 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
564 |
{$ENDIF} |
|
351 | 565 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
566 |
end; |
161 | 567 |
|
175 | 568 |
procedure chVol_p(var s: shortstring); |
174 | 569 |
begin |
175 | 570 |
inc(cVolumeDelta, 3) |
174 | 571 |
end; |
572 |
||
175 | 573 |
procedure chVol_m(var s: shortstring); |
174 | 574 |
begin |
175 | 575 |
dec(cVolumeDelta, 3) |
174 | 576 |
end; |
577 |
||
176 | 578 |
procedure chFindhh(var s: shortstring); |
579 |
begin |
|
580 |
if CheckNoTeamOrHH then exit; |
|
581 |
bShowFinger:= true; |
|
602 | 582 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 583 |
end; |
584 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
585 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
586 |
begin |
1743 | 587 |
if gameType <> gmtNet then |
588 |
isPaused:= not isPaused; |
|
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
589 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
590 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
591 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
592 |
procedure chRotateMask(var s: shortstring); |
691 | 593 |
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
|
594 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
595 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
596 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
597 |
|
589 | 598 |
procedure chAddTrigger(var s: shortstring); |
615 | 599 |
const MAXPARAMS = 16; |
600 |
var params: array[0..Pred(MAXPARAMS)] of Longword; |
|
601 |
i: LongInt; |
|
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
602 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
603 |
tmp: shortstring; |
589 | 604 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
605 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
606 |
Delete(s, 1, 1); |
615 | 607 |
|
608 |
i:= 0; |
|
609 |
while (i < MAXPARAMS) and |
|
610 |
(Length(s) > 0) do |
|
611 |
begin |
|
612 |
SplitBySpace(s, tmp); |
|
613 |
val(s, params[i]); |
|
614 |
s:= tmp; |
|
615 |
inc(i) |
|
616 |
end; |
|
617 |
||
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
618 |
case c of |
613 | 619 |
's': begin // sTYPE TICKS LIVES GEARTYPE X Y GEARTRIGGER |
615 | 620 |
TryDo(i = 7, errmsgWrongNumber, true); |
621 |
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
|
622 |
end; |
613 | 623 |
'C': begin |
615 | 624 |
TryDo(i = 3, errmsgWrongNumber, true); |
625 |
AddTriggerSuccess(params[0], params[1], params[2]); |
|
626 |
end; |
|
627 |
'F': begin |
|
628 |
TryDo(i = 3, errmsgWrongNumber, true); |
|
629 |
AddTriggerFail(params[0], params[1], params[2]); |
|
613 | 630 |
end; |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
631 |
end |
589 | 632 |
end; |
626 | 633 |
|
634 |
procedure chSpeedup_p(var s: shortstring); |
|
635 |
begin |
|
636 |
isSpeed:= true |
|
637 |
end; |
|
638 |
||
639 |
procedure chSpeedup_m(var s: shortstring); |
|
640 |
begin |
|
641 |
isSpeed:= false |
|
642 |
end; |
|
946 | 643 |
|
644 |
procedure chChat(var s: shortstring); |
|
645 |
begin |
|
990
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
646 |
GameState:= gsChat; |
dfa6a6fe1542
Implement history for chat (27 entries), no key binding yet
unc0rr
parents:
970
diff
changeset
|
647 |
KeyPressChat(27) |
946 | 648 |
end; |
991 | 649 |
|
650 |
procedure chHistory(var s: shortstring); |
|
651 |
begin |
|
652 |
uChat.showAll:= not uChat.showAll |
|
653 |
end; |