46 begin |
46 begin |
47 slot:= Gear^.MsgParam; |
47 slot:= Gear^.MsgParam; |
48 |
48 |
49 with PHedgehog(Gear^.Hedgehog)^ do |
49 with PHedgehog(Gear^.Hedgehog)^ do |
50 begin |
50 begin |
51 Gear^.Message:= Gear^.Message and not gm_Slot; |
51 Gear^.Message:= Gear^.Message and not gmSlot; |
52 ammoidx:= 0; |
52 ammoidx:= 0; |
53 while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx); |
53 while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx); |
54 |
54 |
55 if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or |
55 if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or |
56 ((MultiShootAttacks > 0) and (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) = 0)) or |
56 ((MultiShootAttacks > 0) and (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) = 0)) or |
57 ((Gear^.State and gstHHDriven) = 0) then exit; |
57 ((Gear^.State and gstHHDriven) = 0) then exit; |
58 |
58 |
59 if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(PHedgehog(Gear^.Hedgehog)^); |
59 if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(PHedgehog(Gear^.Hedgehog)^); |
60 |
60 |
61 MultiShootAttacks:= 0; |
61 MultiShootAttacks:= 0; |
62 Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
62 Gear^.Message:= Gear^.Message and not (gmLJump or gmHJump); |
63 |
63 |
64 if Ammoz[CurAmmoType].Slot = slot then |
64 if Ammoz[CurAmmoType].Slot = slot then |
65 begin |
65 begin |
66 i:= 0; |
66 i:= 0; |
67 repeat |
67 repeat |
114 end; |
114 end; |
115 |
115 |
116 procedure HHSetTimer(Gear: PGear); |
116 procedure HHSetTimer(Gear: PGear); |
117 var CurWeapon: PAmmo; |
117 var CurWeapon: PAmmo; |
118 begin |
118 begin |
119 Gear^.Message:= Gear^.Message and not gm_Timer; |
119 Gear^.Message:= Gear^.Message and not gmTimer; |
120 CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^); |
120 CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^); |
121 with PHedgehog(Gear^.Hedgehog)^ do |
121 with PHedgehog(Gear^.Hedgehog)^ do |
122 if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then |
122 if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then |
123 begin |
123 begin |
124 CurWeapon^.Timer:= 1000 * Gear^.MsgParam; |
124 CurWeapon^.Timer:= 1000 * Gear^.MsgParam; |
145 ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) or |
145 ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) or |
146 ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) and |
146 ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) and |
147 ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then |
147 ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then |
148 begin |
148 begin |
149 State:= State or gstAttacking; |
149 State:= State or gstAttacking; |
150 if Power = cMaxPower then Message:= Message and not gm_Attack |
150 if Power = cMaxPower then Message:= Message and not gmAttack |
151 else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then Message:= Message and not gm_Attack |
151 else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then Message:= Message and not gmAttack |
152 else begin |
152 else begin |
153 if Power = 0 then |
153 if Power = 0 then |
154 begin |
154 begin |
155 AttackBar:= CurrentTeam^.AttackBar; |
155 AttackBar:= CurrentTeam^.AttackBar; |
156 PlaySound(sndThrowPowerUp) |
156 PlaySound(sndThrowPowerUp) |
157 end; |
157 end; |
158 inc(Power) |
158 inc(Power) |
159 end; |
159 end; |
160 if ((Message and gm_Attack) <> 0) then exit; |
160 if ((Message and gmAttack) <> 0) then exit; |
161 |
161 |
162 if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then |
162 if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then |
163 begin |
163 begin |
164 StopSound(sndThrowPowerUp); |
164 StopSound(sndThrowPowerUp); |
165 PlaySound(sndThrowRelease); |
165 PlaySound(sndThrowRelease); |
283 Power:= 0; |
283 Power:= 0; |
284 if (CurAmmoGear <> nil) |
284 if (CurAmmoGear <> nil) |
285 and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then |
285 and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then |
286 begin |
286 begin |
287 CurAmmoGear^.AmmoType:= CurAmmoType; |
287 CurAmmoGear^.AmmoType:= CurAmmoType; |
288 Message:= Message or gm_Attack; |
288 Message:= Message or gmAttack; |
289 CurAmmoGear^.Message:= Message |
289 CurAmmoGear^.Message:= Message |
290 end else begin |
290 end else begin |
291 if not CurrentTeam^.ExtDriven and |
291 if not CurrentTeam^.ExtDriven and |
292 ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
292 ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then SendIPC('a'); |
293 AfterAttack; |
293 AfterAttack; |
294 end |
294 end |
295 end else Message:= Message and not gm_Attack; |
295 end else Message:= Message and not gmAttack; |
296 end |
296 end |
297 end; |
297 end; |
298 |
298 |
299 procedure AfterAttack; |
299 procedure AfterAttack; |
300 var s: shortstring; |
300 var s: shortstring; |
463 begin |
463 begin |
464 if isCursorVisible then |
464 if isCursorVisible then |
465 with PHedgehog(Gear^.Hedgehog)^ do |
465 with PHedgehog(Gear^.Hedgehog)^ do |
466 with CurWeapon^ do |
466 with CurWeapon^ do |
467 begin |
467 begin |
468 if (Gear^.Message and gm_Left ) <> 0 then |
468 if (Gear^.Message and gmLeft ) <> 0 then |
469 Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount |
469 Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount |
470 else |
470 else |
471 if (Gear^.Message and gm_Right ) <> 0 then |
471 if (Gear^.Message and gmRight ) <> 0 then |
472 Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
472 Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount |
473 else exit; |
473 else exit; |
474 StepTicks:= 200; |
474 StepTicks:= 200; |
475 exit |
475 exit |
476 end; |
476 end; |
477 |
477 |
478 if ((Gear^.Message and gm_Animate) <> 0) then |
478 if ((Gear^.Message and gmAnimate) <> 0) then |
479 begin |
479 begin |
480 Gear^.Message:= 0; |
480 Gear^.Message:= 0; |
481 Gear^.State:= Gear^.State or gstAnimation; |
481 Gear^.State:= Gear^.State or gstAnimation; |
482 Gear^.Tag:= Gear^.MsgParam; |
482 Gear^.Tag:= Gear^.MsgParam; |
483 Gear^.Timer:= 0; |
483 Gear^.Timer:= 0; |
484 Gear^.Pos:= 0 |
484 Gear^.Pos:= 0 |
485 end; |
485 end; |
486 |
486 |
487 if ((Gear^.Message and gm_LJump ) <> 0) then |
487 if ((Gear^.Message and gmLJump ) <> 0) then |
488 begin |
488 begin |
489 Gear^.Message:= Gear^.Message and not gm_LJump; |
489 Gear^.Message:= Gear^.Message and not gmLJump; |
490 DeleteCI(Gear); |
490 DeleteCI(Gear); |
491 if not TestCollisionYwithGear(Gear, -1) then |
491 if not TestCollisionYwithGear(Gear, -1) then |
492 if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else |
492 if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else |
493 if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; |
493 if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; |
494 if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
494 if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) |
500 PlaySound(sndJump1, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
500 PlaySound(sndJump1, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
501 exit |
501 exit |
502 end; |
502 end; |
503 end; |
503 end; |
504 |
504 |
505 if ((Gear^.Message and gm_HJump ) <> 0) then |
505 if ((Gear^.Message and gmHJump ) <> 0) then |
506 begin |
506 begin |
507 DeleteCI(Gear); |
507 DeleteCI(Gear); |
508 Gear^.Message:= Gear^.Message and not gm_HJump; |
508 Gear^.Message:= Gear^.Message and not gmHJump; |
509 |
509 |
510 Gear^.dY:= -_0_2; |
510 Gear^.dY:= -_0_2; |
511 SetLittle(Gear^.dX); |
511 SetLittle(Gear^.dX); |
512 Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
512 Gear^.State:= Gear^.State or gstMoving or gstHHJumping; |
513 PlaySound(sndJump3, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
513 PlaySound(sndJump3, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
514 exit |
514 exit |
515 end; |
515 end; |
516 |
516 |
517 PrevdX:= hwSign(Gear^.dX); |
517 PrevdX:= hwSign(Gear^.dX); |
518 if (Gear^.Message and gm_Left )<>0 then Gear^.dX:= -cLittle else |
518 if (Gear^.Message and gmLeft )<>0 then Gear^.dX:= -cLittle else |
519 if (Gear^.Message and gm_Right )<>0 then Gear^.dX:= cLittle else exit; |
519 if (Gear^.Message and gmRight )<>0 then Gear^.dX:= cLittle else exit; |
520 |
520 |
521 if (Gear^.Message and (gm_Left or gm_Right)) <> 0 then |
521 if (Gear^.Message and (gmLeft or gmRight)) <> 0 then |
522 begin |
522 begin |
523 StepSoundTimer:= cHHStepTicks; |
523 StepSoundTimer:= cHHStepTicks; |
524 end; |
524 end; |
525 |
525 |
526 StepTicks:= cHHStepTicks; |
526 StepTicks:= cHHStepTicks; |
546 or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
546 or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
547 if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) |
547 if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) |
548 or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
548 or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; |
549 end; |
549 end; |
550 |
550 |
551 if (not cArtillery) and ((Gear^.Message and gm_Precise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
551 if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then |
552 Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
552 Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); |
553 |
553 |
554 SetAllHHToActive; |
554 SetAllHHToActive; |
555 |
555 |
556 if not TestCollisionYwithGear(Gear, 1) then |
556 if not TestCollisionYwithGear(Gear, 1) then |
593 begin |
593 begin |
594 with PHedgehog(Gear^.Hedgehog)^ do |
594 with PHedgehog(Gear^.Hedgehog)^ do |
595 if (CurAmmoType = amRope) |
595 if (CurAmmoType = amRope) |
596 and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1; |
596 and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1; |
597 |
597 |
598 if (((Gear^.Message and gm_Precise) = 0) or ((GameTicks mod 5) = 1)) then |
598 if (((Gear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then |
599 if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Angle >= CurMinAngle + da) then dec(Gear^.Angle, da) |
599 if ((Gear^.Message and gmUp) <> 0) and (Gear^.Angle >= CurMinAngle + da) then dec(Gear^.Angle, da) |
600 else |
600 else |
601 if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Angle + da <= CurMaxAngle) then inc(Gear^.Angle, da) |
601 if ((Gear^.Message and gmDown) <> 0) and (Gear^.Angle + da <= CurMaxAngle) then inc(Gear^.Angle, da) |
602 end; |
602 end; |
603 |
603 |
604 procedure doStepHedgehog(Gear: PGear); forward; |
604 procedure doStepHedgehog(Gear: PGear); forward; |
605 //////////////////////////////////////////////////////////////////////////////// |
605 //////////////////////////////////////////////////////////////////////////////// |
606 procedure doStepHedgehogMoving(Gear: PGear); |
606 procedure doStepHedgehogMoving(Gear: PGear); |
750 or (CurAmmoGear <> nil) then // we are moving |
750 or (CurAmmoGear <> nil) then // we are moving |
751 begin |
751 begin |
752 with Hedgehog^ do |
752 with Hedgehog^ do |
753 if (CurAmmoGear = nil) |
753 if (CurAmmoGear = nil) |
754 and (Gear^.dY > _0_39) |
754 and (Gear^.dY > _0_39) |
755 and (CurAmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack; |
755 and (CurAmmoType = amParachute) then Gear^.Message:= Gear^.Message or gmAttack; |
756 // check for case with ammo |
756 // check for case with ammo |
757 t:= CheckGearNear(Gear, gtCase, 36, 36); |
757 t:= CheckGearNear(Gear, gtCase, 36, 36); |
758 if t <> nil then |
758 if t <> nil then |
759 PickUp(Gear, t) |
759 PickUp(Gear, t) |
760 end; |
760 end; |
761 |
761 |
762 if (CurAmmoGear = nil) then |
762 if (CurAmmoGear = nil) then |
763 if (((Gear^.Message and gm_Attack) <> 0) |
763 if (((Gear^.Message and gmAttack) <> 0) |
764 or ((Gear^.State and gstAttacking) <> 0)) then |
764 or ((Gear^.State and gstAttacking) <> 0)) then |
765 Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
765 Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs |
766 else |
766 else |
767 else |
767 else |
768 with Hedgehog^ do |
768 with Hedgehog^ do |
769 if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
769 if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
770 and ((Gear^.Message and gm_LJump) <> 0) |
770 and ((Gear^.Message and gmLJump) <> 0) |
771 and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
771 and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then |
772 begin |
772 begin |
773 Gear^.Message:= Gear^.Message and not gm_LJump; |
773 Gear^.Message:= Gear^.Message and not gmLJump; |
774 Attack(Gear) |
774 Attack(Gear) |
775 end; |
775 end; |
776 |
776 |
777 if (CurAmmoGear = nil) |
777 if (CurAmmoGear = nil) |
778 or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
778 or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) |
779 or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) then |
779 or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0) then |
780 begin |
780 begin |
781 if ((Gear^.Message and gm_Slot) <> 0) then |
781 if ((Gear^.Message and gmSlot) <> 0) then |
782 begin |
782 begin |
783 ChangeAmmo(Gear); |
783 ChangeAmmo(Gear); |
784 ApplyAmmoChanges(Hedgehog^) |
784 ApplyAmmoChanges(Hedgehog^) |
785 end; |
785 end; |
786 |
786 |
787 if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); |
787 if ((Gear^.Message and gmWeapon) <> 0) then HHSetWeapon(Gear); |
788 |
788 |
789 if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear); |
789 if ((Gear^.Message and gmTimer) <> 0) then HHSetTimer(Gear); |
790 end; |
790 end; |
791 |
791 |
792 if CurAmmoGear <> nil then |
792 if CurAmmoGear <> nil then |
793 begin |
793 begin |
794 CurAmmoGear^.Message:= Gear^.Message; |
794 CurAmmoGear^.Message:= Gear^.Message; |
800 |
800 |
801 if (Gear^.State and gstMoving) <> 0 then |
801 if (Gear^.State and gstMoving) <> 0 then |
802 begin |
802 begin |
803 wasJumping:= ((Gear^.State and gstHHJumping) <> 0); |
803 wasJumping:= ((Gear^.State and gstHHJumping) <> 0); |
804 |
804 |
805 if ((Gear^.Message and gm_HJump) <> 0) and |
805 if ((Gear^.Message and gmHJump) <> 0) and |
806 wasJumping and |
806 wasJumping and |
807 ((Gear^.State and gstHHHJump) = 0) then |
807 ((Gear^.State and gstHHHJump) = 0) then |
808 if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then |
808 if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then |
809 begin |
809 begin |
810 Gear^.State:= Gear^.State or gstHHHJump; |
810 Gear^.State:= Gear^.State or gstHHHJump; |
811 Gear^.dY:= -_0_25; |
811 Gear^.dY:= -_0_25; |
812 if not cArtillery then Gear^.dX:= -SignAs(_0_02, Gear^.dX); |
812 if not cArtillery then Gear^.dX:= -SignAs(_0_02, Gear^.dX); |
813 PlaySound(sndJump2, Hedgehog^.Team^.voicepack) |
813 PlaySound(sndJump2, Hedgehog^.Team^.voicepack) |
814 end; |
814 end; |
815 |
815 |
816 Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
816 Gear^.Message:= Gear^.Message and not (gmLJump or gmHJump); |
817 |
817 |
818 if (not cArtillery) and wasJumping and |
818 if (not cArtillery) and wasJumping and |
819 TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
819 TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); |
820 |
820 |
821 doStepHedgehogMoving(Gear); |
821 doStepHedgehogMoving(Gear); |