From dab7859ea7fbfa66a755f121ddbd51a997d8e254 Mon Sep 17 00:00:00 2001
From: Superstarxalien <ernesto_vallenilla@hotmail.com>
Date: Wed, 5 Jun 2024 19:19:27 -0400
Subject: [PATCH] add divide_scale functionality

---
 .../properties.txt                                          | 2 ++
 .../properties.txt                                          | 2 ++
 .../properties.txt                                          | 2 ++
 .../properties.txt                                          | 2 ++
 Basic templates/example/properties.txt                      | 2 ++
 Basic templates/example_animated/properties.txt             | 2 ++
 Basic templates/example_asymmetricalrotation/properties.txt | 2 ++
 .../example_asymmetricalrotation_animated/properties.txt    | 2 ++
 Basic templates/example_symmetricalrotation/properties.txt  | 2 ++
 .../properties.txt                                          | 2 ++
 .../properties.txt                                          | 2 ++
 .../example_symmetricalrotation_animated/properties.txt     | 2 ++
 src/main.c                                                  | 6 +++++-
 13 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/Advanced templates/example_asymmetricalrotation_7statesfull_animated/properties.txt b/Advanced templates/example_asymmetricalrotation_7statesfull_animated/properties.txt
index 5ed24ab..86cf489 100644
--- a/Advanced templates/example_asymmetricalrotation_7statesfull_animated/properties.txt	
+++ b/Advanced templates/example_asymmetricalrotation_7statesfull_animated/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Advanced templates/example_asymmetricalrotation_7statesfull_animated_chaoillustration/properties.txt b/Advanced templates/example_asymmetricalrotation_7statesfull_animated_chaoillustration/properties.txt
index 5ed24ab..86cf489 100644
--- a/Advanced templates/example_asymmetricalrotation_7statesfull_animated_chaoillustration/properties.txt	
+++ b/Advanced templates/example_asymmetricalrotation_7statesfull_animated_chaoillustration/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Advanced templates/example_symmetricalrotation_7statesfull_animated/properties.txt b/Advanced templates/example_symmetricalrotation_7statesfull_animated/properties.txt
index 7e65f55..eff742c 100644
--- a/Advanced templates/example_symmetricalrotation_7statesfull_animated/properties.txt	
+++ b/Advanced templates/example_symmetricalrotation_7statesfull_animated/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Advanced templates/example_symmetricalrotation_7statesfull_animated_chaoillustration/properties.txt b/Advanced templates/example_symmetricalrotation_7statesfull_animated_chaoillustration/properties.txt
index 7e65f55..eff742c 100644
--- a/Advanced templates/example_symmetricalrotation_7statesfull_animated_chaoillustration/properties.txt	
+++ b/Advanced templates/example_symmetricalrotation_7statesfull_animated_chaoillustration/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example/properties.txt b/Basic templates/example/properties.txt
index 9d862e1..03c7bb7 100644
--- a/Basic templates/example/properties.txt	
+++ b/Basic templates/example/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example_animated/properties.txt b/Basic templates/example_animated/properties.txt
index 4c0a70c..9cf14e5 100644
--- a/Basic templates/example_animated/properties.txt	
+++ b/Basic templates/example_animated/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example_asymmetricalrotation/properties.txt b/Basic templates/example_asymmetricalrotation/properties.txt
index f26301a..0987b31 100644
--- a/Basic templates/example_asymmetricalrotation/properties.txt	
+++ b/Basic templates/example_asymmetricalrotation/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example_asymmetricalrotation_animated/properties.txt b/Basic templates/example_asymmetricalrotation_animated/properties.txt
index 096a05a..8a6136a 100644
--- a/Basic templates/example_asymmetricalrotation_animated/properties.txt	
+++ b/Basic templates/example_asymmetricalrotation_animated/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example_symmetricalrotation/properties.txt b/Basic templates/example_symmetricalrotation/properties.txt
index 454a007..1f6b682 100644
--- a/Basic templates/example_symmetricalrotation/properties.txt	
+++ b/Basic templates/example_symmetricalrotation/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example_symmetricalrotation_2states_animated/properties.txt b/Basic templates/example_symmetricalrotation_2states_animated/properties.txt
index e54b26e..1ee6f69 100644
--- a/Basic templates/example_symmetricalrotation_2states_animated/properties.txt	
+++ b/Basic templates/example_symmetricalrotation_2states_animated/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example_symmetricalrotation_7states_animated/properties.txt b/Basic templates/example_symmetricalrotation_7states_animated/properties.txt
index 26707d2..889507a 100644
--- a/Basic templates/example_symmetricalrotation_7states_animated/properties.txt	
+++ b/Basic templates/example_symmetricalrotation_7states_animated/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/Basic templates/example_symmetricalrotation_animated/properties.txt b/Basic templates/example_symmetricalrotation_animated/properties.txt
index bee2ea0..61bc6be 100644
--- a/Basic templates/example_symmetricalrotation_animated/properties.txt	
+++ b/Basic templates/example_symmetricalrotation_animated/properties.txt	
@@ -18,6 +18,8 @@
 	"mode_explanation": "If floating (0) or on the ground (1).",
 	"scale": 1,
 	"scale_explanation": "(in Fracunits) Scale relative to the player's. Value entered will be inserted as [value] * FRACUNIT",
