Adding new deities, how to hook into the character creation?

Discussion in 'General Modification' started by firemephit, Sep 26, 2022.

Remove all ads!
  1. firemephit

    firemephit Member

    Joined:
    May 6, 2010
    Messages:
    12
    Likes Received:
    7
    Not sure if this is the right place to ask this but I figured I'd give it a go. So I was trying to see if it was possible to add new deities to the game and was first met with some success. I was able to make one with all its corresponding properties(domains ect) and it functions as expected(taking a level in cleric shows the right domain choices ect) but I've run into a problem. So far the only way I've been able to set worship of this new deity is to console it in, but ideally I'd like to add it to the character creation. From what I can tell this should involve adding a hook into the deity stage of character creation using replaceFunction. My snag is that since no hook exists I'm not sure what the memory address of this stage is or how to find it. Could anyone point me in the right direction?
     
    August likes this.
  2. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Hi mephit, it's cool that you're up for hooking functions :)

    Here' the latest decompiled code:
    https://ufile.io/jy02zkg5

    The character creation widgets for deity selection are initialized in:
    sub_101873F0

    And then there's the various ChargenDeityXXX functions.

    Let me know if you need further help (though it sounds like you're very much a can-do person ;) )
     
    Buffed Rabbit and August like this.
  3. firemephit

    firemephit Member

    Joined:
    May 6, 2010
    Messages:
    12
    Likes Received:
    7
    Sorry for the very late response, life reared its ugly head right after posting this and I didn't have any time to play around with it for a while. I've managed a bit of work on it but have run into something slightly confusing. I was trying out making a new window/widgets ect for deities based off the new ones used for classes but I'm running into a crash problem when selecting deity in character creation(right after setting alignment) To the best of my knowledge the "activate" function should be getting called then, but although its name is in the decompiled code you gave me it doesn't actually seem to be implemented(the deity one at least). Stranger still, the call of functionreplace for the class activate uses 0x101885D0 as the location of classactivate but in the decompiled code it seems to be at 0x10188550. Was I missing something?
     
  4. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    The activate function is at 0x10187390, and it contains just a single function call to 0x10187340 (which itself sets the button disable/enabled state).

    Can't say much about crashes without any further info, so I'll assume you'll post more info if you need help with that. I'm guessing the issue is that the Activate function is now mismatched with the new widgets, so once that's straightened out it should be ok.

    Similar to the above, one just contains a call to the other, so I replaced the inner function being called just in case.
     
  5. firemephit

    firemephit Member

    Joined:
    May 6, 2010
    Messages:
    12
    Likes Received:
    7
    Thanks for that, I did have a conflict(which let me also discover another one with a name mismatch) and the crashing problem is fixed. I've successfully gotten new buttons and the ability to add and select new deities with their appropriate domains. There's just 2 things left, one that is rather bizarre. The first(and probably easy one) is that domain related feats seems to be hard coded to the deities that originally had them(namely the war domain prof and focus feats) but I'm guessing I can just manually check and add them during the finalize step or something.
    The real problem left is that for some reason the bottom button on every page(I just copied the class structure for it so 11 buttons a page with next/prev buttons) is always showing whatever deity is last in the list. In this case I enabled all the normally non-selectable deities the game has and added one new one, Phaulkon(Kord's father). So rather than button 11 being kord himself it shows up as phaulkon(both the name and click effects), same with button 22 on the second page while on the third he shows up in his intended place. I've tried ostreaming out what button id's/deity id's/deity names are being used but it always shows them as intended and not with this odd overwrite. Anything come to mind that would cause something like this? I've been running through it but drawing a bit of a blank.
     
  6. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Cool!
    The first part should probably be pythonized, or made data driven at least. That way other modules could benefit from this (e.g. IWD).

    Not sure what's causing the latter, can you post the branch for review?
     
    anatoliy and August like this.
  7. firemephit

    firemephit Member

    Joined:
    May 6, 2010
    Messages:
    12
    Likes Received:
    7
    I can do that but there's something I could clarify first. The branch I was editing was actually the Sagenlicht Beta branch, and to be honest I've never actually added anything to such a large project before. Is there any type of naming convention or anything else I should stick to?(just mildly terrified of accidentally overwriting something/messing something up, all I had done was grab the source code rather than a regular git call or anything)
     
  8. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Preferred style is CamelCaseFunction, lowerCamelVars (and not pHungarian). Also prefer Var &byRef where possible.
    But to be honest we're not super consistent with either...

    Now would also be a good time to actually git your changes, of course :) I won't force you but if we're going to have more back and forths it would be more convenient.
     
  9. firemephit

    firemephit Member

    Joined:
    May 6, 2010
    Messages:
    12
    Likes Received:
    7
    Ah sorry, what I meant was would you like me to commit this as a new branch? While I was working with the beta branch I'm not sure it's actually using or dependent on it at all.
    edit: and if yes to a new branch, is it worth saying its based off the beta or just the main?
     
  10. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Ah ok, a new branch it is, yes. I don't think SL beta modifies that part of the code so it should be safe to carry over via cherry pick.
     
  11. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    August likes this.
  12. firemephit

    firemephit Member

    Joined:
    May 6, 2010
    Messages:
    12
    Likes Received:
    7
    I believe I fixed the stuck at features problem(alignment choice wasn't being set for energy channeling), but I seem to be unable to push changes(authentication failed, I've tried relogging but doesn't help). Do I need permission or should I be making pull requests for merging like the first time?
     
    Buffed Rabbit likes this.
  13. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Greay! And yes, make a PR please.
     
    Buffed Rabbit likes this.
  14. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Do you intend to do further work on this or is this more of a personal use kind of thing?
     
    Buffed Rabbit likes this.
  15. firemephit

    firemephit Member

    Joined:
    May 6, 2010
    Messages:
    12
    Likes Received:
    7
    Honestly at first it was just going to be a personal use thing. I'm not sure how much more I'll be doing with it but I'll commit and push anything I do if I think it's helpful. If you or anyone else wants to run with it or change it a bit I'm fine with that, I was mostly concerned with just getting it into a somewhat working state.
     
Our Host!