Adding A New PartyBar UIObject_OnUpdate_XXXX Section?

Does anybody know how to add another UIObject_OnUpdate_XXXXX type section to the Party Bar, so that we can add our own overlay should we want to?

E.g. When a PC goes up a level, they get a “+” sign on the portrait. Or if they die, they get the “death” overlay. The leader has a little “crown” image, etc.

Having looked at the code, I can add the section easily enough, but I do not know how to differentiate between the PCs in the party line up. Each call in the XML code (of which I can see four by default) all use a direct “UIObject_OnUpdate_XXXXX” type call, which I am guessing is probably hard-coded. However, I wondered if there was another method to apply the new overlay I have drawn by some similar or other means?

Thanks in advance.

hey Lance,
unfortunately we can’t just code our own gui-functions. All we can do is ExecuteScript i think.

the fundamental problem to overcome, perhaps, is how to determine which character is positioned where on the partybar.

If that could be done, I believe an invisible overlay could be added (either prototyped or covering the entire partybar area) with hidden labels/icons, then an OnUpdate call could be made to UIObject_Misc_ExecuteServerScript() that tests if a given character is, eg. in combat, resting, etc.

The script would then hide/unhide a label/icon over the character’s portrait accordingly …

eg

    OnUpdate='UIObject_Misc_ExecuteServerScript("gui_target_info_update")' update="true" updaterate="0.3"

/thoughts

EDIT: the script would go like,

    if (char.isResting)
    {
        show(ui_element)
    }
    else
    {
        hide(ui_element)
    }

right, just read that. Neither do i  :)

1 Like

Hi KevL.

What you had there was very similar to what I tried, but I could only ever have the overlay (which worked fine) appear on the Main PC. I could never get the call to distinguish between the PCs in the list. It’s as if you have to do that kind of call with a dedicated XML type function, which the ExecuteServerScript version is unable to accommodate. :frowning:

I am going down the spell effect icon route now (unless this path is ever resolved) and have a post here asking if players had any preferences: Preferences - AI Feedback Icon

Cheers!

more thoughts:

you could try something semi-ridiculous like using UIText_OnUpdate_DisplayTargetObjectName() to print the character’s name to a textbox (invisible I guess), then try to read it immediately afterward w/ UI_Object_Misc_ExecuteServerScript()

but that approach strikes me as pretty dicey, if at all possible … ie, I don’t see a function for GetGUIObjectText()

 
stepping back, we can take it for granted that party-members are added to the partybar in an order. I’m guessing it’s (strongly) related to the order in which they joined the party. But (trying to) determine/track such … /meh

(i suspect that, to even approach robustness, the party would have to be dissolved and re-added on every transition, etc. incl/ dealing with Companions, Associates, to the point of “not worth it”)

 
that said, the AI icons would be nice

 
applying a custom spell w/ custom spell effect icon seems okay … perhaps not as obviously as an overlay on a portrait tho /shrug

but do what ya gotta do – maybe someone can resolve this (determine which character belongs to which portrait on the partybar).

that’s odd… i suspect it could be overcome somehow… and i believe it’s of only secondary importance to this:

1 Like

You have gone through the same thought processes and come to the same conclusions as I did … :slight_smile:

While parking the “on the portrait” idea as a nice to have (for now), maybe you can help give me some pointers for the spell icon idea? …

Obviously, the icon that indicates AI is on is just that … simply an icon. However, at the moment I am having trouble attaching it to the PC and it may be because I have to apply some sort of effect. I have just tried an instant VFX (permanently), but that did not attach it (and now I see it was because I can only attach instant ones as an instant effect probably)… and so will not try a permanent VFX - however, I need to be somewhat choosy here, because I do not want to add a VFX that detracts/clashes while playing.

Bottom line, any way to add an effect icon without any actual “real” effect?

EDIT: Changing from an instant to a permanent VFX does nothing - In fact, at least the instant showed its VFX, even though it did not apply the AI icon. A permanent VFX (like barkskin) did nothing as far as I could see.

// AFW-OEI 02/13/2007
// Returns an effect that adds an effect icon to a character portrait.
// * nEffectIconId comes from the effecticon.2da
effect EffectEffectIcon(int nEffectIconId);

note: Typo, should be EffectIcons.2da

void main()
{
    object oTarget = ; // whatever
    if (GetIsObjectValid(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
    {
        effect eIcon = EffectEffectIcon(2); // Regenerate icon
        eIcon = SetEffectSpellId(eIcon, 12345); // custom spellId
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eIcon, oTarget);
    }
}

 
then run a script that removes effect-id when player clicks off his/her ai

2 Likes

Ah!

So are you saying that if we pass an effectively null spell ID (even if its a script that simply sends a bit of test saying AI enabled or something), that it will stay attached?

Also, I found that an instant VFX does work, as long as there was an effect that applied at the same time. If you say the spell id may work as an alternative (which I will now try), then great! That may be the answer.

I will test that now and come back to you with results … unless you post to add anything more first. :slight_smile:

RESULT! :slight_smile: Well done mate! … All PCs show the small AI icon meaning AI is on!

2 Likes

sweet  :)

oh, you should probably make it Supernatural (!)

1 Like

I have made it both supernatural and extraordinary so nothing will remove it until we want it removed. :slight_smile:

And having just tested further, I did not know we could pass any spellID, even anything not used (for example I passed -1005 to match my effect icon ID number and that it would still work. I know I have done things similar to this before (including the drow light effect), but it still caught me by surprise!

Now to sort out its purpose!

EDIT: The basic idea is that it will be easier to tell which PCs you are allowing AI to control and which you are controlling - but I guess you probably knew that already. :wink:

Thanks again!

1 Like

The effect subtypes are mutually exclusive. Extraodinary effects cannot be dispelled, but are removed when resting. Supernatural effects cannot be dispelled and cannot be removed by resting.

2 Likes

Goodness me - Really!? :open_mouth:

I guess that means I will need to re-examine a few other scripts then as well.

Thanks for the heads up.

Yep, see GetEffectSubType():
https://nwnlexicon.com/index.php?title=GetEffectSubType

Returns one of three subtype constants (SUBTYPE_*). An effect applied to an object will default to being of the Magical variety, but by using the other apply effect commands you can place supernatural or extraordinary effects on an object.
Return a 0 on error.

int    SUBTYPE_MAGICAL          = 8;
int    SUBTYPE_SUPERNATURAL     = 16;
int    SUBTYPE_EXTRAORDINARY    = 24;
1 Like

Good to know!

I had one other script where I had applied both, not realising this fact!

Thanks again!

EDIT: I am going to try to add the facility to right-click toggle AI on a PC.

UPDATE: I did manage to add it to the right-click menu, but decided to opt for the simpler double right-click portrait to toggle the individual AI. This is because the other option added the toggle to henchmen as well, which cannot have this AI toggle.