merge hedgeroid
authorXeli
Wed, 17 Aug 2011 12:32:40 +0200
branchhedgeroid
changeset 5587 0b0a0f0c2cdc
parent 5579 3176ee8a9d94 (current diff)
parent 5585 c09f5b41644a (diff)
child 5589 b95d10c82f7f
merge
hedgewars/uScript.pas
--- a/QTfrontend/pagedata.cpp	Wed Aug 17 12:31:10 2011 +0200
+++ b/QTfrontend/pagedata.cpp	Wed Aug 17 12:32:40 2011 +0200
@@ -35,7 +35,7 @@
     BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
 
     web = new QWebView(this);
-    connect(this, SIGNAL(linkClicked(const QUrl&)), this, SLOT(install(const QUrl&)));
+    connect(web, SIGNAL(linkClicked(const QUrl&)), this, SLOT(install(const QUrl&)));
     web->load(QUrl("http://m8y.org/hw/downloads/"));
     web->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
     pageLayout->addWidget(web, 0, 0, 1, 3);
--- a/QTfrontend/pagedata.h	Wed Aug 17 12:31:10 2011 +0200
+++ b/QTfrontend/pagedata.h	Wed Aug 17 12:32:40 2011 +0200
@@ -32,7 +32,7 @@
     QPushButton *BtnBack;
     QWebView *web;
 
-private:
+private slots:
     void install(const QUrl &url);
 };
 
--- a/hedgewars/HHHandlers.inc	Wed Aug 17 12:31:10 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Wed Aug 17 12:32:40 2011 +0200
@@ -551,7 +551,13 @@
 case Gear^.Pos of
        posCaseUtility,
        posCaseAmmo: begin
-                    a:= Gear^.AmmoType;
+                    if Gear^.AmmoType <> amNothing then a:= Gear^.AmmoType 
+                    else
+                        begin
+                        for i:= 0 to GameTicks and $7F do GetRandom(2); // Burn some random numbers
+                        if Gear^.Pos = posCaseUtility then a:= GetUtility
+                        else a:= GetAmmo
+                        end;
                     AddAmmo(HH^.Hedgehog^, a);
 // Possibly needs to check shared clan ammo game flag once added.
 // On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up
--- a/hedgewars/VGSHandlers.inc	Wed Aug 17 12:31:10 2011 +0200
+++ b/hedgewars/VGSHandlers.inc	Wed Aug 17 12:32:40 2011 +0200
@@ -498,6 +498,7 @@
     begin
     dec(Gear^.Timer, Steps);
     Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
+    Gear^.X:= Gear^.X + Gear^.dX * Steps
     end;
 end;
 
@@ -515,17 +516,15 @@
 begin
 s:= '';
 
-Gear^.dY:= -0.08;
-
 str(Gear^.State, s);
 if Gear^.Hedgehog <> nil then
     Gear^.Tex:= RenderStringTex(s, Gear^.Hedgehog^.Team^.Clan^.Color, fnt16)
 else
     Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16);
 
-if round(Gear^.Y) < cWaterLine then
-    Gear^.doStep:= @doStepHealthTagWork
-else
+Gear^.doStep:= @doStepHealthTagWork;
+
+if (round(Gear^.Y) < cWaterLine) and (Gear^.Frame = 0)  then
     Gear^.doStep:= @doStepHealthTagWorkUnderWater;
 
 Gear^.Y:= Gear^.Y - Gear^.Tex^.h;
--- a/hedgewars/uGears.pas	Wed Aug 17 12:31:10 2011 +0200
+++ b/hedgewars/uGears.pas	Wed Aug 17 12:32:40 2011 +0200
@@ -40,6 +40,8 @@
 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 ProcessGears;
 procedure EndTurnCleanup;
@@ -1693,6 +1695,59 @@
     SpawnFakeCrateAt := FollowGear;
 end;
 
