Recommended Posts

Is it possible to program gui events, for example when i switch character in inventory menu, can i attach some script to this action?

Share this post


Link to post
Share on other sites

As far as I know, the party selection screen is the only GUI to have something like that, but even then only when opened via script in the first place (the ShowPartySelectionGUI function allows you to define an exit script).

Share this post


Link to post
Share on other sites

I have some exp with Dragon Age Origins modding, some things in Kotor not equal, but very similar. In DAO almost on every action (open inventory, cast spell, attacking) firing some event, you can hook that event and add some custom code to it, which exeute every time when this event fires. Something similar here? https://nwn.fandom.com/wiki/Module_event something similar in nwn if i understand it right, dont have exp with nwn. Cant find something like this in kotor scripts.

Edited by DiePutinDie

Share this post


Link to post
Share on other sites

A module's IFO has provision for specifying OnXYZ event scripts for most of those, although I don't know how many of them actually function aside from the specific module events, since most are left blank in the vanilla modules. Odyssey has a lot of leftover Aurora (NWN) stuff.

Share this post


Link to post
Share on other sites

Pretty sure they're all dummied NWN hooks, but it would be pretty funny if they worked all along and no-one had ever checked.

Okay, so I went and tested them just to be sure, and they do actually work if you put a script in them. Minus the ones which obviously can't trigger in KotOR like the multiplayer ones, anyway.

It'd be a bit of a pain to fill them up for every module to get consistent behaviour, but this is actually a pretty big deal in terms of what new feats can be added. The onPlayerLevelUp hook especially.

But this doesn't really help the OP, because there's very little GUI stuff in there.

  • Like 1

Share this post


Link to post
Share on other sites
Spoiler

1.png

I found script which probably do what i want - k_hen_leadchng.ncs, im sucessfully decompiled it and add AdjustAlignment function just to test its working. Do you know more polished way to do such tests? Some logging maybe? PrintString in nwscript.nss? Is it possible to turn on logging?

Spoiler

2.png

 

 

Edited by DiePutinDie

Share this post


Link to post
Share on other sites
5 hours ago, TamerBill said:

Pretty sure they're all dummied NWN hooks, but it would be pretty funny if they worked all along and no-one had ever checked.

Okay, so I went and tested them just to be sure, and they do actually work if you put a script in them. Minus the ones which obviously can't trigger in KotOR like the multiplayer ones, anyway.

It'd be a bit of a pain to fill them up for every module to get consistent behaviour, but this is actually a pretty big deal in terms of what new feats can be added. The onPlayerLevelUp hook especially.

But this doesn't really help the OP, because there's very little GUI stuff in there.

Wait, so if you were willing to edit every relevant module (which might be all of them), you could add additional scripts to specific locations and events? That does feel huge.

 

Off the top of my head you could...

Add AOE damage on story relevant location (The Ravager, poison rooms, etc.)

Send the PC to jail/or healing room on a death event

Turn NPCs hostile if you are wielding certain items (Red lightsabers, Revan robes, Jedi Robes, etc.) in specific areas

 

 

Share this post


Link to post
Share on other sites
4 hours ago, DiePutinDie said:

Some logging maybe? PrintString in nwscript.nss? Is it possible to turn on logging?

No. The debug features require the debug build. We have the shipping build in which all the debug features were stripped out. However, there is the SendMessageToPC function, which pipes strings to the in-game message window. You can make use of this for script debugging functionality, although the message window buffer is very small, so during combat especially you will find your messages quickly disappear. Armbands that provide location info (like the WhereAmI armband) are a good example of the use of SendMessageToPC. You can also edit the various debug include functions and switch out their use of PrintString/AurPostString to use SendMessageToPC, then recompile the target script/s.

  • Like 1

Share this post


Link to post
Share on other sites

Another question,  i suppose its impossible, but asking anyway just for sure. Im using DestroyObject and CreateItemOnObject functions in script and every time when they firinfg there is shows popup window in game "item received" and "item lost", is there anyway not to show this window in certain case? Maybe there is another functions with similar functionallity, but without popup window?

Share this post


Link to post
Share on other sites
10 hours ago, DarthParametric said:

Not in K1. You can in TSL, since Obsidian added an extra variable for suppressing those messages.

 Create container, create item in container, give item to char, destroy container. Ugly, but working)

Share this post


Link to post
Share on other sites

You'll still see UI notifications and feedback messages for gained/lost items. If it is really important and it involves a party member, you can temporarily remove them from the active party to do whatever you need, then add them back. Although typically you want to do this under a fadeout/during a cutscene.

Share this post


Link to post
Share on other sites
22 hours ago, DiePutinDie said:

Another question,  i suppose its impossible, but asking anyway just for sure. Im using DestroyObject and CreateItemOnObject functions in script and every time when they firinfg there is shows popup window in game "item received" and "item lost", is there anyway not to show this window in certain case? Maybe there is another functions with similar functionallity, but without popup window?

21 hours ago, DarthParametric said:

