hedgewars/HHHandlers.inc
changeset 38 c1ec4b15d70e
parent 37 2b7f2a43b999
child 39 b78e7185ed13
equal deleted inserted replaced
37:2b7f2a43b999 38:c1ec4b15d70e
   124                       amBazooka: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
   124                       amBazooka: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Grenade, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
   125                       amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
   125                       amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
   126                           amUFO: FollowGear:= AddGear(round(X), round(Y), gtUFO,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
   126                           amUFO: FollowGear:= AddGear(round(X), round(Y), gtUFO,          0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor);
   127                       amShotgun: begin
   127                       amShotgun: begin
   128                                  PlaySound(sndShotgunReload);
   128                                  PlaySound(sndShotgunReload);
   129                                  FollowGear:= AddGear(round(X + xx*20), round(Y + yy*20), gtShotgunShot,  0, xx * 0.5, 0.5 * yy);
   129                                  FollowGear:= AddGear(round(X), round(Y), gtShotgunShot,  0, xx * 0.5, yy * 0.5);
   130                                  end;
   130                                  end;
   131                        amDEagle: begin
   131                        amDEagle: begin
   132                                  FollowGear:= AddGear(round(X + xx*20), round(Y + yy*20), gtDEagleShot,  0, xx * 0.5, 0.5 * yy);
   132                                  FollowGear:= AddGear(round(X), round(Y), gtDEagleShot,   0, xx * 0.5, yy * 0.5);
   133                                  end;
   133                                  end;
   134                          amSkip: TurnTimeLeft:= 0;
   134                          amSkip: TurnTimeLeft:= 0;
   135                    amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHHalfHeight, gtPickHammer, 0);
   135                    amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHHalfHeight, gtPickHammer, 0);
   136                          amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
   136                          amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
   137                          amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.01, 0, 3000);
   137                          amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.01, 0, 3000);
   207       with PHedgehog(Gear.Hedgehog)^ do
   207       with PHedgehog(Gear.Hedgehog)^ do
   208             begin
   208             begin
   209             Gear.State:= Gear.State or gstAttacking;
   209             Gear.State:= Gear.State or gstAttacking;
   210             if Gear.Power = cMaxPower then Gear.Message:= Gear.Message and not gm_Attack
   210             if Gear.Power = cMaxPower then Gear.Message:= Gear.Message and not gm_Attack
   211                else
   211                else
   212                if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then Attack(Gear)
   212                if (Ammo[CurSlot, CurAmmo].Propz and ammoprop_Power) = 0 then
       
   213                   Gear.Message:= Gear.Message and not gm_Attack
   213                   else begin
   214                   else begin
   214                   if Gear.Power = 0 then
   215                   if Gear.Power = 0 then
   215                      begin
   216                      begin
   216                      AttackBar:= CurrentTeam.AttackBar;
   217                      AttackBar:= CurrentTeam.AttackBar;
   217                      PlaySound(sndThrowPowerUp)
   218                      PlaySound(sndThrowPowerUp)
   223 
   224 
   224 if ((Gear.State and gstAttacking) <> 0) and ((Gear.Message and gm_Attack) = 0) then
   225 if ((Gear.State and gstAttacking) <> 0) and ((Gear.Message and gm_Attack) = 0) then
   225    begin
   226    begin
   226    RemoveIntersectorsCR(Gear);
   227    RemoveIntersectorsCR(Gear);
   227    Attack(Gear);
   228    Attack(Gear);
       
   229    StepTicks:= 40
   228    end;
   230    end;
   229 
   231 
   230 if (Gear.State and gstFalling) <> 0 then
   232 if (Gear.State and gstFalling) <> 0 then
   231    begin
   233    begin
   232    // it could be the source to trick: double-backspace jump -> vertical wall
   234    // it could be the source to trick: double-backspace jump -> vertical wall
   353 end;
   355 end;
   354 
   356 
   355 ////////////////////////////////////////////////////////////////////////////////
   357 ////////////////////////////////////////////////////////////////////////////////
   356 procedure doStepHedgehogFree(Gear: PGear);
   358 procedure doStepHedgehogFree(Gear: PGear);
   357 begin
   359 begin
   358 if Gear.CollIndex < High(Longword) then DeleteCR(Gear);
       
   359 if not HHTestCollisionYwithGear(Gear, 1) then
   360 if not HHTestCollisionYwithGear(Gear, 1) then
   360    begin
   361    begin
   361    if (Gear.dY < 0) and HHTestCollisionYwithGear(Gear, -1) then Gear.dY:= 0;
   362    if (Gear.dY < 0) and HHTestCollisionYwithGear(Gear, -1) then Gear.dY:= 0;
   362    Gear.State:= Gear.State or gstFalling or gstMoving;
   363    Gear.State:= Gear.State or gstFalling or gstMoving;
   363    Gear.dY:= Gear.dY + cGravity
   364    Gear.dY:= Gear.dY + cGravity
   367       and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX);
   368       and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX);
   368    Gear.State:= Gear.State and not (gstFalling or gstHHJumping);
   369    Gear.State:= Gear.State and not (gstFalling or gstHHJumping);
   369    if Gear.dY > 0    then Gear.dY:= 0;
   370    if Gear.dY > 0    then Gear.dY:= 0;
   370    if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction
   371    if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction
   371    end;
   372    end;
       
   373 
       
   374 if (Gear.State <> 0) and (Gear.CollIndex < High(Longword)) then DeleteCR(Gear);
   372 
   375 
   373 
   376 
   374 if (Gear.State and gstMoving) <> 0 then
   377 if (Gear.State and gstMoving) <> 0 then
   375    if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
   378    if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
   376       if ((Gear.State and gstFalling) = 0) then
   379       if ((Gear.State and gstFalling) = 0) then