Aller au contenu

Photo

Intercept hardcoding via editing the contextmenu.xml?


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
kamal_

kamal_
  • Members
  • 5 260 messages
Obsidian unfortunately left a number of things hardcoded. Things I'd like to have access to, like pickpocket and remove/set traps. Fortunately, these are abilities that are accessed via the context menu (what pops up when you right click on something). It looks like I could write a custom script and access it via UIObject_Misc_ExecuteServerScript("gui_mystuff"). Is this possible? If so how? Where does the script go? I tried a generic hello world type script in my campaign folder, but it did not get executed.

Edit: I want to intercept calls to pickpocket scripting itself, so I can send calls to the standard pickpocket script with my own scripting. I don't want to edit OnInventoryDisturbed scripts. (This will allow me to do some neat things.) So I'm looking at overriding calls to sleight of hand when accessed via the context menu right click on npcs. Same goes for remove/set trap functionality.

Modifié par kamal_, 15 juillet 2012 - 01:59 .


#2
kevL

kevL
  • Members
  • 4 078 messages
it sounds entirely possible, Kam_

and the script should work from Campaign folder, though as you know there are vagaries: one of them is that a variable_object has to be passed from the Gui to the script as an _int

In the .Xml:

OnLeftClick='UIObject_Input_ActionTargetScript("creature",29,31,0,"TRUE","gui_script_1","target:object")'

In "gui_script_1":

void main(int iTarget)
{
// GUI SENDS OBJECT AS AN INT
object oTarget = IntToObject(iTarget);
}

- strings might also work, not sure.

But I haven't done much else with variables in .Xml files. The simpler

OnLeftClick='UIObject_Misc_ExecuteServerScript("gui_script_1")'

may work well for ya if the right .Xml element is found ... the only two sources of information i found are Lance's tutorial and "Obsidian Programmer"s website.

#3
kamal_

kamal_
  • Members
  • 5 260 messages
Yeah, I saw and looked through Lance's tutorial and the Obsidian Programmer. I couldn't find anything relevant, maybe I missed it? I've never done any XML/Gui coding, so I'm not sure how to go about it. My initial attempt did stop the original activity (attempt pickpocket) from happening, but did not seem to run my script (just sending a message to player saying "testing pickpocket script").

#4
kevL

kevL
  • Members
  • 4 078 messages
I'm surprised,
getting the 'ExecuteServerScript' to fire was a lot simpler than i thought it would be


it's gotta be .. one of those toopid things.

OBJECT_SELF is always the PlayerCharacter, i think, and don't forget:

scriptloadable="true"

up at the top in UIScene - though i'm not sure if that means the Gui can be loaded by a script or the Gui can fire off a script ....

#5
MasterChanger

MasterChanger
  • Members
  • 686 messages
Many people have overriden the context menu specifically. I would look at some examples from Heed's and/or KEMO's PC tools or from Kaldor's context menu implementation of M. Rieder's selective transparency for PCs.

One of the most annoying things about XML files for NWN2 is that any error will completely prevent the GUI from working. I had talked a while ago with Zebransky about whether it would be possible to create a system that gives you feedback on which line the error is on, but that never really went anywhere.

Grinning Fool also has a reference set up of all the available functions. There aren't any comments in this resource, so it's sometimes hard to make sense of.

Also be aware that there are other ways to access some things on the context menu. Active skills such as Sleight of Hand, Heal, Taunt, etc. can be dragged to the quick bars.

I know that overriding pickpocket behavior is something that has been done through NWNX. Maybe it's time to check in with Pain about the progress for making NWNX4 work seamlessly for single-player?