Teach vgtSmallDamageTag to use dX, dY and screen coords (Frame<>0)
authorWuzzy <Wuzzy2@mail.ru>
Sun, 13 Dec 2020 21:21:41 +0100
changeset 15773 da1bb21e6fbf
parent 15772 95db10dcad71
child 15774 9588bd852202
Teach vgtSmallDamageTag to use dX, dY and screen coords (Frame<>0)
ChangeLog.txt
hedgewars/uVisualGears.pas
hedgewars/uVisualGearsHandlers.pas
hedgewars/uVisualGearsList.pas
--- a/ChangeLog.txt	Sun Dec 13 21:16:25 2020 +0100
+++ b/ChangeLog.txt	Sun Dec 13 21:21:41 2020 +0100
@@ -54,6 +54,7 @@
 
 Lua:
  + Add RopeKnocking library
+ + vgtSmallDamageTag: Can change dX, dY; add screen coordinates (Frame~=0)
  * Fix crash when spawning a vgtSmallDamageTag
 
 ====================== 1.0.0 =======================
--- a/hedgewars/uVisualGears.pas	Sun Dec 13 21:16:25 2020 +0100
+++ b/hedgewars/uVisualGears.pas	Sun Dec 13 21:21:41 2020 +0100
@@ -55,7 +55,7 @@
 begin
 if cAltDamage then
     begin
-    Gear:= AddVisualGear(X, Y, vgtSmallDamageTag);
+    Gear:= AddVisualGear(X, Y, vgtSmallDamageTag, Damage);
     if Gear <> nil then
         with Gear^ do
             Tex:= RenderStringTex(ansistring(inttostr(Damage)), Color, fntSmall);
@@ -266,7 +266,16 @@
                                     else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and ((Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Team = CurrentTeam))) or (Gear^.State = 2)) then
                                         DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
                vgtSmallDamageTag: if Gear^.Tex <> nil then
-                                    DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex);
+                                    begin
+                                    if Gear^.Frame = 0 then
+                                        DrawTextureCentered(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;
                vgtHealthTag: if Gear^.Tex <> nil then
                                begin
                                if Gear^.Frame = 0 then
--- a/hedgewars/uVisualGearsHandlers.pas	Sun Dec 13 21:16:25 2020 +0100
+++ b/hedgewars/uVisualGearsHandlers.pas	Sun Dec 13 21:21:41 2020 +0100
@@ -43,7 +43,7 @@
 procedure doStepEgg(Gear: PVisualGear; Steps: Longword);
 procedure doStepFire(Gear: PVisualGear; Steps: Longword);
 procedure doStepShell(Gear: PVisualGear; Steps: Longword);
-procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword);
+procedure doStepSmallDamageTag(Gear: PVisualGear; Steps: Longword);
 procedure doStepBubble(Gear: PVisualGear; Steps: Longword);
 procedure doStepSteam(Gear: PVisualGear; Steps: Longword);
 procedure doStepAmmo(Gear: PVisualGear; Steps: Longword);
@@ -402,16 +402,18 @@
     dec(Gear^.FrameTicks, Steps)
 end;
 
-procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword);
+procedure doStepSmallDamageTag(Gear: PVisualGear; Steps: Longword);
 var s: shortstring;
 begin
-Gear^.Y:= Gear^.Y - 0.02 * Steps;
 if Gear^.Tex = nil then
     begin
     s:= IntToStr(Gear^.State);
     Gear^.Tex:= RenderStringTex(ansistring(s), cWhiteColor, fntSmall);
     end;
 
+Gear^.X:= Gear^.X + Gear^.dX * Steps;
+Gear^.Y:= Gear^.Y + Gear^.dY * Steps;
+
 if Gear^.FrameTicks <= Steps then
     DeleteVisualGear(Gear)
 else
@@ -1042,7 +1044,7 @@
             @doStepExpl,
             @doStepExpl,
             @doStepFire,
-            @doStepSmallDamage,
+            @doStepSmallDamageTag,
             @doStepTeamHealthSorter,
             @doStepSpeechBubble,
             @doStepBubble,
--- a/hedgewars/uVisualGearsList.pas	Sun Dec 13 21:16:25 2020 +0100
+++ b/hedgewars/uVisualGearsList.pas	Sun Dec 13 21:21:41 2020 +0100
@@ -177,7 +177,10 @@
         vgtShell: FrameTicks:= 500;
     vgtSmallDamageTag:
                 begin
-                gear^.FrameTicks:= 1100
+                gear^.Frame:= 0;
+                gear^.FrameTicks:= 1100;
+                gear^.dX:= 0;
+                gear^.dY:= -0.02;
                 end;
     vgtBubble:
                 begin