hedgewars/HHHandlers.inc
changeset 2428 6800f8aa0184
parent 2376 ece7b87f1334
child 2434 5faa05d99241
equal deleted inserted replaced
2427:241e3bb6a146 2428:6800f8aa0184
    41 			begin
    41 			begin
    42 			CurAmmo:= 0;
    42 			CurAmmo:= 0;
    43 			inc(i);
    43 			inc(i);
    44 			TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
    44 			TryDo(i < 2, 'Engine bug: no ammo in current slot', true)
    45 			end;
    45 			end;
    46 		until (Ammo^[slot, CurAmmo].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, CurAmmo].AmmoType].SkipTurns)
    46 		until (Ammo^[slot, CurAmmo].Count > 0) and ((Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, CurAmmo].AmmoType].SkipTurns) or ((TrainingFlags and tfIgnoreDelays) <> 0))
    47 		end else
    47 		end else
    48 		begin
    48 		begin
    49 		i:= 0;
    49 		i:= 0;
    50 		// check whether there is ammo in slot
    50 		// check whether there is ammo in slot
    51 		while (i <= cMaxSlotAmmoIndex)
    51 		while (i <= cMaxSlotAmmoIndex)
    52 		  and ((Ammo^[slot, i].Count = 0)
    52 		  and ((Ammo^[slot, i].Count = 0)
    53 		       or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i);
    53 		       or ((Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns) and ((TrainingFlags and tfIgnoreDelays) = 0))) do inc(i);
    54 
    54 
    55 		if i <= cMaxSlotAmmoIndex then
    55 		if i <= cMaxSlotAmmoIndex then
    56 			begin
    56 			begin
    57 			CurSlot:= slot;
    57 			CurSlot:= slot;
    58 			CurAmmo:= i
    58 			CurAmmo:= i
    65 var t: LongInt;
    65 var t: LongInt;
    66     weap: TAmmoType;
    66     weap: TAmmoType;
    67 begin
    67 begin
    68 weap:= TAmmoType(Gear^.MsgParam);
    68 weap:= TAmmoType(Gear^.MsgParam);
    69 
    69 
    70 if PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then exit; // weapon is not activated yet
    70 if (PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns) and ((TrainingFlags and tfIgnoreDelays) = 0) then exit; // weapon is not activated yet
    71 
    71 
    72 Gear^.MsgParam:= Ammoz[weap].Slot;
    72 Gear^.MsgParam:= Ammoz[weap].Slot;
    73 
    73 
    74 t:= cMaxSlotAmmoIndex;
    74 t:= cMaxSlotAmmoIndex;
    75 
    75 
   162                          amWhip: begin
   162                          amWhip: begin
   163                                  CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtWhip, 0, SignAs(_1, dX), - _0_8, 0);
   163                                  CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtWhip, 0, SignAs(_1, dX), - _0_8, 0);
   164                                  PlaySound(sndWhipCrack, false, nil)
   164                                  PlaySound(sndWhipCrack, false, nil)
   165                                  end;
   165                                  end;
   166                   amBaseballBat: begin
   166                   amBaseballBat: begin
   167 								 CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0);
   167 								 CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0);
   168 								 PlaySound(sndBaseballBat, false, nil);
   168 								 PlaySound(sndBaseballBat, false, nil);
   169 								 end;
   169 								 end;
   170                     amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0);
   170                     amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0);
   171                     amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0);
   171                     amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0);
   172                    amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
   172                    amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
   295 
   295 
   296 ////////////////////////////////////////////////////////////////////////////////
   296 ////////////////////////////////////////////////////////////////////////////////
   297 procedure PickUp(HH, Gear: PGear);
   297 procedure PickUp(HH, Gear: PGear);
   298 var s: shortstring;
   298 var s: shortstring;
   299     a: TAmmoType;
   299     a: TAmmoType;
       
   300 	i: Integer;
   300 begin
   301 begin
   301 Gear^.Message:= gm_Destroy;
   302 Gear^.Message:= gm_Destroy;
   302 case Gear^.Pos of
   303 case Gear^.Pos of
   303        posCaseUtility,
   304        posCaseUtility,
   304        posCaseAmmo: begin
   305        posCaseAmmo: begin
   316                     inc(HH^.Health, Gear^.Health);
   317                     inc(HH^.Health, Gear^.Health);
   317                     str(Gear^.Health, s);
   318                     str(Gear^.Health, s);
   318                     s:= '+' + s;
   319                     s:= '+' + s;
   319                     AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo);
   320                     AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo);
   320                     RenderHealth(PHedgehog(HH^.Hedgehog)^);
   321                     RenderHealth(PHedgehog(HH^.Hedgehog)^);
   321                     RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team)
   322                     RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team);
       
   323 
       
   324 					i:= 0;
       
   325 					while i < Gear^.Health do
       
   326 						begin
       
   327 						AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtHealth);
       
   328 						inc(i, 5);
       
   329 						end;
   322                     end;
   330                     end;
   323      end
   331      end
   324 end;
   332 end;
   325 
   333 
   326 const StepTicks: LongWord = 0;
   334 const StepTicks: LongWord = 0;
   541       Gear^.dY:= _0;
   549       Gear^.dY:= _0;
   542       Gear^.Y:= Gear^.Y + _1
   550       Gear^.Y:= Gear^.Y + _1
   543       end;
   551       end;
   544    CheckGearDrowning(Gear);
   552    CheckGearDrowning(Gear);
   545    if (Gear^.State and gstDrowning) <> 0 then isCursorVisible:= false
   553    if (Gear^.State and gstDrowning) <> 0 then isCursorVisible:= false
   546    end
   554    end;
       
   555 
       
   556 if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) then
       
   557     begin
       
   558     inc(Gear^.FlightTime, 1);
       
   559 	if Gear^.FlightTime = 2000 then
       
   560 		begin
       
   561 		AddCaption(GetEventString(eidHomerun), $FFFFFF, capgrpMessage);
       
   562 		PlaySound(sndHomerun, false, nil)
       
   563 		end;
       
   564 	end
       
   565 else
       
   566     begin
       
   567     Gear^.FlightTime:= 0;
       
   568 	end;
       
   569 
   547 end;
   570 end;
   548 
   571 
   549 procedure doStepHedgehogDriven(Gear: PGear);
   572 procedure doStepHedgehogDriven(Gear: PGear);
   550 var t: PGear;
   573 var t: PGear;
   551 	wasJumping: boolean;
   574 	wasJumping: boolean;