diff -r 43e106417a05 -r b5b79a8f9354 hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Tue Mar 26 22:39:22 2013 +0200 +++ b/hedgewars/uGearsHedgehog.pas Wed Mar 27 11:18:00 2013 +0100 @@ -23,18 +23,18 @@ uses uTypes; procedure doStepHedgehog(Gear: PGear); -procedure AfterAttack; -procedure HedgehogStep(Gear: PGear); -procedure doStepHedgehogMoving(Gear: PGear); -procedure HedgehogChAngle(HHGear: PGear); +procedure AfterAttack; +procedure HedgehogStep(Gear: PGear); +procedure doStepHedgehogMoving(Gear: PGear); +procedure HedgehogChAngle(HHGear: PGear); procedure PickUp(HH, Gear: PGear); procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); procedure CheckIce(Gear: PGear); inline; implementation -uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, +uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript, - uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, + uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, uGearsUtils; var GHStepTicks: LongWord = 0; @@ -75,7 +75,7 @@ MultiShootAttacks:= 0; HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); - + if Ammoz[CurAmmoType].Slot = slot then begin i:= 0; @@ -90,8 +90,8 @@ end; until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)) - - end + + end else begin i:= 0; @@ -114,7 +114,7 @@ LoadHedgehogHat(HHGear^.Hedgehog^, Hat); end; // Try again in the next slot - if CurAmmoType = prevAmmo then + if CurAmmoType = prevAmmo then begin if slot >= cMaxSlotIndex then slot:= 0 else inc(slot); HHGear^.MsgParam:= slot; @@ -213,7 +213,7 @@ if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstHHChooseTarget)) = 0) and (((State and gstMoving) = 0) or (Power > 0) or (CurAmmoType = amTeleport) - or + or // Allow attacks while moving on ammo with AltAttack ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) @@ -257,7 +257,7 @@ and ((Gear^.Message and gmLJump) <> 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then begin - newDx:= dX; + newDx:= dX; newDy:= dY; altUse:= true end @@ -285,15 +285,15 @@ amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0); amMine: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000); amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); - amKnife: begin + amKnife: begin newGear:= AddGear(hwRound(lx), hwRound(ly), gtKnife, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); - newGear^.State:= newGear^.State or gstMoving; + newGear^.State:= newGear^.State or gstMoving; newGear^.Radius:= 4 // temporarily shrink so it doesn't instantly embed in the ground end; amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0); amPortalGun: begin - newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, + newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, // set selected color CurWeapon^.Pos); end; @@ -353,7 +353,7 @@ cGravity:= cMaxWindSpeed; cGravityf:= 0.00025 end; - amExtraDamage: begin + amExtraDamage: begin PlaySound(sndHellishImpact4); cDamageModifier:= _1_5 end; @@ -383,21 +383,18 @@ end; //amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000); amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000); - amIceGun: begin - newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0); - newGear^.radius := 8; - end; + amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0); end; if altUse and (newGear <> nil) then begin newGear^.dX:= newDx / newGear^.Density; newGear^.dY:= newDY / newGear^.Density end; - + case CurAmmoType of - amGrenade, amMolotov, - amClusterBomb, amGasBomb, - amBazooka, amSnowball, + amGrenade, amMolotov, + amClusterBomb, amGasBomb, + amBazooka, amSnowball, amBee, amSMine, amMortar, amWatermelon, amHellishBomb, amDrill: FollowGear:= newGear; @@ -418,7 +415,7 @@ amTardis, amPiano, amIceGun: CurAmmoGear:= newGear; end; - + if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then newGear^.FlightTime:= GameTicks + 1000 else if CurAmmoType = amDrill then @@ -442,7 +439,7 @@ newGear^.Elasticity:= newGear^.Elasticity * elastic else if elastic > _1 then newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic); - (* Experimented with friction modifier. Didn't seem helpful + (* Experimented with friction modifier. Didn't seem helpful fric:= int2hwfloat(CurWeapon^.Bounciness) / _250; if fric < _1 then newGear^.Friction:= newGear^.Friction * fric else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*) @@ -478,7 +475,7 @@ AfterAttack; end end - else + else Message:= Message and (not gmAttack); end; TargetPoint.X := NoPointX; @@ -498,13 +495,13 @@ if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then begin Inc(MultiShootAttacks); - + if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then begin s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1); AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); end; - + if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) or ((GameFlags and gfMultiWeapon) <> 0) then begin @@ -519,7 +516,7 @@ TagTurnTimeLeft:= TurnTimeLeft; TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; end; - if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then + if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then HHGear^.State:= HHGear^.State or gstAttacked; if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then ApplyAmmoChanges(CurrentHedgehog^) @@ -547,7 +544,7 @@ dec(Gear^.Timer); if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) - end + end else if Gear^.Timer = 1 then begin Gear^.State:= Gear^.State or gstNoDamage; @@ -555,7 +552,7 @@ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; DeleteGear(Gear); SetAllToActive - end + end else // Gear^.Timer = 0 begin AllInactive:= false; @@ -608,7 +605,7 @@ if cnt <> 0 then AddAmmo(HH, ammo, cnt) else AddAmmo(HH, ammo); - if (not (HH.Team^.ExtDriven + if (not (HH.Team^.ExtDriven or (HH.BotLevel > 0))) or (HH.Team^.Clan^.ClanIndex = LocalClan) or (GameType = gmtDemo) then @@ -646,7 +643,7 @@ posCaseUtility, posCaseAmmo: begin PlaySound(sndShotgunReload); - if Gear^.AmmoType <> amNothing then + if Gear^.AmmoType <> amNothing then begin AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y)); end @@ -654,7 +651,7 @@ begin // Add spawning here... AddRandomness(GameTicks); - + gi := GearsList; while gi <> nil do begin @@ -769,7 +766,7 @@ if (Gear^.Message and gmLeft )<>0 then Gear^.dX:= -cLittle else if (Gear^.Message and gmRight )<>0 then - Gear^.dX:= cLittle + Gear^.dX:= cLittle else exit; StepSoundTimer:= cHHStepTicks; @@ -836,7 +833,7 @@ Gear^.dY:= _0; Gear^.State:= Gear^.State or gstMoving; if (CurrentHedgehog^.Gear = Gear) - and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then + and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then begin // TODO: why so aggressive at setting FollowGear when falling? FollowGear:= Gear; @@ -852,7 +849,7 @@ or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density end - end + end else begin land:= TestCollisionYwithGear(Gear, 1); @@ -911,7 +908,7 @@ Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - _2 - end + end else if not (TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) or (TestCollisionYwithXYShift(Gear, hwSign(Gear^.dX) - hwRound(Gear^.dX), -1, -1))) then @@ -978,7 +975,7 @@ // ARTILLERY but not being moved by explosions Gear^.X:= Gear^.X + Gear^.dX; Gear^.Y:= Gear^.Y + Gear^.dY; - if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) + if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then begin CheckHHDamage(Gear); @@ -1071,7 +1068,7 @@ or ((HHGear^.State and gstAttacking) <> 0)) then Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs else -else +else with Hedgehog^ do if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and ((HHGear^.Message and gmLJump) <> 0) @@ -1176,7 +1173,7 @@ begin ResurrectHedgehog(Gear); end - else + else begin Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); Gear^.doStep:= @doStepHedgehogDead; @@ -1220,9 +1217,9 @@ procedure CheckIce(Gear: PGear); inline; (* var x,y,tx,ty: LongInt; - tdX, tdY, slope: hwFloat; + tdX, tdY, slope: hwFloat; land: Word; *) -var slope: hwFloat; +var slope: hwFloat; begin if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) @@ -1263,7 +1260,7 @@ end; if GameTicks mod 100 = 0 then CheckIce(Gear); (* -if Gear^.Hedgehog^.Effects[heFrozen] > 0 then +if Gear^.Hedgehog^.Effects[heFrozen] > 0 then begin if (Gear^.Hedgehog^.Effects[heFrozen] > 256) and (CurrentHedgehog^.Team^.Clan <> Gear^.Hedgehog^.Team^.Clan) then dec(Gear^.Hedgehog^.Effects[heFrozen]) @@ -1271,7 +1268,7 @@ dec(Gear^.Hedgehog^.Effects[heFrozen]) end; *) -if (GameTicks mod 10 = 0) and (Gear^.Hedgehog^.Effects[heFrozen] > 0) and (Gear^.Hedgehog^.Effects[heFrozen] < 256) then +if (GameTicks mod 10 = 0) and (Gear^.Hedgehog^.Effects[heFrozen] > 0) and (Gear^.Hedgehog^.Effects[heFrozen] < 256) then dec(Gear^.Hedgehog^.Effects[heFrozen]); if (Gear^.State and gstHHDriven) = 0 then doStepHedgehogFree(Gear)