+function GetAmmo: TAmmoType;
+var t, aTot: LongInt;
+    i: TAmmoType;
+begin
+
+aTot:= 0;
+for i:= Low(TAmmoType) to High(TAmmoType) do
+    if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
+        inc(aTot, Ammoz[i].Probability);
+
+t:= aTot;
+i:= Low(TAmmoType);
+if (t > 0) then
+    begin
+    t:= GetRandom(t);
+    AddFileLog(inttostr(t)+' --------------');
+    while t >= 0 do
+      begin
+      inc(i);
+      if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
+          dec(t, Ammoz[i].Probability)
+      end
+    end;
+GetAmmo:= i
+end;
+
+function GetUtility: TAmmoType;
+var t, uTot: LongInt;
+    i: TAmmoType;
+begin
+
+uTot:= 0;
+for i:= Low(TAmmoType) to High(TAmmoType) do
+    if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
+        inc(uTot, Ammoz[i].Probability);
+
+t:= uTot;
+i:= Low(TAmmoType);
+if (t > 0) then
+    begin
+    t:= GetRandom(t);
+    while t >= 0 do
+      begin
+      inc(i);
+      if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
+          dec(t, Ammoz[i].Probability)
+      end
+    end;
+GetUtility:= i
+end;
+
+
+
 procedure SpawnBoxOfSmth;
 var t, aTot, uTot, a, h: LongInt;
     i: TAmmoType;
@@ -1744,12 +1799,6 @@
         FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0);
         t:= GetRandom(t);
         i:= Low(TAmmoType);
-        while t >= 0 do
-          begin
-          inc(i);
-          if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
-              dec(t, Ammoz[i].Probability)
-          end;
         FollowGear^.Pos:= posCaseAmmo;
         FollowGear^.AmmoType:= i;
         AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo);
@@ -1763,12 +1812,6 @@
         FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0);
         t:= GetRandom(t);
         i:= Low(TAmmoType);
-        while t >= 0 do
-          begin
-          inc(i);
-          if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
-              dec(t, Ammoz[i].Probability)
-          end;
         FollowGear^.Pos:= posCaseUtility;
         FollowGear^.AmmoType:= i;
         AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo);
--- a/hedgewars/uScript.pas	Wed Aug 17 12:31:10 2011 +0200
+++ b/hedgewars/uScript.pas	Wed Aug 17 12:32:40 2011 +0200
@@ -1542,6 +1542,8 @@
 // push game variables so they may be modified by the script
 ScriptSetInteger('GameFlags', GameFlags);
 ScriptSetString('Seed', cSeed);
+ScriptSetInteger('ScreenHeight', cScreenHeight);
+ScriptSetInteger('ScreenWidth', cScreenWidth);
 ScriptSetInteger('TurnTime', cHedgehogTurnTime);
 ScriptSetInteger('CaseFreq', cCaseFactor);
 ScriptSetInteger('HealthCaseProb', cHealthCaseProb);
--- a/hedgewars/uTypes.pas	Wed Aug 17 12:31:10 2011 +0200
+++ b/hedgewars/uTypes.pas	Wed Aug 17 12:32:40 2011 +0200
@@ -282,6 +282,7 @@
         Text: shortstring;
         Tint: Longword;
         uid: Longword;
+        Layer: byte;
         end;
 
     TStatistics = record
--- a/hedgewars/uVariables.pas	Wed Aug 17 12:31:10 2011 +0200
+++ b/hedgewars/uVariables.pas	Wed Aug 17 12:32:40 2011 +0200
@@ -2313,7 +2313,10 @@
     texl, texr: GLuint;
 
 
-    VisualGearsList: PVisualGear;
+    VisualGearsLayer0: PVisualGear;
+    VisualGearsLayer1: PVisualGear;
+    VisualGearsLayer2: PVisualGear;
+    VisualGearsLayer3: PVisualGear;
     lastVisualGearByUID: PVisualGear;
     vobFrameTicks, vobFramesCount, vobCount: Longword;
     vobVelocity, vobFallSpeed: LongInt;
--- a/hedgewars/uVisualGears.pas	Wed Aug 17 12:31:10 2011 +0200
+++ b/hedgewars/uVisualGears.pas	Wed Aug 17 12:32:40 2011 +0200
@@ -282,6 +282,7 @@
   vgtHealthTag: begin
                 Frame:= 0;
                 Timer:= 1500;
