51 begin |
53 begin |
52 inc(TeamsCount); |
54 inc(TeamsCount); |
53 TryDo(TeamsCount <= 5, 'Too many teams', true); |
55 TryDo(TeamsCount <= 5, 'Too many teams', true); |
54 AddTeam |
56 AddTeam |
55 end; |
57 end; |
56 |
58 |
57 if GameType in [gmtDemo, gmtSave] then CurrentTeam.ExtDriven:= true |
59 if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true |
58 end; |
60 end; |
59 |
61 |
60 procedure chTeamLocal(var s: shortstring); |
62 procedure chTeamLocal(var s: shortstring); |
61 begin |
63 begin |
62 if not isDeveloperMode then exit; |
64 if not isDeveloperMode then exit; |
63 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
65 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); |
64 CurrentTeam.ExtDriven:= true |
66 CurrentTeam^.ExtDriven:= true |
65 end; |
67 end; |
66 |
68 |
67 procedure chName(var id: shortstring); |
69 procedure chName(var id: shortstring); |
68 var s: shortstring; |
70 var s: shortstring; |
69 begin |
71 begin |
70 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true); |
72 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true); |
71 SplitBySpace(id, s); |
73 SplitBySpace(id, s); |
72 if s[1]='"' then Delete(s, 1, 1); |
74 if s[1]='"' then Delete(s, 1, 1); |
73 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
75 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
74 if id = 'team' then CurrentTeam.TeamName:= s |
76 if id = 'team' then CurrentTeam^.TeamName:= s |
75 else if (id[1] = 'h') and (id[2] = 'h') |
77 else if (id[1] = 'h') and (id[2] = 'h') |
76 and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then |
78 and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then |
77 CurrentTeam.Hedgehogs[byte(id[3])-48].Name:= s |
79 CurrentTeam^.Hedgehogs[byte(id[3])-48].Name:= s |
78 else OutError(errmsgUnknownVariable + ' "' + id + '"') |
80 else OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
79 end; |
81 end; |
80 |
82 |
81 procedure chGrave(var s: shortstring); |
83 procedure chGrave(var s: shortstring); |
82 begin |
84 begin |
83 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
85 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
84 if s[1]='"' then Delete(s, 1, 1); |
86 if s[1]='"' then Delete(s, 1, 1); |
85 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
87 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
86 CurrentTeam.GraveName:= s |
88 CurrentTeam^.GraveName:= s |
87 end; |
89 end; |
88 |
90 |
89 procedure chFort(var s: shortstring); |
91 procedure chFort(var s: shortstring); |
90 begin |
92 begin |
91 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
93 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); |
92 if s[1]='"' then Delete(s, 1, 1); |
94 if s[1]='"' then Delete(s, 1, 1); |
93 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
95 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
94 CurrentTeam.FortName:= s |
96 CurrentTeam^.FortName:= s |
95 end; |
97 end; |
96 |
98 |
97 procedure chColor(var id: shortstring); |
99 procedure chColor(var id: shortstring); |
98 var c: integer; |
100 var c: integer; |
99 begin |
101 begin |
100 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true); |
102 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/color"', true); |
101 val(id, CurrentTeam.Color, c); |
103 val(id, CurrentTeam^.Color, c); |
102 CurrentTeam.AdjColor:= CurrentTeam.Color; |
104 CurrentTeam^.AdjColor:= CurrentTeam^.Color; |
103 AdjustColor(CurrentTeam.AdjColor) |
105 AdjustColor(CurrentTeam^.AdjColor) |
104 end; |
106 end; |
105 |
107 |
106 procedure chAddHH(var id: shortstring); |
108 procedure chAddHH(var id: shortstring); |
107 var s: shortstring; |
109 var s: shortstring; |
108 c: integer; |
110 c: integer; |
136 if CurrentTeam = nil then exit; |
138 if CurrentTeam = nil then exit; |
137 SplitBySpace(id, s); |
139 SplitBySpace(id, s); |
138 if s[1]='"' then Delete(s, 1, 1); |
140 if s[1]='"' then Delete(s, 1, 1); |
139 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
141 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
140 b:= KeyNameToCode(id); |
142 b:= KeyNameToCode(id); |
141 if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"') |
143 if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
142 else CurrentTeam.Binds[b]:= s |
144 else CurrentTeam^.Binds[b]:= s |
143 end; |
145 end; |
144 |
146 |
145 procedure chLeft_p(var s: shortstring); |
147 procedure chLeft_p(var s: shortstring); |
146 begin |
148 begin |
147 if CheckNoTeamOrHH then exit; |
149 if CheckNoTeamOrHH then exit; |
148 bShowFinger:= false; |
150 bShowFinger:= false; |
149 if not CurrentTeam.ExtDriven then SendIPC('L'); |
151 if not CurrentTeam^.ExtDriven then SendIPC('L'); |
150 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
152 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
151 Message:= Message or gm_Left |
153 Message:= Message or gm_Left |
152 end; |
154 end; |
153 |
155 |
154 procedure chLeft_m(var s: shortstring); |
156 procedure chLeft_m(var s: shortstring); |
155 begin |
157 begin |
156 if CheckNoTeamOrHH then exit; |
158 if CheckNoTeamOrHH then exit; |
157 if not CurrentTeam.ExtDriven then SendIPC('l'); |
159 if not CurrentTeam^.ExtDriven then SendIPC('l'); |
158 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
160 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
159 Message:= Message and not gm_Left |
161 Message:= Message and not gm_Left |
160 end; |
162 end; |
161 |
163 |
162 procedure chRight_p(var s: shortstring); |
164 procedure chRight_p(var s: shortstring); |
163 begin |
165 begin |
164 if CheckNoTeamOrHH then exit; |
166 if CheckNoTeamOrHH then exit; |
165 bShowFinger:= false; |
167 bShowFinger:= false; |
166 if not CurrentTeam.ExtDriven then SendIPC('R'); |
168 if not CurrentTeam^.ExtDriven then SendIPC('R'); |
167 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
169 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
168 Message:= Message or gm_Right |
170 Message:= Message or gm_Right |
169 end; |
171 end; |
170 |
172 |
171 procedure chRight_m(var s: shortstring); |
173 procedure chRight_m(var s: shortstring); |
172 begin |
174 begin |
173 if CheckNoTeamOrHH then exit; |
175 if CheckNoTeamOrHH then exit; |
174 if not CurrentTeam.ExtDriven then SendIPC('r'); |
176 if not CurrentTeam^.ExtDriven then SendIPC('r'); |
175 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
177 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
176 Message:= Message and not gm_Right |
178 Message:= Message and not gm_Right |
177 end; |
179 end; |
178 |
180 |
179 procedure chUp_p(var s: shortstring); |
181 procedure chUp_p(var s: shortstring); |
180 begin |
182 begin |
181 if CheckNoTeamOrHH then exit; |
183 if CheckNoTeamOrHH then exit; |
182 bShowFinger:= false; |
184 bShowFinger:= false; |
183 if not CurrentTeam.ExtDriven then SendIPC('U'); |
185 if not CurrentTeam^.ExtDriven then SendIPC('U'); |
184 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
186 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
185 Message:= Message or gm_Up |
187 Message:= Message or gm_Up |
186 end; |
188 end; |
187 |
189 |
188 procedure chUp_m(var s: shortstring); |
190 procedure chUp_m(var s: shortstring); |
189 begin |
191 begin |
190 if CheckNoTeamOrHH then exit; |
192 if CheckNoTeamOrHH then exit; |
191 if not CurrentTeam.ExtDriven then SendIPC('u'); |
193 if not CurrentTeam^.ExtDriven then SendIPC('u'); |
192 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
194 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
193 Message:= Message and not gm_Up |
195 Message:= Message and not gm_Up |
194 end; |
196 end; |
195 |
197 |
196 procedure chDown_p(var s: shortstring); |
198 procedure chDown_p(var s: shortstring); |
197 begin |
199 begin |
198 if CheckNoTeamOrHH then exit; |
200 if CheckNoTeamOrHH then exit; |
199 bShowFinger:= false; |
201 bShowFinger:= false; |
200 if not CurrentTeam.ExtDriven then SendIPC('D'); |
202 if not CurrentTeam^.ExtDriven then SendIPC('D'); |
201 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
203 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
202 Message:= Message or gm_Down |
204 Message:= Message or gm_Down |
203 end; |
205 end; |
204 |
206 |
205 procedure chDown_m(var s: shortstring); |
207 procedure chDown_m(var s: shortstring); |
206 begin |
208 begin |
207 if CheckNoTeamOrHH then exit; |
209 if CheckNoTeamOrHH then exit; |
208 if not CurrentTeam.ExtDriven then SendIPC('d'); |
210 if not CurrentTeam^.ExtDriven then SendIPC('d'); |
209 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
211 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
210 Message:= Message and not gm_Down |
212 Message:= Message and not gm_Down |
211 end; |
213 end; |
212 |
214 |
213 procedure chLJump(var s: shortstring); |
215 procedure chLJump(var s: shortstring); |
214 begin |
216 begin |
215 if CheckNoTeamOrHH then exit; |
217 if CheckNoTeamOrHH then exit; |
216 bShowFinger:= false; |
218 bShowFinger:= false; |
217 if not CurrentTeam.ExtDriven then SendIPC('j'); |
219 if not CurrentTeam^.ExtDriven then SendIPC('j'); |
218 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
220 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
219 Message:= Message or gm_LJump |
221 Message:= Message or gm_LJump |
220 end; |
222 end; |
221 |
223 |
222 procedure chHJump(var s: shortstring); |
224 procedure chHJump(var s: shortstring); |
223 begin |
225 begin |
224 if CheckNoTeamOrHH then exit; |
226 if CheckNoTeamOrHH then exit; |
225 bShowFinger:= false; |
227 bShowFinger:= false; |
226 if not CurrentTeam.ExtDriven then SendIPC('J'); |
228 if not CurrentTeam^.ExtDriven then SendIPC('J'); |
227 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
229 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
228 Message:= Message or gm_HJump |
230 Message:= Message or gm_HJump |
229 end; |
231 end; |
230 |
232 |
231 procedure chAttack_p(var s: shortstring); |
233 procedure chAttack_p(var s: shortstring); |
232 begin |
234 begin |
233 if CheckNoTeamOrHH then exit; |
235 if CheckNoTeamOrHH then exit; |
234 bShowFinger:= false; |
236 bShowFinger:= false; |
235 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
237 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
236 begin |
238 begin |
237 {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear.State = '+inttostr(State));{$ENDIF} |
239 {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} |
238 if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then |
240 if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then |
239 begin |
241 begin |
240 FollowGear:= CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear; |
242 FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear; |
241 if not CurrentTeam.ExtDriven then SendIPC('A'); |
243 if not CurrentTeam^.ExtDriven then SendIPC('A'); |
242 Message:= Message or gm_Attack |
244 Message:= Message or gm_Attack |
243 end |
245 end |
244 end |
246 end |
245 end; |
247 end; |
246 |
248 |
247 procedure chAttack_m(var s: shortstring); |
249 procedure chAttack_m(var s: shortstring); |
248 begin |
250 begin |
249 if CheckNoTeamOrHH then exit; |
251 if CheckNoTeamOrHH then exit; |
250 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
252 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
251 begin |
253 begin |
252 if not CurrentTeam.ExtDriven and |
254 if not CurrentTeam^.ExtDriven and |
253 ((Message and gm_Attack) <> 0) then SendIPC('a'); |
255 ((Message and gm_Attack) <> 0) then SendIPC('a'); |
254 Message:= Message and not gm_Attack |
256 Message:= Message and not gm_Attack |
255 end |
257 end |
256 end; |
258 end; |
257 |
259 |
258 procedure chSwitch(var s: shortstring); |
260 procedure chSwitch(var s: shortstring); |
259 begin |
261 begin |
260 if CheckNoTeamOrHH then exit; |
262 if CheckNoTeamOrHH then exit; |
261 if not CurrentTeam.ExtDriven then SendIPC('S'); |
263 if not CurrentTeam^.ExtDriven then SendIPC('S'); |
262 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^ do |
264 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do |
263 Message:= Message or gm_Switch |
265 Message:= Message or gm_Switch |
264 end; |
266 end; |
265 |
267 |
266 procedure chNextTurn(var s: shortstring); |
268 procedure chNextTurn(var s: shortstring); |
267 begin |
269 begin |
268 if AllInactive then |
270 if AllInactive then |
269 begin |
271 begin |
270 if not CurrentTeam.ExtDriven then SendIPC('N'); |
272 if not CurrentTeam^.ExtDriven then SendIPC('N'); |
271 {$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
273 {$IFDEF DEBUGFILE}AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));{$ENDIF} |
272 SwitchHedgehog; |
274 SwitchHedgehog; |
273 end |
275 end |
274 end; |
276 end; |
275 |
277 |
331 if bShowAmmoMenu then |
333 if bShowAmmoMenu then |
332 begin |
334 begin |
333 bSelected:= true; |
335 bSelected:= true; |
334 exit |
336 exit |
335 end; |
337 end; |
336 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear^, |
338 with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^, |
337 CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do |
339 CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog] do |
338 if (State and gstHHChooseTarget) <> 0 then |
340 if (State and gstHHChooseTarget) <> 0 then |
339 begin |
341 begin |
340 isCursorVisible:= false; |
342 isCursorVisible:= false; |
341 if not CurrentTeam.ExtDriven then |
343 if not CurrentTeam^.ExtDriven then |
342 begin |
344 begin |
343 SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
345 SDL_GetMouseState(@TargetPoint.X, @TargetPoint.Y); |
344 dec(TargetPoint.X, WorldDx); |
346 dec(TargetPoint.X, WorldDx); |
345 dec(TargetPoint.Y, WorldDy); |
347 dec(TargetPoint.Y, WorldDy); |
346 SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
348 SendIPCXY('p', TargetPoint.X, TargetPoint.Y); |
347 end; |
349 end; |
348 State:= State and not gstHHChooseTarget; |
350 State:= State and not gstHHChooseTarget; |
349 if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
351 if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackingPut) <> 0 then |
350 Message:= Message or gm_Attack; |
352 Message:= Message or gm_Attack; |
351 end else if CurrentTeam.ExtDriven then OutError('got /put while not being in choose target mode', false) |
353 end else if CurrentTeam^.ExtDriven then OutError('got /put while not being in choose target mode', false) |
352 end; |
354 end; |
353 |
355 |
354 procedure chCapture(var s: shortstring); |
356 procedure chCapture(var s: shortstring); |
355 begin |
357 begin |
356 flagMakeCapture:= true |
358 flagMakeCapture:= true |
357 end; |
359 end; |
358 |
360 |
359 procedure chSkip(var s: shortstring); |
361 procedure chSkip(var s: shortstring); |
360 begin |
362 begin |
361 if not CurrentTeam.ExtDriven then SendIPC(','); |
363 if not CurrentTeam^.ExtDriven then SendIPC(','); |
362 TurnTimeLeft:= 0 |
364 TurnTimeLeft:= 0 |
363 end; |
365 end; |
364 |
366 |
365 procedure chSetMap(var s: shortstring); |
367 procedure chSetMap(var s: shortstring); |
366 begin |
368 begin |