hedgewars/GSHandlers.inc
changeset 4327 224efdd648e1
parent 4325 ca254d2a46ac
child 4337 85e02b1a8e8f
equal deleted inserted replaced
4325:ca254d2a46ac 4327:224efdd648e1
   706 ////////////////////////////////////////////////////////////////////////////////
   706 ////////////////////////////////////////////////////////////////////////////////
   707 procedure doStepBulletWork(Gear: PGear);
   707 procedure doStepBulletWork(Gear: PGear);
   708 var 
   708 var 
   709     i, x, y: LongWord;
   709     i, x, y: LongWord;
   710     oX, oY: hwFloat;
   710     oX, oY: hwFloat;
   711     trail: PVisualGear;
   711     VGear: PVisualGear;
   712 begin
   712 begin
   713     AllInactive := false;
   713     AllInactive := false;
   714     inc(Gear^.Timer);
   714     inc(Gear^.Timer);
   715     i := 80;
   715     i := 80;
   716     oX := Gear^.X;
   716     oX := Gear^.X;
   754         if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then
   754         if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then
   755             cLaserSighting := false;
   755             cLaserSighting := false;
   756         if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and
   756         if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and
   757            ((GameFlags and gfArtillery) = 0) then cArtillery := false;
   757            ((GameFlags and gfArtillery) = 0) then cArtillery := false;
   758         
   758         
       
   759         // Bullet Hit
       
   760         if (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) 
       
   761             and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then
       
   762         begin
       
   763             VGear := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBulletHit);
       
   764             if VGear <> nil then
       
   765             begin
       
   766                 VGear^.Angle := DxDy2Angle(-Gear^.dX, Gear^.dY);
       
   767             end;
       
   768         end;
       
   769         
   759         // Bullet trail
   770         // Bullet trail
   760         trail := AddVisualGear(
   771         VGear := AddVisualGear(
   761             hwround(CurrentHedgehog^.Gear^.X) + GetLaunchX(CurrentHedgehog^.CurAmmoType, hwSign(CurrentHedgehog^.Gear^.dX), CurrentHedgehog^.Gear^.Angle), 
   772             hwround(CurrentHedgehog^.Gear^.X) + GetLaunchX(CurrentHedgehog^.CurAmmoType, hwSign(CurrentHedgehog^.Gear^.dX), CurrentHedgehog^.Gear^.Angle), 
   762             hwround(CurrentHedgehog^.Gear^.Y) + GetLaunchY(CurrentHedgehog^.CurAmmoType, CurrentHedgehog^.Gear^.Angle),
   773             hwround(CurrentHedgehog^.Gear^.Y) + GetLaunchY(CurrentHedgehog^.CurAmmoType, CurrentHedgehog^.Gear^.Angle),
   763             vgtLineTrail
   774             vgtLineTrail
   764         );
   775         );
   765         if trail <> nil then
   776         if VGear <> nil then
   766         begin
   777         begin
   767             // http://mantis.freepascal.org/view.php?id=17714 hits again
   778             // http://mantis.freepascal.org/view.php?id=17714 hits again
   768             trail^.dX := Gear^.X.QWordValue / SignAs(_1,_1).QWordValue;
   779             VGear^.dX := Gear^.X.QWordValue / SignAs(_1,_1).QWordValue;
   769             trail^.dY := Gear^.Y.QWordValue / SignAs(_1,_1).QWordValue;
   780             VGear^.dY := Gear^.Y.QWordValue / SignAs(_1,_1).QWordValue;
   770             
   781             
   771             // reached edge of land. assume infinite beam. Extend it way out past camera
   782             // reached edge of land. assume infinite beam. Extend it way out past camera
   772             if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) 
   783             if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) 
   773                 or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
   784                 or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
   774             begin
   785             begin
   775                 trail^.dX := trail^.dX + (CurrentHedgehog^.Gear^.dX * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue;
   786                 VGear^.dX := VGear^.dX + (CurrentHedgehog^.Gear^.dX * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue;
   776                 trail^.dY := trail^.dY + (CurrentHedgehog^.Gear^.dY * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue;
   787                 VGear^.dY := VGear^.dY + (CurrentHedgehog^.Gear^.dY * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue;
   777             end;
   788             end;
   778             
   789             
   779             trail^.Timer := 200;
   790             VGear^.Timer := 200;
   780         end;
   791         end;
   781         
   792         
   782         Gear^.doStep := @doStepShotIdle
   793         Gear^.doStep := @doStepShotIdle
   783     end;
   794     end;
   784 end;
   795 end;