User Tag List

Results 1 to 5 of 5

Thread: [std.zh]CenterX and CenterY functions disrespect offset values

  1. #1
    Gel
    Join Date
    Dec 2012
    Posts
    18
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    268
    Level
    6
    vBActivity - Bars
    Lv. Percent
    4.33%
    Daily Activity
    0%
    Weekly Activity
    70%
    Monthly Activity
    45.15%

    Not A Bug [std.zh]CenterX and CenterY functions disrespect offset values

    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

  2. #2
    The Timelord
    ZC Developer
    ZoriaRPG's Avatar
    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,148
    Mentioned
    102 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    3,937
    Level
    19
    vBActivity - Bars
    Lv. Percent
    97.74%
    Daily Activity
    0%
    Weekly Activity
    120%
    Monthly Activity
    56.43%
    Are you calling CenterX/Y with those offsets in the function call, as a calculation?

    Code:
    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.
    Last edited by ZoriaRPG; 01-01-2016 at 11:33 PM.


    Featured Scripts & Headers: RPG.zh ( v. a0.97.1 ) ( RPG.zh Thread ) | Zelda 3 Thief's Town Treasure Chest Minigame (ffc) | Bobomb (enemy)
    ZScript & ZC-Related Pastebin | Quests and ZScript Repository | ZC Dev & Betas | Latest ZC 2.54 Beta | YouTube Channel
    All of the code that I create and publish here is free for use, modification and distribution under the GPL v2.0, or v3.0 where applicable..

  3. #3
    Gel
    Join Date
    Dec 2012
    Posts
    18
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    268
    Level
    6
    vBActivity - Bars
    Lv. Percent
    4.33%
    Daily Activity
    0%
    Weekly Activity
    70%
    Monthly Activity
    45.15%
    ...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".

  4. #4
    The Timelord
    ZC Developer
    ZoriaRPG's Avatar
    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,148
    Mentioned
    102 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    3,937
    Level
    19
    vBActivity - Bars
    Lv. Percent
    97.74%
    Daily Activity
    0%
    Weekly Activity
    120%
    Monthly Activity
    56.43%
    Quote Originally Posted by Alucard View Post
    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.

    Code:
    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.
    Last edited by ZoriaRPG; 01-05-2016 at 07:34 AM.


    Featured Scripts & Headers: RPG.zh ( v. a0.97.1 ) ( RPG.zh Thread ) | Zelda 3 Thief's Town Treasure Chest Minigame (ffc) | Bobomb (enemy)
    ZScript & ZC-Related Pastebin | Quests and ZScript Repository | ZC Dev & Betas | Latest ZC 2.54 Beta | YouTube Channel
    All of the code that I create and publish here is free for use, modification and distribution under the GPL v2.0, or v3.0 where applicable..

  5. #5
    Gel
    Join Date
    Dec 2012
    Posts
    18
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    268
    Level
    6
    vBActivity - Bars
    Lv. Percent
    4.33%
    Daily Activity
    0%
    Weekly Activity
    70%
    Monthly Activity
    45.15%
    Quote Originally Posted by ZoriaRPG View Post
    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.

    Code:
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •