HorseCreateHorse(string, location, object, string, int, int, int, string)

Create a horse.

object HorseCreateHorse(
    string sResRef,
    location lLoc,   
    object oOwner = OBJECT_INVALID,    
    string sTag = "",    
    int nAppearance = -1,
    int nTail = -1,
    int nFootstep = -1,
    string sScript = ""



The template resref of the horse to be created.


The location at which the horse will be created.


If specified, the creature who will own the horse.


If specified, the horse will have this tag instead of the resref default.


If specified, the horse will have this appearance type when dismounted.


If specified, this tail type determines what the horse looks like when mounted.


If specified, the horse will have this footstep type sound when moving.


If specified, this script will execute on the horse after spawning.


This function will create a horse using the resref at the specified location.

It returns the object id of the horse that was spawned.

The remaining parameters can be set to non-default values to customize the horse.

This function is set up the way it is so that you could potentially use a single blueprint to store multiple appearance horses.


It's safer to use this function for horses, rather than CopyObject, because it sets the horse system variables for the new horse cleanly.

The horse is created with no owner, unless one is specified.

If an owner is specified, the horse becomes owned, but is not assigned.

If you want the horse to be assigned for mounting, you can call HorseSetOwner after this function has created the horse.

The option to specify appearance, tail and footsteps will normally only be required for custom models.

Using the pre-defined appearance and tail constants for creatures that are not horses may have bizarre results.

For example, you can create a horse with a dragon appearance using a horse resref, but when mounted it will still look like a horse, unless a custom tail model is provided.

Similarly, if you use a dragon resref without a custom tail model, the creature will be invisible when mounted.

Known Bugs

The tail parameter doesn't work as specified. Instead, you can set the local integer X3_HORSE_TAIL on the horse after using the function.


#include "x3_inc_horse"




// An existing horse with a tag of "HorseTemplate" is used to create a new horse 
// with a tag of "NewHorse" near the PC, who becomes the owner of the new horse.
#include "x3_inc_horse"

void main()
   object oPC    = GetPCSpeaker();
   object oHorse = HorseCreateHorse(GetResRef(GetObjectByTag("HorseTemplate")), GetLocation(oPC), oPC, "NewHorse");

See Also

functions:  HorseInstantMount | HorseSummonPaladinMount | HorseSetOwner
categories:  Horse Functions

author: Proleric, editor: Mistress