Difference between revisions of "EnterTargetingMode"

From NWN Lexicon
Jump to: navigation, search
m (Remarks)
Line 22: Line 22:
  
 
===Remarks===
 
===Remarks===
The "targeting" can be cancelled by the player, it is not guaranteed to run [[OnPlayerTarget]].
+
The [[OnPlayerTarget]] script will run whether the player targeted a valid object or manually exited targeting mode.
  
 
Since the [[OnPlayerTarget]] event won't know what script / reason that has occurred, it is suggested to track this from a standard integer stored on the player entering the targeting mode, eg: a "TARGET_MODE_ID" which then loads the appropriate response.
 
Since the [[OnPlayerTarget]] event won't know what script / reason that has occurred, it is suggested to track this from a standard integer stored on the player entering the targeting mode, eg: a "TARGET_MODE_ID" which then loads the appropriate response.
  
The nValidObjecTypes can be OR'ed together, so that a list can be produced of all the valid types eg:
+
The nValidObjecTypes can be bitmasked together so that a list can be produced of all the valid types eg:
  
 
<nwscript>
 
<nwscript>
Line 33: Line 33:
  
 
OBJECT_TYPE_TILE is a new constant used solely in this function that counts as "the ground".
 
OBJECT_TYPE_TILE is a new constant used solely in this function that counts as "the ground".
 +
 +
The targeting cursor will appear disabled (gray-colored) when targeting an object that is under a chat window, however, players can successfully target through the chat windows.
  
 
===Version===
 
===Version===

Revision as of 06:32, 11 February 2021

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.

Makes oPC enter a targeting mode, letting them select an object as a target.

void EnterTargetingMode(
    object oPC,
    int nValidObjectTypes = OBJECT_TYPE_ALL,
    int nMouseCursorId = MOUSECURSOR_MAGIC
);

Parameters

oPC
The player to enter targeting mode.
nValidObjectTypes
An OBJECT_TYPE_* constant specifying the type of object to target.
nMouseCursorId
The mouse cursor id to use.

Description

Makes oPC enter a targeting mode, letting them select an object or location as a target.

If a PC selects a target, it will trigger the module OnPlayerTarget event.

Remarks

The OnPlayerTarget script will run whether the player targeted a valid object or manually exited targeting mode.

Since the OnPlayerTarget event won't know what script / reason that has occurred, it is suggested to track this from a standard integer stored on the player entering the targeting mode, eg: a "TARGET_MODE_ID" which then loads the appropriate response.

The nValidObjecTypes can be bitmasked together so that a list can be produced of all the valid types eg:

EnterTargetingMode(oPC, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);

OBJECT_TYPE_TILE is a new constant used solely in this function that counts as "the ground".

The targeting cursor will appear disabled (gray-colored) when targeting an object that is under a chat window, however, players can successfully target through the chat windows.

Version

This function was added in 1.80.8193.14 of NWN:EE.

Example

Information icon.png This article is in need of examples. You can help the NWN Lexicon by showing how to use this code effectively.

See Also

functions: GetTargetingModeSelectedObject() GetTargetingModeSelectedPosition() GetLastPlayerToSelectTarget()



 author: Shadguy