hedgewars/uGearsHandlersMess.pas
changeset 13408 419c5eab88eb
parent 13407 06792533ef91
child 13463 f1d349a52bc7
equal deleted inserted replaced
13407:06792533ef91 13408:419c5eab88eb
  1390         Inc(Bullet^.PortalCounter);
  1390         Inc(Bullet^.PortalCounter);
  1391         Bullet^.FlightTime:= 1;
  1391         Bullet^.FlightTime:= 1;
  1392     end;
  1392     end;
  1393 end;
  1393 end;
  1394 
  1394 
       
  1395 procedure CreateBubblesForBullet(Gear: PGear);
       
  1396 var i, iInit: LongWord;
       
  1397 begin
       
  1398 if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Health > 0) then
       
  1399     begin
       
  1400     // draw bubbles
       
  1401     if (not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF)) then
       
  1402         begin
       
  1403         case Gear^.Kind of
       
  1404             gtMinigunBullet: iInit:= Gear^.Health * 100;
       
  1405             gtDEagleShot, gtSniperRifleShot: iInit:= Gear^.Health * 4
       
  1406             end;
       
  1407         for i:=iInit downto 0 do
       
  1408             begin
       
  1409             if Random(6) = 0 then
       
  1410                 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble);
       
  1411             Gear^.X := Gear^.X + Gear^.dX;
       
  1412             Gear^.Y := Gear^.Y + Gear^.dY;
       
  1413             end;
       
  1414         end;
       
  1415     // bullet dies underwater
       
  1416     Gear^.Health:= 0;
       
  1417     end;
       
  1418 end;
       
  1419 
  1395 procedure doStepBulletWork(Gear: PGear);
  1420 procedure doStepBulletWork(Gear: PGear);
  1396 var
  1421 var
  1397     i, x, y, iInit: LongWord;
  1422     i, x, y, iInit: LongWord;
  1398     oX, oY, tX, tY, tDx, tDy: hwFloat;
  1423     oX, oY, tX, tY, tDx, tDy: hwFloat;
  1399     VGear: PVisualGear;
  1424     VGear: PVisualGear;
  1474     until (i = 0) or (isDead);
  1499     until (i = 0) or (isDead);
  1475 
  1500 
  1476     LineShoveHelp(Gear, oX, oY, Gear^.X, Gear^.Y,
  1501     LineShoveHelp(Gear, oX, oY, Gear^.X, Gear^.Y,
  1477                   Gear^.dX, Gear^.dY, iInit + 2 - i);
  1502                   Gear^.dX, Gear^.dY, iInit + 2 - i);
  1478 
  1503 
  1479     if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Health > 0) then
  1504     CreateBubblesForBullet(Gear);
  1480         begin
  1505 
  1481         // draw bubbles
  1506     x := hwRound(Gear^.X);
  1482         if (not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF)) then
  1507     y := hwRound(Gear^.Y);
  1483             begin
  1508     if (isDead) or (x and LAND_WIDTH_MASK <> 0) or (y and LAND_HEIGHT_MASK <> 0) then
  1484 			case Gear^.Kind of
  1509         begin
  1485 				gtMinigunBullet: iInit:= Gear^.Health * 100;
  1510         if (Gear^.Kind = gtSniperRifleShot) then
  1486 				gtDEagleShot, gtSniperRifleShot: iInit:= Gear^.Health * 4
  1511             cLaserSightingSniper := false;
  1487 				end;
  1512         if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and (CurrentHedgehog^.Effects[heArtillery] = 2) then
  1488             for i:=iInit downto 0 do
  1513             CurrentHedgehog^.Effects[heArtillery]:= 0;
  1489                 begin
  1514 
  1490                 if Random(6) = 0 then
  1515         // Bullet Hit
  1491                     AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble);
  1516         if ((Gear^.State and gstDrowning) = 0) and (x and LAND_WIDTH_MASK = 0) and (y and LAND_HEIGHT_MASK = 0) then
  1492                 Gear^.X := Gear^.X + Gear^.dX;
  1517             begin
  1493                 Gear^.Y := Gear^.Y + Gear^.dY;
  1518             if Gear^.Kind = gtMinigunBullet then
       
  1519                 begin
       
  1520                 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 5,
       
  1521                                 Gear^.Hedgehog, EXPLNoDamage{ or EXPLDontDraw or EXPLNoGfx});
       
  1522                 VGear := AddVisualGear(hwRound(Gear^.X + Gear^.dX * 5), hwRound(Gear^.Y + Gear^.dY * 5), vgtBulletHit);
       
  1523                 end
       
  1524             else
       
  1525                 VGear := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBulletHit);
       
  1526 
       
  1527             if VGear <> nil then
       
  1528                 begin
       
  1529                 VGear^.Angle := DxDy2Angle(-Gear^.dX, Gear^.dY);
  1494                 end;
  1530                 end;
  1495             end;
  1531             end;
  1496         // bullet dies underwater
  1532 
  1497         Gear^.Health:= 0;
  1533         spawnBulletTrail(Gear, Gear^.X, Gear^.Y, Gear^.FlightTime = 0);
  1498         end;
  1534         Gear^.FlightTime:= 1;
  1499 
  1535         if Gear^.Kind = gtMinigunBullet then
  1500     if (isDead)
  1536             ClearHitOrderLeq(Gear^.Tag);
  1501         or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0)
  1537 
  1502         or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
  1538         if (worldEdge = weSea) and (Gear^.Kind = gtMinigunBullet)
  1503             begin
  1539             and Gear^.Y.isNegative and Gear^.dY.isNegative
  1504             if (Gear^.Kind = gtSniperRifleShot) then
  1540             and (Gear^.Health > 0) and (not isZero(Gear^.dX)) then
  1505                 cLaserSightingSniper := false;
  1541         begin
  1506             if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and (CurrentHedgehog^.Effects[heArtillery] = 2) then
  1542             if Gear^.dX.isNegative then
  1507                 CurrentHedgehog^.Effects[heArtillery]:= 0;
  1543                 begin
  1508 
  1544 
  1509         // Bullet Hit
  1545                 Gear^.X:= int2hwFloat(-1);
  1510             if ((Gear^.State and gstDrowning) = 0) and (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then
  1546                 iInit:= x - leftX;
  1511                 begin
  1547                 end
  1512                 if Gear^.Kind = gtMinigunBullet then
  1548             else
  1513                     begin
  1549                 begin
  1514                     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 5,
  1550                 Gear^.X:= int2hwFloat(LAND_WIDTH);
  1515                                     Gear^.Hedgehog, EXPLNoDamage{ or EXPLDontDraw or EXPLNoGfx});
  1551                 iInit:= rightX - x - 1;
  1516                     VGear := AddVisualGear(hwRound(Gear^.X + Gear^.dX * 5), hwRound(Gear^.Y + Gear^.dY * 5), vgtBulletHit);
       
  1517                     end
       
  1518                 else
       
  1519                     VGear := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBulletHit);
       
  1520 
       
  1521                 if VGear <> nil then
       
  1522                     begin
       
  1523                     VGear^.Angle := DxDy2Angle(-Gear^.dX, Gear^.dY);
       
  1524                     end;
       
  1525                 end;
  1552                 end;
  1526 
  1553             Gear^.Y:= Gear^.Y + Gear^.dY * hwAbs(int2hwFloat(iInit) / Gear^.dX);
  1527             spawnBulletTrail(Gear, Gear^.X, Gear^.Y, Gear^.FlightTime = 0);
  1554             CheckGearDrowning(Gear);
  1528             Gear^.FlightTime:= 1;
  1555             CreateBubblesForBullet(Gear);
  1529             if Gear^.Kind = gtMinigunBullet then
  1556         end;
  1530                 ClearHitOrderLeq(Gear^.Tag);
  1557         Gear^.doStep := @doStepShotIdle
  1531             Gear^.doStep := @doStepShotIdle
  1558         end;
  1532             end;
       
  1533 end;
  1559 end;
  1534 
  1560 
  1535 procedure doStepDEagleShot(Gear: PGear);
  1561 procedure doStepDEagleShot(Gear: PGear);
  1536 begin
  1562 begin
  1537     Gear^.Data:= nil;
  1563     Gear^.Data:= nil;