SetCommandable(int, object)

Makes NPC available for new instructions.

void SetCommandable(
    int bCommandable,
    object oTarget = OBJECT_SELF
);

Parameters

bCommandable

TRUE/FALSE boolean argument.

oTarget

Object to set commandable. (Default: OBJECT_SELF)


Description

Set whether oTarget's action queue can be modified.



Remarks

PC's cannot actually add more actions, however, if actions with icons (EG: Casting Magic Missile) are queued and not cancled, then the PC will still cast them (Same for NPC's) but more importantly, can cancle them.

Therefore, making them do an action, and using SetCommandable to force it, is not sure-fire. The state of a PC (Dead/dying) has no effect on weather SetCommandable can be set or not.


Known Bugs

ActionMoveToLocation ignores the commandable state of the creature given the action. Thus, the ActionMoveToLocation action is added to the end of non-commandable creatures' action queues.


Version

1.61

Example

// this first clears oUser's action queue, 
// then assigns them an animation to play.  
// then, to insure that they do not just 
// click to move away and cancel the animation, 
// we take their ability to modify their 
// action queue away from them.  4.8 seconds 
// later, we return command of their action 
// queue to them again, allowing them to do 
// what they want or their AI dictates.

object oUser = GetLastUsedBy();
AssignCommand(oUser,ClearAllActions());
AssignCommand(oUser,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
DelayCommand(0.2,SetCommandable(FALSE,oUser));
DelayCommand(4.8,SetCommandable(TRUE,oUser));

See Also

functions: AssignCommand | GetCommandable
categories: Miscellaneous Functions


 author: Jody Fletcher, editor: Jasperre, additional contributor(s): Jason Hyde, Lilac Soul, Jasperre
 Send comments on this topic.