hedgewars/uGearsHandlersMess.pas
branchqmlfrontend
changeset 11606 99966b4a6e1e
parent 11553 5415e9d7436f
child 11698 e86feecadced
child 11765 10860d4bca22
equal deleted inserted replaced
11544:b69f5f22a3ba 11606:99966b4a6e1e
  1335             end;
  1335             end;
  1336 end;
  1336 end;
  1337 
  1337 
  1338 procedure doStepDEagleShot(Gear: PGear);
  1338 procedure doStepDEagleShot(Gear: PGear);
  1339 begin
  1339 begin
       
  1340     Gear^.Data:= nil;
       
  1341     // remember who fired this
       
  1342     if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
       
  1343         Gear^.Data:= Pointer(Gear^.Hedgehog^.Gear);
       
  1344 
  1340     PlaySound(sndGun);
  1345     PlaySound(sndGun);
  1341     // add 3 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just plain old weird angles
  1346     // add 2 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just plain old weird angles
  1342     Gear^.X := Gear^.X + Gear^.dX * 3;
  1347     Gear^.X := Gear^.X + Gear^.dX * 2;
  1343     Gear^.Y := Gear^.Y + Gear^.dY * 3;
  1348     Gear^.Y := Gear^.Y + Gear^.dY * 2;
  1344     Gear^.doStep := @doStepBulletWork
  1349     Gear^.doStep := @doStepBulletWork
  1345 end;
  1350 end;
  1346 
  1351 
  1347 procedure doStepSniperRifleShot(Gear: PGear);
  1352 procedure doStepSniperRifleShot(Gear: PGear);
  1348 var
  1353 var
  1349     HHGear: PGear;
  1354     HHGear: PGear;
  1350     shell: PVisualGear;
  1355     shell: PVisualGear;
  1351 begin
  1356 begin
       
  1357 
  1352     cArtillery := true;
  1358     cArtillery := true;
  1353     HHGear := Gear^.Hedgehog^.Gear;
  1359     HHGear := Gear^.Hedgehog^.Gear;
  1354 
  1360 
  1355     if HHGear = nil then
  1361     if HHGear = nil then
  1356         begin
  1362         begin
  1357         DeleteGear(gear);
  1363         DeleteGear(gear);
  1358         exit
  1364         exit
  1359         end;
  1365         end;
       
  1366 
       
  1367     // remember who fired this
       
  1368     Gear^.Data:= Pointer(Gear^.Hedgehog^.Gear);
  1360 
  1369 
  1361     HHGear^.State := HHGear^.State or gstNotKickable;
  1370     HHGear^.State := HHGear^.State or gstNotKickable;
  1362     HedgehogChAngle(HHGear);
  1371     HedgehogChAngle(HHGear);
  1363     if not cLaserSighting then
  1372     if not cLaserSighting then
  1364         // game does not have default laser sight. turn it on and give them a chance to aim
  1373         // game does not have default laser sight. turn it on and give them a chance to aim
  1380             end;
  1389             end;
  1381         Gear^.State := Gear^.State or gstAnimation;
  1390         Gear^.State := Gear^.State or gstAnimation;
  1382         Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
  1391         Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5;
  1383         Gear^.dY := -AngleCos(HHGear^.Angle) * _0_5;
  1392         Gear^.dY := -AngleCos(HHGear^.Angle) * _0_5;
  1384         PlaySound(sndGun);
  1393         PlaySound(sndGun);
  1385         // add 3 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just weird angles
  1394         // add 2 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just weird angles
  1386         Gear^.X := Gear^.X + Gear^.dX * 3;
  1395         Gear^.X := Gear^.X + Gear^.dX * 2;
  1387         Gear^.Y := Gear^.Y + Gear^.dY * 3;
  1396         Gear^.Y := Gear^.Y + Gear^.dY * 2;
  1388         Gear^.doStep := @doStepBulletWork;
  1397         Gear^.doStep := @doStepBulletWork;
  1389         end
  1398         end
  1390     else
  1399     else
  1391         if (GameTicks mod 32) = 0 then
  1400         if (GameTicks mod 32) = 0 then
  1392             if (GameTicks mod 4096) < 2048 then
  1401             if (GameTicks mod 4096) < 2048 then
  2644 procedure doStepAirAttackWork(Gear: PGear);
  2653 procedure doStepAirAttackWork(Gear: PGear);
  2645 begin
  2654 begin
  2646     AllInactive := false;
  2655     AllInactive := false;
  2647     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
  2656     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
  2648 
  2657 
  2649     if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then
  2658     if (Gear^.Health > 0) and (not (Gear^.X < Gear^.dX)) and (Gear^.X < Gear^.dX + cAirPlaneSpeed) then
  2650         begin
  2659         begin
  2651         dec(Gear^.Health);
  2660         dec(Gear^.Health);
  2652             case Gear^.State of
  2661             case Gear^.State of
  2653                 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  2662                 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  2654                 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine,    0, cBombsSpeed * Gear^.Tag, _0, 0);
  2663                 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine,    0, cBombsSpeed * Gear^.Tag, _0, 0);
  2688         Gear^.Tag := -1;
  2697         Gear^.Tag := -1;
  2689         Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048);
  2698         Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048);
  2690         end;
  2699         end;
  2691 
  2700 
  2692     Gear^.Y := int2hwFloat(topY-300);
  2701     Gear^.Y := int2hwFloat(topY-300);
  2693     Gear^.dX := int2hwFloat(Gear^.Target.X) - int2hwFloat(Gear^.Tag * Gear^.Health * Gear^.Damage) / 2;
  2702     Gear^.dX := int2hwFloat(Gear^.Target.X) - int2hwFloat(Gear^.Tag * (Gear^.Health-1) * Gear^.Damage) / 2;
  2694 
  2703 
  2695     // calcs for Napalm Strike, so that it will hit the target (without wind at least :P)
  2704     // calcs for Napalm Strike, so that it will hit the target (without wind at least :P)
  2696     if (Gear^.State = 2) then
  2705     if (Gear^.State = 2) then
  2697         Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900
  2706         Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900
  2698     // calcs for regular falling gears
  2707     // calcs for regular falling gears
  4355 
  4364 
  4356             if (hwRound(Distance(Gear^.X-ox,Gear^.Y-oy)) > Gear^.Radius + 1 ) then
  4365             if (hwRound(Distance(Gear^.X-ox,Gear^.Y-oy)) > Gear^.Radius + 1 ) then
  4357                 continue;
  4366                 continue;
  4358             end;
  4367             end;
  4359 
  4368 
  4360         // draw bullet trail
  4369         if (iterator^.Kind = gtDEagleShot) or (iterator^.Kind = gtSniperRifleShot) then
  4361         if isbullet then
  4370             begin
       
  4371             // draw bullet trail
  4362             spawnBulletTrail(iterator);
  4372             spawnBulletTrail(iterator);
       
  4373             // the bullet can now hurt the hog that fired it
       
  4374             iterator^.Data:= nil;
       
  4375             end;
  4363 
  4376 
  4364         // calc gear offset in portal vector direction
  4377         // calc gear offset in portal vector direction
  4365         ox := (iterator^.X - Gear^.X);
  4378         ox := (iterator^.X - Gear^.X);
  4366         oy := (iterator^.Y - Gear^.Y);
  4379         oy := (iterator^.Y - Gear^.Y);
  4367         poffs:= (Gear^.dX * ox + Gear^.dY * oy);
  4380         poffs:= (Gear^.dX * ox + Gear^.dY * oy);
  5004 var
  5017 var
  5005     HHGear: PGear;
  5018     HHGear: PGear;
  5006 begin
  5019 begin
  5007     PlaySound(sndSineGun);
  5020     PlaySound(sndSineGun);
  5008 
  5021 
  5009     // push the shooting Hedgehog back
  5022     if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
  5010     HHGear := CurrentHedgehog^.Gear;
  5023         begin
  5011     Gear^.dX.isNegative := not Gear^.dX.isNegative;
  5024         HHGear := Gear^.Hedgehog^.Gear;
  5012     Gear^.dY.isNegative := not Gear^.dY.isNegative;
  5025         // push the shooting Hedgehog back
  5013     HHGear^.dX := Gear^.dX;
  5026         Gear^.dX.isNegative := not Gear^.dX.isNegative;
  5014     HHGear^.dY := Gear^.dY;
  5027         Gear^.dY.isNegative := not Gear^.dY.isNegative;
  5015     AmmoShove(Gear, 0, 80);
  5028         HHGear^.dX := Gear^.dX;
  5016     Gear^.dX.isNegative := not Gear^.dX.isNegative;
  5029         HHGear^.dY := Gear^.dY;
  5017     Gear^.dY.isNegative := not Gear^.dY.isNegative;
  5030         AmmoShove(Gear, 0, 80);
       
  5031         Gear^.dX.isNegative := not Gear^.dX.isNegative;
       
  5032         Gear^.dY.isNegative := not Gear^.dY.isNegative;
       
  5033         end;
  5018 
  5034 
  5019     Gear^.doStep := @doStepSineGunShotWork;
  5035     Gear^.doStep := @doStepSineGunShotWork;
  5020     {$IFNDEF PAS2C}
  5036     {$IFNDEF PAS2C}
  5021     with mobileRecord do
  5037     with mobileRecord do
  5022         if (performRumble <> nil) and (not fastUntilLag) then
  5038         if (performRumble <> nil) and (not fastUntilLag) then