+                dY:= -0.08;
                 //gear^.Z:= 2002;
                 end;
   vgtSmokeTrace,
@@ -330,12 +331,77 @@
 
 if State <> 0 then gear^.State:= State;
 
-if VisualGearsList <> nil then
-    begin
-    VisualGearsList^.PrevGear:= gear;
-    gear^.NextGear:= VisualGearsList
-    end;
-VisualGearsList:= gear;
+case Gear^.Kind of
+    // 0: this layer is very distant in the background when stereo
+    vgtTeamHealthSorter,
+    vgtSmoothWindBar,
+    vgtFlake, 
+    vgtCloud: begin
+              if VisualGearsLayer0 <> nil then
+                  begin
+                  VisualGearsLayer0^.PrevGear:= gear;
+                  gear^.NextGear:= VisualGearsLayer0
+                  end;
+              gear^.Layer:= 0;
+              VisualGearsLayer0:= gear
+              end; 
+    // 1: this layer is on the land level (which is close but behind the screen plane) when stereo
+    vgtSmokeTrace,
+    vgtEvilTrace,
+    vgtLineTrail,
+    vgtSmoke,
+    vgtSmokeWhite,
+    vgtDust,
+    vgtFire,
+    vgtSplash,
+    vgtDroplet,
+    vgtBubble: begin
+              if VisualGearsLayer1 <> nil then
+                  begin
+                  VisualGearsLayer1^.PrevGear:= gear;
+                  gear^.NextGear:= VisualGearsLayer1
+                  end;
+              gear^.Layer:= 1;
+              VisualGearsLayer1:= gear
+              end; 
+    // 3: this layer is on the screen plane (depth = 0) when stereo
+    vgtSpeechBubble,
+    vgtSmallDamageTag,
+    vgtHealthTag,
+    vgtStraightShot,
+    vgtChunk: begin
+              if VisualGearsLayer3 <> nil then
+                  begin
+                  VisualGearsLayer3^.PrevGear:= gear;
+                  gear^.NextGear:= VisualGearsLayer3
+                  end;
+              gear^.Layer:= 3;
+              VisualGearsLayer3:= gear
+              end; 
+    // 2: this layer is outside the screen when stereo
+    vgtExplosion,
+    vgtBigExplosion,
+    vgtExplPart,
+    vgtExplPart2,
+    vgtSteam,
+    vgtAmmo,
+    vgtShell,
+    vgtFeather,
+    vgtEgg,
+    vgtBeeTrace,
+    vgtSmokeRing,
+    vgtNote,
+    vgtBulletHit,
+    vgtCircle: begin
+              if VisualGearsLayer2 <> nil then
+                  begin
+                  VisualGearsLayer2^.PrevGear:= gear;
+                  gear^.NextGear:= VisualGearsLayer2
+                  end;
+              gear^.Layer:= 2;
+              VisualGearsLayer2:= gear
+              end; 
+end;
 
 AddVisualGear:= gear;
 end;
@@ -348,7 +414,13 @@
 
     if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
     if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear
-    else VisualGearsList:= Gear^.NextGear;
+    else
+        case Gear^.Layer of
+            0: VisualGearsLayer0:= Gear^.NextGear;
+            1: VisualGearsLayer1:= Gear^.NextGear;
+            2: VisualGearsLayer2:= Gear^.NextGear;
+            3: VisualGearsLayer3:= Gear^.NextGear;
+        end;
 
     if lastVisualGearByUID = Gear then lastVisualGearByUID:= nil;
 
@@ -360,7 +432,28 @@
 begin
 if Steps = 0 then exit;
 
-t:= VisualGearsList;
+t:= VisualGearsLayer0;
+while t <> nil do
+      begin
+      Gear:= t;
+      t:= Gear^.NextGear;
+      Gear^.doStep(Gear, Steps)
+      end;
+t:= VisualGearsLayer1;
+while t <> nil do
+      begin
+      Gear:= t;
+      t:= Gear^.NextGear;
+      Gear^.doStep(Gear, Steps)
+      end;
+t:= VisualGearsLayer2;
+while t <> nil do
+      begin
+      Gear:= t;
+      t:= Gear^.NextGear;
+      Gear^.doStep(Gear, Steps)
+      end;
+t:= VisualGearsLayer3;
 while t <> nil do
       begin
       Gear:= t;
