386 end; |
386 end; |
387 Gear:= Gear^.NextGear |
387 Gear:= Gear^.NextGear |
388 end; |
388 end; |
389 end; |
389 end; |
390 |
390 |
|
391 procedure HealthMachine; |
|
392 var Gear: PGear; |
|
393 begin |
|
394 Gear:= GearsList; |
|
395 |
|
396 while Gear <> nil do |
|
397 begin |
|
398 if Gear^.Kind = gtHedgehog then |
|
399 Gear^.Damage:= min(cHealthDecrease, Gear^.Health - 1); |
|
400 |
|
401 Gear:= Gear^.NextGear |
|
402 end; |
|
403 end; |
|
404 |
391 procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); |
405 procedure AddDamageTag(X, Y, Damage: LongWord; Gear: PGear); |
392 begin |
406 begin |
393 if cAltDamage then |
407 if cAltDamage then |
394 AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
408 AddGear(X, Y, gtSmallDamage, Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; |
395 end; |
409 end; |
396 |
410 |
397 procedure ProcessGears; |
411 procedure ProcessGears; |
398 const delay: LongWord = 0; |
412 const delay: LongWord = 0; |
399 step: (stDelay, stChDmg, stTurnReact, |
413 step: (stDelay, stChDmg, stTurnReact, |
400 stAfterDelay, stChWin, stSpawn, stNTurn) = stDelay; |
414 stAfterDelay, stChWin, stHealth, stSpawn, stNTurn) = stDelay; |
|
415 |
401 var Gear, t: PGear; |
416 var Gear, t: PGear; |
402 begin |
417 begin |
403 PrvInactive:= AllInactive; |
418 PrvInactive:= AllInactive; |
404 AllInactive:= true; |
419 AllInactive:= true; |
405 t:= GearsList; |
420 t:= GearsList; |
406 while t<>nil do |
421 while t <> nil do |
407 begin |
422 begin |
408 Gear:= t; |
423 Gear:= t; |
409 t:= Gear^.NextGear; |
424 t:= Gear^.NextGear; |
410 if Gear^.Active then Gear^.doStep(Gear); |
425 if Gear^.Active then Gear^.doStep(Gear); |
411 end; |
426 end; |
438 |
453 |
439 if delay = 0 then |
454 if delay = 0 then |
440 inc(step) |
455 inc(step) |
441 end; |
456 end; |
442 stChWin: if not CheckForWin then inc(step) else step:= stDelay; |
457 stChWin: if not CheckForWin then inc(step) else step:= stDelay; |
|
458 stHealth: if (cHealthDecrease = 0) |
|
459 or bBetweenTurns |
|
460 or isInMultiShoot |
|
461 or (FinishedTurnsTotal = 0) then inc(step) |
|
462 else begin |
|
463 bBetweenTurns:= true; |
|
464 HealthMachine; |
|
465 step:= stChDmg |
|
466 end; |
443 stSpawn: begin |
467 stSpawn: begin |
444 if not isInMultiShoot then SpawnBoxOfSmth; |
468 if not isInMultiShoot then SpawnBoxOfSmth; |
445 inc(step) |
469 inc(step) |
446 end; |
470 end; |
447 stNTurn: begin |
471 stNTurn: begin |
448 if isInMultiShoot then isInMultiShoot:= false |
472 if isInMultiShoot then isInMultiShoot:= false |
449 else begin |
473 else begin |
450 ParseCommand('/nextturn', true); |
474 ParseCommand('/nextturn', true); |
|
475 bBetweenTurns:= false |
451 end; |
476 end; |
452 step:= Low(step) |
477 step:= Low(step) |
453 end; |
478 end; |
454 end; |
479 end; |
455 |
480 |