hedgewars/uGears.pas
changeset 6468 da1e7fe7cff7
parent 6453 11c578d30bd3
child 6472 bced12412f94
--- a/hedgewars/uGears.pas	Tue Nov 29 17:42:42 2011 +0400
+++ b/hedgewars/uGears.pas	Fri Dec 30 13:54:39 2011 +0400
@@ -37,17 +37,14 @@
 
 procedure initModule;
 procedure freeModule;
-function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
 function  SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear;
 function  SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean ): PGear;
 function  GetAmmo: TAmmoType;
 function  GetUtility: TAmmoType;
-procedure ResurrectHedgehog(gear: PGear);
 procedure HideHog(HH: PHedgehog);
 procedure RestoreHog(HH: PHedgehog);
 procedure ProcessGears;
 procedure EndTurnCleanup;
-procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
 procedure SetAllToActive;
 procedure SetAllHHToActive;
 procedure DrawGears;
@@ -57,27 +54,20 @@
 function  GearByUID(uid : Longword) : PGear;
 procedure InsertGearToList(Gear: PGear);
 procedure RemoveGearFromList(Gear: PGear);
-function  ModifyDamage(dmg: Longword; Gear: PGear): Longword;
-procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean = false);
 procedure DeleteGear(Gear: PGear); 
 
 
 implementation
 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics,
      uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables,
-     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture;
+     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture,
+     uGearsHedgehog;
 
 
-procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord = $FFFFFFFF); forward;
 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
 //procedure AmmoFlameWork(Ammo: PGear); forward;
 function  GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; forward;
-function  CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward;
 procedure SpawnBoxOfSmth; forward;
-procedure AfterAttack; forward;
-procedure HedgehogStep(Gear: PGear); forward;
-procedure doStepHedgehogMoving(Gear: PGear); forward;
-procedure HedgehogChAngle(HHGear: PGear); forward;
 procedure ShotgunShot(Gear: PGear); forward;
 procedure PickUp(HH, Gear: PGear); forward;
 procedure HHSetWeapon(HHGear: PGear); forward;
@@ -88,7 +78,6 @@
 // Note: step handlers of gears that are hedgehogs are in a different file
 //       than the handlers for all other gears.
 {$INCLUDE "GSHandlers.inc"}
-{$INCLUDE "HHHandlers.inc"}
 
 const doStepHandlers: array[TGearType] of TGearStepProcedure = (
             @doStepBomb,
@@ -154,523 +143,6 @@
             @doStepLandGun,
             @doStepTardis);
 