@@ -374,7 +467,7 @@
     dmg: LongInt;
 begin
 if (vobCount = 0) or (vobCount > 200) then exit;
-t:= VisualGearsList;
+t:= VisualGearsLayer0;
 while t <> nil do
       begin
       Gear:= t;
@@ -400,179 +493,191 @@
     tinted: boolean;
     tmp: real;
 begin
-Gear:= VisualGearsList;
 case Layer of
     // this layer is very distant in the background when stereo
-    0: while Gear <> nil do
-        begin
-        if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
-        case Gear^.Kind of
-            vgtFlake: if SuddenDeathDmg then
-                          if vobSDVelocity = 0 then
-                              DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
-                          else
-                              DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
-                      else
-                          if vobVelocity = 0 then
-                              DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
-                          else
-                              DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
-            vgtCloud: if SuddenDeathDmg then
-                          DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
-                      else
-                          DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
-            end;
-        if Gear^.Tint <> $FFFFFFFF then Tint($FF,$FF,$FF,$FF);
-        Gear:= Gear^.NextGear
+    0: begin
+       Gear:= VisualGearsLayer0;
+       while Gear <> nil do
+           begin
+           if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
+           case Gear^.Kind of
+               vgtFlake: if SuddenDeathDmg then
+                             if vobSDVelocity = 0 then
+                                 DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                             else
+                                 DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle)
+                         else
+                             if vobVelocity = 0 then
+                                 DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                             else
+                                 DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
+               vgtCloud: if SuddenDeathDmg then
+                             DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                         else
+                             DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
+               end;
+           if Gear^.Tint <> $FFFFFFFF then Tint($FF,$FF,$FF,$FF);
+           Gear:= Gear^.NextGear
+           end
        end;
     // this layer is on the land level (which is close but behind the screen plane) when stereo
-    1: while Gear <> nil do
-        begin
-        //tinted:= false;
-        if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
-        case Gear^.Kind of
-            vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
-            vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
-            vgtLineTrail: DrawLine(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 1.0, $FF, min(Gear^.Timer, $C0), min(Gear^.Timer, $80), min(Gear^.Timer, $FF));
-        end;
-        if (cReducedQuality and rqAntiBoom) = 0 then
-            case Gear^.Kind of
-                vgtSmoke: DrawSprite(sprSmoke, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
-                vgtSmokeWhite: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
-                vgtDust: if Gear^.State = 1 then
-                             DrawSprite(sprSnowDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame)
-                         else
-                             DrawSprite(sprDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
-                vgtFire: if (Gear^.State and gstTmpFlag) = 0 then
-                             DrawSprite(sprFlame, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy, (RealTicks shr 6 + Gear^.Frame) mod 8)
-                         else
-                             DrawTextureF(SpritesData[sprFlame].Texture, Gear^.FrameTicks / 900, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, (RealTicks shr 7 + Gear^.Frame) mod 8, 1, 16, 16);
-                vgtSplash: if SuddenDeathDmg then
-                               DrawSprite(sprSDSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37))
+    1: begin
+       Gear:= VisualGearsLayer1;
+       while Gear <> nil do
+          begin
+          //tinted:= false;
+          if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
+          case Gear^.Kind of
+              vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
+              vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State);
+              vgtLineTrail: DrawLine(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 1.0, $FF, min(Gear^.Timer, $C0), min(Gear^.Timer, $80), min(Gear^.Timer, $FF));
+          end;
+          if (cReducedQuality and rqAntiBoom) = 0 then
+              case Gear^.Kind of
+                  vgtSmoke: DrawSprite(sprSmoke, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+                  vgtSmokeWhite: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+                  vgtDust: if Gear^.State = 1 then
+                               DrawSprite(sprSnowDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame)
                            else
-                               DrawSprite(sprSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
-                vgtDroplet: if SuddenDeathDmg then
-                                DrawSprite(sprSDDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame)
-                            else
-                                DrawSprite(sprDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);
-                vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
-            end;
-        //if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
-        if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF);
-        Gear:= Gear^.NextGear
+                               DrawSprite(sprDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+                  vgtFire: if (Gear^.State and gstTmpFlag) = 0 then
+                               DrawSprite(sprFlame, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy, (RealTicks shr 6 + Gear^.Frame) mod 8)
+                           else
+                               DrawTextureF(SpritesData[sprFlame].Texture, Gear^.FrameTicks / 900, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, (RealTicks shr 7 + Gear^.Frame) mod 8, 1, 16, 16);
+                  vgtSplash: if SuddenDeathDmg then
+                                 DrawSprite(sprSDSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37))
+                             else
+                                 DrawSprite(sprSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37));
+                  vgtDroplet: if SuddenDeathDmg then
+                                  DrawSprite(sprSDDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame)
+                              else
+                                  DrawSprite(sprDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);
+                  vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8);
+              end;
+          //if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
+          if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF);
+          Gear:= Gear^.NextGear
+          end
        end;
     // this layer is on the screen plane (depth = 0) when stereo
