hedgewars/GSHandlers.inc
branchwebgl
changeset 8444 75db7bb8dce8
parent 8330 aaefa587e277
parent 8413 454191defee6
child 8446 c18ba8726f5a
equal deleted inserted replaced
8340:46a9fde631f4 8444:75db7bb8dce8
   296 
   296 
   297 ////////////////////////////////////////////////////////////////////////////////
   297 ////////////////////////////////////////////////////////////////////////////////
   298 procedure doStepBomb(Gear: PGear);
   298 procedure doStepBomb(Gear: PGear);
   299 var
   299 var
   300     i, x, y: LongInt;
   300     i, x, y: LongInt;
   301     dX, dY: hwFloat;
   301     dX, dY, gdX: hwFloat;
   302     vg: PVisualGear;
   302     vg: PVisualGear;
   303 begin
   303 begin
   304     AllInactive := false;
   304     AllInactive := false;
   305 
   305 
   306     doStepFallingGear(Gear);
   306     doStepFallingGear(Gear);
   336             gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, Gear^.Hedgehog, EXPLAutoSound);
   336             gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, Gear^.Hedgehog, EXPLAutoSound);
   337             gtClusterBomb:
   337             gtClusterBomb:
   338                 begin
   338                 begin
   339                 x := hwRound(Gear^.X);
   339                 x := hwRound(Gear^.X);
   340                 y := hwRound(Gear^.Y);
   340                 y := hwRound(Gear^.Y);
       
   341                 gdX:= Gear^.dX;
   341                 doMakeExplosion(x, y, 20, Gear^.Hedgehog, EXPLAutoSound);
   342                 doMakeExplosion(x, y, 20, Gear^.Hedgehog, EXPLAutoSound);
   342                 for i:= 0 to 4 do
   343                 for i:= 0 to 4 do
   343                     begin
   344                     begin
   344                     dX := rndSign(GetRandomf * _0_1) + Gear^.dX / 5;
   345                     dX := rndSign(GetRandomf * _0_1) + gdX / 5;
   345                     dY := (GetRandomf - _3) * _0_08;
   346                     dY := (GetRandomf - _3) * _0_08;
   346                     FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25)
   347                     FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25)
   347                     end
   348                     end
   348                 end;
   349                 end;
   349             gtWatermelon:
   350             gtWatermelon:
   350                 begin
   351                 begin
   351                 x := hwRound(Gear^.X);
   352                 x := hwRound(Gear^.X);
   352                 y := hwRound(Gear^.Y);
   353                 y := hwRound(Gear^.Y);
       
   354                 gdX:= Gear^.dX;
   353                 doMakeExplosion(x, y, 75, Gear^.Hedgehog, EXPLAutoSound);
   355                 doMakeExplosion(x, y, 75, Gear^.Hedgehog, EXPLAutoSound);
   354                 for i:= 0 to 5 do
   356                 for i:= 0 to 5 do
   355                     begin
   357                     begin
   356                     dX := rndSign(GetRandomf * _0_1) + Gear^.dX / 5;
   358                     dX := rndSign(GetRandomf * _0_1) + gdX / 5;
   357                     dY := (GetRandomf - _1_5) * _0_3;
   359                     dY := (GetRandomf - _1_5) * _0_3;
   358                     FollowGear:= AddGear(x, y, gtMelonPiece, 0, dX, dY, 75);
   360                     FollowGear:= AddGear(x, y, gtMelonPiece, 0, dX, dY, 75);
   359                     FollowGear^.DirAngle := i * 60
   361                     FollowGear^.DirAngle := i * 60
   360                     end
   362                     end
   361                 end;
   363                 end;
  2412         end
  2414         end
  2413 end;
  2415 end;
  2414 
  2416 
  2415 ////////////////////////////////////////////////////////////////////////////////
  2417 ////////////////////////////////////////////////////////////////////////////////
  2416 procedure doStepMortar(Gear: PGear);
  2418 procedure doStepMortar(Gear: PGear);
  2417 var
  2419 var 
  2418     dX, dY: hwFloat;
  2420     dX, dY, gdX, gdY: hwFloat;
  2419     i: LongInt;
  2421     i: LongInt;
  2420     dxn, dyn: boolean;
  2422     dxn, dyn: boolean;
  2421 begin
  2423 begin
  2422     AllInactive := false;
  2424     AllInactive := false;
  2423     dxn := Gear^.dX.isNegative;
  2425     dxn := Gear^.dX.isNegative;
  2424     dyn := Gear^.dY.isNegative;
  2426     dyn := Gear^.dY.isNegative;
  2425 
  2427 
  2426     doStepFallingGear(Gear);
  2428     doStepFallingGear(Gear);
  2427     if (Gear^.State and gstCollision) <> 0 then
  2429     if (Gear^.State and gstCollision) <> 0 then
  2428         begin
  2430         begin
       
  2431         gdX := Gear^.dX;
       
  2432         gdY := Gear^.dY;
  2429         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
  2433         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
  2430 
  2434 
  2431         Gear^.dX.isNegative := not dxn;
  2435         gdX.isNegative := not dxn;
  2432         Gear^.dY.isNegative := not dyn;
  2436         gdY.isNegative := not dyn;
  2433         for i:= 0 to 4 do
  2437         for i:= 0 to 4 do
  2434             begin
  2438             begin
  2435             dX := Gear^.dX + (GetRandomf - _0_5) * _0_03;
  2439             dX := gdX + (GetRandomf - _0_5) * _0_03;
  2436             dY := Gear^.dY + (GetRandomf - _0_5) * _0_03;
  2440             dY := gdY + (GetRandomf - _0_5) * _0_03;
  2437             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25);
  2441             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25);
  2438             end;
  2442             end;
  2439 
  2443 
  2440         DeleteGear(Gear);
  2444         DeleteGear(Gear);
  2441         exit
  2445         exit
  5180         exit
  5184         exit
  5181         end;
  5185         end;
  5182 if (Gear^.State and gstTmpFlag <> 0) or (GameTicks and $7 = 0) then
  5186 if (Gear^.State and gstTmpFlag <> 0) or (GameTicks and $7 = 0) then
  5183     begin
  5187     begin
  5184     doStepFallingGear(Gear);
  5188     doStepFallingGear(Gear);
  5185     if (Gear^.State and gstInvisible <> 0) and (GameTicks and $FF = 0) and ((hwRound(Gear^.X) < leftX) or (hwRound(Gear^.X) > rightX) or (hwRound(Gear^.Y) < topY)) then
  5189     if (Gear^.State and gstInvisible <> 0) and (GameTicks and $FF = 0) and (hwRound(Gear^.X) < LongInt(leftX)) or (hwRound(Gear^.X) > LongInt(rightX)) or (hwRound(Gear^.Y) < LongInt(topY)) then
  5186         begin
  5190         begin
  5187         Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
  5191         Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
  5188         Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
  5192         Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
  5189         Gear^.dX:= _90-(GetRandomf*_360);
  5193         Gear^.dX:= _90-(GetRandomf*_360);
  5190         Gear^.dY:= _90-(GetRandomf*_360)
  5194         Gear^.dY:= _90-(GetRandomf*_360)
  5273     end;
  5277     end;
  5274 end;
  5278 end;
  5275 
  5279 
  5276 ////////////////////////////////////////////////////////////////////////////////
  5280 ////////////////////////////////////////////////////////////////////////////////
  5277 procedure doStepKnife(Gear: PGear);
  5281 procedure doStepKnife(Gear: PGear);
  5278 var ox, oy: LongInt;
  5282 //var ox, oy: LongInt;
  5279     la: hwFloat;
  5283 //    la: hwFloat;
  5280     a: real;
  5284 var   a: real;
  5281 begin
  5285 begin
  5282     // Gear is shrunk so it can actually escape the hog without carving into the terrain
  5286     // Gear is shrunk so it can actually escape the hog without carving into the terrain
  5283     if (Gear^.Radius = 6) and (Gear^.CollisionMask = $FFFF) then Gear^.Radius:= 16;
  5287     if (Gear^.Radius = 6) and (Gear^.CollisionMask = $FFFF) then Gear^.Radius:= 16;
  5284     if Gear^.Damage > 100 then Gear^.CollisionMask:= 0
  5288     if Gear^.Damage > 100 then Gear^.CollisionMask:= 0
  5285     else if Gear^.Damage > 30 then
  5289     else if Gear^.Damage > 30 then
  5297         CalcRotationDirAngle(Gear);
  5301         CalcRotationDirAngle(Gear);
  5298         Gear^.DirAngle:= a+(Gear^.DirAngle-a)*2*hwSign(Gear^.dX) // double rotation
  5302         Gear^.DirAngle:= a+(Gear^.DirAngle-a)*2*hwSign(Gear^.dX) // double rotation
  5299         end
  5303         end
  5300     else if (Gear^.CollisionIndex = -1) and (Gear^.Timer = 0) then
  5304     else if (Gear^.CollisionIndex = -1) and (Gear^.Timer = 0) then
  5301         begin
  5305         begin
  5302         ox:= 0; oy:= 0;
  5306         (*ox:= 0; oy:= 0;
  5303         if TestCollisionYwithGear(Gear, -1) <> 0 then oy:= -1;
  5307         if TestCollisionYwithGear(Gear, -1) <> 0 then oy:= -1;
  5304         if TestCollisionXwithGear(Gear, 1)       then ox:=  1;
  5308         if TestCollisionXwithGear(Gear, 1)       then ox:=  1;
  5305         if TestCollisionXwithGear(Gear, -1)      then ox:= -1;
  5309         if TestCollisionXwithGear(Gear, -1)      then ox:= -1;
  5306         if TestCollisionYwithGear(Gear, 1) <> 0  then oy:=  1;
  5310         if TestCollisionYwithGear(Gear, 1) <> 0  then oy:=  1;
  5307         if Gear^.Health > 0 then
  5311         if Gear^.Health > 0 then
  5308             PlaySound(sndRopeAttach);
  5312             PlaySound(sndRopeAttach);
  5309 (*
  5313 
  5310         la:= _10000;
  5314         la:= _10000;
  5311         if (ox <> 0) or (oy <> 0) then
  5315         if (ox <> 0) or (oy <> 0) then
  5312             la:= CalcSlopeNearGear(Gear, ox, oy);
  5316             la:= CalcSlopeNearGear(Gear, ox, oy);
  5313         if la = _10000 then
  5317         if la = _10000 then
  5314             begin
  5318             begin