SetObjectHiliteColor( object, int )

From NWN Lexicon
Jump to: navigation, search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.
Overrides the mouse-over (“hilite”) colour on objects.
void SetObjectHiliteColor(
    object oObject,
    int nColor
);

Parameters

oObject
The object to update hilite colors.
nColor
The color hilite to apply to the object.

Description

Sets oObject's hilite color to nColor. The nColor format is 0xRRGGBB; -1 clears the color override.

Remarks

The effect is game-wide. For singleplayer or co-op modules this means it is easy to show or hide information as required for certain objects. An example is provided in the script section.

For multiplayer it applies to everyone, so could be used for team colours in a PvP mode, but is less useful for hiding information - would another player know a certain chest is empty? Instanced dungeons which are more common in NWN:EE tend to alleviate this.

Black (or 0x000000) is considered "off" and basically removes the highlight entirely.

It is also important to know the default colours can be changed by players in the game options - this is done by those with colour blindness. Other than toggling the colour off, you might want to be careful to allow some of the colours set - if used for gameplay features such as "treasure hunts" or "puzzles" - by the player in a special menu so they can complete such things properly.

Version

This function was added in 1.80.8193.14 of NWN:EE.

Example

// OnClosed script for placeables
 
// This will turn a placeables hilite colour off (set to black) if
// it is emptied. This makes it easier to see unsearched chests.
// An alternative change can be to set the colour to something else
// if there are items left, because a PC has opened it at least once.
 
// Better for singleplayer/co-op or instanced MP areas.
 
const int DARK_BLUE = 0x0000FF;
const int DARK_RED = 0xFF0000;
const int DARK_GREEN = 0x00FF00;
const int BLACK = 0x000000;
const int WHITE = 0xFFFFFF;
 
void main()
{
    // If empty set to "all empty" colour
    if(!GetIsObjectValid(GetFirstItemInInventory(OBJECT_SELF)))
    {
        SetObjectHiliteColor(OBJECT_SELF, BLACK);
    }
    else
    {
        // Else reset to default highlight
        // Alternatively change -1 to a colour to mark it as "searched but still has items in it"
        SetObjectHiliteColor(OBJECT_SELF, -1);
    }
}

 author: Shadguy