# HG changeset patch # User unc0rr # Date 1182091695 0 # Node ID ec26095f1bedbd3efc5ac20f4d91b2f58493b49d # Parent bc7be7f6d3e886982c23f3cf5c4b978c502fd8e5 - Get rid of ammoProp_AttackInFall and gstFalling - Fix some regressions diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/CCHandlers.inc Sun Jun 17 14:48:15 2007 +0000 @@ -237,7 +237,8 @@ with CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^ do begin {$IFDEF DEBUGFILE}AddFileLog('/+attack: Gear^.State = '+inttostr(State));{$ENDIF} - if ((State and gstHHDriven)<>0)and((State and (gstAttacked or gstHHChooseTarget or gstMoving)) = 0) then + if ((State and gstHHDriven) <> 0) and + ((State and (gstAttacked or gstHHChooseTarget)) = 0) then begin FollowGear:= CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear; if not CurrentTeam^.ExtDriven then SendIPC('A'); diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/GSHandlers.inc Sun Jun 17 14:48:15 2007 +0000 @@ -70,12 +70,13 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepFallingGear(Gear: PGear); +var isFalling: boolean; begin Gear^.State:= Gear^.State and not gstCollision; if Gear^.dY.isNegative then begin - Gear^.State:= Gear^.State or gstFalling; + isFalling:= true; if TestCollisionYwithGear(Gear, -1) then begin Gear^.dX:= Gear^.dX * Gear^.Friction; @@ -85,11 +86,11 @@ end else if TestCollisionYwithGear(Gear, 1) then begin - Gear^.State:= Gear^.State and not gstFalling; + isFalling:= false; Gear^.dX:= Gear^.dX * Gear^.Friction; Gear^.dY:= - Gear^.dY * Gear^.Elasticity; Gear^.State:= Gear^.State or gstCollision - end else Gear^.State:= Gear^.State or gstFalling; + end else isFalling:= true; if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then begin @@ -97,14 +98,14 @@ Gear^.State:= Gear^.State or gstCollision end; -if (Gear^.State and gstFalling) <> 0 then Gear^.dY:= Gear^.dY + cGravity; +if isFalling then Gear^.dY:= Gear^.dY + cGravity; Gear^.X:= Gear^.X + Gear^.dX; Gear^.Y:= Gear^.Y + Gear^.dY; CheckGearDrowning(Gear); if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and - ((Gear^.State and gstFalling) = 0) then Gear^.State:= Gear^.State and not gstMoving - else Gear^.State:= Gear^.State or gstMoving + (not isFalling) then Gear^.State:= Gear^.State and not gstMoving + else Gear^.State:= Gear^.State or gstMoving end; //////////////////////////////////////////////////////////////////////////////// @@ -505,7 +506,7 @@ HHGear^.State:= HHGear^.State and not gstNoDamage end; - if (HHGear^.State and gstFalling) <> 0 then Gear^.Timer:= 0 + if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 end; if b then @@ -544,7 +545,7 @@ with HHGear^ do begin Message:= Message and not gm_Attack; - State:= State or gstFalling; + State:= State or gstMoving; end; DeleteGear(Gear); OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); @@ -664,12 +665,12 @@ Gear^.Elasticity:= Gear^.Elasticity + _1; HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; DeleteCI(HHGear); -if (HHGear^.State and gstFalling) <> 0 then +if (HHGear^.State and gstMoving) <> 0 then if TestCollisionYwithGear(HHGear, 1) then begin HHGear^.dY:= _0; CheckHHDamage(HHGear); - HHGear^.State:= HHGear^.State and not (gstFalling or gstHHJumping); + HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); end else begin if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); @@ -754,11 +755,11 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepMine(Gear: PGear); begin -if (Gear^.State and (gstMoving or gstFalling)) <> 0 then +if (Gear^.State and gstMoving) <> 0 then begin DeleteCI(Gear); doStepFallingGear(Gear); - if (Gear^.State and (gstMoving or gstFalling)) = 0 then + if (Gear^.State and gstMoving) = 0 then begin AddGearCI(Gear); Gear^.dX:= _0; @@ -977,7 +978,7 @@ HHGear^.dY:= HHGear^.dY + cGravity; if not (HHGear^.dY.isNegative) then begin - HHGear^.State:= HHGear^.State or gstFalling; + HHGear^.State:= HHGear^.State or gstMoving; DeleteGear(Gear); AfterAttack; exit @@ -1023,7 +1024,7 @@ SetLittle(dx); dY:= _0; State:= State and not (gstAttacking or gstAttacked); - State:= State or gstFalling; + State:= State or gstMoving; end; DeleteGear(Gear); if Gear^.Timer > 10 then @@ -1158,7 +1159,7 @@ Gear^.doStep:= @doStepTeleportAfter; HHGear^.X:= int2hwFloat(TargetPoint.X); HHGear^.Y:= int2hwFloat(TargetPoint.Y); - HHGear^.State:= HHGear^.State or gstFalling + HHGear^.State:= HHGear^.State or gstMoving end; TargetPoint.X:= NoPointX end; diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/HHHandlers.inc Sun Jun 17 14:48:15 2007 +0000 @@ -24,11 +24,9 @@ PHedgehog(Gear^.Hedgehog)^ do begin if ((State and gstHHDriven) <> 0)and - // (((State and gstAttacking) <> 0) or ((Message and gm_Attack) <> 0))and - ((State and (gstAttacked or gstMoving or gstHHChooseTarget)) = 0)and - (((State and gstFalling ) = 0)or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInFall) <> 0))and - (((State and gstHHJumping) = 0)or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInJump) <> 0))and - ((TargetPoint.X <> NoPointX) or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then + ((State and (gstAttacked or gstHHChooseTarget)) = 0)and + (((State and gstMoving) = 0)or((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInMove) <> 0))and + ((TargetPoint.X <> NoPointX) or ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then begin State:= State or gstAttacking; if Power = cMaxPower then Message:= Message and not gm_Attack @@ -135,16 +133,16 @@ procedure HedgehogStep(Gear: PGear); var PrevdX: LongInt; begin -if ((Gear^.State and (gstAttacking or gstMoving or gstFalling)) = 0) then +if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then begin if isCursorVisible then with PHedgehog(Gear^.Hedgehog)^ do with Ammo^[CurSlot, CurAmmo] do begin - if (Gear^.Message and gm_Left )<>0 then + if (Gear^.Message and gm_Left ) <> 0 then Pos:= (Pos + Ammoz[AmmoType].PosCount - 1) mod Ammoz[AmmoType].PosCount else - if (Gear^.Message and gm_Right )<>0 then + if (Gear^.Message and gm_Right ) <> 0 then Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount else exit; StepTicks:= 200; @@ -153,7 +151,7 @@ if ((Gear^.Message and gm_LJump ) <> 0) then begin - Gear^.Message:= 0; + Gear^.Message:= Gear^.Message and not gm_LJump; DeleteCI(Gear); if not TestCollisionYwithGear(Gear, -1) then if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else @@ -163,7 +161,7 @@ begin Gear^.dY:= -_0_15; Gear^.dX:= SignAs(_0_15, Gear^.dX); - Gear^.State:= Gear^.State or gstFalling or gstHHJumping; + Gear^.State:= Gear^.State or gstMoving or gstHHJumping; exit end; end; @@ -171,12 +169,12 @@ if ((Gear^.Message and gm_HJump ) <> 0) then begin DeleteCI(Gear); - Gear^.Message:= 0; + Gear^.Message:= Gear^.Message and not gm_HJump; if not TestCollisionYwithGear(Gear, -1) then begin Gear^.dY:= -_0_2; SetLittle(Gear^.dX); - Gear^.State:= Gear^.State or gstFalling or gstHHJumping; + Gear^.State:= Gear^.State or gstMoving or gstHHJumping; exit end; end; @@ -231,7 +229,7 @@ begin Gear^.Y:= Gear^.Y - _6; Gear^.dY:= _0; - Gear^.State:= Gear^.State or gstFalling; + Gear^.State:= Gear^.State or gstMoving; exit end; end @@ -246,7 +244,7 @@ procedure HedgehogChAngle(Gear: PGear); begin -if ((Gear^.State and (gstMoving or gstFalling)) = 0) then +if ((Gear^.State and gstMoving) = 0) then if (Gear^.Message and gm_Up )<>0 then if Gear^.Angle > CurMinAngle then dec(Gear^.Angle) else else if (Gear^.Message and gm_Down )<>0 then if Gear^.Angle < CurMaxAngle then inc(Gear^.Angle); @@ -256,12 +254,14 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepHedgehogMoving(Gear: PGear); var prevState: Longword; + isFalling: boolean; begin prevState:= Gear^.State; -if not TestCollisionYKick(Gear, 1) then +isFalling:= not TestCollisionYKick(Gear, 1); +if isFalling then begin if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0; - Gear^.State:= Gear^.State or gstFalling or gstMoving; + Gear^.State:= Gear^.State or gstMoving; Gear^.dY:= Gear^.dY + cGravity end else begin @@ -271,7 +271,7 @@ if not Gear^.dY.isNegative then begin CheckHHDamage(Gear); - Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping or gstHHHJump); + Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); Gear^.dY:= _0; end else Gear^.dY:= Gear^.dY + cGravity; @@ -282,7 +282,7 @@ if (Gear^.State and gstMoving) <> 0 then if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then - if ((Gear^.State and gstFalling) = 0) then + if not isFalling then if hwAbs(Gear^.dX) > _0_01 then if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - _1 end else if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - _2 end else @@ -301,7 +301,7 @@ else if hwAbs(Gear^.dX) > cLittle then Gear^.dX:= -Gear^.Elasticity * Gear^.dX else SetLittle(Gear^.dX); -if ((Gear^.State and gstFalling) = 0)and +if (not isFalling) and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then begin Gear^.State:= Gear^.State and not gstMoving; @@ -343,8 +343,8 @@ Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); exit end; - -if ((Gear^.State and (gstFalling or gstMoving)) <> 0) + +if ((Gear^.State and gstMoving) <> 0) or (StepTicks = cHHStepTicks) or (CurAmmoGear <> nil) then // we're moving begin @@ -361,16 +361,16 @@ end; if ((Gear^.Message and gm_Attack) <> 0) or - ((Gear^.State and gstAttacking) <> 0)then Attack(Gear); + ((Gear^.State and gstAttacking) <> 0) then Attack(Gear); -if (Gear^.State and (gstFalling or gstMoving)) <> 0 then +if (Gear^.State and gstMoving) <> 0 then begin if ((Gear^.Message and gm_HJump) <> 0) and ((Gear^.State and gstHHJumping) <> 0) and ((Gear^.State and gstHHHJump) = 0) then if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then begin - Gear^.State:= Gear^.State or gstHHHJump; + Gear^.State:= Gear^.State or gstHHHJump or gstMoving; Gear^.dY:= -_0_25; Gear^.dX:= SignAs(_0_02, Gear^.dX) end; @@ -380,11 +380,11 @@ TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); doStepHedgehogMoving(Gear); - - if (Gear^.State and (gstFalling or gstMoving)) = 0 then + + if (Gear^.State and gstMoving) = 0 then begin AddGearCI(Gear); - StepTicks:= 300 + StepTicks:= 350 end; exit end; diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/uAI.pas --- a/hedgewars/uAI.pas Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/uAI.pas Sun Jun 17 14:48:15 2007 +0000 @@ -278,7 +278,7 @@ procedure StartThink(Me: PGear); var a: TAmmoType; begin -if ((Me^.State and (gstAttacking or gstHHJumping or gstFalling or gstMoving)) <> 0) +if ((Me^.State and (gstAttacking or gstHHJumping or gstMoving)) <> 0) or isInMultiShoot then exit; //DeleteCI(Me); // this might break demo diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/uAIMisc.pas Sun Jun 17 14:48:15 2007 +0000 @@ -262,7 +262,7 @@ begin Gear^.dY:= -_0_2; SetLittle(Gear^.dX); - Gear^.State:= Gear^.State or gstFalling or gstHHJumping; + Gear^.State:= Gear^.State or gstMoving or gstHHJumping; end else exit(Result); jmpLJump: begin if not TestCollisionYwithGear(Gear, -1) then @@ -273,14 +273,14 @@ begin Gear^.dY:= -_0_15; Gear^.dX:= SignAs(_0_15, Gear^.dX); - Gear^.State:= Gear^.State or gstFalling or gstHHJumping + Gear^.State:= Gear^.State or gstMoving or gstHHJumping end else exit(Result) end end; repeat if not (hwRound(Gear^.Y) + cHHRadius < cWaterLine) then exit(Result); -if (Gear^.State and gstFalling) <> 0 then +if (Gear^.State and gstMoving) <> 0 then begin if (GoInfo.Ticks = 350) then if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then @@ -297,7 +297,7 @@ Gear^.Y:= Gear^.Y + Gear^.dY; if (not Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, 1) then begin - Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping); + Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping); Gear^.dY:= _0; case JumpType of jmpHJump: if bY - hwRound(Gear^.Y) > 5 then @@ -333,7 +333,7 @@ pX:= hwRound(Gear^.X); pY:= hwRound(Gear^.Y); if pY + cHHRadius >= cWaterLine then exit(false); -if (Gear^.State and gstFalling) <> 0 then +if (Gear^.State and gstMoving) <> 0 then begin inc(GoInfo.Ticks); Gear^.dY:= Gear^.dY + cGravity; @@ -348,7 +348,7 @@ if TestCollisionYwithGear(Gear, 1) then begin inc(GoInfo.Ticks, 300); - Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping); + Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping); Gear^.dY:= _0; Result:= true; HHJump(AltGear, jmpLJump, GoInfo); // try ljump instead of fall @@ -401,7 +401,7 @@ begin Gear^.Y:= Gear^.Y - _6; Gear^.dY:= _0; - Gear^.State:= Gear^.State or gstFalling + Gear^.State:= Gear^.State or gstMoving end end end @@ -409,9 +409,9 @@ end end end; -if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstFalling) = 0) then +if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then exit(true); -until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstFalling) = 0); +until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0); HHJump(AltGear, jmpHJump, GoInfo); HHGo:= Result end; diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/uCollisions.pas --- a/hedgewars/uCollisions.pas Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/uCollisions.pas Sun Jun 17 14:48:15 2007 +0000 @@ -207,7 +207,7 @@ with cGear^ do begin dX:= Gear^.dX; - dY:= Gear^.dY; + dY:= Gear^.dY * _0_5; State:= State or gstMoving; Active:= true end; @@ -254,8 +254,8 @@ begin with cGear^ do begin - dX:= Gear^.dX; - dY:= Gear^.dY * _0_5; + dX:= Gear^.dX * _0_5; + dY:= Gear^.dY; State:= State or gstMoving; Active:= true end; diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/uConsts.pas Sun Jun 17 14:48:15 2007 +0000 @@ -145,7 +145,6 @@ gstAttacking = $00000010; gstCollision = $00000020; gstHHChooseTarget = $00000040; - gstFalling = $00000080; gstHHJumping = $00000100; gsttmpFlag = $00000200; gstHHThinking = $00000800; @@ -170,8 +169,7 @@ ammoprop_Power = $00000002; ammoprop_NeedTarget = $00000004; ammoprop_ForwMsgs = $00000008; - ammoprop_AttackInFall = $00000010; - ammoprop_AttackInJump = $00000020; + ammoprop_AttackInMove = $00000010; ammoprop_NoCrosshair = $00000040; ammoprop_AttackingPut = $00000080; AMMO_INFINITE = High(LongWord); @@ -440,8 +438,7 @@ Probability: 0; NumberInCase: 1; Ammo: (Propz: ammoprop_ForwMsgs or - ammoprop_AttackInFall or - ammoprop_AttackInJump or + ammoprop_AttackInMove or ammoprop_NoCrosshair; Count: 2; NumPerTurn: 0; @@ -473,8 +470,7 @@ Probability: 100; NumberInCase: 3; Ammo: (Propz: ammoprop_ForwMsgs or - ammoprop_AttackInFall or - ammoprop_AttackInJump; + ammoprop_AttackInMove; Count: 5; NumPerTurn: 0; Timer: 0; @@ -520,8 +516,7 @@ Probability: 100; NumberInCase: 1; Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_AttackInJump or - ammoprop_AttackInFall; + ammoprop_AttackInMove; Count: 1; NumPerTurn: 0; Timer: 0; @@ -538,8 +533,7 @@ NumberInCase: 1; Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_ForwMsgs or - ammoprop_AttackInJump or - ammoprop_AttackInFall; + ammoprop_AttackInMove; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 0; @@ -570,8 +564,7 @@ Probability: 100; NumberInCase: 1; Ammo: (Propz: ammoprop_ForwMsgs or - ammoprop_AttackInJump or - ammoprop_AttackInFall or + ammoprop_AttackInMove or ammoprop_NoCrosshair; Count: 2; NumPerTurn: 0; diff -r bc7be7f6d3e8 -r ec26095f1bed hedgewars/uGears.pas --- a/hedgewars/uGears.pas Mon Jun 11 15:53:29 2007 +0000 +++ b/hedgewars/uGears.pas Sun Jun 17 14:48:15 2007 +0000 @@ -474,7 +474,7 @@ if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, GameTicks div 32 mod 16, Surface); - if (Gear^.State and (gstMoving or gstDrowning or gstFalling)) = 0 then + if (Gear^.State and (gstMoving or gstDrowning)) = 0 then if (Gear^.State and gstHHThinking) <> 0 then DrawGear(sQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, Surface) else