-procedure InsertGearToList(Gear: PGear);
-var tmp, ptmp: PGear;
-begin
-    tmp:= GearsList;
-    ptmp:= GearsList;
-    while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do
-        begin
-        ptmp:= tmp;
-        tmp:= tmp^.NextGear
-        end;
-
-    if ptmp <> tmp then
-        begin
-        Gear^.NextGear:= ptmp^.NextGear;
-        Gear^.PrevGear:= ptmp;
-        if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear;
-        ptmp^.NextGear:= Gear
-        end
-    else
-        begin
-        Gear^.NextGear:= GearsList;
-        if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear;
-        GearsList:= Gear;
-        end;
-end;
-
-procedure RemoveGearFromList(Gear: PGear);
-begin
-if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
-if Gear^.PrevGear <> nil then
-    Gear^.PrevGear^.NextGear:= Gear^.NextGear
-else
-    GearsList:= Gear^.NextGear
-end;
-
-procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword);
-var tag: PVisualGear;
-begin
-tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg);
-if (tag <> nil) then
-    tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color
-AllInactive:= false;
-HHGear^.Active:= true;
-end;
-
-function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
-const Counter: Longword = 0;
-var gear: PGear;
-begin
-inc(Counter);
-AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
-
-New(gear);
-FillChar(gear^, sizeof(TGear), 0);
-gear^.X:= int2hwFloat(X);
-gear^.Y:= int2hwFloat(Y);
-gear^.Target.X:= NoPointX;
-gear^.Kind := Kind;
-gear^.State:= State;
-gear^.Active:= true;
-gear^.dX:= dX;
-gear^.dY:= dY;
-gear^.doStep:= doStepHandlers[Kind];
-gear^.CollisionIndex:= -1;
-gear^.Timer:= Timer;
-gear^.FlightTime:= 0;
-gear^.uid:= Counter;
-gear^.SoundChannel:= -1;
-gear^.ImpactSound:= sndNone;
-gear^.nImpactSounds:= 0;
-gear^.Density:= _1;
-// Define ammo association, if any.
-gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
-if Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then gear^.Z:= cHHZ+1
-else gear^.Z:= cUsualZ;
-
-if CurrentHedgehog <> nil then
-    begin
-    gear^.Hedgehog:= CurrentHedgehog;
-    gear^.IntersectGear:= CurrentHedgehog^.Gear
-    end;
-    
-case Kind of
-     gtGrenade,
-     gtClusterBomb,
-     gtGasBomb: begin
-                gear^.ImpactSound:= sndGrenadeImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.AdvBounce:= 1;
-                gear^.Radius:= 5;
-                gear^.Elasticity:= _0_8;
-                gear^.Friction:= _0_8;
-                gear^.Density:= _1_5;
-                gear^.RenderTimer:= true;
-                if gear^.Timer = 0 then gear^.Timer:= 3000
-                end;
-  gtWatermelon: begin
-                gear^.ImpactSound:= sndMelonImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.AdvBounce:= 1;
-                gear^.Radius:= 6;
-                gear^.Elasticity:= _0_8;
-                gear^.Friction:= _0_995;
-                gear^.Density:= _2;
-                gear^.RenderTimer:= true;
-                if gear^.Timer = 0 then gear^.Timer:= 3000
-                end;
-  gtMelonPiece: begin
-                gear^.Density:= _2;
-                end;
-    gtHedgehog: begin
-                gear^.AdvBounce:= 1;
-                gear^.Radius:= cHHRadius;
-                gear^.Elasticity:= _0_35;
-                gear^.Friction:= _0_999;
-                gear^.Angle:= cMaxAngle div 2;
-                gear^.Density:= _3;
-                gear^.Z:= cHHZ;
-                if (GameFlags and gfAISurvival) <> 0 then
-                    if gear^.Hedgehog^.BotLevel > 0 then
-                        gear^.Hedgehog^.Effects[heResurrectable] := true;
-                end;
-       gtShell: begin
-                gear^.Radius:= 4;
-                gear^.Density:= _1;
-                end;
-       gtSnowball: begin
-                gear^.ImpactSound:= sndMudballImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.Radius:= 4;
-                gear^.Elasticity:= _1;
-                gear^.Friction:= _1;
-                gear^.Density:= _0_5;
-                end;
-
-     gtFlake: begin
-                with Gear^ do
-                    begin
-                    Pos:= 0;
-                    Radius:= 1;
-                    DirAngle:= random * 360;
-                    if State and gstTmpFlag = 0 then
-                        begin
-                        dx.isNegative:= GetRandom(2) = 0;
-                        dx.QWordValue:= GetRandom(100000000);
-                        dy.isNegative:= false;
-                        dy.QWordValue:= GetRandom(70000000);
-                        if GetRandom(2) = 0 then dx := -dx
-                        end;
-                    State:= State or gstInvisible;
-                    Health:= random(vobFrameTicks);
-                    Timer:= random(vobFramesCount);
-                    Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity
-                    end
-                end;
-       gtGrave: begin
-                gear^.ImpactSound:= sndGraveImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.Radius:= 10;
-                gear^.Elasticity:= _0_6;
-                end;
-         gtBee: begin
-                gear^.Radius:= 5;
-                gear^.Timer:= 500;
-                gear^.RenderTimer:= true;
-                gear^.Elasticity:= _0_9;
-                gear^.Tag:= 0;
-                end;
-   gtSeduction: begin
-                gear^.Radius:= 250;
-                end;
- gtShotgunShot: begin
-                gear^.Timer:= 900;
-                gear^.Radius:= 2
-                end;
-  gtPickHammer: begin
-                gear^.Radius:= 10;
-                gear^.Timer:= 4000
-                end;
-   gtHammerHit: begin
-                gear^.Radius:= 8;
-                gear^.Timer:= 125
-                end;
-        gtRope: begin
-                gear^.Radius:= 3;
-                gear^.Friction:= _450 * _0_01 * cRopePercent;
-                RopePoints.Count:= 0;
-                end;
-        gtMine: begin
-                gear^.ImpactSound:= sndMineImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.Health:= 10;
-                gear^.State:= gear^.State or gstMoving;
-                gear^.Radius:= 2;
-                gear^.Elasticity:= _0_55;
-                gear^.Friction:= _0_995;
-                gear^.Density:= _0_9;
-                if cMinesTime < 0 then
-                    gear^.Timer:= getrandom(51)*100
-                else
-                    gear^.Timer:= cMinesTime;
-                end;
-       gtSMine: begin
-                gear^.Health:= 10;
-                gear^.State:= gear^.State or gstMoving;
-                gear^.Radius:= 2;
-                gear^.Elasticity:= _0_55;
-                gear^.Friction:= _0_995;
-                gear^.Density:= _0_9;
-                gear^.Timer:= 500;
-                end;
-        gtCase: begin
-                gear^.ImpactSound:= sndGraveImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.Radius:= 16;
-                gear^.Elasticity:= _0_3
-                end;
-  gtExplosives: begin
-                gear^.ImpactSound:= sndGrenadeImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.Radius:= 16;
-                gear^.Elasticity:= _0_4;
-                gear^.Friction:= _0_995;
-                gear^.Density:= _6;
-                gear^.Health:= cBarrelHealth;
-                gear^.Z:= cHHZ-1
-                end;
-  gtDEagleShot: begin
-                gear^.Radius:= 1;
-                gear^.Health:= 50
-                end;
-  gtSniperRifleShot: begin
-                gear^.Radius:= 1;
-                gear^.Health:= 50
-                end;
-    gtDynamite: begin
-                gear^.Radius:= 3;
-                gear^.Elasticity:= _0_55;
-                gear^.Friction:= _0_03;
-                gear^.Density:= _2;
-                gear^.Timer:= 5000;
-                end;
-     gtCluster: begin
-                gear^.Radius:= 2;
-                gear^.Density:= _1_5;
-                gear^.RenderTimer:= true
-                end;
-      gtShover: gear^.Radius:= 20;
-       gtFlame: begin
-                gear^.Tag:= GetRandom(32);
-                gear^.Radius:= 1;
-                gear^.Health:= 5;
-                gear^.Density:= _1;
-                if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then
-                    begin
-                    gear^.dY:= (getrandom - _0_8) * _0_03;
-                    gear^.dX:= (getrandom - _0_5) * _0_4
-                    end
-                end;
-   gtFirePunch: begin
-                gear^.Radius:= 15;
-                gear^.Tag:= Y
-                end;
-     gtAirBomb: begin
-                gear^.Radius:= 5;
-                gear^.Density:= _2;
-                end;
-   gtBlowTorch: begin
-                gear^.Radius:= cHHRadius + cBlowTorchC;
-                gear^.Timer:= 7500
-                end;
-    gtSwitcher: begin
-                gear^.Z:= cCurrHHZ
-                end;
-      gtTarget: begin
-                gear^.ImpactSound:= sndGrenadeImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.Radius:= 10;
-                gear^.Elasticity:= _0_3;
-                gear^.Timer:= 0
-                end;
-      gtTardis: begin
-                gear^.Timer:= 0;
-                gear^.Pos:= 1;
-                gear^.Z:= cCurrHHZ+1;
-                end;
-      gtMortar: begin
-                gear^.Radius:= 4;
-                gear^.Elasticity:= _0_2;
-                gear^.Friction:= _0_08;
-                gear^.Density:= _1;
-                end;
-        gtWhip: gear^.Radius:= 20;
-      gtHammer: gear^.Radius:= 20;
-    gtKamikaze: begin
-                gear^.Health:= 2048;
-                gear^.Radius:= 20
-                end;
-        gtCake: begin
-                gear^.Health:= 2048;
-                gear^.Radius:= 7;
-                gear^.Z:= cOnHHZ;
-                gear^.RenderTimer:= true;
-                gear^.DirAngle:= -90 * hwSign(Gear^.dX);
-                if not dX.isNegative then gear^.Angle:= 1 else gear^.Angle:= 3
-                end;
- gtHellishBomb: begin
-                gear^.ImpactSound:= sndHellishImpact1;
-                gear^.nImpactSounds:= 4;
-                gear^.AdvBounce:= 1;
-                gear^.Radius:= 4;
-                gear^.Elasticity:= _0_5;
-                gear^.Friction:= _0_96;
-                gear^.Density:= _1_5;
-                gear^.RenderTimer:= true;
-                gear^.Timer:= 5000
-                end;
-       gtDrill: begin
-                if gear^.Timer = 0 then gear^.Timer:= 5000;
-                // Tag for drill strike. if 1 then first impact occured already
-                gear^.Tag := 0;
-                gear^.Radius:= 4;
-                gear^.Density:= _1;
-                end;
-        gtBall: begin
-                gear^.ImpactSound:= sndGrenadeImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.AdvBounce:= 1;
-                gear^.Radius:= 5;
-                gear^.Tag:= random(8);
-                gear^.Timer:= 5000;
-                gear^.Elasticity:= _0_7;
-                gear^.Friction:= _0_995;
-                gear^.Density:= _1_5;
-                end;
-     gtBallgun: begin
-                gear^.Timer:= 5001;
-                end;
-     gtRCPlane: begin
-                gear^.Timer:= 15000;
-                gear^.Health:= 3;
-                gear^.Radius:= 8
-                end;
-     gtJetpack: begin
-                gear^.Health:= 2000;
-                gear^.Damage:= 100
-                end;
-     gtMolotov: begin
-                gear^.Radius:= 6;
-                gear^.Density:= _2;
-                end;
-       gtBirdy: begin
-                gear^.Radius:= 16; // todo: check
-                gear^.Timer:= 0;
-                gear^.Health := 2000;
-                gear^.FlightTime := 2;
-                end;
-         gtEgg: begin
-                gear^.Radius:= 4;
-                gear^.Elasticity:= _0_6;
-                gear^.Friction:= _0_96;
-                gear^.Density:= _1;
-                if gear^.Timer = 0 then gear^.Timer:= 3000
-                end;
-      gtPortal: begin
-                gear^.ImpactSound:= sndMelonImpact;
-                gear^.nImpactSounds:= 1;
-                gear^.AdvBounce:= 0;
-                gear^.Radius:= 17;
-                // set color
-                gear^.Tag:= 2 * gear^.Timer;
-                gear^.Timer:= 15000;
-                gear^.RenderTimer:= false;
-                gear^.Health:= 100;
-                end;
-       gtPiano: begin
-                gear^.Radius:= 32;
-                gear^.Density:= _50;
-                end;
- gtSineGunShot: begin
-                gear^.Radius:= 5;
-                gear^.Health:= 6000;
-                end;
-gtFlamethrower: begin
-                gear^.Tag:= 10;
-                gear^.Timer:= 10;
-                gear^.Health:= 500;
-                gear^.Damage:= 100;
-                end;
-     gtLandGun: begin
-                gear^.Tag:= 10;
-                gear^.Timer:= 10;
-                gear^.Health:= 1000;
-                gear^.Damage:= 100;
-                end;
- gtPoisonCloud: begin
-                gear^.Timer:= 5000;
-                gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000;
-                end;
- gtResurrector: begin
-                gear^.Radius := 100;
-                gear^.Tag := 0
-                end;
-     gtWaterUp: begin
-                gear^.Tag := 47;
-                end;
-  gtNapalmBomb: begin
-                gear^.Timer:= 1000;
-                gear^.Radius:= 5;
-                gear^.Density:= _1_5;
-                end;
-   gtStructure: begin
-                gear^.Elasticity:= _0_55;
-                gear^.Friction:= _0_995;
-                gear^.Density:= _0_9;
-                gear^.Radius:= 13;
-                gear^.Health:= 200;
-                gear^.Tag:= 3;
-                end;
-    end;
-
-InsertGearToList(gear);
-AddGear:= gear;
-
-ScriptCall('onGearAdd', gear^.uid);
-end;
-
-procedure DeleteGear(Gear: PGear);
-var team: PTeam;
-    t,i: Longword;
-    k: boolean;
-begin
-
-ScriptCall('onGearDelete', gear^.uid);
-
-DeleteCI(Gear);
-
-FreeTexture(Gear^.Tex);
-Gear^.Tex:= nil;
-
-// make sure that portals have their link removed before deletion
-if (Gear^.Kind = gtPortal) then
-    begin
-    if (Gear^.IntersectGear <> nil) then
-        if (Gear^.IntersectGear^.IntersectGear = Gear) then
-            Gear^.IntersectGear^.IntersectGear:= nil;
-    end
-else if Gear^.Kind = gtHedgehog then
-    (*
-    This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS.  I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves.  I believe it should be removed
-     if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then
-        begin
-        AttackBar:= 0;
-        Gear^.Message:= gmDestroy;
-        CurAmmoGear^.Message:= gmDestroy;
-        exit
-        end
-    else*)
-        begin
-        if (hwRound(Gear^.Y) >= cWaterLine) then
-            begin
-            t:= max(Gear^.Damage, Gear^.Health);
-            Gear^.Damage:= t;
-            if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cWaterOpacity < $FF))) and (hwRound(Gear^.Y) < cWaterLine + 256) then
-                spawnHealthTagForHH(Gear, t);
-            end;
-
-        team:= Gear^.Hedgehog^.Team;
-        if CurrentHedgehog^.Gear = Gear then
-            begin
-            AttackBar:= 0;
-            FreeActionsList; // to avoid ThinkThread on drawned gear
-            if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (CurrentHedgehog^.MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^);
-            end;
-
-        Gear^.Hedgehog^.Gear:= nil;
-        if Gear^.Hedgehog^.King then
-            begin
-            // are there any other kings left? Just doing nil check.  Presumably a mortally wounded king will get reaped soon enough
-            k:= false;
-            for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
-                if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true;
-            if not k then
-                for i:= 0 to Pred(team^.Clan^.TeamsNumber) do
-                    begin
-                    team^.Clan^.Teams[i]^.hasGone:= true;
-                    TeamGoneEffect(team^.Clan^.Teams[i]^)
-                    end
-            end;
-
-        // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
-        // same stand for CheckHHDamage
-        if (Gear^.LastDamage <> nil) then
-            uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
-        else
-            uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
-
-        inc(KilledHHs);
-        RecountTeamHealth(team);
-        if (CurrentHedgehog <> nil) and CurrentHedgehog^.Effects[heResurrectable] and (not Gear^.Hedgehog^.Effects[heResurrectable]) then
-            with CurrentHedgehog^ do 
-                begin
-                inc(Team^.stats.AIKills);
-                FreeTexture(Team^.AIKillsTex);
-                Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
-                end
-        end;
-with Gear^ do
-    AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
-
-if CurAmmoGear = Gear then CurAmmoGear:= nil;
-if FollowGear = Gear then FollowGear:= nil;
-if lastGearByUID = Gear then lastGearByUID := nil;
-RemoveGearFromList(Gear);
-Dispose(Gear)
-end;
-
 function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs
 var Gear: PGear;
     dmg: LongInt;