+	"scale_divide": 1,
+	"scale_divide_explanation": "The value that the follower's scale will be divided by. Value entered will be inserted as [scale] * FRACUNIT / [scale_divide]. Combine with scale to make fractionary scales such as 2/5 (e.g. scale is set to 2 and scale_divide is set to 5), most useful for hi-res sprites.",
 	"bubblescale": 0,
 	"bubblescale_explanation": "(in Fracunits) Bubble scale relative to the player scale. If not set, no bubble will spawn.",
 	"atangle": 230,
diff --git a/src/main.c b/src/main.c
index ee4470f..c968c15 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,7 +35,7 @@
 #define MAX_IMAGE_SIZE 256*256
 
 // it's only a snippet, the whole thing can't be a macro since it's variable now
-#define FOLLOWER_SOC_SNIPPET_TEMPLATE "%s\nFOLLOWER\nName = %s\nIcon = ICOF%s\nCategory = %s\nHornSound = DSFH%s\nDefaultColor = %s\nMode = %s\nScale = %d*FRACUNIT\nBubbleScale = %d*FRACUNIT\nAtAngle = %d\nDistance = %d*FRACUNIT\nHeight = %d*FRACUNIT\nZOffs = %d*FRACUNIT\nHorzLag = %d*FRACUNIT\nVertLag = %d*FRACUNIT\nAngleLag = %d*FRACUNIT\nBobAmp = %d*FRACUNIT\nBobSpeed = %d*FRACUNIT\nHitConfirmTime = %d\nRingTime = %d\n"
+#define FOLLOWER_SOC_SNIPPET_TEMPLATE "%s\nFOLLOWER\nName = %s\nIcon = ICOF%s\nCategory = %s\nHornSound = DSFH%s\nDefaultColor = %s\nMode = %s\nScale = %d*FRACUNIT/%d\nBubbleScale = %d*FRACUNIT\nAtAngle = %d\nDistance = %d*FRACUNIT\nHeight = %d*FRACUNIT\nZOffs = %d*FRACUNIT\nHorzLag = %d*FRACUNIT\nVertLag = %d*FRACUNIT\nAngleLag = %d*FRACUNIT\nBobAmp = %d*FRACUNIT\nBobSpeed = %d*FRACUNIT\nHitConfirmTime = %d\nRingTime = %d\n"
 
 #define FOLLOWERNAMESIZE 16
 
@@ -72,6 +72,7 @@ struct followerstructthingwhatever {
 	char prefcolor[32];
 	char mode[8]; // if floating or on ground
 	char scale;
+	char scale_divide;
 	char bubblescale;
 	short atangle;
 	char distance;
@@ -777,6 +778,8 @@ void addFollower(struct wadfile* wad)
 
 	if (cJSON_GetObjectItem(metadata, "scale"))
 		kfollower.scale = cJSON_GetObjectItem(metadata, "scale")->valueint;
+	if (cJSON_GetObjectItem(metadata, "scale_divide"))
+		kfollower.scale_divide = cJSON_GetObjectItem(metadata, "scale_divide")->valueint;
 	if (cJSON_GetObjectItem(metadata, "bubblescale"))
 		kfollower.bubblescale = cJSON_GetObjectItem(metadata, "bubblescale")->valueint;
 	if (cJSON_GetObjectItem(metadata, "atangle"))
@@ -1035,6 +1038,7 @@ void addFollower(struct wadfile* wad)
 		kfollower.prefcolor,
 		kfollower.mode,
 		kfollower.scale,
+		kfollower.scale_divide,
 		kfollower.bubblescale,
 		kfollower.atangle,
 		kfollower.distance,
-- 
GitLab