hedgewars/GSHandlers.inc
changeset 7335 3c6f08af7dac
parent 7325 a68eca3ad1fe
child 7339 5984b749ad9b
equal deleted inserted replaced
7333:520a16a14747 7335:3c6f08af7dac
  3191 end;
  3191 end;
  3192 
  3192 
  3193 ////////////////////////////////////////////////////////////////////////////////
  3193 ////////////////////////////////////////////////////////////////////////////////
  3194 procedure doStepSeductionWork(Gear: PGear);
  3194 procedure doStepSeductionWork(Gear: PGear);
  3195 var i: LongInt;
  3195 var i: LongInt;
  3196     hogs: TPGearArray;
  3196     hogs: PGearArrayS;
  3197 begin
  3197 begin
  3198     AllInactive := false;
  3198     AllInactive := false;
  3199     hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius);
  3199     hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius);
  3200     if Length(hogs) > 0 then
  3200     if hogs.size > 0 then
  3201         begin
  3201         begin
  3202         for i:= 0 to Length(hogs) - 1 do
  3202         for i:= 0 to hogs.size - 1 do
  3203             begin
  3203             with hogs.ar^[i]^ do
  3204             if hogs[i] <> CurrentHedgehog^.Gear then
  3204                 begin
  3205                 begin
  3205                 if hogs.ar^[i] <> CurrentHedgehog^.Gear then
  3206                 //d:= Distance(Gear^.X - hogs[i]^.X, Gear^.Y - hogs[i]^.Y);
  3206                     begin
  3207                 hogs[i]^.dX:= _50 * cGravity * (Gear^.X - hogs[i]^.X) / _25;
  3207                     dX:= _50 * cGravity * (Gear^.X - X) / _25;
  3208                 //if Gear^.X < hogs[i]^.X then hogs[i]^.dX.isNegative:= true;
  3208                     dY:= -_450 * cGravity;
  3209                 hogs[i]^.dY:= -_450 * cGravity;
  3209                     Active:= true;
  3210                 hogs[i]^.Active:= true;
  3210                     end
  3211                 end
  3211                 end;
  3212             end;
       
  3213         end ;
  3212         end ;
  3214         AfterAttack;
  3213         AfterAttack;
  3215         DeleteGear(Gear);
  3214         DeleteGear(Gear);
  3216 (*
  3215 (*
  3217     Gear^.X := Gear^.X + Gear^.dX;
  3216     Gear^.X := Gear^.X + Gear^.dX;
  5060 end;
  5059 end;
  5061 
  5060 
  5062 ////////////////////////////////////////////////////////////////////////////////
  5061 ////////////////////////////////////////////////////////////////////////////////
  5063 procedure doStepResurrectorWork(Gear: PGear);
  5062 procedure doStepResurrectorWork(Gear: PGear);
  5064 var
  5063 var
  5065     graves: TPGearArray;
  5064     graves: PGearArrayS;
  5066     resgear: PGear;
  5065     resgear: PGear;
  5067     hh: PHedgehog;
  5066     hh: PHedgehog;
  5068     i: LongInt;
  5067     i: LongInt;
  5069 begin
  5068 begin
  5070     if (TurnTimeLeft > 0) then
  5069     if (TurnTimeLeft > 0) then
  5095             hh^.Gear^.Y := hh^.Gear^.Y - _1;
  5094             hh^.Gear^.Y := hh^.Gear^.Y - _1;
  5096         end;
  5095         end;
  5097 
  5096 
  5098     graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius);
  5097     graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius);
  5099 
  5098 
  5100     if Length(graves) = 0 then
  5099     if graves.size = 0 then
  5101         begin
  5100         begin
  5102         StopSoundChan(Gear^.SoundChannel);
  5101         StopSoundChan(Gear^.SoundChannel);
  5103         Gear^.Timer := 250;
  5102         Gear^.Timer := 250;
  5104         Gear^.doStep := @doStepIdle;
  5103         Gear^.doStep := @doStepIdle;
  5105         exit;
  5104         exit;
  5106         end;
  5105         end;
  5107 
  5106 
  5108     if ((Gear^.Message and gmAttack) <> 0) and (hh^.Gear^.Health > 0) and (TurnTimeLeft > 0) then
  5107     if ((Gear^.Message and gmAttack) <> 0) and (hh^.Gear^.Health > 0) and (TurnTimeLeft > 0) then
  5109         begin
  5108         begin
  5110         if Length(graves) <= Gear^.Tag then Gear^.Tag:= 0;
  5109         if graves.size <= Gear^.Tag then Gear^.Tag:= 0;
  5111         dec(hh^.Gear^.Health);
  5110         dec(hh^.Gear^.Health);
  5112         if (hh^.Gear^.Health = 0) and (hh^.Gear^.Damage = 0) then
  5111         if (hh^.Gear^.Health = 0) and (hh^.Gear^.Damage = 0) then
  5113             hh^.Gear^.Damage:= 1;
  5112             hh^.Gear^.Damage:= 1;
  5114         RenderHealth(hh^);
  5113         RenderHealth(hh^);
  5115         inc(graves[Gear^.Tag]^.Health);
  5114         inc(graves.ar^[Gear^.Tag]^.Health);
  5116         inc(Gear^.Tag)
  5115         inc(Gear^.Tag)
  5117 {-for i:= 0 to High(graves) do begin
  5116 {-for i:= 0 to High(graves) do begin
  5118             if hh^.Gear^.Health > 0 then begin
  5117             if hh^.Gear^.Health > 0 then begin
  5119                 dec(hh^.Gear^.Health);
  5118                 dec(hh^.Gear^.Health);
  5120                 inc(graves[i]^.Health);
  5119                 inc(graves[i]^.Health);
  5122         end; -}
  5121         end; -}
  5123         end 
  5122         end 
  5124     else 
  5123     else 
  5125         begin
  5124         begin
  5126         // now really resurrect the hogs with the hp saved in the graves
  5125         // now really resurrect the hogs with the hp saved in the graves
  5127         for i:= 0 to Length(graves) - 1 do
  5126         for i:= 0 to graves.size - 1 do
  5128             if graves[i]^.Health > 0 then
  5127             if graves.ar^[i]^.Health > 0 then
  5129                 begin
  5128                 begin
  5130                 resgear := AddGear(hwRound(graves[i]^.X), hwRound(graves[i]^.Y), gtHedgehog, gstWait, _0, _0, 0);
  5129                 resgear := AddGear(hwRound(graves.ar^[i]^.X), hwRound(graves.ar^[i]^.Y), gtHedgehog, gstWait, _0, _0, 0);
  5131                 resgear^.Hedgehog := graves[i]^.Hedgehog;
  5130                 resgear^.Hedgehog := graves.ar^[i]^.Hedgehog;
  5132                 resgear^.Health := graves[i]^.Health;
  5131                 resgear^.Health := graves.ar^[i]^.Health;
  5133                 PHedgehog(graves[i]^.Hedgehog)^.Gear := resgear;
  5132                 PHedgehog(graves.ar^[i]^.Hedgehog)^.Gear := resgear;
  5134                 DeleteGear(graves[i]);
  5133                 DeleteGear(graves.ar^[i]);
  5135                 RenderHealth(resgear^.Hedgehog^);
  5134                 RenderHealth(resgear^.Hedgehog^);
  5136                 RecountTeamHealth(resgear^.Hedgehog^.Team);
  5135                 RecountTeamHealth(resgear^.Hedgehog^.Team);
  5137                 resgear^.Hedgehog^.Effects[heResurrected]:= 1;
  5136                 resgear^.Hedgehog^.Effects[heResurrected]:= 1;
  5138                 // only make hat-less hedgehogs look like zombies, preserve existing hats
  5137                 // only make hat-less hedgehogs look like zombies, preserve existing hats
  5139                 
  5138                 
  5151     //if hh^.Gear^.Health = 0 then doStepHedgehogFree(hh^.Gear);
  5150     //if hh^.Gear^.Health = 0 then doStepHedgehogFree(hh^.Gear);
  5152 end;
  5151 end;
  5153 
  5152 
  5154 procedure doStepResurrector(Gear: PGear);
  5153 procedure doStepResurrector(Gear: PGear);
  5155 var
  5154 var
  5156     graves: TPGearArray;
  5155     graves: PGearArrayS;
  5157     i: LongInt;
  5156     i: LongInt;
  5158 begin
  5157 begin
  5159     AllInactive := false;
  5158     AllInactive := false;
  5160     graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius);
  5159     graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius);
  5161 
  5160 
  5162     if Length(graves) > 0 then
  5161     if graves.size > 0 then
  5163         begin
  5162         begin
  5164         for i:= 0 to Length(graves) - 1 do
  5163         for i:= 0 to graves.size - 1 do
  5165             begin
  5164             begin
  5166             PHedgehog(graves[i]^.Hedgehog)^.Gear := nil;
  5165             PHedgehog(graves.ar^[i]^.Hedgehog)^.Gear := nil;
  5167             graves[i]^.Health := 0;
  5166             graves.ar^[i]^.Health := 0;
  5168             end;
  5167             end;
  5169         Gear^.doStep := @doStepResurrectorWork;
  5168         Gear^.doStep := @doStepResurrectorWork;
  5170         end 
  5169         end 
  5171     else 
  5170     else 
  5172         begin
  5171         begin
  5481 procedure doStepIceGun(Gear: PGear);
  5480 procedure doStepIceGun(Gear: PGear);
  5482 var 
  5481 var 
  5483     HHGear, iter: PGear;
  5482     HHGear, iter: PGear;
  5484     ndX, ndY: hwFloat;
  5483     ndX, ndY: hwFloat;
  5485     i, t, gX, gY: LongInt;
  5484     i, t, gX, gY: LongInt;
  5486     hogs: TPGearArray;
  5485     hogs: PGearArrayS;
  5487 begin
  5486 begin
  5488     HHGear := Gear^.Hedgehog^.Gear;
  5487     HHGear := Gear^.Hedgehog^.Gear;
  5489     if (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) then
  5488     if (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) then
  5490         begin
  5489         begin
  5491         DeleteGear(Gear);
  5490         DeleteGear(Gear);
  5545                     Y:= HHGear^.Y
  5544                     Y:= HHGear^.Y
  5546                     end;
  5545                     end;
  5547 // freeze nearby hogs
  5546 // freeze nearby hogs
  5548                 if GameTicks mod 10 = 0 then dec(Gear^.Health);
  5547                 if GameTicks mod 10 = 0 then dec(Gear^.Health);
  5549                 hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius);
  5548                 hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius);
  5550                 if Length(hogs) > 0 then
  5549                 if hogs.size > 0 then
  5551                     for i:= 0 to Length(hogs) - 1 do
  5550                     for i:= 0 to hogs.size - 1 do
  5552                         if hogs[i] <> HHGear then
  5551                         if hogs.ar^[i] <> HHGear then
  5553                             begin
  5552                             begin
  5554                             //if Gear^.Hedgehog^.Effects[heFrozen]:= 0;
  5553                             //if Gear^.Hedgehog^.Effects[heFrozen]:= 0;
  5555                             end;
  5554                             end;
  5556                 inc(Pos)
  5555                 inc(Pos)
  5557                 end
  5556                 end