hedgewars/GSHandlers.inc
changeset 4808 7c3e5b52344a
parent 4805 01332828b568
child 4824 efbc8f80acac
equal deleted inserted replaced
4807:180dbfb13903 4808:7c3e5b52344a
  1970         PlaySound(sndWarp);
  1970         PlaySound(sndWarp);
  1971 
  1971 
  1972     if (Gear^.Tag = 0) and (Gear^.Timer < 1000) then
  1972     if (Gear^.Tag = 0) and (Gear^.Timer < 1000) then
  1973         inc(Gear^.Timer)
  1973         inc(Gear^.Timer)
  1974     else if Gear^.Tag = 1 then
  1974     else if Gear^.Tag = 1 then
  1975         begin
  1975         Gear^.Tag := 2
  1976             Gear^.Tag := 2;
       
  1977             if (TrainingFlags and tfTimeTrial) <> 0 then
       
  1978             begin
       
  1979                 inc(TurnTimeLeft, TrainingTimeInc);
       
  1980 
       
  1981                 if TrainingTimeInc > TrainingTimeInM then
       
  1982                     dec(TrainingTimeInc, TrainingTimeInD);
       
  1983                 if TurnTimeLeft > TrainingTimeMax then
       
  1984                     TurnTimeLeft := TrainingTimeMax;
       
  1985             end;
       
  1986         end
       
  1987     else if Gear^.Tag = 2 then
  1976     else if Gear^.Tag = 2 then
  1988              if Gear^.Timer > 0 then
  1977              if Gear^.Timer > 0 then
  1989                  dec(Gear^.Timer)
  1978                  dec(Gear^.Timer)
  1990     else
  1979     else
  1991     begin
  1980     begin
  1992         if (TrainingFlags and tfTargetRespawn) <> 0 then
       
  1993         begin
       
  1994             TrainingTargetGear := AddGear(0, 0, gtTarget, 0, _0, _0, 0);
       
  1995             FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH);
       
  1996         end;
       
  1997         DeleteGear(Gear);
  1981         DeleteGear(Gear);
  1998         exit;
  1982         exit;
  1999     end;
  1983     end;
  2000 
  1984 
  2001     doStepCase(Gear)
  1985     doStepCase(Gear)
  3105     trueAngle: Longword;
  3089     trueAngle: Longword;
  3106     t: PGear;
  3090     t: PGear;
  3107 begin
  3091 begin
  3108     AllInactive := false;
  3092     AllInactive := false;
  3109 
  3093 
  3110     if ((TrainingFlags and tfRCPlane) = 0) and (Gear^.Timer > 0) then dec(Gear^.Timer);
       
  3111 
       
  3112     if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (
       
  3113        TimeTrialStartTime = 0) then TimeTrialStartTime := RealTicks;
       
  3114 
       
  3115     HHGear := Gear^.Hedgehog^.Gear;
  3094     HHGear := Gear^.Hedgehog^.Gear;
  3116     FollowGear := Gear;
  3095     FollowGear := Gear;
  3117 
  3096 
  3118     fChanged := false;
  3097     fChanged := false;
  3119     if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then
  3098     if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then
  3152     end;
  3131     end;
  3153 
  3132 
  3154     Gear^.X := Gear^.X + Gear^.dX;
  3133     Gear^.X := Gear^.X + Gear^.dX;
  3155     Gear^.Y := Gear^.Y + Gear^.dY;
  3134     Gear^.Y := Gear^.Y + Gear^.dY;
  3156 
  3135 
  3157     if (TrainingFlags and tfRCPlane) = 0 then
  3136     if (GameTicks and $FF) = 0 then
  3158     begin
  3137         if Gear^.Timer < 3500 then
  3159         if (GameTicks and $FF) = 0 then
  3138             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace)
  3160             if Gear^.Timer < 3500 then
       
  3161                 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace)
       
  3162         else
       
  3163             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
       
  3164 
       
  3165         if ((HHGear^.Message and gmAttack) <> 0) and (Gear^.Health <> 0) then
       
  3166         begin
       
  3167             HHGear^.Message := HHGear^.Message and not gmAttack;
       
  3168             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY *
       
  3169             _0_5, 0);
       
  3170             dec(Gear^.Health)
       
  3171         end;
       
  3172 
       
  3173         if ((HHGear^.Message and gmLJump) <> 0)
       
  3174            and ((Gear^.State and gsttmpFlag) = 0) then
       
  3175         begin
       
  3176             Gear^.State := Gear^.State or gsttmpFlag;
       
  3177             PauseMusic;
       
  3178             playSound(sndRideOfTheValkyries);
       
  3179         end;
       
  3180 
       
  3181         // pickup bonuses
       
  3182         t := CheckGearNear(Gear, gtCase, 36, 36);
       
  3183         if t <> nil then
       
  3184             PickUp(HHGear, t);
       
  3185     end
       
  3186     else
  3139     else
  3187     begin
  3140         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  3188         if (GameTicks and $FF) = 0 then
  3141 
  3189             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  3142     if ((HHGear^.Message and gmAttack) <> 0) and (Gear^.Health <> 0) then
  3190 
  3143     begin
  3191         // pickup targets
  3144         HHGear^.Message := HHGear^.Message and not gmAttack;
  3192         t := CheckGearNear(Gear, gtTarget, 36, 36);
  3145         AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY *
  3193         if t <> nil then
  3146         _0_5, 0);
  3194         begin
  3147         dec(Gear^.Health)
  3195             if t^.Tag <> 0 then // collect it only once
  3148     end;
  3196                 exit;
  3149 
  3197             PlaySound(sndShotgunReload);
  3150     if ((HHGear^.Message and gmLJump) <> 0)
  3198             t^.Tag := 1;
  3151        and ((Gear^.State and gsttmpFlag) = 0) then
  3199             TrainingTargetGear := nil;
  3152     begin
  3200             // remove target cursor
  3153         Gear^.State := Gear^.State or gsttmpFlag;
  3201             exit;
  3154         PauseMusic;
  3202         end;
  3155         playSound(sndRideOfTheValkyries);
  3203 
  3156     end;
  3204         if (TurnTimeLeft > 0) then
  3157 
  3205             dec(TurnTimeLeft)
  3158     // pickup bonuses
  3206     end;
  3159     t := CheckGearNear(Gear, gtCase, 36, 36);
       
  3160     if t <> nil then
       
  3161         PickUp(HHGear, t);
  3207 
  3162 
  3208     CheckCollision(Gear);
  3163     CheckCollision(Gear);
  3209 
  3164 
  3210     if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (
  3165     if ((Gear^.State and gstCollision) <> 0) or CheckGearDrowning(Gear) then
  3211        TurnTimeLeft = 0))
  3166     begin
  3212        or CheckGearDrowning(Gear) then
       
  3213     begin
       
  3214         if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (
       
  3215            TimeTrialStopTime = 0) then TimeTrialStopTime := RealTicks;
       
  3216         StopSound(Gear^.SoundChannel);
  3167         StopSound(Gear^.SoundChannel);
  3217         StopSound(sndRideOfTheValkyries);
  3168         StopSound(sndRideOfTheValkyries);
  3218         ResumeMusic;
  3169         ResumeMusic;
  3219 
  3170 
  3220         if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (
  3171         if ((Gear^.State and gstCollision) <> 0) then
  3221            TurnTimeLeft = 0)) then
       
  3222         begin
  3172         begin
  3223             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound);
  3173             doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound);
  3224             for i:= 0 to 32 do
  3174             for i:= 0 to 32 do
  3225             begin
  3175             begin
  3226                 dX := AngleCos(i * 64) * _0_5 * (GetRandom + _1);
  3176                 dX := AngleCos(i * 64) * _0_5 * (GetRandom + _1);
  3232         end;
  3182         end;
  3233 
  3183 
  3234         AfterAttack;
  3184         AfterAttack;
  3235         CurAmmoGear := nil;
  3185         CurAmmoGear := nil;
  3236         if (GameFlags and gfInfAttack) = 0 then TurnTimeLeft := 14 * 125;
  3186         if (GameFlags and gfInfAttack) = 0 then TurnTimeLeft := 14 * 125;
  3237 
       
  3238         if (TrainingFlags and tfRCPlane) <> 0 then
       
  3239             TurnTimeLeft := 0;
       
  3240         // HACK: RCPlane training allows unlimited plane starts in last 2 seconds
       
  3241 
  3187 
  3242         HHGear^.Message := 0;
  3188         HHGear^.Message := 0;
  3243         ParseCommand('/taunt '#1, true)
  3189         ParseCommand('/taunt '#1, true)
  3244     end
  3190     end
  3245 end;
  3191 end;