hedgewars/GSHandlers.inc
changeset 4272 cf18de7ea3d4
parent 4265 039b08012887
child 4275 24137d2be956
equal deleted inserted replaced
4269:945f2d104268 4272:cf18de7ea3d4
   316     end;
   316     end;
   317 
   317 
   318     if Gear^.AdvBounce > 1 then dec(Gear^.AdvBounce);
   318     if Gear^.AdvBounce > 1 then dec(Gear^.AdvBounce);
   319 
   319 
   320     if isFalling then Gear^.dY := Gear^.dY + cGravity;
   320     if isFalling then Gear^.dY := Gear^.dY + cGravity;
       
   321     if (GameFlags and gfMoreWind) <> 0 then Gear^.dX := Gear^.dX + cWindSpeed * _4 / HHGear^.Radius;
   321 
   322 
   322     Gear^.X := Gear^.X + Gear^.dX;
   323     Gear^.X := Gear^.X + Gear^.dX;
   323     Gear^.Y := Gear^.Y + Gear^.dY;
   324     Gear^.Y := Gear^.Y + Gear^.dY;
   324     CheckGearDrowning(Gear);
   325     CheckGearDrowning(Gear);
   325     //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and
   326     //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and
   510 
   511 
   511 ////////////////////////////////////////////////////////////////////////////////
   512 ////////////////////////////////////////////////////////////////////////////////
   512 procedure doStepShell(Gear: PGear);
   513 procedure doStepShell(Gear: PGear);
   513 begin
   514 begin
   514     AllInactive := false;
   515     AllInactive := false;
   515     Gear^.dX := Gear^.dX + cWindSpeed;
   516     if (GameFlags and gfMoreWind) = 0 then Gear^.dX := Gear^.dX + cWindSpeed;
   516     doStepFallingGear(Gear);
   517     doStepFallingGear(Gear);
   517     if (Gear^.State and gstCollision) <> 0 then
   518     if (Gear^.State and gstCollision) <> 0 then
   518     begin
   519     begin
   519         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   520         doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   520         DeleteGear(Gear);
   521         DeleteGear(Gear);
  3048             dec(Gear^.Health, fuel div 5);
  3049             dec(Gear^.Health, fuel div 5);
  3049             Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  3050             Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  3050             Gear^.Timer := GameTicks
  3051             Gear^.Timer := GameTicks
  3051             end
  3052             end
  3052         end;
  3053         end;
       
  3054     if not isUnderwater and ((GameFlags and gfMoreWind) <> 0) then HHGear^.dX := HHGear^.dX + cWindSpeed * _4 / HHGear^.Radius;
  3053 
  3055 
  3054     // erases them all at once :-/
  3056     // erases them all at once :-/
  3055     if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then
  3057     if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then
  3056         begin
  3058         begin
  3057         Gear^.Timer := 0;
  3059         Gear^.Timer := 0;
  3166         Gear^.Tag := -1
  3168         Gear^.Tag := -1
  3167     else
  3169     else
  3168         Gear^.Tag := 1;
  3170         Gear^.Tag := 1;
  3169 
  3171 
  3170     if (HHGear^.Message and gmUp) <> 0 then
  3172     if (HHGear^.Message and gmUp) <> 0 then
  3171     begin
  3173         begin
  3172         if (not HHGear^.dY.isNegative) or (HHGear^.Y > -_256) then
  3174         if (not HHGear^.dY.isNegative) or (HHGear^.Y > -_256) then
  3173             HHGear^.dY := HHGear^.dY - move;
  3175             HHGear^.dY := HHGear^.dY - move;
  3174         dec(Gear^.Health, fuel);
  3176         dec(Gear^.Health, fuel);
  3175         Gear^.MsgParam := Gear^.MsgParam or gmUp;
  3177         Gear^.MsgParam := Gear^.MsgParam or gmUp;
  3176     end;
  3178         end;
  3177     if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true;
  3179     if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true;
  3178     if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
  3180     if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then
  3179     begin
  3181         begin
  3180         HHGear^.dX := HHGear^.dX + (move * _0_1);
  3182         HHGear^.dX := HHGear^.dX + (move * _0_1);
  3181         dec(Gear^.Health, fuel div 5);
  3183         dec(Gear^.Health, fuel div 5);
  3182         Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  3184         Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight));
  3183     end;
  3185         end;
       
  3186     if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed * _4 / HHGear^.Radius;
  3184 
  3187 
  3185     if Gear^.Health < 0 then Gear^.Health := 0;
  3188     if Gear^.Health < 0 then Gear^.Health := 0;
  3186     if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) then
  3189     if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) then
  3187         for i:= ((500-Gear^.Health) div 250) downto 0 do
  3190         for i:= ((500-Gear^.Health) div 250) downto 0 do
  3188             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
  3191             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather);
  3189 
  3192 
  3190     if (HHGear^.Message and gmAttack <> 0) then
  3193     if (HHGear^.Message and gmAttack <> 0) then
  3191     begin
  3194         begin
  3192         HHGear^.Message := HHGear^.Message and not gmAttack;
  3195         HHGear^.Message := HHGear^.Message and not gmAttack;
  3193         if Gear^.FlightTime > 0 then
  3196         if Gear^.FlightTime > 0 then
  3194         begin
  3197             begin
  3195             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + 32, gtEgg, 0, Gear^.dX * _0_5, Gear^.dY, 0)
  3198             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + 32, gtEgg, 0, Gear^.dX * _0_5, Gear^.dY, 0);
  3196             ;
       
  3197             PlaySound(sndBirdyLay);
  3199             PlaySound(sndBirdyLay);
  3198             dec(Gear^.FlightTime)
  3200             dec(Gear^.FlightTime)
  3199         end;
  3201             end;
  3200     end;
  3202         end;
  3201 
  3203 
  3202     if HHGear^.Message and (gmUp or gmPrecise or gmLeft or gmRight) <> 0 then 
  3204     if HHGear^.Message and (gmUp or gmPrecise or gmLeft or gmRight) <> 0 then 
  3203         Gear^.State := Gear^.State and not gsttmpFlag;
  3205         Gear^.State := Gear^.State and not gsttmpFlag;
  3204     HHGear^.Message := HHGear^.Message and not (gmUp or gmPrecise or gmLeft or gmRight);
  3206     HHGear^.Message := HHGear^.Message and not (gmUp or gmPrecise or gmLeft or gmRight);
  3205     HHGear^.State := HHGear^.State or gstMoving;
  3207     HHGear^.State := HHGear^.State or gstMoving;
  3217        or (TurnTimeLeft = 0)
  3219        or (TurnTimeLeft = 0)
  3218        // allow brief ground touches - to be fair on this, might need another counter
  3220        // allow brief ground touches - to be fair on this, might need another counter
  3219        or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and TestCollisionYwithGear(
  3221        or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and TestCollisionYwithGear(
  3220        HHGear, 1))
  3222        HHGear, 1))
  3221        or ((Gear^.Message and gmAttack) <> 0) then
  3223        or ((Gear^.Message and gmAttack) <> 0) then
  3222     begin
  3224         begin
  3223         with HHGear^ do
  3225         with HHGear^ do
  3224         begin
  3226             begin
  3225             Message := 0;
  3227             Message := 0;
  3226             Active := true;
  3228             Active := true;
  3227             State := State or gstMoving
  3229             State := State or gstMoving
  3228         end;
  3230             end;
  3229         Gear^.State := Gear^.State or gstAnimation or gstTmpFlag;
  3231         Gear^.State := Gear^.State or gstAnimation or gstTmpFlag;
  3230         if HHGear^.dY < _0 then
  3232         if HHGear^.dY < _0 then
  3231         begin
  3233             begin
  3232             Gear^.dX := HHGear^.dX;
  3234             Gear^.dX := HHGear^.dX;
  3233             Gear^.dY := HHGear^.dY;
  3235             Gear^.dY := HHGear^.dY;
  3234         end;
  3236             end;
  3235         Gear^.Timer := 0;
  3237         Gear^.Timer := 0;
  3236         Gear^.doStep := @doStepBirdyDisappear;
  3238         Gear^.doStep := @doStepBirdyDisappear;
  3237         CurAmmoGear := nil;
  3239         CurAmmoGear := nil;
  3238         isCursorVisible := false;
  3240         isCursorVisible := false;
  3239         AfterAttack;
  3241         AfterAttack;
  3240     end
  3242         end
  3241 end;
  3243 end;
  3242 
  3244 
  3243 ////////////////////////////////////////////////////////////////////////////////
  3245 ////////////////////////////////////////////////////////////////////////////////
  3244 procedure doStepBirdyDescend(Gear: PGear);
  3246 procedure doStepBirdyDescend(Gear: PGear);
  3245 var 
  3247 var