1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Pixel Offset fix request

Discussion in 'Modding [KAG]' started by Pirate-Rob, Feb 23, 2017.

  1. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    For Driver class there is this function:
    PixelOffset@ getPixelOffset(const string&in filename, int frame)

    It's most common (if only use) is to find the head pixels used in sprites.

    So as we know, a common bug in kag is that creating a custom class will often have the female sprites bugging out and the head goes flying everywhere. The normal fix for this is usually to specify the exact path to the sprites and it'll start working. However in a recent mod, my female's heads are still broken despite this. After looking about, my suspicion was that pixeloffset is giving some whack co-ordinates. And after checking, it does!
    [​IMG]
    (Pixel offset is 81, 14)

    I think pixel offset is broken somehow. I believe the easiest fix would be to allow us to set the size of frames. Currently, PO is somehow generating it's own frames, which isn't ideal in the least.
     
    king-george and Osmal like this.
  2. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    I fixed it in my mod :> . i'll send you solution later, not on pc right now
     
  3. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    I fixed it in my mod too eventually, but it'd be nice if we didn't have to work around such a common thing.
     
  4. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    Its not pixel offsets problem, its delay when player changing sex value
     
  5. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    I think you're missing my point, Pixel offsets returned 81,14 as the co-ordinates for the pixel, even though I'm using 32x32 frames. I doubt it's a problem with the sex value as the character is already considered female when I get these bizarre offsets.
     
  6. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    How you fixed this?
    --- Double Post Merged, Feb 27, 2017, Original Post Date: Feb 27, 2017 ---
    Its not loading correctly, bcos ur head pixel offsets loading faster then ur character female/male number, when player created it start a from loading head instead of updating values, head loads offsets from male sprite, and then player loads sex values and update his own sprite. Dunno if you will understand that
     
  7. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    The way I fixed it was simply hotwiring the head script to only load head pixels from the male version.

    And the way I've coded it, the sprites are reloaded consistently (specifically including the head) (every second or so), so any 'lag/delay' doesn't make an effect. Either way, the female and male pixel sprites are in the exact same position, so even if it was using the male pixels, it should still work. The issue here is that no matter how many times I reload the female sprite and try to get pixel offsets, they're always in the wrong position.
     
  8. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    This has been bugging me for ages tbh. I'll see what I can do - what I'd prefer though is really to just give access to the texture pixels so you can calculate your own offsets (and provide an implementation for finding the first of a specific colour in a given frame, like the current offsets do). It'd be super useful for lining up overlay sprites among other things.
     
    Osmal and Pirate-Rob like this.
  9. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    That'd be an awesome feature, especially when you have to stitch a ton of sub sprites together.
     
    Osmal likes this.
  10. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    I looked into this today. Unfortunately, it might have to wait til I get time to sink into the file loading rework - it's all REALLY tangled. Everything goes back to cfilematcher and precache, and anything that isn't file data is stored "where it was convenient when I wrote this", by the look of it. The pixel offset code is mixed into the team texture colouring code, for example.

    I'll see what the heck is going on with the erroneous pixel offsets in the meantime, if I can.
     
    Pirate-Rob likes this.