-    3: while Gear <> nil do
-        begin
-        tinted:= false;
-        if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
-        case Gear^.Kind of
-            vgtSpeechBubble: begin
-                             if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then
-                                 begin
-                                 tinted:= true;
-                                 Tint($FF, $FF, $FF,  $66);
-                                 DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
-                                 end
-                             else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team = CurrentTeam)) or (Gear^.State = 2)) then
-                                 DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
-                             end;
-            vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
-            vgtHealthTag: if Gear^.Tex <> nil then 
-                            begin
-                            if Gear^.Frame = 0 then 
-                                DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
-                            else
-                                begin 
-                                SetScale(cDefaultZoomLevel); 
-                                DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex); 
-                                SetScale(zoom)
-                                end
-                            end;
-//if Gear^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
-            vgtStraightShot: DrawRotatedF(TSprite(Gear^.State), round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-        end;
-        if (cReducedQuality and rqAntiBoom) = 0 then
-            case Gear^.Kind of
-                vgtChunk: DrawRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-            end;
-        if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
-        Gear:= Gear^.NextGear
+    3: begin
+       Gear:= VisualGearsLayer3;
+       while Gear <> nil do
+           begin
+           tinted:= false;
+           if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
+           case Gear^.Kind of
+               vgtSpeechBubble: begin
+                                if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then
+                                    begin
+                                    tinted:= true;
+                                    Tint($FF, $FF, $FF,  $66);
+                                    DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
+                                    end
+                                else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team = CurrentTeam)) or (Gear^.State = 2)) then
+                                    DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+                                end;
+               vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+               vgtHealthTag: if Gear^.Tex <> nil then 
+                               begin
+                               if Gear^.Frame = 0 then 
+                                   DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex)
+                               else
+                                   begin
+                                   SetScale(cDefaultZoomLevel);
+                                   if Gear^.Angle = 0 then DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex)
+                                   else DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex, Gear^.Angle); 
+                                   SetScale(zoom)
+                                   end
+                               end;
+    //if Ger^.Tex <> nil then DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+               vgtStraightShot: DrawRotatedF(TSprite(Gear^.State), round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+           end;
+           if (cReducedQuality and rqAntiBoom) = 0 then
+               case Gear^.Kind of
+                   vgtChunk: DrawRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+               end;
+           if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
+           Gear:= Gear^.NextGear
+           end
        end;
     // this layer is outside the screen when stereo
