HorseGetMyHorse(object)

Retrieves an object's assigned horse.

object HorseGetMyHorse(
    object oRider
);

Parameters

oRider

The object whose assigned horse is required.


Description

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.



Remarks

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.


Requirements

#include "x3_inc_horse"

Version

1.69

Example

// 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);

  if(!GetIsObjectValid(oHorse))
  {
    oHorse = HorseGetHorse(oPC);
  }

  if(GetIsObjectValid(oHorse)) 
  {
    AssignCommand(oPC, HorseMount(oHorse));
  }
}

See Also

functions:  HorseGetHorse | HorseGetOwner | HorseGetPaladinMount
categories:  Horse Functions


author: Proleric, editor: Mistress