hedgewars/GSHandlers.inc
changeset 7053 8c9dcaedc7a8
parent 7036 d99934a827f0
child 7061 4e0fc59ab1ce
equal deleted inserted replaced
7052:cefb73639f70 7053:8c9dcaedc7a8
    86             begin
    86             begin
    87             d := r - hwRound(Distance(gi^.X - x, gi^.Y - y));
    87             d := r - hwRound(Distance(gi^.X - x, gi^.Y - y));
    88             if (d > 1) and (not gi^.Invulnerable) and (GetRandom(2) = 0) then
    88             if (d > 1) and (not gi^.Invulnerable) and (GetRandom(2) = 0) then
    89                 begin
    89                 begin
    90                 if (CurrentHedgehog^.Gear = gi) then
    90                 if (CurrentHedgehog^.Gear = gi) then
    91                     PlaySound(sndOops, gi^.Hedgehog^.Team^.voicepack)
    91                     PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack)
    92                     
    92                     
    93                 else
    93                 else
    94                     begin
    94                     begin
    95                     if (gi^.State and gstMoving) = 0 then
    95                     if (gi^.State and gstMoving) = 0 then
    96                         gi^.State := gi^.State or gstLoser;
    96                         gi^.State := gi^.State or gstLoser;
    97                         
    97                         
    98                     if d > r div 2 then
    98                     if d > r div 2 then
    99                         PlaySound(sndNooo, gi^.Hedgehog^.Team^.voicepack) 
    99                         PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack) 
   100                     else
   100                     else
   101                         PlaySound(sndUhOh, gi^.Hedgehog^.Team^.voicepack);
   101                         PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack);
   102                     end;
   102                     end;
   103                 end;
   103                 end;
   104             end;
   104             end;
   105             
   105             
   106         gi := gi^.NextGear
   106         gi := gi^.NextGear
   777         AddVisualGear(gX, cWaterLine, vgtSplash);
   777         AddVisualGear(gX, cWaterLine, vgtSplash);
   778         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   778         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   779         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   779         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   780         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   780         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   781         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   781         AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet);
   782         StopSound(Gear^.SoundChannel);
   782         StopSoundChan(Gear^.SoundChannel);
   783         if nuw then
   783         if nuw then
   784             begin
   784             begin
   785             Gear^.SoundChannel := LoopSound(sndBeeWater);
   785             Gear^.SoundChannel := LoopSound(sndBeeWater);
   786             Gear^.Tag := 1;
   786             Gear^.Tag := 1;
   787         end
   787         end
   816 
   816 
   817 
   817 
   818     CheckCollision(Gear);
   818     CheckCollision(Gear);
   819     if ((Gear^.State and gstCollision) <> 0) then
   819     if ((Gear^.State and gstCollision) <> 0) then
   820         begin
   820         begin
   821         StopSound(Gear^.SoundChannel);
   821         StopSoundChan(Gear^.SoundChannel);
   822         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
   822         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
   823         for i:= 0 to 31 do
   823         for i:= 0 to 31 do
   824             begin
   824             begin
   825             flower:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot);
   825             flower:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot);
   826             if flower <> nil then
   826             if flower <> nil then
   844         dec(Gear^.Timer)
   844         dec(Gear^.Timer)
   845     else
   845     else
   846         begin
   846         begin
   847         if nuw then
   847         if nuw then
   848            begin
   848            begin
   849             StopSound(Gear^.SoundChannel);
   849             StopSoundChan(Gear^.SoundChannel);
   850             CheckGearDrowning(Gear);
   850             CheckGearDrowning(Gear);
   851             end
   851             end
   852         else
   852         else
   853             doStepFallingGear(Gear);
   853             doStepFallingGear(Gear);
   854         end;
   854         end;
  1179         dec(TurnTimeLeft);
  1179         dec(TurnTimeLeft);
  1180     if (TurnTimeLeft = 0) or (Gear^.Timer = 0)
  1180     if (TurnTimeLeft = 0) or (Gear^.Timer = 0)
  1181     or((Gear^.Message and gmDestroy) <> 0)
  1181     or((Gear^.Message and gmDestroy) <> 0)
  1182     or((HHGear^.State and gstHHDriven) =0) then
  1182     or((HHGear^.State and gstHHDriven) =0) then
  1183         begin
  1183         begin
  1184         StopSound(Gear^.SoundChannel);
  1184         StopSoundChan(Gear^.SoundChannel);
  1185         DeleteGear(Gear);
  1185         DeleteGear(Gear);
  1186         AfterAttack;
  1186         AfterAttack;
  1187         doStepHedgehogMoving(HHGear);  // for gfInfAttack
  1187         doStepHedgehogMoving(HHGear);  // for gfInfAttack
  1188         exit
  1188         exit
  1189         end;
  1189         end;
  2451     Gear^.dX := SignAs(_0_45, Gear^.dX);
  2451     Gear^.dX := SignAs(_0_45, Gear^.dX);
  2452     Gear^.dY := - _0_9;
  2452     Gear^.dY := - _0_9;
  2453     Gear^.doStep := @doStepFirePunchWork;
  2453     Gear^.doStep := @doStepFirePunchWork;
  2454     DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
  2454     DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
  2455 
  2455 
  2456     PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), HHGear^.Hedgehog^.Team^.voicepack)
  2456     PlaySoundV(TSound(ord(sndFirePunch1) + GetRandom(6)), HHGear^.Hedgehog^.Team^.voicepack)
  2457 end;
  2457 end;
  2458 
  2458 
  2459 ////////////////////////////////////////////////////////////////////////////////
  2459 ////////////////////////////////////////////////////////////////////////////////
  2460 
  2460 
  2461 procedure doStepParachuteWork(Gear: PGear);
  2461 procedure doStepParachuteWork(Gear: PGear);
  2541                 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
  2541                 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
  2542             //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
  2542             //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
  2543             //                 Gear^.Tag, _0, 5000);
  2543             //                 Gear^.Tag, _0, 5000);
  2544             end;
  2544             end;
  2545         Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag);
  2545         Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag);
  2546         StopSound(Gear^.SoundChannel, 4000);
  2546         StopSoundChan(Gear^.SoundChannel, 4000);
  2547         end;
  2547         end;
  2548 
  2548 
  2549     if (GameTicks and $3F) = 0 then
  2549     if (GameTicks and $3F) = 0 then
  2550         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  2550         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  2551 
  2551 
  2552     if (hwRound(Gear^.X) > (LAND_WIDTH+2048)) or (hwRound(Gear^.X) < -2048) then
  2552     if (hwRound(Gear^.X) > (LAND_WIDTH+2048)) or (hwRound(Gear^.X) < -2048) then
  2553         begin
  2553         begin
  2554         // avoid to play forever (is this necessary?)
  2554         // avoid to play forever (is this necessary?)
  2555         StopSound(Gear^.SoundChannel);
  2555         StopSoundChan(Gear^.SoundChannel);
  2556         DeleteGear(Gear)
  2556         DeleteGear(Gear)
  2557         end;
  2557         end;
  2558 end;
  2558 end;
  2559 
  2559 
  2560 procedure doStepAirAttack(Gear: PGear);
  2560 procedure doStepAirAttack(Gear: PGear);
  2919     AllInactive := false;
  2919     AllInactive := false;
  2920     dec(Gear^.Timer);
  2920     dec(Gear^.Timer);
  2921     if Gear^.Timer = 0 then
  2921     if Gear^.Timer = 0 then
  2922         begin
  2922         begin
  2923         Gear^.Pos := 1;
  2923         Gear^.Pos := 1;
  2924         PlaySound(sndKamikaze, Gear^.Hedgehog^.Team^.voicepack);
  2924         PlaySoundV(sndKamikaze, Gear^.Hedgehog^.Team^.voicepack);
  2925         Gear^.doStep := @doStepKamikazeWork
  2925         Gear^.doStep := @doStepKamikazeWork
  2926         end
  2926         end
  2927 end;
  2927 end;
  2928 
  2928 
  2929 procedure doStepKamikaze(Gear: PGear);
  2929 procedure doStepKamikaze(Gear: PGear);
  3211     if Gear^.Timer > 250 then
  3211     if Gear^.Timer > 250 then
  3212         begin
  3212         begin
  3213         Gear^.Timer := 0;
  3213         Gear^.Timer := 0;
  3214         inc(Gear^.Pos);
  3214         inc(Gear^.Pos);
  3215         if Gear^.Pos = 5 then
  3215         if Gear^.Pos = 5 then
  3216             PlaySound(sndYoohoo, Gear^.Hedgehog^.Team^.voicepack)
  3216             PlaySoundV(sndYoohoo, Gear^.Hedgehog^.Team^.voicepack)
  3217         end;
  3217         end;
  3218 
  3218 
  3219     if (Gear^.Pos = 14) and (RealTicks and $3 = 0) then
  3219     if (Gear^.Pos = 14) and (RealTicks and $3 = 0) then
  3220         begin
  3220         begin
  3221         heart:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot);
  3221         heart:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot);
  3295         DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6);
  3295         DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6);
  3296         if (Gear^.Timer mod 30) = 0 then
  3296         if (Gear^.Timer mod 30) = 0 then
  3297             AddVisualGear(hwRound(Gear^.X + _20 * Gear^.dX), hwRound(Gear^.Y + _20 * Gear^.dY), vgtDust);
  3297             AddVisualGear(hwRound(Gear^.X + _20 * Gear^.dX), hwRound(Gear^.Y + _20 * Gear^.dY), vgtDust);
  3298         if (CheckGearDrowning(Gear)) then
  3298         if (CheckGearDrowning(Gear)) then
  3299            begin
  3299            begin
  3300             StopSound(Gear^.SoundChannel);
  3300             StopSoundChan(Gear^.SoundChannel);
  3301             exit
  3301             exit
  3302     end
  3302     end
  3303     end;
  3303     end;
  3304 
  3304 
  3305     if GameTicks > Gear^.FlightTime then
  3305     if GameTicks > Gear^.FlightTime then
  3312     or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))))
  3312     or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))))
  3313 // CheckLandValue returns true if the type isn't matched
  3313 // CheckLandValue returns true if the type isn't matched
  3314     or (not CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible)) then
  3314     or (not CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible)) then
  3315         begin
  3315         begin
  3316         //out of time or exited ground
  3316         //out of time or exited ground
  3317         StopSound(Gear^.SoundChannel);
  3317         StopSoundChan(Gear^.SoundChannel);
  3318         if (Gear^.State and gsttmpFlag) <> 0 then
  3318         if (Gear^.State and gsttmpFlag) <> 0 then
  3319             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound)
  3319             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound)
  3320         else
  3320         else
  3321             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
  3321             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound);
  3322         DeleteGear(Gear);
  3322         DeleteGear(Gear);
  3323         exit
  3323         exit
  3324         end
  3324         end
  3325         
  3325         
  3326     else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then
  3326     else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then
  3327         begin
  3327         begin
  3328         StopSound(Gear^.SoundChannel);
  3328         StopSoundChan(Gear^.SoundChannel);
  3329         Gear^.Tag := 1;
  3329         Gear^.Tag := 1;
  3330         Gear^.doStep := @doStepDrill
  3330         Gear^.doStep := @doStepDrill
  3331         end;
  3331         end;
  3332 
  3332 
  3333     dec(Gear^.Timer);
  3333     dec(Gear^.Timer);
  3527 
  3527 
  3528     CheckCollision(Gear);
  3528     CheckCollision(Gear);
  3529 
  3529 
  3530     if ((Gear^.State and gstCollision) <> 0) or CheckGearDrowning(Gear) then
  3530     if ((Gear^.State and gstCollision) <> 0) or CheckGearDrowning(Gear) then
  3531         begin
  3531         begin
  3532         StopSound(Gear^.SoundChannel);
  3532         StopSoundChan(Gear^.SoundChannel);
  3533         StopSound(sndRideOfTheValkyries);
  3533         StopSound(sndRideOfTheValkyries);
  3534         ResumeMusic;
  3534         ResumeMusic;
  3535 
  3535 
  3536         if ((Gear^.State and gstCollision) <> 0) then
  3536         if ((Gear^.State and gstCollision) <> 0) then
  3537             begin
  3537             begin
  5052 
  5052 
  5053     graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius);
  5053     graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius);
  5054 
  5054 
  5055     if Length(graves) = 0 then
  5055     if Length(graves) = 0 then
  5056         begin
  5056         begin
  5057         StopSound(Gear^.SoundChannel);
  5057         StopSoundChan(Gear^.SoundChannel);
  5058         Gear^.Timer := 250;
  5058         Gear^.Timer := 250;
  5059         Gear^.doStep := @doStepIdle;
  5059         Gear^.doStep := @doStepIdle;
  5060         exit;
  5060         exit;
  5061         end;
  5061         end;
  5062 
  5062 
  5097                 end;
  5097                 end;
  5098 
  5098 
  5099         hh^.Gear^.dY := _0;
  5099         hh^.Gear^.dY := _0;
  5100         hh^.Gear^.dX := _0;
  5100         hh^.Gear^.dX := _0;
  5101         doStepHedgehogMoving(hh^.Gear);
  5101         doStepHedgehogMoving(hh^.Gear);
  5102         StopSound(Gear^.SoundChannel);
  5102         StopSoundChan(Gear^.SoundChannel);
  5103         Gear^.Timer := 250;
  5103         Gear^.Timer := 250;
  5104         Gear^.doStep := @doStepIdle;
  5104         Gear^.doStep := @doStepIdle;
  5105         end
  5105         end
  5106     //if hh^.Gear^.Health = 0 then doStepHedgehogFree(hh^.Gear);
  5106     //if hh^.Gear^.Health = 0 then doStepHedgehogFree(hh^.Gear);
  5107 end;
  5107 end;
  5123             end;
  5123             end;
  5124         Gear^.doStep := @doStepResurrectorWork;
  5124         Gear^.doStep := @doStepResurrectorWork;
  5125         end 
  5125         end 
  5126     else 
  5126     else 
  5127         begin
  5127         begin
  5128         StopSound(Gear^.SoundChannel);
  5128         StopSoundChan(Gear^.SoundChannel);
  5129         Gear^.Timer := 250;
  5129         Gear^.Timer := 250;
  5130         Gear^.doStep := @doStepIdle;
  5130         Gear^.doStep := @doStepIdle;
  5131         end
  5131         end
  5132 end;
  5132 end;
  5133 
  5133 
  5280     i,j,cnt: LongWord;
  5280     i,j,cnt: LongWord;
  5281 begin
  5281 begin
  5282 HH:= Gear^.Hedgehog;
  5282 HH:= Gear^.Hedgehog;
  5283 if Gear^.Pos = 2 then
  5283 if Gear^.Pos = 2 then
  5284     begin
  5284     begin
  5285     StopSound(Gear^.SoundChannel);
  5285     StopSoundChan(Gear^.SoundChannel);
  5286     if (Gear^.Timer = 0) then
  5286     if (Gear^.Timer = 0) then
  5287         begin
  5287         begin
  5288         if (HH^.Gear <> nil) and (HH^.Gear^.State and gstInvisible = 0) then
  5288         if (HH^.Gear <> nil) and (HH^.Gear^.State and gstInvisible = 0) then
  5289             begin
  5289             begin
  5290             AfterAttack;
  5290             AfterAttack;
  5324     dec(Gear^.Power);
  5324     dec(Gear^.Power);
  5325 if (Gear^.Pos = 1) and (Gear^.Power = 255) and ((GameTicks mod 2000) = 1000) then
  5325 if (Gear^.Pos = 1) and (Gear^.Power = 255) and ((GameTicks mod 2000) = 1000) then
  5326     Gear^.Pos:= 2;
  5326     Gear^.Pos:= 2;
  5327 if (Gear^.Pos = 3) and (Gear^.Power = 0) then
  5327 if (Gear^.Pos = 3) and (Gear^.Power = 0) then
  5328     begin
  5328     begin
  5329     StopSound(Gear^.SoundChannel);
  5329     StopSoundChan(Gear^.SoundChannel);
  5330     if HH^.GearHidden = nil then
  5330     if HH^.GearHidden = nil then
  5331         begin
  5331         begin
  5332         DeleteGear(Gear);
  5332         DeleteGear(Gear);
  5333         exit
  5333         exit
  5334         end;
  5334         end;