Saturday, July 14, 2012

Working around hardcoding

Obsidian unfortunately left some things hardcoded that I'd like to access. Namely, pickpocket and the set/remove trap skills. These skills can be accessed via the context menu. Looking into the context menu, the options for the buttons include the ExecuteServerScript function. Does that mean it should be possible to run our own scripts there by replacing the standard call to UIRadialNode_OnInit_UseSkill(int,int) with UIObject_Misc_ExecuteServerScript("gui_mystuff")?

The UIRadialNode_OnInit_UseSkill ultimately activates a call to the UseSkill function, which is hardcoded and unavailable.If UseSkill could be recreated, we could simply route calls to it to our own version. Unfortunately, there's no where to get this. Even nwnx doesn't seem to have it. It would not be necessary to recode the entire function, even specific functions for the individual skills we'd call would be sufficient.


  1. I did a very little bit of xml tweaking but I did get a script to fire in the levelup gui. And I found you can have multiple scripts fire.

    Below is the example that I did when clicking the finish button on leveling up. Click = the hardcode apply the level, Click0 = is Kaedrin script and modification for his classes and Click1 = Is my script for leveling a half-fiend/celestial.

    <UIButton name="CHOICE_FINISH" strref="113712" x="336" y="0" style="STYLE_MENU_BUTTON_SML"
    OnLeftClick=UIButton_Input_CharGenCommit("LEVELUP","CHARGEN_FINISH") OnLeftClick0=UIObject_Misc_ExecuteServerScript("gui_ccs_player_levelup") OnLeftClick1=UIObject_Misc_ExecuteServerScript("gui_jezzebel_lvlup")

    So I guess it may be possible to add you own script and either keep or remove the hardcode line. I think this is going to involve a lot of trial and error as there is little documentation. Lance should be able to give you a bit more information as well.

  2. Hi Kamal,

    Trying to edit around hardcoded stuff is quite difficult, even when we can edit the XML files. The reason being, even if we add/alter the XML line that makes the hardcoded call to our own software call, we then need to do all the coding for the call in question. i.e. You would need to write the entire thing from scratch, and the likelihood is you will not catch everything you need to consider that the hard-coded stuff does "automatically".

    That said, without looking at this more closely, I would not like to say just how well one could edit a "skill" like this and have it work.

    Sorry I could not be of more help. There are still a couple more guru's out there who may be able to suggest something more, but I am not sure if the amount of work required will justify the final result.


  3. I don't think writing a pickpocket function would be too terrible an undertaking. It is a relatively simple check. My random pickpocket loot system (and traps in pockets for the careless thief) require access to pickpocket scripting. It sounds like I should put this idea aside for now, and come back to it once everything else is up and running and I have testers.