Not in K1. You can in TSL, since Obsidian added an extra variable for suppressing those messages.

The way to do it in K1 is to call SuppressStatusSummaryEntry before the creation or destruction.

// 763. SuppressStatusSummaryEntry
// This will prevent the next n entries that should have shown up in the status summary
// from being added
// This will not add on to any existing summary suppressions, but rather replace it.  So
// to clear the supression system pass 0 as the entry value
void SuppressStatusSummaryEntry(int nNumEntries = 1);

For example:

SuppressStatusSummaryEntry();
CreateItemOnObject("g_w_lghtsbr01");
  • Like 4
  • Light Side Points 1

Share this post


Link to post
Share on other sites
3 hours ago, DarthParametric said:

You'll still see UI notifications and feedback messages for gained/lost items. If it is really important and it involves a party member, you can temporarily remove them from the active party to do whatever you need, then add them back. Although typically you want to do this under a fadeout/during a cutscene.

Nope, with this code, no messages, no notifications. I ve tested it already. But JCarter's way is better i suppose.

UPD

Tested

SuppressStatusSummaryEntry();

No notifications, but text about item aquired or item lost appears in log, with my ugly hack there is no entries in log, if that important for anyone.)

Spoiler

1.png.e9cbc23527ec7fdb04c4dbd7efe20af8.png

 

Share this post


Link to post
Share on other sites

Yes, GiveItem does not seem to prompt any feedback or status summary whatsoever. That is what I used for my Vision Enhancement to unequip and reequip the player's clothing and headgear. I found a few cases of this in game code as well.

I thought I had learned of SuppressStatusSummaryEntry from reading game code, but I've looked and I haven't been able to find a single use of it in either game.

Share this post


Link to post
Share on other sites
On 5/11/2022 at 12:12 AM, TamerBill said:

Pretty sure they're all dummied NWN hooks, but it would be pretty funny if they worked all along and no-one had ever checked.

Okay, so I went and tested them just to be sure, and they do actually work if you put a script in them. Minus the ones which obviously can't trigger in KotOR like the multiplayer ones, anyway.

It'd be a bit of a pain to fill them up for every module to get consistent behaviour, but this is actually a pretty big deal in terms of what new feats can be added. The onPlayerLevelUp hook especially.

But this doesn't really help the OP, because there's very little GUI stuff in there.

I ve try to put script in module for testing, but no success. What am i doing wrong? I ve edited module.ifo file, is it right? Then i packed module.ifo back in rim file with ERFEdit. And put rim file in override folder with script.

Spoiler

2.png

Spoiler

1.png.203c0f84ea695267bff8f9deff684b8c.png

 

Share this post


Link to post
Share on other sites
3 hours ago, DiePutinDie said:

And put rim file in override folder with script.

Module rims have to go in the Modules folder I believe, not the Override.

Oh yeah, and onPlayerLevelup will apparently only trigger on the PC's level-ups, not other party members. So, temper your expectations there, it's not as good as I thought.

  • Sad 1

Share this post


Link to post
Share on other sites
50 minutes ago, TamerBill said:

Module rims have to go in the Modules folder I believe, not the Override.

Oh yeah, and onPlayerLevelup will apparently only trigger on the PC's level-ups, not other party members. So, temper your expectations there, it's not as good as I thought.

Put it in modules folder, not working. Can you tell me how you test this step by step?

Share this post


Link to post
Share on other sites
1 hour ago, DiePutinDie said:

Put it in modules folder, not working. Can you tell me how you test this step by step?

Don't think I did it fundamentally differently from you, but sure, here's what I did.

- KotorTool, RIMS, Modules, tar_m02aa.rim, module.ifo -> Extract file.

- K-GFF, open module.ifo, Mod_OnPlrLvlUp, change the Value to onLevelUp (I put unique values in all of the slots so I could check each one, just 'test' is fine too).

- Save. K-GFF does not manually prompt you to save, so double-check that.

- ERFEdit, open KOTOR /modules/tar_m02aa.rim

- Drag module.ifo onto the window, say Yes to replacing it.

- Save. This is not best practice, as JCarter said, but I have the module folder backed up so it doesn't hurt me.

- KotorTool, Text Editor, write something I can easily check, save it as onLevelUp.nss and compile. I go with GiveGoldToCreature(getFirstPC(), 1) traditionally since you get the obvious popup.

- Put the compiled onLevelUp.ncs in the Override.

- Load the game, load my save in Taris South Apartments.

- Level up the PC, receive 1 credit. 

- (Level up Carth, get no credits, get annoyed and scrap your nascent plans)

  • Thanks 1

Share this post


Link to post
Share on other sites

Guys, what about *.gui files (inventory.gui etc). In DAO there be gfx files for ui and it is possible to decompile it and programming on ActionScript (yeah flash). Some alternative in Kotor maybe? Some tools?  I found NWN explorer it tells that its tool can decompile gui files, but it needs nwn installation that i dont have.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.