HorseGetCanBeMounted

From NWN Lexicon
Jump to: navigation, search


HorseGetCanBeMounted(object, object, int)

Check whether an object can be mounted.

int HorseGetCanBeMounted(
    object oTarget,
    object oRider = OBJECT_INVALID,    
    int bAssignMount = FALSE
);

Parameters

oTarget

The object to be mounted.

oRider

If specified, the rider who will mount. (Default: OBJECT_INVALID)

bAssignMount

If TRUE, the function will ignore whether someone can mount a horse in the area or not. This allows the script to check whether assignment is legal, even if mounting isn't. (Default: FALSE)


Description

This function will return TRUE if the target can be mounted.

If a rider is specified, it will also make sure that the target can be ridden by the rider.



Remarks

Similar to HorseGetMountFailureMessage to discover why a horse can't be mounted.

By design, this function does not check that the rider has the Mount Actions feat, in order to leave the system open to customizations that don't use the standard feats. Since the module builder determines which creatures are scripted, this is only a problem if you issue a command to an invalid creature by mistake. If necessary, you can check for Mount Actions separately, as shown in the example.

The option to check whether assignment is legal assumes that both horse and rider are in the same area.


Known Bugs

The function doesn't check whether the horse already has an owner (unless it's a Paladin mount).

When checking whether assignment (only) is legal, the function returns FALSE if the rider is a mounted PC. This is clearly wrong, because a mounted PC is allowed to have other assigned horses. Also, it does not recognize that a henchman's horse can be reassigned to a PC.


Requirements

#include " x3_inc_horse "

Version

1.69

Example

// Check that an NPC has the Mount Actions feat and can ride a particular horse.
 
#include "x3_inc_horse"
void main()
{
  object oNPC = GetObjectByTag("enter NPC tag here");
  object oHorse = GetObjectByTag("enter horse tag here");
 
  if(HorseGetCanBeMounted(oHorse))
  {
    if(GetHasFeat(FEAT_HORSE_MENU,oNPC)) 
    {
      AssignCommand(oNPC, HorseMount(oHorse));
    }      
  }
}

See Also

functions: 

HorseGetMountFailureMessage



author: Proleric, editor: Mistress