-    2: while Gear <> nil do
-        begin
-        tinted:= false;
-        if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
-        case Gear^.Kind of
-            vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State);
-            vgtBigExplosion: begin
-                             tinted:= true;
-                             Tint($FF, $FF, $FF, round($FF * (1 - power(Gear^.Timer / 250, 4))));
-                             DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
-                             end;
-        end;
-        if (cReducedQuality and rqAntiBoom) = 0 then
-            case Gear^.Kind of
-                vgtExplPart: DrawSprite(sprExplPart, round(Gear^.X) + WorldDx - 16, round(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
-                vgtExplPart2: DrawSprite(sprExplPart2, round(Gear^.X) + WorldDx - 16, round(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
-                vgtSteam: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
-                vgtAmmo: begin
-                         tinted:= true;
-                         Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
-                         DrawTextureF(ropeIconTex, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 32, 32);
-                         DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
-                         end;
-                vgtShell: begin
-                          if Gear^.FrameTicks < $FF then
-                              begin
-                              Tint($FF, $FF, $FF, Gear^.FrameTicks);
-                              tinted:= true
-                              end;
-                          DrawRotatedF(sprShell, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-                          end;
-                vgtFeather: begin
-                            if Gear^.FrameTicks < 255 then
-                                begin
-                                Tint($FF, $FF, $FF, Gear^.FrameTicks);
-                                tinted:= true
+    2: begin
+       Gear:= VisualGearsLayer2;
+       while Gear <> nil do
+           begin
+           tinted:= false;
+           if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint);
+           case Gear^.Kind of
+               vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State);
+               vgtBigExplosion: begin
+                                tinted:= true;
+                                Tint($FF, $FF, $FF, round($FF * (1 - power(Gear^.Timer / 250, 4))));
+                                DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle);
                                 end;
-                            DrawRotatedF(sprFeather, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-                          end;
-                vgtEgg: begin
-                        if Gear^.FrameTicks < $FF then
-                            begin
-                                Tint($FF, $FF, $FF, Gear^.FrameTicks);
-                                tinted:= true
+           end;
+           if (cReducedQuality and rqAntiBoom) = 0 then
+               case Gear^.Kind of
+                   vgtExplPart: DrawSprite(sprExplPart, round(Gear^.X) + WorldDx - 16, round(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
+                   vgtExplPart2: DrawSprite(sprExplPart2, round(Gear^.X) + WorldDx - 16, round(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame);
+                   vgtSteam: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame);
+                   vgtAmmo: begin
+                            tinted:= true;
+                            Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
+                            DrawTextureF(ropeIconTex, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 32, 32);
+                            DrawTextureF(SpritesData[sprAMAmmos].Texture, Gear^.scale * 0.90, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame - 1, 1, 32, 32);
                             end;
-                        DrawRotatedF(sprEgg, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-                        end;
-                vgtBeeTrace: begin
+                   vgtShell: begin
                              if Gear^.FrameTicks < $FF then
-                                 Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
-                             else
-                                 Tint($FF, $FF, $FF, $80);
-                             tinted:= true;
-                             DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
+                                 begin
+                                 Tint($FF, $FF, $FF, Gear^.FrameTicks);
+                                 tinted:= true
+                                 end;
+                             DrawRotatedF(sprShell, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+                             end;
+                   vgtFeather: begin
+                               if Gear^.FrameTicks < 255 then
+                                   begin
+                                   Tint($FF, $FF, $FF, Gear^.FrameTicks);
+                                   tinted:= true
+                                   end;
+                               DrawRotatedF(sprFeather, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
                              end;
-                vgtSmokeRing: begin
-                              tinted:= true;
-                              Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
-                              DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
-                              end;
-                vgtNote: DrawRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
-                vgtBulletHit: DrawRotatedF(sprBulletHit, round(Gear^.X) + WorldDx - 0, round(Gear^.Y) + WorldDy - 0, 7 - (Gear^.FrameTicks div 50), 1, Gear^.Angle);
-            end;
-        case Gear^.Kind of
-            vgtCircle: if gear^.Angle = 1 then
-                           begin
-                           tmp:= Gear^.State / 100;
-                           DrawTexture(round(Gear^.X-24*tmp) + WorldDx, round(Gear^.Y-24*tmp) + WorldDy, SpritesData[sprVampiric].Texture, tmp)
-                           end
-                       else DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer);
-        end;
-        if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
-        Gear:= Gear^.NextGear
+                   vgtEgg: begin
+                           if Gear^.FrameTicks < $FF then
+                               begin
+                                   Tint($FF, $FF, $FF, Gear^.FrameTicks);
+                                   tinted:= true
+                               end;
+                           DrawRotatedF(sprEgg, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+                           end;
+                   vgtBeeTrace: begin
+                                if Gear^.FrameTicks < $FF then
+                                    Tint($FF, $FF, $FF, Gear^.FrameTicks div 2)
+                                else
+                                    Tint($FF, $FF, $FF, $80);
+                                tinted:= true;
+                                DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle);
+                                end;
+                   vgtSmokeRing: begin
+                                 tinted:= true;
+                                 Tint($FF, $FF, $FF, round(Gear^.alpha * $FF));
+                                 DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle);
+                                 end;
+                   vgtNote: DrawRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle);
+                   vgtBulletHit: DrawRotatedF(sprBulletHit, round(Gear^.X) + WorldDx - 0, round(Gear^.Y) + WorldDy - 0, 7 - (Gear^.FrameTicks div 50), 1, Gear^.Angle);
+               end;
+           case Gear^.Kind of
+               vgtCircle: if gear^.Angle = 1 then
+                              begin
+                              tmp:= Gear^.State / 100;
+                              DrawTexture(round(Gear^.X-24*tmp) + WorldDx, round(Gear^.Y-24*tmp) + WorldDy, SpritesData[sprVampiric].Texture, tmp)
+                              end
+                          else DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer);
+           end;
+           if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF);
+           Gear:= Gear^.NextGear
+           end
        end
     end;
 end;
@@ -587,7 +692,40 @@
     VisualGearByUID:= lastVisualGearByUID;
     exit
     end;
-vg:= VisualGearsList;
+vg:= VisualGearsLayer0;
+while vg <> nil do
+    begin
+    if vg^.uid = uid then
+        begin
+        lastVisualGearByUID:= vg;
+        VisualGearByUID:= vg;
+        exit
+        end;
+    vg:= vg^.NextGear
+    end;
+vg:= VisualGearsLayer1;
+while vg <> nil do
+    begin
+    if vg^.uid = uid then
+        begin
+        lastVisualGearByUID:= vg;
+        VisualGearByUID:= vg;
+        exit
+        end;
+    vg:= vg^.NextGear
+    end;
+vg:= VisualGearsLayer2;
+while vg <> nil do
+    begin
+    if vg^.uid = uid then
+        begin
+        lastVisualGearByUID:= vg;
+        VisualGearByUID:= vg;
+        exit
+        end;
+    vg:= vg^.NextGear
+    end;
+vg:= VisualGearsLayer3;
 while vg <> nil do
     begin
     if vg^.uid = uid then
@@ -612,7 +750,7 @@
     vg, tmp: PVisualGear;
 begin
 if cCloudsNumber = cSDCloudsNumber then exit;
-vg:= VisualGearsList;
+vg:= VisualGearsLayer0;
 while vg <> nil do
     if vg^.Kind = vgtCloud then
         begin
@@ -644,7 +782,7 @@
 begin
 if (cReducedQuality and rqKillFlakes) <> 0 then exit;
 if vobCount = vobSDCount then exit;
-vg:= VisualGearsList;
+vg:= VisualGearsLayer0;
 while vg <> nil do
     if vg^.Kind = vgtFlake then
         begin
@@ -663,12 +801,18 @@
 
 procedure initModule;
 begin
-    VisualGearsList:= nil;
+    VisualGearsLayer0:= nil;
+    VisualGearsLayer1:= nil;
+    VisualGearsLayer2:= nil;
+    VisualGearsLayer3:= nil;
 end;
 
 procedure freeModule;
 begin
-    while VisualGearsList <> nil do DeleteVisualGear(VisualGearsList);
+    while VisualGearsLayer0 <> nil do DeleteVisualGear(VisualGearsLayer0);
+    while VisualGearsLayer1 <> nil do DeleteVisualGear(VisualGearsLayer1);
+    while VisualGearsLayer2 <> nil do DeleteVisualGear(VisualGearsLayer2);
+    while VisualGearsLayer3 <> nil do DeleteVisualGear(VisualGearsLayer3);
 end;
 
 end.