hedgewars/uGears.pas
changeset 5316 191cd6c06203
parent 5313 5e18eaef65d0
child 5319 51d8e4747876
--- a/hedgewars/uGears.pas	Sun Jun 26 02:47:36 2011 +0200
+++ b/hedgewars/uGears.pas	Sun Jun 26 13:38:47 2011 -0400
@@ -222,12 +222,64 @@
 gear^.SoundChannel:= -1;
 gear^.ImpactSound:= sndNone;
 gear^.nImpactSounds:= 0;
+gear^.AmmoType:= amNothing;
 
 if CurrentHedgehog <> nil then
     begin
     gear^.Hedgehog:= CurrentHedgehog;
     gear^.IntersectGear:= CurrentHedgehog^.Gear
     end;
+// Define ammo association, if any.
+case Kind of
+        gtGrenade: gear^.AmmoType:= amGrenade;
+          gtShell: gear^.AmmoType:= amBazooka;
+            gtBee: gear^.AmmoType:= amBee;
+    gtShotgunShot: gear^.AmmoType:= amShotgun;
+     gtPickHammer: gear^.AmmoType:= amPickHammer;
+           gtRope: gear^.AmmoType:= amRope;
+     gtDEagleShot: gear^.AmmoType:= amDEagle;
+       gtDynamite: gear^.AmmoType:= amDynamite;
+    gtClusterBomb, 
+        gtCluster: gear^.AmmoType:= amClusterBomb;
+         gtShover: gear^.AmmoType:= amBaseballBat;  // Shover is only used for baseball bat right now
+      gtFirePunch: gear^.AmmoType:= amFirePunch;
+      gtParachute: gear^.AmmoType:= amParachute;
+        gtAirBomb: gear^.AmmoType:= amAirAttack;
+      gtBlowTorch: gear^.AmmoType:= amBlowTorch;
+         gtGirder: gear^.AmmoType:= amGirder;
+       gtTeleport: gear^.AmmoType:= amTeleport;
+       gtSwitcher: gear^.AmmoType:= amSwitch;
+         gtMortar: gear^.AmmoType:= amMortar;
+           gtWhip: gear^.AmmoType:= amWhip;
+       gtKamikaze: gear^.AmmoType:= amKamikaze;
+           gtCake: gear^.AmmoType:= amCake;
+      gtSeduction: gear^.AmmoType:= amSeduction;
+     gtWatermelon,
+     gtMelonPiece: gear^.AmmoType:= amWatermelon;
+    gtHellishBomb: gear^.AmmoType:= amHellishBomb;
+          gtDrill: gear^.AmmoType:= amDrill;
+        gtBallGun,
+           gtBall: gear^.AmmoType:= amBallgun;
+        gtRCPlane: gear^.AmmoType:= amRCPlane;
+gtSniperRifleShot: gear^.AmmoType:= amSniperRifle;
+        gtJetpack: gear^.AmmoType:= amJetpack;
+        gtMolotov: gear^.AmmoType:= amMolotov;
+          gtBirdy, 
+            gtEgg: gear^.AmmoType:= amBirdy;
+         gtPortal: gear^.AmmoType:= amPortalGun;
+          gtPiano: gear^.AmmoType:= amPiano;
+        gtGasBomb: gear^.AmmoType:= amGasBomb;
+    gtSineGunShot: gear^.AmmoType:= amSineGun;
+   gtFlamethrower: gear^.AmmoType:= amFlamethrower;
+          gtSMine: gear^.AmmoType:= amSMine;
+         gtHammer, 
+      gtHammerHit: gear^.AmmoType:= amHammer;
+    gtResurrector: gear^.AmmoType:= amResurrector;
+       gtSnowball: gear^.AmmoType:= amSnowball;
+      gtStructure: gear^.AmmoType:= amStructure;  // TODO - This will undoubtedly change once there is more than one structure
+        gtLandGun: gear^.AmmoType:= amLandGun;
+         gtTardis: gear^.AmmoType:= amTardis;
+end;
 
 case Kind of
      gtGrenade,
@@ -550,6 +602,18 @@
                 end;
     end;
 
+if ((Ammoz[gear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) and (CurrentHedgehog <> nil) then 
+    if CurrentHedgehog^.Bounce < _1 then 
+        begin
+        gear^.Elasticity:= gear^.Elasticity * CurrentHedgehog^.Bounce;
+        gear^.Friction:= gear^.Friction * CurrentHedgehog^.Bounce
+        end
+    else 
+        begin
+        gear^.Elasticity:= _1 - ((_1-gear^.Elasticity) / CurrentHedgehog^.Bounce);
+        gear^.Friction:= _1 - ((_1-gear^.Friction) / CurrentHedgehog^.Bounce);
+        end;
+
 InsertGearToList(gear);
 AddGear:= gear;