HorseDismount(int, int)

Action - Dismount from horse.

object HorseDismount(
    int bAnimate = TRUE,
    int bSetOwner = TRUE
);

Parameters

bAnimate

If TRUE, the dismount is animated.

bSetOwner

If TRUE, the caller becomes the owner of the horse, which is assigned for mounting. Otherwise, ownership and assignment are removed.


Description

This function will cause the caller to dismount if it is mounted. It returns the new object that is the dismounted horse.



Remarks

This is an Action which must be added to the caller's queue. As with all Actions, it is not executed immediately.

Since it returns an object, AssignCommand requires it to be wrapped in a null action that accepts an object as a parameter (see example for one way to do this).

If your script requires the horse to do something after dismounting, you need to remove ownership, otherwise henchman AI will take control of the horse.

Check that the caller is mounted before using this function. Otherwise, no harm will result, but if the caller is a PC they will receive a slightly cryptic message, e.g. "Error resref missing".

In cutscenes, time must be allowed for the animation to complete. The default is HORSE_DISMOUNT_DURATION.

It's wise to allow another second or two for action queue lag etc. Really strange bugs can occur if your script doesn't wait long enough for dismounting to complete before pressing on with the action, because this function manages fragile AI switches.

If you over-ride the defaults, the formula is (HORSE_DISMOUNT_DURATION + fX3_MOUNT_DELAY) * fX3_MOUNT_MULTIPLE.


Requirements

#include "x3_inc_horse"

Version

1.69

Example

// Dismount and store the horse object.
// As this is an action, the variable MyHorse will not be set immediately.
// Allow time for the action to complete before referring to it.
#include "x3_inc_horse"


void main()
{
   object oPC = GetEnteringObject();

   AssignCommand(oPC, SetLocalObject(oPC, "MyHorse", HorseDismount()));
}

See Also

functions:  HorseInstantDismount | HorseSetOwner | HorseMount | HorseGetIsMounted
categories:  Horse Functions


author: Proleric, editor: Mistress