hedgewars/GSHandlers.inc
changeset 6126 61c1161ee32f
parent 6122 58ecb4fb743d
child 6130 026fd01a5e2c
equal deleted inserted replaced
6125:663e05d9cf66 6126:61c1161ee32f
   405 ////////////////////////////////////////////////////////////////////////////////
   405 ////////////////////////////////////////////////////////////////////////////////
   406 procedure doStepBomb(Gear: PGear);
   406 procedure doStepBomb(Gear: PGear);
   407 var 
   407 var 
   408     i, x, y: LongInt;
   408     i, x, y: LongInt;
   409     dX, dY: hwFloat;
   409     dX, dY: hwFloat;
   410     Fire: PGear;
       
   411     vg: PVisualGear;
   410     vg: PVisualGear;
   412 begin
   411 begin
   413     AllInactive := false;
   412     AllInactive := false;
   414 
   413 
   415     doStepFallingGear(Gear);
   414     doStepFallingGear(Gear);
   476 
   475 
   477                 for i:= 0 to 127 do
   476                 for i:= 0 to 127 do
   478                     begin
   477                     begin
   479                     dX := AngleCos(i * 16) * _0_5 * (GetRandom + _1);
   478                     dX := AngleCos(i * 16) * _0_5 * (GetRandom + _1);
   480                     dY := AngleSin(i * 16) * _0_5 * (GetRandom + _1);
   479                     dY := AngleSin(i * 16) * _0_5 * (GetRandom + _1);
   481                     Fire := AddGear(x, y, gtFlame, 0, dX, dY, 0);
   480                     if i mod 2 = 0 then 
   482                     if i mod 2 = 0 then Fire^.State := Fire^.State or gsttmpFlag;
   481                         begin
   483                     Fire := AddGear(x, y, gtFlame, 0, dX, -dY, 0);
   482                         AddGear(x, y, gtFlame, gstTmpFlag, dX, dY, 0);
   484                     if i mod 2 <> 0 then Fire^.State := Fire^.State or gsttmpFlag;
   483                         AddGear(x, y, gtFlame, 0, dX, -dY, 0)
       
   484                         end
       
   485                     else
       
   486                         begin 
       
   487                         AddGear(x, y, gtFlame, 0, dX, dY, 0);
       
   488                         AddGear(x, y, gtFlame, gstTmpFlag, dX, -dY, 0)
       
   489                         end;
   485                     end
   490                     end
   486                 end;
   491                 end;
   487             gtGasBomb:
   492             gtGasBomb:
   488                 begin
   493                 begin
   489                 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
   494                 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound);
   520 procedure doStepMolotov(Gear: PGear);
   525 procedure doStepMolotov(Gear: PGear);
   521 var 
   526 var 
   522 	s: Longword;
   527 	s: Longword;
   523     i, gX, gY: LongInt;
   528     i, gX, gY: LongInt;
   524     dX, dY: hwFloat;
   529     dX, dY: hwFloat;
   525     Fire: PGear;
       
   526     smoke, glass: PVisualGear;
   530     smoke, glass: PVisualGear;
   527 begin
   531 begin
   528     AllInactive := false;
   532     AllInactive := false;
   529 
   533 
   530     doStepFallingGear(Gear);
   534     doStepFallingGear(Gear);
   568                     FrameTicks:= 750;
   572                     FrameTicks:= 750;
   569                     State:= ord(sprEgg)
   573                     State:= ord(sprEgg)
   570                     end;
   574                     end;
   571             end;
   575             end;
   572         for i:= 0 to 24 do
   576         for i:= 0 to 24 do
   573         begin
   577             begin
   574             dX := AngleCos(i * 2) * ((_0_15*(i div 5))) * (GetRandom + _1);
   578             dX := AngleCos(i * 2) * ((_0_15*(i div 5))) * (GetRandom + _1);
   575             dY := AngleSin(i * 8) * _0_5 * (GetRandom + _1);
   579             dY := AngleSin(i * 8) * _0_5 * (GetRandom + _1);
   576             Fire := AddGear(gX, gY, gtFlame, 0, dX, dY, 0);
   580             AddGear(gX, gY, gtFlame, gstTmpFlag, dX, dY, 0);
   577             Fire^.State := Fire^.State or gsttmpFlag;
   581             AddGear(gX, gY, gtFlame, gstTmpFlag, dX,-dY, 0);
   578             Fire := AddGear(gX, gY, gtFlame, 0, dX, -dY, 0);
   582             AddGear(gX, gY, gtFlame, gstTmpFlag,-dX, dY, 0);
   579             Fire^.State := Fire^.State or gsttmpFlag;
   583             AddGear(gX, gY, gtFlame, gstTmpFlag,-dX,-dY, 0);
   580             Fire := AddGear(gX, gY, gtFlame, 0, -dX, dY, 0);
   584             end;
   581             Fire^.State := Fire^.State or gsttmpFlag;
       
   582             Fire := AddGear(gX, gY, gtFlame, 0, -dX, -dY, 0);
       
   583             Fire^.State := Fire^.State or gsttmpFlag;
       
   584         end;
       
   585         DeleteGear(Gear);
   585         DeleteGear(Gear);
   586         exit
   586         exit
   587     end;
   587     end;
   588 end;
   588 end;
   589 
   589 
  2138                 for i:= 0 to 31 do
  2138                 for i:= 0 to 31 do
  2139                 begin
  2139                 begin
  2140                     dX := AngleCos(i * 64) * _0_5 * (getrandom + _1);
  2140                     dX := AngleCos(i * 64) * _0_5 * (getrandom + _1);
  2141                     dY := AngleSin(i * 64) * _0_5 * (getrandom + _1);
  2141                     dY := AngleSin(i * 64) * _0_5 * (getrandom + _1);
  2142                     AddGear(x, y, gtFlame, 0, dX, dY, 0);
  2142                     AddGear(x, y, gtFlame, 0, dX, dY, 0);
  2143                     AddGear(x, y, gtFlame, 0, -dX, -dY, 0)^.State := gsttmpFlag;
  2143                     AddGear(x, y, gtFlame, gstTmpFlag, -dX, -dY, 0);
  2144                 end
  2144                 end
  2145             end;
  2145             end;
  2146         exit
  2146         exit
  2147     end;
  2147     end;
  2148 
  2148 
  4590 procedure doStepFlamethrowerWork(Gear: PGear);
  4590 procedure doStepFlamethrowerWork(Gear: PGear);
  4591 var 
  4591 var 
  4592     HHGear: PGear;
  4592     HHGear: PGear;
  4593     rx, ry, speed: hwFloat;
  4593     rx, ry, speed: hwFloat;
  4594     i, gX, gY: LongInt;
  4594     i, gX, gY: LongInt;
  4595     Fire: PGear;
       
  4596 begin
  4595 begin
  4597     AllInactive := false;
  4596     AllInactive := false;
  4598     HHGear := Gear^.Hedgehog^.Gear;
  4597     HHGear := Gear^.Hedgehog^.Gear;
  4599     HedgehogChAngle(HHGear);
  4598     HedgehogChAngle(HHGear);
  4600     gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle);
  4599     gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle);
  4622             begin
  4621             begin
  4623             rx := rndSign(getRandom * _0_1);
  4622             rx := rndSign(getRandom * _0_1);
  4624             ry := rndSign(getRandom * _0_1);
  4623             ry := rndSign(getRandom * _0_1);
  4625             speed := _0_5 * (_10 / Gear^.Tag);
  4624             speed := _0_5 * (_10 / Gear^.Tag);
  4626     
  4625     
  4627             Fire := AddGear(gx, gy, gtFlame, 0,
  4626             AddGear(gx, gy, gtFlame, gstTmpFlag,
  4628                         SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4627                     SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4629                 AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4628                     AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4630             Fire^.State := Fire^.State or gsttmpFlag;
       
  4631             
  4629             
  4632             if (Gear^.Health mod 30) = 0 then 
  4630             if (Gear^.Health mod 30) = 0 then 
  4633                 Fire := AddGear(gx, gy, gtFlame, 0,
  4631                 AddGear(gx, gy, gtFlame, 0,
  4634                             SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4632                         SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
  4635                     AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4633                         AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4636             end;
  4634             end;
  4637         Gear^.Timer:= Gear^.Tag
  4635         Gear^.Timer:= Gear^.Tag
  4638         end;
  4636         end;
  4639 
  4637 
  4640     if (Gear^.Health = 0) or (HHGear^.Damage <> 0) then
  4638     if (Gear^.Health = 0) or (HHGear^.Damage <> 0) then
  4669 procedure doStepLandGunWork(Gear: PGear);
  4667 procedure doStepLandGunWork(Gear: PGear);
  4670 var 
  4668 var 
  4671     HHGear: PGear;
  4669     HHGear: PGear;
  4672     rx, ry, speed: hwFloat;
  4670     rx, ry, speed: hwFloat;
  4673     i, gX, gY: LongInt;
  4671     i, gX, gY: LongInt;
  4674     Flake: PGear;
       
  4675 begin
  4672 begin
  4676     AllInactive := false;
  4673     AllInactive := false;
  4677     HHGear := Gear^.Hedgehog^.Gear;
  4674     HHGear := Gear^.Hedgehog^.Gear;
  4678     HedgehogChAngle(HHGear);
  4675     HedgehogChAngle(HHGear);
  4679     gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle);
  4676     gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle);
  4700 
  4697 
  4701         rx := rndSign(getRandom * _0_1);
  4698         rx := rndSign(getRandom * _0_1);
  4702         ry := rndSign(getRandom * _0_1);
  4699         ry := rndSign(getRandom * _0_1);
  4703         speed := (_3 / Gear^.Tag);
  4700         speed := (_3 / Gear^.Tag);
  4704 
  4701 
  4705         Flake := AddGear(gx, gy, gtFlake, 0, _0, _0, 0);
  4702         AddGear(gx, gy, gtFlake, gstTmpFlag, 
  4706         Flake^.dX:= SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx;
  4703                 SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, 
  4707         Flake^.dY:= AngleCos(HHGear^.Angle) * ( - speed) + ry;
  4704                 AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
  4708         Flake^.State := Flake^.State or gsttmpFlag;
       
  4709             
  4705             
  4710         Gear^.Timer:= Gear^.Tag
  4706         Gear^.Timer:= Gear^.Tag
  4711         end;
  4707         end;
  4712 
  4708 
  4713     if (Gear^.Health = 0) or (HHGear^.Damage <> 0) or ((HHGear^.Message and gmAttack) <> 0) then
  4709     if (Gear^.Health = 0) or (HHGear^.Damage <> 0) or ((HHGear^.Message and gmAttack) <> 0) then