@@ -1075,69 +547,6 @@
             RecountTeamHealth(TeamsArray[i])
 end;
 
-procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource);
-var s: shortstring;
-    vampDmg, tmpDmg, i: Longword;
-    vg: PVisualGear;
-begin
-  if Damage = 0 then exit; // nothing to apply
-
-    if (Gear^.Kind = gtHedgehog) then
-    begin
-    Gear^.LastDamage := AttackerHog;
-
-    Gear^.Hedgehog^.Team^.Clan^.Flawless:= false;
-    HHHurt(Gear^.Hedgehog, Source);
-    AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color);
-    tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage));
-    if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then
-        begin
-        if cVampiric then
-            begin
-            vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8);
-            if vampDmg >= 1 then
-                begin
-                // was considering pulsing on attack, Tiy thinks it should be permanent while in play
-                //CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric;
-                inc(CurrentHedgehog^.Gear^.Health,vampDmg);
-                str(vampDmg, s);
-                s:= '+' + s;
-                AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
-                RenderHealth(CurrentHedgehog^);
-                RecountTeamHealth(CurrentHedgehog^.Team);
-                i:= 0;
-                while i < vampDmg do
-                    begin
-                    vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot);
-                    if vg <> nil then
-                        with vg^ do
-                            begin
-                            Tint:= $FF0000FF;
-                            State:= ord(sprHealth)
-                            end;
-                    inc(i, 5);
-                    end;
-                end
-            end;
-        if ((GameFlags and gfKarma) <> 0) and
-           ((GameFlags and gfInvulnerable) = 0) and
-           (not CurrentHedgehog^.Gear^.Invulnerable) then
-           begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
-           inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
-           CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog;
-           spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg);
-           end;
-        uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false);    
-        end;
-    end else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure
-        begin
-        Gear^.Hedgehog:= AttackerHog;
-        end;
-    inc(Gear^.Damage, Damage);
-    
-    ScriptCall('onGearDamage', Gear^.UID, Damage);
-end;
-
 procedure SetAllToActive;
 var t: PGear;
 begin
