From NWN Lexicon
Jump to: navigation, search


Retrieves an object's assigned horse.



The object whose assigned horse is required.


When dismounted, this function returns the horse currently assigned to the rider (OBJECT_INVALID if there is none).

In certain script hooks (pre-mount, post-mount and post-dismount), the function returns the horse that is currently being mounted / dismounted.

This function should not be used when the rider is mounted, or in a pre-dismount script hook.


Remember, it is possible for a character to own a horse, but have none assigned.

So, if you just want to refer to a horse which the character owns, it's simpler to use HorseGetHorse.

When dismounted, this function allows you to respect the precise horse assignments which the player may have made. The example shows how to give priority to the assigned horse; if there is none, the first horse owned is used instead.

For example, if a henchman has a warhorse and a pack horse, you might want to allow the player to specify which horse is mounted.

The function will give a meaningless result in the prohibited situations, because a PC can choose to mount a horse which is not their assigned horse. Technically, the new horse doesn't become the assigned horse until the PC dismounts - it doesn't exist as an object while mounted. When the rider is mounted, and in a pre-dismount script, the function may return OBJECT_INVALID or some other horse that was assigned in the past.


#include " x3_inc_horse "




// This example actions the PC to mount their assigned horse (if there is one)
// or else the first horse (if any) that they own.
#include "x3_inc_horse"
void main()
  object oPC    = GetPCSpeaker();
  object oHorse = HorseGetMyHorse(oPC);
    oHorse = HorseGetHorse(oPC);
    AssignCommand(oPC, HorseMount(oHorse));

See Also



author: Proleric, editor: Mistress