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
[std.zh]CenterX and CenterY functions disrespect offset values
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.
...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".
Alucard wrote:
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. 😛
Fixed.
Tell me if this works for you, or if you need HitXOffset to be adjusted by TileWidth, and so forth.
ZoriaRPG wrote:Which way would you find best?CenterX(x+HitXOffset)
or
CenterX(x) + HitXOffsetThe 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