182 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
182 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; |
183 const Counter: Longword = 0; |
183 const Counter: Longword = 0; |
184 var Result: PGear; |
184 var Result: PGear; |
185 begin |
185 begin |
186 inc(Counter); |
186 inc(Counter); |
187 {$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF} |
187 {$IFDEF DEBUGFILE} |
|
188 AddFileLog('AddGear: (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
|
189 {$ENDIF} |
|
190 |
188 New(Result); |
191 New(Result); |
189 {$IFDEF DEBUGFILE}AddFileLog('AddGear: type = ' + inttostr(ord(Kind)));{$ENDIF} |
|
190 FillChar(Result^, sizeof(TGear), 0); |
192 FillChar(Result^, sizeof(TGear), 0); |
191 Result^.X:= int2hwFloat(X); |
193 Result^.X:= int2hwFloat(X); |
192 Result^.Y:= int2hwFloat(Y); |
194 Result^.Y:= int2hwFloat(Y); |
193 Result^.Kind := Kind; |
195 Result^.Kind := Kind; |
194 Result^.State:= State; |
196 Result^.State:= State; |
348 t: Longword; |
350 t: Longword; |
349 begin |
351 begin |
350 DeleteCI(Gear); |
352 DeleteCI(Gear); |
351 |
353 |
352 if Gear^.Tex <> nil then |
354 if Gear^.Tex <> nil then |
353 begin |
355 begin |
354 FreeTexture(Gear^.Tex); |
356 FreeTexture(Gear^.Tex); |
355 Gear^.Tex:= nil |
357 Gear^.Tex:= nil |
356 end; |
358 end; |
357 |
359 |
358 if Gear^.Kind = gtHedgehog then |
360 if Gear^.Kind = gtHedgehog then |
359 if CurAmmoGear <> nil then |
361 if CurAmmoGear <> nil then |
360 begin |
362 begin |
361 Gear^.Message:= gm_Destroy; |
363 Gear^.Message:= gm_Destroy; |
362 CurAmmoGear^.Message:= gm_Destroy; |
364 CurAmmoGear^.Message:= gm_Destroy; |
363 exit |
365 exit |
364 end else |
366 end |
365 begin |
367 else |
366 if not (hwRound(Gear^.Y) < cWaterLine) then |
368 begin |
367 begin |
369 if not (hwRound(Gear^.Y) < cWaterLine) then |
368 t:= max(Gear^.Damage, Gear^.Health); |
370 begin |
369 Gear^.Damage:= t; |
371 t:= max(Gear^.Damage, Gear^.Health); |
370 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
372 Gear^.Damage:= t; |
371 uStats.HedgehogDamaged(Gear) |
373 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
372 end; |
374 uStats.HedgehogDamaged(Gear) |
373 team:= PHedgehog(Gear^.Hedgehog)^.Team; |
375 end; |
374 if CurrentHedgehog^.Gear = Gear then |
376 team:= PHedgehog(Gear^.Hedgehog)^.Team; |
375 FreeActionsList; // to avoid ThinkThread on drawned gear |
377 if CurrentHedgehog^.Gear = Gear then |
376 PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
378 FreeActionsList; // to avoid ThinkThread on drawned gear |
377 inc(KilledHHs); |
379 PHedgehog(Gear^.Hedgehog)^.Gear:= nil; |
378 RecountTeamHealth(team); |
380 inc(KilledHHs); |
379 end; |
381 RecountTeamHealth(team); |
380 {$IFDEF DEBUGFILE}AddFileLog('DeleteGear');{$ENDIF} |
382 end; |
|
383 |
|
384 {$IFDEF DEBUGFILE} |
|
385 with Gear^ do AddFileLog('Delete: (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); |
|
386 {$ENDIF} |
|
387 |
381 if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
388 if Gear^.TriggerId <> 0 then TickTrigger(Gear^.TriggerId); |
382 if CurAmmoGear = Gear then CurAmmoGear:= nil; |
389 if CurAmmoGear = Gear then CurAmmoGear:= nil; |
383 if FollowGear = Gear then FollowGear:= nil; |
390 if FollowGear = Gear then FollowGear:= nil; |
384 RemoveGearFromList(Gear); |
391 RemoveGearFromList(Gear); |
385 |
392 |
432 end; |
439 end; |
433 |
440 |
434 procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); |
441 procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); |
435 begin |
442 begin |
436 if cAltDamage then |
443 if cAltDamage then |
437 AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
444 AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
438 end; |
445 end; |
439 |
446 |
440 procedure ProcessGears; |
447 procedure ProcessGears; |
441 const delay: LongWord = 0; |
448 const delay: LongWord = 0; |
442 step: (stDelay, stChDmg, stTurnReact, |
449 step: (stDelay, stChDmg, stTurnReact, |
443 stAfterDelay, stChWin, stWater, stChWin2, stHealth, |
450 stAfterDelay, stChWin, stWater, stChWin2, stHealth, |
444 stSpawn, stNTurn) = stDelay; |
451 stSpawn, stNTurn) = stDelay; |
445 |
452 |
446 var Gear, t: PGear; |
453 var Gear, t: PGear; |
447 begin |
454 begin |
448 PrvInactive:= AllInactive; |
455 PrvInactive:= AllInactive; |
449 AllInactive:= true; |
456 AllInactive:= true; |
|
457 |
450 t:= GearsList; |
458 t:= GearsList; |
451 while t <> nil do |
459 while t <> nil do |
452 begin |
460 begin |
453 Gear:= t; |
461 Gear:= t; |
454 t:= Gear^.NextGear; |
462 t:= Gear^.NextGear; |