Changing width based on scale constant

Started by SaltAddict, October 23, 2021, 04:23:28 PM

Previous topic - Next topic

SaltAddict

I'm trying to set it so that my character's width value is automatically changed based on the value of the xscale constant. This is to make it easier for the user to resize the character if needed, since his sprites are bigger than normal. However, my code is giving me bonkers results:

[state -2 change width based on sprite scale]
type = width
trigger1 = 1
value = floor(29*const(size.xscale)), floor(25*const(size.xscale))
ignorehitpause = 1


29 and 25 are the original width values, which fit perfectly with the full sized sprites. For some reason this code makes the width line HUGE, way wider than the character, even though I've set the xscale to 0.85.  Even if I set the xscale to 1 (so, no multiplication, in theory), the width line is still massive.
I'm not good at maths so there might be something obvious I'm missing here? I've tried it with ceil instead, and without floor nor ceil; I've also tried const(size.ground.front)*(const.size.xscale), but it gives me the same result.

Odb718

#1
With my Samus I use
; fvar 14 = Const(size.xscale) ;used for positioning projectiles
to keep track of the scale. You're going to run into a TON of problems if you try to use size.xscale/yscale to do the math.

Some examples:
Spoiler (click to show)
[State -2, Gas]
type = Explod
trigger1 = NumExplod(4444) = 0
trigger1 = var(11) = 1
;trigger1 = time%1 = 0
anim = 4444
ID = 4444
pos = floor(fvar(14)),floor(fvar(14))
postype = p1  ;p2,front,back,left,right
;facing =  ifelse(P2Dist X < -10,-1,1)
vfacing = 1
bindtime = -1
removetime = -2
scale = fvar(14),fvar(14)
sprpriority = -9
Spoiler (click to show)

[State 0, ModifyExplod]
type = ModifyExplod 
trigger1 = parent, anim = [1200,1210]
trigger1 = 1
ID = 22026
anim = 22022
pos = floor(60* parent, Fvar(14)),floor(-200* parent, Fvar(14))
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = -1
removetime = 122
scale = (0.17*parent,var(29)*parent,Fvar(14)),(0.17*parent,var(29)*parent,Fvar(14))
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 1
ignorehitpause = 1)

This is how I have my width set up

[State 0, Width]
type = Width
trigger1 = anim = [1000,1002]
trigger1 = (AnimElemTime (2) >= 0) && (AnimElemTime (18) < 0)
edge = floor(290*fvar(14)),0;45
vVv Gouken718 vVv SabreTooth718 vVv


SaltAddict

#2
Quote from: Odb718 on October 24, 2021, 12:08:36 AM
With my Samus I use
; fvar 14 = Const(size.xscale) ;used for positioning projectiles
to keep track of the scale. You're going to run into a TON of problems if you try to use size.xscale/yscale to do the math.

Some examples:
Spoiler (click to show)
[State -2, Gas]
type = Explod
trigger1 = NumExplod(4444) = 0
trigger1 = var(11) = 1
;trigger1 = time%1 = 0
anim = 4444
ID = 4444
pos = floor(fvar(14)),floor(fvar(14))
postype = p1  ;p2,front,back,left,right
;facing =  ifelse(P2Dist X < -10,-1,1)
vfacing = 1
bindtime = -1
removetime = -2
scale = fvar(14),fvar(14)
sprpriority = -9
Spoiler (click to show)

[State 0, ModifyExplod]
type = ModifyExplod 
trigger1 = parent, anim = [1200,1210]
trigger1 = 1
ID = 22026
anim = 22022
pos = floor(60* parent, Fvar(14)),floor(-200* parent, Fvar(14))
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = -1
removetime = 122
scale = (0.17*parent,var(29)*parent,Fvar(14)),(0.17*parent,var(29)*parent,Fvar(14))
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 0
removeongethit = 1
ignorehitpause = 1)

This is how I have my width set up

[State 0, Width]
type = Width
trigger1 = anim = [1000,1002]
trigger1 = (AnimElemTime (2) >= 0) && (AnimElemTime (18) < 0)
edge = floor(290*fvar(14)),0;45

Same problem. I set fvar(14) to 0.85, the width bar still becomes huge.

EDIT: Ok, this is really weird, it seems like the width from the controller gets added to the character's regular width? But here: https://mugenguild.com/forum/topics/width-sctrl-170306.0.html it says the controller sets the width, not adds to it?