hedgewars/HHHandlers.inc
branchexperimental3D
changeset 4812 f924be23ffb4
parent 4790 4cb3f7890fbd
child 4824 efbc8f80acac
equal deleted inserted replaced
4347:0ddb100fea61 4812:f924be23ffb4
    46     ammoidx: LongInt;
    46     ammoidx: LongInt;
    47 begin
    47 begin
    48 ChangeAmmo:= false;
    48 ChangeAmmo:= false;
    49 slot:= Gear^.MsgParam;
    49 slot:= Gear^.MsgParam;
    50 
    50 
    51 with PHedgehog(Gear^.Hedgehog)^ do
    51 with Gear^.Hedgehog^ do
    52     begin
    52     begin
    53     Gear^.Message:= Gear^.Message and not gmSlot;
    53     Gear^.Message:= Gear^.Message and not gmSlot;
    54     ammoidx:= 0;
    54     ammoidx:= 0;
    55     if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or
    55     if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or
    56        (TargetPoint.X <> NoPointX) or
    56        (TargetPoint.X <> NoPointX) or
    58        ((Gear^.State and gstHHDriven) = 0) then exit;
    58        ((Gear^.State and gstHHDriven) = 0) then exit;
    59     ChangeAmmo:= true;
    59     ChangeAmmo:= true;
    60 
    60 
    61     while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx);
    61     while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx);
    62 
    62 
    63     if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(PHedgehog(Gear^.Hedgehog)^);
    63     if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(Gear^.Hedgehog^);
    64 
    64 
    65     MultiShootAttacks:= 0;
    65     MultiShootAttacks:= 0;
    66     Gear^.Message:= Gear^.Message and not (gmLJump or gmHJump);
    66     Gear^.Message:= Gear^.Message and not (gmLJump or gmHJump);
    67     
    67     
    68     if Ammoz[CurAmmoType].Slot = slot then
    68     if Ammoz[CurAmmoType].Slot = slot then
    99     weap: TAmmoType;
    99     weap: TAmmoType;
   100     Hedgehog: PHedgehog;
   100     Hedgehog: PHedgehog;
   101     s: boolean;
   101     s: boolean;
   102 begin
   102 begin
   103 weap:= TAmmoType(Gear^.MsgParam);
   103 weap:= TAmmoType(Gear^.MsgParam);
   104 Hedgehog:= PHedgehog(Gear^.Hedgehog);
   104 Hedgehog:= Gear^.Hedgehog;
   105 
   105 
   106 if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then exit; // weapon is not activated yet
   106 if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then exit; // weapon is not activated yet
   107 
   107 
   108 Gear^.MsgParam:= Ammoz[weap].Slot;
   108 Gear^.MsgParam:= Ammoz[weap].Slot;
   109 
   109 
   116         begin
   116         begin
   117         s:= ChangeAmmo(Gear);
   117         s:= ChangeAmmo(Gear);
   118         dec(t)
   118         dec(t)
   119         end;
   119         end;
   120 
   120 
   121 if s then ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^)
   121 if s then ApplyAmmoChanges(Gear^.Hedgehog^)
   122 end;
   122 end;
   123 
   123 
   124 procedure HHSetTimer(Gear: PGear);
   124 procedure HHSetTimer(Gear: PGear);
   125 var CurWeapon: PAmmo;
   125 var CurWeapon: PAmmo;
   126 begin
   126 begin
   127 Gear^.Message:= Gear^.Message and not gmTimer;
   127 Gear^.Message:= Gear^.Message and not gmTimer;
   128 CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
   128 CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^);
   129 with PHedgehog(Gear^.Hedgehog)^ do
   129 with Gear^.Hedgehog^ do
   130     if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then
   130     if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then
   131         begin
   131         begin
   132         CurWeapon^.Timer:= 1000 * Gear^.MsgParam;
   132         CurWeapon^.Timer:= 1000 * Gear^.MsgParam;
   133         with CurrentTeam^ do
   133         with CurrentTeam^ do
   134             ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
   134             ApplyAmmoChanges(Hedgehogs[CurrHedgehog]);
   141     tmpGear: PVisualGear;
   141     tmpGear: PVisualGear;
   142     CurWeapon: PAmmo;
   142     CurWeapon: PAmmo;
   143     altUse: boolean;
   143     altUse: boolean;
   144 begin
   144 begin
   145 bShowFinger:= false;
   145 bShowFinger:= false;
   146 CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
   146 CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^);
   147 with Gear^,
   147 with Gear^,
   148      PHedgehog(Gear^.Hedgehog)^ do
   148      Gear^.Hedgehog^ do
   149      begin
   149      begin
   150      if ((State and gstHHDriven) <> 0)and
   150      if ((State and gstHHDriven) <> 0)and
   151         ((State and (gstAttacked or gstHHChooseTarget)) = 0) and
   151         ((State and (gstAttacked or gstHHChooseTarget)) = 0) and
   152         (((State and gstMoving) = 0) or
   152         (((State and gstMoving) = 0) or
   153             // Allow attacks while moving on ammo with AltAttack
   153             // Allow attacks while moving on ammo with AltAttack
   205                       amGrenade: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBomb,         0, newDx, newDy, CurWeapon^.Timer);
   205                       amGrenade: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBomb,         0, newDx, newDy, CurWeapon^.Timer);
   206                       amMolotov: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov,      0, newDx, newDy, 0);
   206                       amMolotov: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov,      0, newDx, newDy, 0);
   207                   amClusterBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb,  0, newDx, newDy, CurWeapon^.Timer);
   207                   amClusterBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb,  0, newDx, newDy, CurWeapon^.Timer);
   208                       amGasBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb,      0, newDx, newDy, CurWeapon^.Timer);
   208                       amGasBomb: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb,      0, newDx, newDy, CurWeapon^.Timer);
   209                       amBazooka: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtShell,        0, newDx, newDy, 0);
   209                       amBazooka: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtShell,        0, newDx, newDy, 0);
       
   210                      amSnowball: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtSnowball,     0, newDx, newDy, 0);
   210                           amBee: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBee,          0, newDx, newDy, 0);
   211                           amBee: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtBee,          0, newDx, newDy, 0);
   211                       amShotgun: begin
   212                       amShotgun: begin
   212                                  PlaySound(sndShotgunReload);
   213                                  PlaySound(sndShotgunReload);
   213                                  CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   214                                  CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot,  0, xx * _0_5, yy * _0_5, 0);
   214                                  end;
   215                                  end;
   220                                  else
   221                                  else
   221                                     AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   222                                     AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000);
   222                         amSMine: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   223                         amSMine: FollowGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0);
   223                        amDEagle: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   224                        amDEagle: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
   224                       amSineGun: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   225                       amSineGun: CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0);
   225                     amPortalGun: AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 0);
   226                     amPortalGun: begin
       
   227                                  AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, 
       
   228                                  // set selected color
       
   229                                  CurWeapon^.Pos);
       
   230                                  end;
   226                   amSniperRifle: begin
   231                   amSniperRifle: begin
   227                                  PlaySound(sndSniperReload);
   232                                  PlaySound(sndSniperReload);
   228                                  CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0);
   233                                  CurAmmoGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0);
   229                                  end;
   234                                  end;
   230                      amDynamite: AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
   235                      amDynamite: AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
   273                              PlaySound(sndWhistle);
   278                              PlaySound(sndWhistle);
   274                              CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0);
   279                              CurAmmoGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0);
   275                              end;
   280                              end;
   276                       amLowGravity: begin
   281                       amLowGravity: begin
   277                                     PlaySound(sndLowGravity);
   282                                     PlaySound(sndLowGravity);
   278                                     cGravity:= cMaxWindSpeed
   283                                     cGravity:= cMaxWindSpeed;
       
   284                                     cGravityf:= 0.00025
   279                                     end;
   285                                     end;
   280                       amExtraDamage:begin 
   286                       amExtraDamage:begin 
   281                                     PlaySound(sndHellishImpact4);
   287                                     PlaySound(sndHellishImpact4);
   282                                     cDamageModifier:= _1_5
   288                                     cDamageModifier:= _1_5
   283                                     end;
   289                                     end;
   384 ////////////////////////////////////////////////////////////////////////////////
   390 ////////////////////////////////////////////////////////////////////////////////
   385 procedure doStepHedgehogDead(Gear: PGear);
   391 procedure doStepHedgehogDead(Gear: PGear);
   386 const frametime = 200;
   392 const frametime = 200;
   387       timertime = frametime * 6;
   393       timertime = frametime * 6;
   388 begin
   394 begin
   389 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   395 if Gear^.Hedgehog^.Unplaced then exit;
   390 if Gear^.Timer > 1 then
   396 if Gear^.Timer > 1 then
   391     begin
   397     begin
   392     AllInactive:= false;
   398     AllInactive:= false;
   393     dec(Gear^.Timer);
   399     dec(Gear^.Timer);
   394     if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos)
   400     if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos)
   404     begin
   410     begin
   405     AllInactive:= false;
   411     AllInactive:= false;
   406     Gear^.Z:= cCurrHHZ;
   412     Gear^.Z:= cCurrHHZ;
   407     RemoveGearFromList(Gear);
   413     RemoveGearFromList(Gear);
   408     InsertGearToList(Gear);
   414     InsertGearToList(Gear);
   409     PlaySound(sndByeBye, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   415     PlaySound(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
   410     Gear^.Pos:= 0;
   416     Gear^.Pos:= 0;
   411     Gear^.Timer:= timertime
   417     Gear^.Timer:= timertime
   412     end
   418     end
   413 end;
   419 end;
   414 
   420 
   415 ////////////////////////////////////////////////////////////////////////////////
   421 ////////////////////////////////////////////////////////////////////////////////
   416 procedure doStepHedgehogGone(Gear: PGear);
   422 procedure doStepHedgehogGone(Gear: PGear);
   417 const frametime = 65;
   423 const frametime = 65;
   418       timertime = frametime * 11;
   424       timertime = frametime * 11;
   419 begin
   425 begin
   420 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   426 if Gear^.Hedgehog^.Unplaced then exit;
   421 if Gear^.Timer > 1 then
   427 if Gear^.Timer > 1 then
   422     begin
   428     begin
   423     AllInactive:= false;
   429     AllInactive:= false;
   424     dec(Gear^.Timer);
   430     dec(Gear^.Timer);
   425     if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos)
   431     if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos)
   432     begin
   438     begin
   433     AllInactive:= false;
   439     AllInactive:= false;
   434     Gear^.Z:= cCurrHHZ;
   440     Gear^.Z:= cCurrHHZ;
   435     RemoveGearFromList(Gear);
   441     RemoveGearFromList(Gear);
   436     InsertGearToList(Gear);
   442     InsertGearToList(Gear);
   437     PlaySound(sndByeBye, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   443     PlaySound(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
   438     PlaySound(sndWarp);
   444     PlaySound(sndWarp);
   439     Gear^.Pos:= 0;
   445     Gear^.Pos:= 0;
   440     Gear^.Timer:= timertime
   446     Gear^.Timer:= timertime
   441     end
   447     end
   442 end;
   448 end;
   452 PlaySound(sndShotgunReload);
   458 PlaySound(sndShotgunReload);
   453 case Gear^.Pos of
   459 case Gear^.Pos of
   454        posCaseUtility,
   460        posCaseUtility,
   455        posCaseAmmo: begin
   461        posCaseAmmo: begin
   456                     a:= Gear^.AmmoType;
   462                     a:= Gear^.AmmoType;
   457                     AddAmmo(PHedgehog(HH^.Hedgehog)^, a);
   463                     AddAmmo(HH^.Hedgehog^, a);
   458 // Possibly needs to check shared clan ammo game flag once added.
   464 // Possibly needs to check shared clan ammo game flag once added.
   459 // On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up
   465 // On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up
   460                     if (not (PHedgehog(HH^.Hedgehog)^.Team^.ExtDriven 
   466                     if (not (HH^.Hedgehog^.Team^.ExtDriven 
   461                       or (PHedgehog(HH^.Hedgehog)^.BotLevel > 0)))
   467                       or (HH^.Hedgehog^.BotLevel > 0)))
   462                       or (PHedgehog(HH^.Hedgehog)^.Team^.Clan^.ClanIndex = LocalClan)
   468                       or (HH^.Hedgehog^.Team^.Clan^.ClanIndex = LocalClan)
   463                       or (GameType = gmtDemo)  then
   469                       or (GameType = gmtDemo)  then
   464                         begin
   470                         begin
   465                         s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')';
   471                         s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')';
   466                         AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo);
   472                         AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
   467 
   473 
   468                         // show ammo icon
   474                         // show ammo icon
   469                         vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo);
   475                         vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo);
   470                         if vga <> nil then
   476                         if vga <> nil then
   471                             vga^.Frame:= Longword(a);
   477                             vga^.Frame:= Longword(a);
   472                         end;
   478                         end;
   473 
   479 
   474                     end;
   480                     end;
   475      posCaseHealth: begin
   481      posCaseHealth: begin
   476                     inc(HH^.Health, Gear^.Health);
   482                     inc(HH^.Health, Gear^.Health);
   477                     PHedgehog(HH^.Hedgehog)^.Effects[hePoisoned] := false;
   483                     HH^.Hedgehog^.Effects[hePoisoned] := false;
   478                     str(Gear^.Health, s);
   484                     str(Gear^.Health, s);
   479                     s:= '+' + s;
   485                     s:= '+' + s;
   480                     AddCaption(s, PHedgehog(HH^.Hedgehog)^.Team^.Clan^.Color, capgrpAmmoinfo);
   486                     AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
   481                     RenderHealth(PHedgehog(HH^.Hedgehog)^);
   487                     RenderHealth(HH^.Hedgehog^);
   482                     RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team);
   488                     RecountTeamHealth(HH^.Hedgehog^.Team);
   483 
   489 
   484                     i:= 0;
   490                     i:= 0;
   485                     while i < Gear^.Health do
   491                     while i < Gear^.Health do
   486                         begin
   492                         begin
   487                         AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtHealth);
   493                         AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtHealth);
   495 
   501 
   496 procedure HedgehogStep(Gear: PGear);
   502 procedure HedgehogStep(Gear: PGear);
   497 var PrevdX: LongInt;
   503 var PrevdX: LongInt;
   498     CurWeapon: PAmmo;
   504     CurWeapon: PAmmo;
   499 begin
   505 begin
   500 CurWeapon:= GetAmmoEntry(PHedgehog(Gear^.Hedgehog)^);
   506 CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^);
   501 if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then
   507 if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then
   502    begin
   508    begin
   503    if isCursorVisible then
   509    if isCursorVisible then
   504       with PHedgehog(Gear^.Hedgehog)^ do
   510       with Gear^.Hedgehog^ do
   505         with CurWeapon^ do
   511         with CurWeapon^ do
   506           begin
   512           begin
   507           if (Gear^.Message and gmLeft  ) <> 0 then
   513           if (Gear^.Message and gmLeft  ) <> 0 then
   508              Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount
   514              Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount
   509           else
   515           else
   534          or   TestCollisionYwithGear(Gear, -1)) then
   540          or   TestCollisionYwithGear(Gear, -1)) then
   535          begin
   541          begin
   536          Gear^.dY:= -_0_15;
   542          Gear^.dY:= -_0_15;
   537          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   543          if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX);
   538          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   544          Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   539          PlaySound(sndJump1, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   545          PlaySound(sndJump1, Gear^.Hedgehog^.Team^.voicepack);
   540          exit
   546          exit
   541          end;
   547          end;
   542       end;
   548       end;
   543 
   549 
   544    if ((Gear^.Message and gmHJump ) <> 0) then
   550    if ((Gear^.Message and gmHJump ) <> 0) then
   547       Gear^.Message:= Gear^.Message and not gmHJump;
   553       Gear^.Message:= Gear^.Message and not gmHJump;
   548 
   554 
   549       Gear^.dY:= -_0_2;
   555       Gear^.dY:= -_0_2;
   550       SetLittle(Gear^.dX);
   556       SetLittle(Gear^.dX);
   551       Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   557       Gear^.State:= Gear^.State or gstMoving or gstHHJumping;
   552       PlaySound(sndJump3, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack);
   558       PlaySound(sndJump3, Gear^.Hedgehog^.Team^.voicepack);
   553       exit
   559       exit
   554       end;
   560       end;
   555 
   561 
   556    PrevdX:= hwSign(Gear^.dX);
   562    PrevdX:= hwSign(Gear^.dX);
   557    if (Gear^.Message and gmLeft  )<>0 then Gear^.dX:= -cLittle else
   563    if (Gear^.Message and gmLeft  )<>0 then Gear^.dX:= -cLittle else
   568       FollowGear:= Gear;
   574       FollowGear:= Gear;
   569       exit
   575       exit
   570       end;
   576       end;
   571    DeleteCI(Gear); // must be after exit!! (see previous line)
   577    DeleteCI(Gear); // must be after exit!! (see previous line)
   572 
   578 
   573    PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7;
   579    Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7;
   574    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   580    if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   575       begin
   581       begin
   576       if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
   582       if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
   577          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   583          or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
   578       if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
   584       if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
   628 end;
   634 end;
   629 
   635 
   630 procedure HedgehogChAngle(Gear: PGear);
   636 procedure HedgehogChAngle(Gear: PGear);
   631 var da: LongWord;
   637 var da: LongWord;
   632 begin
   638 begin
   633 with PHedgehog(Gear^.Hedgehog)^ do
   639 with Gear^.Hedgehog^ do
   634     if (CurAmmoType = amRope)
   640     if (CurAmmoType = amRope)
   635     and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1;
   641     and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1;
   636 
   642 
   637 if (((Gear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then
   643 if (((Gear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then
   638     if ((Gear^.Message and gmUp) <> 0) and (Gear^.Angle >= CurMinAngle + da) then dec(Gear^.Angle, da)
   644     if ((Gear^.Message and gmUp) <> 0) and (Gear^.Angle >= CurMinAngle + da) then dec(Gear^.Angle, da)
   647 begin
   653 begin
   648 isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
   654 isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius;
   649 if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862;
   655 if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862;
   650 if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862;
   656 if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862;
   651 
   657 
   652 if PHedgehog(Gear^.Hedgehog)^.Unplaced then
   658 if Gear^.Hedgehog^.Unplaced then
   653    begin
   659    begin
   654    Gear^.dY:= _0;
   660    Gear^.dY:= _0;
   655    Gear^.dX:= _0;
   661    Gear^.dX:= _0;
   656    Gear^.State:= Gear^.State and not gstMoving;
   662    Gear^.State:= Gear^.State and not gstMoving;
   657    exit
   663    exit
   665    else
   671    else
   666        begin
   672        begin
   667        Gear^.dY:= Gear^.dY + cGravity;
   673        Gear^.dY:= Gear^.dY + cGravity;
   668 // this set of circumstances could be less complex if jumping was more clearly identified
   674 // this set of circumstances could be less complex if jumping was more clearly identified
   669        if ((GameFlags and gfMoreWind) <> 0) and 
   675        if ((GameFlags and gfMoreWind) <> 0) and 
   670           (Gear^.Damage <> 0) or
   676           (((Gear^.Damage <> 0) or
   671           ((CurAmmoGear <> nil) and
   677           ((CurAmmoGear <> nil) and
   672             ((CurAmmoGear^.AmmoType = amJetpack) or
   678             ((CurAmmoGear^.AmmoType = amJetpack) or
   673             (CurAmmoGear^.AmmoType = amBirdy))) or
   679             (CurAmmoGear^.AmmoType = amBirdy))) or
   674           ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue)
   680           ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue)))
   675           then Gear^.dX := Gear^.dX + cWindSpeed * _0_2
   681           then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density
   676        end
   682        end
   677    end 
   683    end 
   678 else
   684 else
   679    begin
   685    begin
   680    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue)
   686    if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue)
   771 procedure doStepHedgehogDriven(Gear: PGear);
   777 procedure doStepHedgehogDriven(Gear: PGear);
   772 var t: PGear;
   778 var t: PGear;
   773     wasJumping: boolean;
   779     wasJumping: boolean;
   774     Hedgehog: PHedgehog;
   780     Hedgehog: PHedgehog;
   775 begin
   781 begin
   776 Hedgehog:= PHedgehog(Gear^.Hedgehog);
   782 Hedgehog:= Gear^.Hedgehog;
   777 if not isInMultiShoot then
   783 if not isInMultiShoot then
   778    AllInactive:= false
   784    AllInactive:= false
   779 else
   785 else
   780    Gear^.Message:= 0;
   786    Gear^.Message:= 0;
   781 
   787 
   917         Gear^.Timer:= 0;
   923         Gear^.Timer:= 0;
   918         FollowGear:= Gear;
   924         FollowGear:= Gear;
   919         PrvInactive:= false;
   925         PrvInactive:= false;
   920         AllInactive:= false;
   926         AllInactive:= false;
   921 
   927 
   922         if not PHedgehog(Gear^.Hedgehog)^.Team^.hasGone then
   928         if not Gear^.Hedgehog^.Team^.hasGone then
   923             begin
   929             begin
   924             PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] := false;
   930             Gear^.Hedgehog^.Effects[hePoisoned] := false;
   925             if PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] then begin
   931             if Gear^.Hedgehog^.Effects[heResurrectable] then begin
   926                 ResurrectHedgehog(Gear);
   932                 ResurrectHedgehog(Gear);
   927             end else begin
   933             end else begin
   928                 Gear^.State:= Gear^.State or gstHHDeath;
   934                 Gear^.State:= Gear^.State or gstHHDeath;
   929                 Gear^.doStep:= @doStepHedgehogDead;
   935                 Gear^.doStep:= @doStepHedgehogDead;
   930                 // Death message
   936                 // Death message
   931                 AddCaption(Format(GetEventString(eidDied), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage);
   937                 AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
   932             end;
   938             end;
   933             end
   939             end
   934         else
   940         else
   935             begin
   941             begin
   936             Gear^.State:= Gear^.State or gstHHGone;
   942             Gear^.State:= Gear^.State or gstHHGone;
   937             Gear^.doStep:= @doStepHedgehogGone;
   943             Gear^.doStep:= @doStepHedgehogGone;
   938             // Gone message
   944             // Gone message
   939             AddCaption(Format(GetEventString(eidGone), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage);
   945             AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage);
   940             end
   946             end
   941         end;
   947         end;
   942     exit
   948     exit
   943     end;
   949     end;
   944 
   950 
   972 
   978 
   973 if (Gear^.State and gstHHDriven) = 0 then
   979 if (Gear^.State and gstHHDriven) = 0 then
   974     doStepHedgehogFree(Gear)
   980     doStepHedgehogFree(Gear)
   975 else
   981 else
   976     begin
   982     begin
   977     with PHedgehog(Gear^.Hedgehog)^ do
   983     with Gear^.Hedgehog^ do
   978         if Team^.hasGone then TeamGoneEffect(Team^);
   984         if Team^.hasGone then TeamGoneEffect(Team^);
   979     doStepHedgehogDriven(Gear)
   985     doStepHedgehogDriven(Gear)
   980     end;
   986     end;
   981 end;
   987 end;