@@ -1600,24 +1009,6 @@
     end;
 end;
 
-function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear;
-var t: PGear;
-begin
-t:= GearsList;
-rX:= sqr(rX);
-rY:= sqr(rY);
-
-while t <> nil do
-    begin
-    if (t <> Gear) and (t^.Kind = Kind) then
-        if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then
-        exit(t);
-    t:= t^.NextGear
-    end;
-
-CheckGearNear:= nil
-end;
-
 {procedure AmmoFlameWork(Ammo: PGear);
 var t: PGear;
 begin
@@ -1638,21 +1029,6 @@
     end;
 end;}
 
-function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear;
-var t: PGear;
-begin
-t:= GearsList;
-rX:= sqr(rX);
-rY:= sqr(rY);
-while t <> nil do
-    begin
-    if t^.Kind in Kind then
-        if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then
-            exit(t);
-    t:= t^.NextGear
-    end;
-CheckGearsNear:= nil
-end;
 
 function CountGears(Kind: TGearType): Longword;
 var t: PGear;
@@ -1668,33 +1044,6 @@
 CountGears:= count;
 end;
 
-procedure ResurrectHedgehog(gear: PGear);
-var tempTeam : PTeam;
-begin
-    AttackBar:= 0;
-    gear^.dX := _0;
-    gear^.dY := _0;
-    gear^.Damage := 0;
-    gear^.Health := gear^.Hedgehog^.InitialHealth;
-    gear^.Hedgehog^.Effects[hePoisoned] := false;
-    if not CurrentHedgehog^.Effects[heResurrectable] then
-        with CurrentHedgehog^ do 
-            begin
-            inc(Team^.stats.AIKills);
-            FreeTexture(Team^.AIKillsTex);
-            Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
-            end;
-    tempTeam := gear^.Hedgehog^.Team;
-    DeleteCI(gear);
-    FindPlace(gear, false, 0, LAND_WIDTH, true); 
-    if gear <> nil then begin
-        RenderHealth(gear^.Hedgehog^);
-        ScriptCall('onGearResurrect', gear^.uid);
-        gear^.State := gstWait;
-    end;
-    RecountTeamHealth(tempTeam);
-end;
-
 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword): PGear;
 begin
     FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0);
