author | unc0rr |
Fri, 21 Sep 2007 21:51:48 +0000 | |
changeset 604 | 2f1165467a66 |
parent 602 | f7628ebfccde |
child 605 | 2651c3fe4567 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
2 |
* Hedgewars, a worms-like game |
|
393 | 3 |
* Copyright (c) 2004-2007 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); |
|
32 |
begin |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
312
diff
changeset
|
33 |
SendIPC('Q'); |
4 | 34 |
GameState:= gsExit |
35 |
end; |
|
36 |
||
205 | 37 |
procedure chCheckProto(var s: shortstring); |
371 | 38 |
var i, c: LongInt; |
205 | 39 |
begin |
40 |
if isDeveloperMode then |
|
41 |
begin |
|
42 |
val(s, i, c); |
|
43 |
if (c <> 0) or (i = 0) then exit; |
|
44 |
TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true); |
|
45 |
TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true) |
|
46 |
end |
|
47 |
end; |
|
48 |
||
4 | 49 |
procedure chAddTeam(var s: shortstring); |
549 | 50 |
var Color: Longword; |
4 | 51 |
begin |
145 | 52 |
if isDeveloperMode then |
53 |
begin |
|
534 | 54 |
ParseCommand('ammstore 93919294221912103323', true); |
549 | 55 |
val(s, Color); |
56 |
TryDo(Color <> 0, 'Error: black team color', true); |
|
351 | 57 |
|
549 | 58 |
AddTeam(Color); |
59 |
||
60 |
if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true |
|
546 | 61 |
end |
4 | 62 |
end; |
63 |
||
64 |
procedure chTeamLocal(var s: shortstring); |
|
65 |
begin |
|
66 |
if not isDeveloperMode then exit; |
|
67 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
|
351 | 68 |
CurrentTeam^.ExtDriven:= true |
4 | 69 |
end; |
70 |
||
71 |
procedure chName(var id: shortstring); |
|
72 |
var s: shortstring; |
|
73 |
begin |
|
74 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true); |
|
75 |
SplitBySpace(id, s); |
|
76 |
if s[1]='"' then Delete(s, 1, 1); |
|
77 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 78 |
if id = 'team' then CurrentTeam^.TeamName:= s |
83 | 79 |
else if (id[1] = 'h') and (id[2] = 'h') |
80 |
and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then |
|
351 | 81 |
CurrentTeam^.Hedgehogs[byte(id[3])-48].Name:= s |
82 |
else OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
|
4 | 83 |
end; |
84 |
||
85 |
procedure chGrave(var s: shortstring); |
|
86 |
begin |
|
87 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
88 |
if s[1]='"' then Delete(s, 1, 1); |
|
89 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 90 |
CurrentTeam^.GraveName:= s |
4 | 91 |
end; |
92 |
||
93 |
procedure chFort(var s: shortstring); |
|
94 |
begin |
|
95 |
if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
|
96 |
if s[1]='"' then Delete(s, 1, 1); |
|
97 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
351 | 98 |
CurrentTeam^.FortName:= s |
4 | 99 |
end; |
100 |
||
312 | 101 |
procedure chAddHH(var id: shortstring); |
4 | 102 |
var s: shortstring; |
103 |
Gear: PGear; |
|
104 |
begin |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
105 |
if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
312 | 106 |
with CurrentTeam^ do |
107 |
begin |
|
108 |
SplitBySpace(id, s); |
|
602 | 109 |
CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
110 |
val(id, CurrentHedgehog^.BotLevel); |
|
498 | 111 |
Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
495 | 112 |
val(s, Gear^.Health); |
351 | 113 |
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
114 |
PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam; |
|
394
4c017ae1226a
- Implement hack to let ammo stores work without needed assistance of frontend
unc0rr
parents:
393
diff
changeset
|
115 |
Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1; |
312 | 116 |
Hedgehogs[HedgehogsNumber].Gear:= Gear; |
117 |
inc(HedgehogsNumber) |
|
118 |
end |
|
4 | 119 |
end; |
120 |
||
604
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
121 |
procedure chSetHHCoords(var x: shortstring); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
122 |
var y: shortstring; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
123 |
t: Longint; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
124 |
begin |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
125 |
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
|
126 |
SplitBySpace(x, y); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
127 |
val(x, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
128 |
CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
129 |
val(y, t); |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
130 |
CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
131 |
end; |
2f1165467a66
Let hedgehog position be taken from config, still more work is needed
unc0rr
parents:
602
diff
changeset
|
132 |
|
288 | 133 |
procedure chAddAmmoStore(var descr: shortstring); |
134 |
begin |
|
135 |
AddAmmoStore(descr) |
|
136 |
end; |
|
137 |
||
4 | 138 |
procedure chBind(var id: shortstring); |
139 |
var s: shortstring; |
|
371 | 140 |
b: LongInt; |
4 | 141 |
begin |
142 |
if CurrentTeam = nil then exit; |
|
143 |
SplitBySpace(id, s); |
|
144 |
if s[1]='"' then Delete(s, 1, 1); |
|
145 |
if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
|
146 |
b:= KeyNameToCode(id); |
|
351 | 147 |
if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
148 |
else CurrentTeam^.Binds[b]:= s |
|
4 | 149 |
end; |
150 |
||
151 |
procedure chLeft_p(var s: shortstring); |
|
152 |
begin |
|
153 |
if CheckNoTeamOrHH then exit; |
|
176 | 154 |
bShowFinger:= false; |
351 | 155 |
if not CurrentTeam^.ExtDriven then SendIPC('L'); |
602 | 156 |
with CurrentHedgehog^.Gear^ do |
4 | 157 |
Message:= Message or gm_Left |
158 |
end; |
|
159 |
||
160 |
procedure chLeft_m(var s: shortstring); |
|
161 |
begin |
|
162 |
if CheckNoTeamOrHH then exit; |
|
351 | 163 |
if not CurrentTeam^.ExtDriven then SendIPC('l'); |
602 | 164 |
with CurrentHedgehog^.Gear^ do |
4 | 165 |
Message:= Message and not gm_Left |
166 |
end; |
|
167 |
||
168 |
procedure chRight_p(var s: shortstring); |
|
169 |
begin |
|
170 |
if CheckNoTeamOrHH then exit; |
|
176 | 171 |
bShowFinger:= false; |
351 | 172 |
if not CurrentTeam^.ExtDriven then SendIPC('R'); |
602 | 173 |
with CurrentHedgehog^.Gear^ do |
4 | 174 |
Message:= Message or gm_Right |
175 |
end; |
|
176 |
||
177 |
procedure chRight_m(var s: shortstring); |
|
178 |
begin |
|
179 |
if CheckNoTeamOrHH then exit; |
|
351 | 180 |
if not CurrentTeam^.ExtDriven then SendIPC('r'); |
602 | 181 |
with CurrentHedgehog^.Gear^ do |
4 | 182 |
Message:= Message and not gm_Right |
183 |
end; |
|
184 |
||
185 |
procedure chUp_p(var s: shortstring); |
|
186 |
begin |
|
187 |
if CheckNoTeamOrHH then exit; |
|
176 | 188 |
bShowFinger:= false; |
351 | 189 |
if not CurrentTeam^.ExtDriven then SendIPC('U'); |
602 | 190 |
with CurrentHedgehog^.Gear^ do |
4 | 191 |
Message:= Message or gm_Up |
192 |
end; |
|
193 |
||
194 |
procedure chUp_m(var s: shortstring); |
|
195 |
begin |
|
196 |
if CheckNoTeamOrHH then exit; |
|
351 | 197 |
if not CurrentTeam^.ExtDriven then SendIPC('u'); |
602 | 198 |
with CurrentHedgehog^.Gear^ do |
4 | 199 |
Message:= Message and not gm_Up |
200 |
end; |
|
201 |
||
202 |
procedure chDown_p(var s: shortstring); |
|
203 |
begin |
|
204 |
if CheckNoTeamOrHH then exit; |
|
176 | 205 |
bShowFinger:= false; |
351 | 206 |
if not CurrentTeam^.ExtDriven then SendIPC('D'); |
602 | 207 |
with CurrentHedgehog^.Gear^ do |
4 | 208 |
Message:= Message or gm_Down |
209 |
end; |
|
210 |
||
211 |
procedure chDown_m(var s: shortstring); |
|
212 |
begin |
|
213 |
if CheckNoTeamOrHH then exit; |
|
351 | 214 |
if not CurrentTeam^.ExtDriven then SendIPC('d'); |
602 | 215 |
with CurrentHedgehog^.Gear^ do |
4 | 216 |
Message:= Message and not gm_Down |
217 |
end; |
|
218 |
||
219 |
procedure chLJump(var s: shortstring); |
|
220 |
begin |
|
221 |
if CheckNoTeamOrHH then exit; |
|
176 | 222 |
bShowFinger:= false; |
351 | 223 |
if not CurrentTeam^.ExtDriven then SendIPC('j'); |
602 | 224 |
with CurrentHedgehog^.Gear^ do |
4 | 225 |
Message:= Message or gm_LJump |
226 |
end; |
|
227 |
||
228 |
procedure chHJump(var s: shortstring); |
|
229 |
begin |
|
230 |
if CheckNoTeamOrHH then exit; |
|
176 | 231 |
bShowFinger:= false; |
351 | 232 |
if not CurrentTeam^.ExtDriven then SendIPC('J'); |
602 | 233 |
with CurrentHedgehog^.Gear^ do |
4 | 234 |
Message:= Message or gm_HJump |
235 |
end; |
|
236 |
||
237 |
procedure chAttack_p(var s: shortstring); |
|
238 |
begin |
|
239 |
if CheckNoTeamOrHH then exit; |
|
176 | 240 |
bShowFinger:= false; |
602 | 241 |
with CurrentHedgehog^.Gear^ do |
4 | 242 |
begin |
351 | 243 |
{$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} |
542 | 244 |
if ((State and gstHHDriven) <> 0) and |
245 |
((State and (gstAttacked or gstHHChooseTarget)) = 0) then |
|
4 | 246 |
begin |
602 | 247 |
FollowGear:= CurrentHedgehog^.Gear; |
351 | 248 |
if not CurrentTeam^.ExtDriven then SendIPC('A'); |
4 | 249 |
Message:= Message or gm_Attack |
250 |
end |
|
251 |
end |
|
252 |
end; |
|
253 |
||
254 |
procedure chAttack_m(var s: shortstring); |
|
255 |
begin |
|
256 |
if CheckNoTeamOrHH then exit; |
|
602 | 257 |
with CurrentHedgehog^.Gear^ do |
4 | 258 |
begin |
351 | 259 |
if not CurrentTeam^.ExtDriven and |
95 | 260 |
((Message and gm_Attack) <> 0) then SendIPC('a'); |
261 |
Message:= Message and not gm_Attack |
|
4 | 262 |
end |
263 |
end; |
|
264 |
||
265 |
procedure chSwitch(var s: shortstring); |
|
266 |
begin |
|
267 |
if CheckNoTeamOrHH then exit; |
|
351 | 268 |
if not CurrentTeam^.ExtDriven then SendIPC('S'); |
602 | 269 |
with CurrentHedgehog^.Gear^ do |
4 | 270 |
Message:= Message or gm_Switch |
271 |
end; |
|
272 |
||
273 |
procedure chNextTurn(var s: shortstring); |
|
274 |
begin |
|
275 |
if AllInactive then |
|
276 |
begin |
|
351 | 277 |
if not CurrentTeam^.ExtDriven then SendIPC('N'); |
593 | 278 |
TickTrigger(trigTurns); |
4 | 279 |
{$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
280 |
SwitchHedgehog; |
|
281 |
end |
|
282 |
end; |
|
283 |
||
284 |
procedure chSay(var s: shortstring); |
|
285 |
begin |
|
286 |
WriteLnToConsole('> ' + s); |
|
287 |
SendIPC('s'+s) |
|
288 |
end; |
|
289 |
||
290 |
procedure chTimer(var s: shortstring); |
|
291 |
begin |
|
292 |
if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or (CurrentTeam = nil) then exit; |
|
176 | 293 |
bShowFinger:= false; |
602 | 294 |
with CurrentHedgehog^ do |
351 | 295 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then |
4 | 296 |
begin |
351 | 297 |
Ammo^[CurSlot, CurAmmo].Timer:= 1000 * (byte(s[1]) - 48); |
4 | 298 |
with CurrentTeam^ do |
70 | 299 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); |
351 | 300 |
if not CurrentTeam^.ExtDriven then SendIPC(s); |
4 | 301 |
end |
302 |
end; |
|
303 |
||
304 |
procedure chSlot(var s: shortstring); |
|
305 |
var slot: LongWord; |
|
306 |
caSlot, caAmmo: PLongword; |
|
307 |
begin |
|
95 | 308 |
if (s[0] <> #1) or CheckNoTeamOrHH then exit; |
176 | 309 |
bShowFinger:= false; |
4 | 310 |
slot:= byte(s[1]) - 49; |
10 | 311 |
if slot > cMaxSlotIndex then exit; |
351 | 312 |
if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); |
4 | 313 |
with CurrentTeam^ do |
314 |
begin |
|
315 |
with Hedgehogs[CurrHedgehog] do |
|
316 |
begin |
|
351 | 317 |
if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
431 | 318 |
or ((Gear^.State and gstHHDriven) = 0) then exit; |
319 |
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
4 | 320 |
if CurAmmoGear = nil then begin caSlot:= @CurSlot; caAmmo:= @CurAmmo end |
321 |
else begin caSlot:= @AltSlot; caAmmo:= @AltAmmo end; |
|
322 |
if caSlot^ = slot then |
|
323 |
begin |
|
324 |
inc(caAmmo^); |
|
351 | 325 |
if (caAmmo^ > cMaxSlotAmmoIndex) or (Ammo^[slot, caAmmo^].Count = 0) then caAmmo^:= 0 |
4 | 326 |
end else |
351 | 327 |
if Ammo^[slot, 0].Count > 0 then |
4 | 328 |
begin |
329 |
caSlot^:= slot; |
|
330 |
caAmmo^:= 0; |
|
331 |
end; |
|
332 |
end; |
|
70 | 333 |
ApplyAmmoChanges(Hedgehogs[CurrHedgehog]) |
4 | 334 |
end |
335 |
end; |
|
336 |
||
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
337 |
procedure doPut(putX, putY: LongInt; fromAI: boolean); |
4 | 338 |
begin |
339 |
if CheckNoTeamOrHH then exit; |
|
162 | 340 |
if bShowAmmoMenu then |
341 |
begin |
|
342 |
bSelected:= true; |
|
343 |
exit |
|
344 |
end; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
345 |
|
602 | 346 |
with CurrentHedgehog^.Gear^, |
347 |
CurrentHedgehog^ do |
|
4 | 348 |
if (State and gstHHChooseTarget) <> 0 then |
349 |
begin |
|
350 |
isCursorVisible:= false; |
|
351 | 351 |
if not CurrentTeam^.ExtDriven then |
4 | 352 |
begin |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
353 |
if fromAI then |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
354 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
355 |
TargetPoint.X:= putX; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
356 |
TargetPoint.Y:= putY |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
357 |
end else |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
358 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
359 |
SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
360 |
dec(TargetPoint.X, WorldDx); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
361 |
dec(TargetPoint.Y, WorldDy) |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
362 |
end; |
154
5667e6f38704
Network protocol uses integers in network byte order
unc0rr
parents:
145
diff
changeset
|
363 |
SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
4 | 364 |
end; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
365 |
State:= State and not gstHHChooseTarget; |
351 | 366 |
if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
263 | 367 |
Message:= Message or gm_Attack; |
351 | 368 |
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
|
369 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
370 |
end; |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
371 |
|
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
372 |
procedure chPut(var s: shortstring); |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
373 |
begin |
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
374 |
doPut(0, 0, false) |
4 | 375 |
end; |
376 |
||
377 |
procedure chCapture(var s: shortstring); |
|
378 |
begin |
|
379 |
flagMakeCapture:= true |
|
380 |
end; |
|
381 |
||
48 | 382 |
procedure chSkip(var s: shortstring); |
383 |
begin |
|
351 | 384 |
if not CurrentTeam^.ExtDriven then SendIPC(','); |
48 | 385 |
TurnTimeLeft:= 0 |
386 |
end; |
|
387 |
||
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
388 |
procedure chSetMap(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
389 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
390 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
391 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
392 |
Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
393 |
InitStepsFlags:= InitStepsFlags or cifMap |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
394 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
395 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
396 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
397 |
procedure chSetTheme(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
398 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
399 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
400 |
begin |
80 | 401 |
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
|
402 |
InitStepsFlags:= InitStepsFlags or cifTheme |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
403 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
404 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
405 |
|
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
406 |
procedure chSetSeed(var s: shortstring); |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
407 |
begin |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
408 |
if isDeveloperMode then |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
409 |
begin |
102 | 410 |
SetRandomSeed(s); |
81 | 411 |
cSeed:= s; |
55
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
412 |
InitStepsFlags:= InitStepsFlags or cifRandomize |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
413 |
end |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
414 |
end; |
e09f7c952a40
Send run parameters by cmd line, game parameters by IPC... breaks network game
unc0rr
parents:
48
diff
changeset
|
415 |
|
161 | 416 |
procedure chAmmoMenu(var s: shortstring); |
417 |
begin |
|
418 |
if CheckNoTeamOrHH then exit; |
|
419 |
with CurrentTeam^ do |
|
420 |
with Hedgehogs[CurrHedgehog] do |
|
421 |
begin |
|
162 | 422 |
bSelected:= false; |
161 | 423 |
if bShowAmmoMenu then bShowAmmoMenu:= false |
351 | 424 |
else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or (AttacksNum > 0) |
425 |
or ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true |
|
161 | 426 |
end |
427 |
end; |
|
428 |
||
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
429 |
procedure chFullScr(var s: shortstring); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
430 |
var flags: Longword; |
192 | 431 |
{$IFDEF DEBUGFILE} |
432 |
buf: array[byte] of char; |
|
433 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
434 |
begin |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
435 |
if Length(s) = 0 then cFullScreen:= not cFullScreen |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
436 |
else cFullScreen:= s = '1'; |
192 | 437 |
|
358 | 438 |
flags:= SDL_HWSURFACE or SDL_DOUBLEBUF or SDL_HWACCEL; |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
439 |
if cFullScreen then flags:= flags or SDL_FULLSCREEN |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
440 |
else SDL_WM_SetCaption('Hedgewars', nil); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
441 |
SDL_FreeSurface(SDLPrimSurface); |
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
442 |
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); |
192 | 443 |
|
444 |
{$IFDEF DEBUGFILE} |
|
445 |
AddFileLog('SDL video driver: ' + string(SDL_VideoDriverName(buf, sizeof(buf)))); |
|
446 |
{$ENDIF} |
|
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
447 |
TryDo(SDLPrimSurface <> nil, errmsgCreateSurface, true); |
351 | 448 |
PixelFormat:= SDLPrimSurface^.format |
166
2920ab2bf329
Switching between fullscreen and windowed modes on 'F' key
unc0rr
parents:
162
diff
changeset
|
449 |
end; |
161 | 450 |
|
175 | 451 |
procedure chVol_p(var s: shortstring); |
174 | 452 |
begin |
175 | 453 |
inc(cVolumeDelta, 3) |
174 | 454 |
end; |
455 |
||
175 | 456 |
procedure chVol_m(var s: shortstring); |
174 | 457 |
begin |
175 | 458 |
dec(cVolumeDelta, 3) |
174 | 459 |
end; |
460 |
||
176 | 461 |
procedure chFindhh(var s: shortstring); |
462 |
begin |
|
463 |
if CheckNoTeamOrHH then exit; |
|
464 |
bShowFinger:= true; |
|
602 | 465 |
FollowGear:= CurrentHedgehog^.Gear |
176 | 466 |
end; |
467 |
||
281
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
468 |
procedure chPause(var s: shortstring); |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
469 |
begin |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
470 |
isPaused:= not isPaused; |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
471 |
SDL_ShowCursor(ord(isPaused)) |
5b483aa9f2ab
Pause support (mouse cursor is released when the game is paused)
unc0rr
parents:
263
diff
changeset
|
472 |
end; |
539
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
473 |
|
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
474 |
procedure chRotateMask(var s: shortstring); |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
475 |
const map: array[0..7] of byte = (7,4,0,5,2,1,0,3); |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
476 |
begin |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
477 |
cTagsMask:= map[cTagsMask] |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
478 |
end; |
6a9bf1852bbc
Ability to choose which info is shown above hedgehogs
unc0rr
parents:
534
diff
changeset
|
479 |
|
589 | 480 |
procedure chAddTrigger(var s: shortstring); |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
481 |
var ttype, gt, geartrig, Ticks, Lives: LongWord; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
482 |
X, Y: LongInt; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
483 |
c: char; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
484 |
tmp: shortstring; |
589 | 485 |
begin |
595
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
486 |
c:= s[1]; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
487 |
Delete(s, 1, 1); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
488 |
case c of |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
489 |
's': begin // s12345 1 1 33 0 0 123456 |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
490 |
SplitBySpace(s, tmp); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
491 |
val(s, ttype); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
492 |
SplitBySpace(tmp, s); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
493 |
val(tmp, Ticks); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
494 |
SplitBySpace(s, tmp); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
495 |
val(s, Lives); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
496 |
SplitBySpace(tmp, s); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
497 |
val(tmp, gt); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
498 |
SplitBySpace(s, tmp); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
499 |
val(s, X); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
500 |
SplitBySpace(tmp, s); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
501 |
val(tmp, Y); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
502 |
SplitBySpace(s, tmp); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
503 |
val(s, geartrig); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
504 |
AddTriggerSpawner(ttype, Ticks, Lives, X, Y, TGearType(gt), geartrig); |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
505 |
end; |
5ee863f2f568
Triggers PoC: targets are spawned right after the previous damaged
unc0rr
parents:
594
diff
changeset
|
506 |
end |
589 | 507 |
end; |