PDA

View Full Version : [std.zh]CenterX and CenterY functions disrespect offset values



Alucard
12-31-2015, 03:27 PM
As title says CenterX and CenterY functions from std.zh outright ignore HitXOffset and HitYOffset variables. I use those offsets as workaround for edge-of-the-screen limitation for lweapons in stdWeapons.zh. And CenterX and CenterY functions return wrong values, which can lead to bugs and glitches in scripted weapons. Exists in ZC 2.5.2

ZoriaRPG
01-02-2016, 12:22 AM
Are you calling CenterX/Y with those offsets in the function call, as a calculation?



int x = x+ HitXOffset;
CenterX(x);


...or did you anticipate that the various offsets would be auto-tabulated?

...or, most likely, do you want the return value adjusted by HitX/YOffset?

Pretty much, do you need:
CenterX(x+HitXOffset)
or
CenterX(x) + HitXOffset

I could make it do either, as CenterX(lweapon l) with overloads for eweapon, item, and item; as well as CenterLinkX(bool offsets)

The Center* functions are one of the things going into locale too. It's annoying to type the 're' backwards, and can lead to invisible script errors.

Alucard
01-03-2016, 07:20 AM
...or, most likely, do you want the return value adjusted by HitX/YOffset?

Pretty much, do you need:
CenterX(x+HitXOffset)
or
CenterX(x) + HitXOffset

I could make it do either, as CenterX(lweapon l) with overloads for eweapon, item, and item; as well as CenterLinkX(bool offsets)

The Center* functions are one of the things going into locale too. It's annoying to type the 're' backwards, and can lead to invisible script errors.[/QUOTE]

Pretty much like this. Thanks for advice. Now the thread should be marked as "Not a bug".

ZoriaRPG
01-04-2016, 01:59 PM
Pretty much like this. Thanks for advice. Now the thread should be marked as "Not a bug".

Which way would you find best?

CenterX(x+HitXOffset)
or
CenterX(x) + HitXOffset

The value would be different, and I'm thinking that returning CenterX(x) + HitXOffset is what is best, but may not be what you want. I hope that it is. I'll give you both versions, and you can tell me which one works as you want.



int CenterX(lweapon anLWeapon, bool trueoffset) {
if ( trueoffset ) return anLWeapon->X+8*anLWeapon->TileWidth + anLWeapon->HitXOffset;
else return CenterX(anLWeapon);
}
int CenterY(lweapon anLWeapon, bool trueoffset) {
if ( trueoffset ) return anLWeapon->Y+8*anLWeapon->TileHeight + anLWeapon->HitYOffset;
else return CenterX(anLWeapon);
}


I only now realised that both of these returns are identical, as I forgot to remove the + Hit*Offset in the else statement. :p

Fixed.

Tell me if this works for you, or if you need HitXOffset to be adjusted by TileWidth, and so forth.

Alucard
01-05-2016, 08:34 AM
Which way would you find best?

CenterX(x+HitXOffset)
or
CenterX(x) + HitXOffset

The value would be different, and I'm thinking that returning CenterX(x) + HitXOffset is what is best, but may not be what you want. I hope that it is. I'll give you both versions, and you can tell me which one works as you want.



int CenterX(lweapon anLWeapon, bool trueoffset) {
if ( trueoffset ) return anLWeapon->X+8*anLWeapon->TileWidth + anLWeapon->HitXOffset;
else return CenterX(anLWeapon) + anLWeapon->HitXOffset;
}
int CenterY(lweapon anLWeapon, bool trueoffset) {
if ( trueoffset ) return anLWeapon->Y+8*anLWeapon->TileHeight + anLWeapon->HitYOffset;
else return CenterX(anLWeapon) + anLWeapon->HitYOffset;
}

CenterX(x) + HitXOffset