@@ -1886,119 +1235,6 @@
     end
 end;
 
-procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean = false);
-
-    function CountNonZeroz(x, y, r, c: LongInt): LongInt;
-    var i: LongInt;
-        count: LongInt = 0;
-    begin
-    if (y and LAND_HEIGHT_MASK) = 0 then
-        for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do
-            if Land[y, i] <> 0 then
-               begin
-               inc(count);
-               if count = c then exit(count)
-               end;
-    CountNonZeroz:= count;
-    end;
-
-var x: LongInt;
-    y, sy: LongInt;
-    ar: array[0..511] of TPoint;
-    ar2: array[0..1023] of TPoint;
-    cnt, cnt2: Longword;
-    delta: LongInt;
-    reallySkip, tryAgain: boolean;
-begin
-reallySkip:= false; // try not skipping proximity at first
-tryAgain:= true;
-while tryAgain do
-    begin
-    delta:= 250;
-    cnt2:= 0;
-    repeat
-        x:= Left + LongInt(GetRandom(Delta));
-        repeat
-            inc(x, Delta);
-            cnt:= 0;
-            y:= min(1024, topY) - 2 * Gear^.Radius;
-            while y < cWaterLine do
-                begin
-                repeat
-                    inc(y, 2);
-                until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0);
-
-                sy:= y;
-
-                repeat
-                    inc(y);
-                until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0);
-
-                if (y - sy > Gear^.Radius * 2) and
-                   (((Gear^.Kind = gtExplosives)
-                       and (y < cWaterLine)
-                       and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil))
-                       and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius))
-                   or
-                     ((Gear^.Kind <> gtExplosives)
-                       and (y < cWaterLine)
-                       and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil)))) then
-                    begin
-                    ar[cnt].X:= x;
-                    if withFall then ar[cnt].Y:= sy + Gear^.Radius
-                                else ar[cnt].Y:= y - Gear^.Radius;
-                    inc(cnt)
-                    end;
-
-                inc(y, 45)
-                end;
-
-            if cnt > 0 then
-                with ar[GetRandom(cnt)] do
-                    begin
-                    ar2[cnt2].x:= x;
-                    ar2[cnt2].y:= y;
-                    inc(cnt2)
-                    end
-        until (x + Delta > Right);
-
-        dec(Delta, 60)
-    until (cnt2 > 0) or (Delta < 70);
-    if (cnt2 = 0) and skipProximity and (not reallySkip) then tryAgain:= true
-    else tryAgain:= false;
-    reallySkip:= true;
-    end;
-
-if cnt2 > 0 then
-    with ar2[GetRandom(cnt2)] do
-        begin
-        Gear^.X:= int2hwFloat(x);
-        Gear^.Y:= int2hwFloat(y);
-        AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
-        end
-    else
-    begin
-    OutError('Can''t find place for Gear', false);
-    if Gear^.Kind = gtHedgehog then Gear^.Hedgehog^.Effects[heResurrectable] := false;
-    DeleteGear(Gear);
-    Gear:= nil
-    end
-end;
-
-function ModifyDamage(dmg: Longword; Gear: PGear): Longword;
-var i: hwFloat;
-begin
-(* Invulnerability cannot be placed in here due to still needing kicks
-   Not without a new damage machine.
-   King check should be in here instead of ApplyDamage since Tiy wants them kicked less
-*)
-i:= _1;
-if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then i:= _1_5;
-if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then
-   ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5)
-else
-   ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent)
-end;
 
 function GearByUID(uid : Longword) : PGear;
 var gear: PGear;