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