6504 Gear^.dX:= _90-(GetRandomf*_360); |
6504 Gear^.dX:= _90-(GetRandomf*_360); |
6505 Gear^.dY:= _90-(GetRandomf*_360) |
6505 Gear^.dY:= _90-(GetRandomf*_360) |
6506 end; |
6506 end; |
6507 end |
6507 end |
6508 end; |
6508 end; |
6509 (* |
6509 |
6510 procedure doStepCreeper(Gear: PGear); |
6510 procedure doStepCreeper(Gear: PGear); |
6511 var hogs: PGearArrayS; |
6511 var i,t,targDist,tmpDist: LongWord; |
6512 HHGear: PGear; |
6512 targ, tmpG: PGear; |
6513 tdX: hwFloat; |
6513 trackSpeed, airFriction, tX, tY: hwFloat; |
6514 dir: LongInt; |
6514 isUnderwater: Boolean; |
6515 begin |
6515 vg: PVisualGear; |
6516 doStepFallingGear(Gear); |
6516 begin |
6517 if Gear^.Timer > 0 then dec(Gear^.Timer); |
6517 doStepFallingGear(Gear); |
6518 // creeper sleep phase |
6518 if (Gear^.State and gstFrozen) <> 0 then |
6519 if (Gear^.Hedgehog = nil) and (Gear^.Timer > 0) then exit; |
6519 begin |
6520 |
6520 if Gear^.Damage > 0 then |
6521 if Gear^.Hedgehog <> nil then HHGear:= Gear^.Hedgehog^.Gear |
6521 begin |
6522 else HHGear:= nil; |
6522 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); |
6523 |
6523 DeleteGear(Gear) |
6524 // creeper boom phase |
6524 end; |
6525 if (Gear^.State and gstTmpFlag <> 0) then |
6525 exit |
6526 begin |
6526 end; |
6527 if (Gear^.Timer = 0) then |
6527 if (TurnTimeLeft = 0) or (Gear^.Angle = 0) or (Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Gear = nil) then |
6528 begin |
6528 begin |
6529 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 300, CurrentHedgehog, EXPLAutoSound); |
6529 Gear^.Hedgehog:= nil; |
6530 DeleteGear(Gear) |
6530 targ:= nil; |
6531 end; |
6531 end |
6532 // ssssss he essssscaped |
6532 else if Gear^.Hedgehog <> nil then |
6533 if (Gear^.Timer > 250) and ((HHGear = nil) or |
6533 targ:= Gear^.Hedgehog^.Gear; |
6534 (((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) > 180) and |
6534 if (targ <> nil) and ((GameTicks and $3F) = 0) and (TestCollisionYKick(Gear, 1) <> 0) then |
6535 (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > _180))) then |
6535 begin |
6536 begin |
6536 vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite); |
6537 Gear^.State:= Gear^.State and (not gstTmpFlag); |
6537 if vg <> nil then vg^.Tint:= $FF0000FF; |
6538 Gear^.Timer:= 0 |
6538 if (Gear^.X < targ^.X) then // need to add collision checks to avoid walking off edges or getting too close to obstacles where jumping is needed |
6539 end; |
6539 if (WorldEdge = weWrap) and ((targ^.X - Gear^.X) > ((Gear^.X - int2hwFloat(LeftX)) + (int2hwFloat(RightX) - targ^.X))) then |
6540 exit |
6540 Gear^.dX:= -cLittle |
6541 end; |
6541 else |
6542 |
6542 Gear^.dX:= cLittle |
6543 // Search out a new target, as target seek time has expired, target is dead, target is out of range, or we did not have a target |
6543 else if (Gear^.X > targ^.X) then |
6544 if (HHGear = nil) or (Gear^.Timer = 0) or |
6544 if (WorldEdge = weWrap) and ((Gear^.X - targ^.X) > ((targ^.X - int2hwFloat(LeftX)) + (int2hwFloat(RightX) - Gear^.X))) then |
6545 (((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) > Gear^.Angle) and |
6545 Gear^.dX:= cLittle |
6546 (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > int2hwFloat(Gear^.Angle))) |
6546 else |
6547 then |
6547 Gear^.dX:= -cLittle; |
6548 begin |
6548 if (GetRandom(30) = 0) then |
6549 hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Angle); |
6549 begin |
6550 if hogs.size > 1 then |
6550 Gear^.dY := -_0_15; |
6551 Gear^.Hedgehog:= hogs.ar^[GetRandom(hogs.size)]^.Hedgehog |
6551 Gear^.dX:= SignAs(_0_15, Gear^.dX); |
6552 else if hogs.size = 1 then Gear^.Hedgehog:= hogs.ar^[0]^.Hedgehog |
6552 end; |
6553 else Gear^.Hedgehog:= nil; |
6553 MakeHedgehogsStep(Gear); |
6554 if Gear^.Hedgehog <> nil then Gear^.Timer:= 5000; |
6554 end; |
6555 exit |
6555 if (TurnTimeLeft = 0) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) > _0_02.QWordValue) then |
6556 end; |
6556 AllInactive := false; |
6557 |
6557 |
6558 // we have a target. move the creeper. |
6558 if targ <> nil then |
6559 if HHGear <> nil then |
6559 begin |
6560 begin |
6560 tX:=Gear^.X-targ^.X; |
6561 // GOTCHA |
6561 tY:=Gear^.Y-targ^.Y; |
6562 if ((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) < 50) and |
6562 // allow escaping - should maybe flag this too |
6563 (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) < _50) then |
6563 if (GameTicks > Gear^.FlightTime+10000) or |
6564 begin |
6564 ((tX.Round+tY.Round > Gear^.Angle*6) and |
6565 // hisssssssssss |
6565 (hwRound(hwSqr(tX) + hwSqr(tY)) > sqr(Gear^.Angle*6))) then |
6566 Gear^.State:= Gear^.State or gstTmpFlag; |
6566 targ:= nil |
6567 Gear^.Timer:= 1500; |
6567 end; |
6568 exit |
6568 |
6569 end; |
6569 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
6570 if (Gear^.State and gstMoving <> 0) then |
6570 // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0 |
6571 begin |
6571 // then we aren't hunting |
6572 Gear^.dY:= _0; |
6572 if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or |
6573 Gear^.dX:= _0; |
6573 ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or |
6574 end |
6574 (Gear^.State and gsttmpFlag = 0) or |
6575 else if (GameTicks and $FF = 0) then |
6575 (Gear^.Angle = 0) then |
6576 begin |
6576 gear^.State:= gear^.State and (not gstChooseTarget) |
6577 tdX:= HHGear^.X-Gear^.X; |
6577 else if |
6578 dir:= hwSign(tdX); |
6578 // todo, allow not finding new target, set timeout on target retention |
6579 if TestCollisionX(Gear, dir) = 0 then |
6579 (Gear^.State and gstAttacking = 0) and |
6580 Gear^.X:= Gear^.X + signAs(_1,tdX); |
6580 ((GameTicks and $FF) = 17) and |
6581 if TestCollisionXwithXYShift(Gear, signAs(_10,tdX), 0, dir) <> 0 then |
6581 (GameTicks > Gear^.FlightTime) then // recheck hunted hog |
6582 begin |
6582 begin |
6583 Gear^.dX:= SignAs(_0_15, tdX); |
6583 gear^.State:= gear^.State or gstChooseTarget; |
6584 Gear^.dY:= -_0_3; |
6584 if targ <> nil then |
6585 Gear^.State:= Gear^.State or gstMoving |
6585 targDist:= Distance(Gear^.X-targ^.X,Gear^.Y-targ^.Y).Round |
|
6586 else targDist:= 0; |
|
6587 for t:= 0 to Pred(TeamsCount) do |
|
6588 with TeamsArray[t]^ do |
|
6589 for i:= 0 to cMaxHHIndex do |
|
6590 if Hedgehogs[i].Gear <> nil then |
|
6591 begin |
|
6592 tmpG:= Hedgehogs[i].Gear; |
|
6593 tX:=Gear^.X-tmpG^.X; |
|
6594 tY:=Gear^.Y-tmpG^.Y; |
|
6595 if (Gear^.Angle = $FFFFFFFF) or |
|
6596 ((tX.Round+tY.Round < Gear^.Angle) and |
|
6597 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Angle))) then |
|
6598 begin |
|
6599 if targ <> nil then tmpDist:= Distance(tX,tY).Round; |
|
6600 if (targ = nil) or (tmpDist < targDist) then |
|
6601 begin |
|
6602 if targ = nil then targDist:= Distance(tX,tY).Round |
|
6603 else targDist:= tmpDist; |
|
6604 Gear^.Hedgehog:= @Hedgehogs[i]; |
|
6605 targ:= tmpG; |
|
6606 end |
|
6607 end |
|
6608 end; |
|
6609 if targ <> nil then Gear^.FlightTime:= GameTicks + 5000 |
|
6610 end; |
|
6611 |
|
6612 if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then |
|
6613 begin |
|
6614 if ((Gear^.State and gstAttacking) = 0) then |
|
6615 begin |
|
6616 if ((GameTicks and $1F) = 0) then |
|
6617 begin |
|
6618 if targ <> nil then |
|
6619 begin |
|
6620 tX:=Gear^.X-targ^.X; |
|
6621 tY:=Gear^.Y-targ^.Y; |
|
6622 if (tX.Round+tY.Round < Gear^.Boom) and |
|
6623 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then |
|
6624 Gear^.State := Gear^.State or gstAttacking |
|
6625 end |
|
6626 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then |
|
6627 Gear^.State := Gear^.State or gstAttacking |
|
6628 end |
6586 end |
6629 end |
6587 end; |
6630 else // gstAttacking <> 0 |
6588 end; |
6631 begin |
6589 end; |
6632 AllInactive := false; |
6590 *) |
6633 if (Gear^.Timer and $1FF) = 0 then |
|
6634 PlaySound(sndVaporize); |
|
6635 if Gear^.Timer = 0 then |
|
6636 begin |
|
6637 // recheck |
|
6638 if targ <> nil then |
|
6639 begin |
|
6640 tX:=Gear^.X-targ^.X; |
|
6641 tY:=Gear^.Y-targ^.Y; |
|
6642 if (tX.Round+tY.Round < Gear^.Boom) and |
|
6643 (hwRound(hwSqr(tX) + hwSqr(tY)) < sqr(Gear^.Boom)) then |
|
6644 begin |
|
6645 Gear^.Hedgehog:= CurrentHedgehog; |
|
6646 tmpG:= FollowGear; |
|
6647 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); |
|
6648 FollowGear:= tmpG; |
|
6649 DeleteGear(Gear); |
|
6650 exit |
|
6651 end |
|
6652 end |
|
6653 else if (Gear^.Angle > 0) and (CheckGearNear(Gear, gtHedgehog, Gear^.Boom, Gear^.Boom) <> nil) then |
|
6654 begin |
|
6655 Gear^.Hedgehog:= CurrentHedgehog; |
|
6656 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound); |
|
6657 DeleteGear(Gear); |
|
6658 exit |
|
6659 end; |
|
6660 Gear^.State:= Gear^.State and (not gstAttacking); |
|
6661 Gear^.Timer:= Gear^.WDTimer |
|
6662 end; |
|
6663 if Gear^.Timer > 0 then |
|
6664 dec(Gear^.Timer); |
|
6665 end |
|
6666 end |
|
6667 else // gsttmpFlag = 0 |
|
6668 if (TurnTimeLeft = 0) |
|
6669 or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) |
|
6670 or (CurrentHedgehog^.Gear = nil) then |
|
6671 begin |
|
6672 Gear^.FlightTime:= GameTicks; |
|
6673 Gear^.State := Gear^.State or gsttmpFlag |
|
6674 end |
|
6675 end; |
|
6676 |
6591 //////////////////////////////////////////////////////////////////////////////// |
6677 //////////////////////////////////////////////////////////////////////////////// |
6592 procedure doStepKnife(Gear: PGear); |
6678 procedure doStepKnife(Gear: PGear); |
6593 //var ox, oy: LongInt; |
6679 //var ox, oy: LongInt; |
6594 // la: hwFloat; |
6680 // la: hwFloat; |
6595 var a: real; |
6681 var a: real; |