hedgewars/uGearsHandlersMess.pas
changeset 14016 3c40754f6cfe
parent 14014 d203bb36225f
child 14019 f09276eb0c27
equal deleted inserted replaced
14015:fb9ed6adef05 14016:3c40754f6cfe
    30 unit uGearsHandlersMess;
    30 unit uGearsHandlersMess;
    31 interface
    31 interface
    32 uses uTypes, uFloat;
    32 uses uTypes, uFloat;
    33 
    33 
    34 procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean);
    34 procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean);
    35 procedure makeHogsWorry(x, y: hwFloat; r: LongInt);
    35 procedure makeHogsWorry(x, y: hwFloat; r: LongInt; gearType: TGearType);
    36 procedure HideHog(HH: PHedgehog);
    36 procedure HideHog(HH: PHedgehog);
    37 procedure doStepDrowningGear(Gear: PGear);
    37 procedure doStepDrowningGear(Gear: PGear);
    38 procedure doStepFallingGear(Gear: PGear);
    38 procedure doStepFallingGear(Gear: PGear);
    39 procedure doStepBomb(Gear: PGear);
    39 procedure doStepBomb(Gear: PGear);
    40 procedure doStepMolotov(Gear: PGear);
    40 procedure doStepMolotov(Gear: PGear);
   199         or ((Gear^.State and gstMoving) = 0) then
   199         or ((Gear^.State and gstMoving) = 0) then
   200             break;
   200             break;
   201         end;
   201         end;
   202 end;
   202 end;
   203 
   203 
   204 procedure makeHogsWorry(x, y: hwFloat; r: LongInt);
   204 procedure makeHogsWorry(x, y: hwFloat; r: LongInt; gearType: TGearType);
   205 var
   205 var
   206     gi: PGear;
   206     gi: PGear;
   207     d: LongInt;
   207     d: LongInt;
       
   208     grenadeTaunt: boolean;
   208 begin
   209 begin
   209     gi := GearsList;
   210     gi := GearsList;
   210     while gi <> nil do
   211     while gi <> nil do
   211         begin
   212         begin
   212         if (gi^.Kind = gtHedgehog) then
   213         if (gi^.Kind = gtHedgehog) then
   223                         begin
   224                         begin
   224                         gi^.dX.isNegative:= X<gi^.X;
   225                         gi^.dX.isNegative:= X<gi^.X;
   225                         gi^.State := gi^.State or gstLoser;
   226                         gi^.State := gi^.State or gstLoser;
   226                         end;
   227                         end;
   227 
   228 
   228                     if d > r div 2 then
   229                     grenadeTaunt:= false;
   229                         PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack)
   230                     if (gearType = gtGrenade) then
       
   231                         grenadeTaunt:= random(2) = 0;
       
   232 
       
   233                     if grenadeTaunt then
       
   234                         PlaySoundV(sndGrenade, gi^.Hedgehog^.Team^.voicepack)
   230                     else
   235                     else
   231                         PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack);
   236                         if d > r div 2 then
       
   237                             PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack)
       
   238                         else
       
   239                             PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack);
       
   240 
   232                     end;
   241                     end;
   233                 end;
   242                 end;
   234             end;
   243             end;
   235 
   244 
   236         gi := gi^.NextGear
   245         gi := gi^.NextGear
   550     if Gear^.Timer = 1000 then // might need adjustments
   559     if Gear^.Timer = 1000 then // might need adjustments
   551         case Gear^.Kind of
   560         case Gear^.Kind of
   552             gtGrenade,
   561             gtGrenade,
   553             gtClusterBomb,
   562             gtClusterBomb,
   554             gtWatermelon,
   563             gtWatermelon,
   555             gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, Gear^.Boom);
   564             gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, Gear^.Boom, Gear^.Kind);
   556             gtGasBomb: makeHogsWorry(Gear^.X, Gear^.Y, 50);
   565             gtGasBomb: makeHogsWorry(Gear^.X, Gear^.Y, 50, Gear^.Kind);
   557         end;
   566         end;
   558 
   567 
   559     if (Gear^.Kind = gtBall) and ((Gear^.State and gstTmpFlag) <> 0) then
   568     if (Gear^.Kind = gtBall) and ((Gear^.State and gstTmpFlag) <> 0) then
   560         begin
   569         begin
   561         CheckCollision(Gear);
   570         CheckCollision(Gear);
  2283     AllInactive := false;
  2292     AllInactive := false;
  2284 
  2293 
  2285     if Gear^.Timer mod 166 = 0 then
  2294     if Gear^.Timer mod 166 = 0 then
  2286         inc(Gear^.Tag);
  2295         inc(Gear^.Tag);
  2287     if Gear^.Timer = 1000 then // might need better timing
  2296     if Gear^.Timer = 1000 then // might need better timing
  2288         makeHogsWorry(Gear^.X, Gear^.Y, 75);
  2297         makeHogsWorry(Gear^.X, Gear^.Y, 75, Gear^.Kind);
  2289     if Gear^.Timer = 0 then
  2298     if Gear^.Timer = 0 then
  2290         begin
  2299         begin
  2291         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
  2300         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Boom, Gear^.Hedgehog, EXPLAutoSound);
  2292         DeleteGear(Gear);
  2301         DeleteGear(Gear);
  2293         exit
  2302         exit