npcCommands.inc Functions
 
 

AI_Attack

Parameters
(npc, opponent, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
opponent Mobile the NPC will engage in combat with.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
This command will send an SYSEVENT_ENGAGED event to the NPC receiving the event.
Return Values
Returns 1
 

AI_ClearThoughts

Parameters
(npc, flags)
Name Type
npc The NPC that will have its event queue cleared.
flags CLR_* flag for what scripts should have their event queues cleared.
CLR_BRAIN - Clears the brain's queue.
CLR_NERVE - Clears the nerve's queue.
CLR_BOTH - Clears the queue for both.
Explanation
Clears the event queue for the script calling it and or the brain.
Return Values
Returns 1
 

AI_EndNerve

Parameters
(npc, nerve_name, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
nerve_name The key id name of the nerve to stop.
Example: "Combat", "LookAround", "Sleep"
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Used to tell the brain to stop a nerve script.
Return Values
Returns 1
 

AI_FowardEvent

Parameters
(npc, nerve_name, mask, data, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
nerve_name Name of the nerve to forward an event to.
Example: "Combat", "LookAround", "Sleep"
mask The type of event the nerve should handle the forward as.
Example: SYSEVENT_LEFTAREA, SYSEVENT_ENGAGED
data Data that the nerve will receive
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Used to send an event from one nerve to another.
Return Values
Returns 1
 

AI_Move

Parameters
(npc, object, to_from:=NEMOVE_TOWARD, speed:=NEMOVE_RUN, no_wake:=WAKEUP, loop:=0)
Name Type
npc The NPC that will receive the command.
object Item or NPC the NPC will move away from/toward.
to_from NEMOVE_TOWARD  - Will make the NPC move toward the object.
NEMOVE_AWAY      - Will make the NPC move away from the object.
speed NEMOVE_RUN   - NPC will run.
NEMOVE_WALK - NPC will walk.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
loop Number of steps for the NPC to take toward/away from the object.
Note: Loop can be interrupted and end prematurely.
Explanation
Commands an NPC to move toward / away from an object (mobile or item).
Return Values
Returns 1
 

AI_MoveXY

Parameters
(npc, x, y, to_from:=NEMOVE_TOWARD, speed:=NEMOVE_RUN, no_wake:=WAKEUP, loop:=0)
Name Type
npc The NPC that will receive the command.
x X coordinate
y Y coordinate
to_from NEMOVE_TOWARD  - Will make the NPC move toward the X Y coordinate.
NEMOVE_AWAY      - Will make the NPC move away from the X Y coordinate.
speed NEMOVE_RUN   - NPC will run.
NEMOVE_WALK - NPC will walk.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
loop Number of steps for the NPC to take toward/away from the object.
Note: Loop can be interrupted and end prematurely.
Explanation
Commands an NPC to move toward or away from an XY coordinate.
Return Values
Returns 1
 

AI_SetOpponent

Parameters
(npc, opponent, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
opponent NPC reference that will be considered an opponent.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Places the NPC into war mode and sets an opponent.
Return Values
Returns 1
 

AI_Sleep

Parameters
(npc)
Name Type
npc The NPC that will receive the command.
Explanation
Instructs the NPC to go into sleep mode.
Return Values
Returns 1
 

AI_Speak

Parameters
(npc, text, text_type:=SPEAK_TEXTTYPE_DEFAULT, do_event:=SPEAK_DOEVENT_DISABLE, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
text text_type for NPC.em
SPEAK_TEXTTYPE_DEFAULT
SPEAK_TEXTTYPE_WHISPER
SPEAK_TEXTTYPE_YELL
text_type Flags for sending a system event for speech to surrounding NPCs.
SPEAK_DOEVENT_DISABLE
SPEAK_DOEVENT_ENABLE
do_event Type
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Commands the NPC to speak.
Return Values
Returns 1
 

AI_StartNerve

Parameters
(npc, nerve_name, script_name, data, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
nerve_name String containing the name of the nerve (dictionary key).
script_name Path of the script to start.
data Data to be sent to the nerve once it starts.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Used to start a custom nerve up from within a nerve..
Return Values
Returns 1
 

AI_Turn

Parameters
(npc, turn_to, direction:=NETURN_TOWARD, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
object Item or moble reference to turn away from / toward.
direction Direction the NPC will face:
NETURN_TOWARD - Will make the NPC turn toward the object.
NETURN_AWAY - Will make the NPC turn away from the object.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Commands the NPC to face away from / toward an object.
Return Values
Returns 1
 

AI_TurnXY

Parameters
(npc, x, y, direction:=NETURN_TOWARD, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
x X Coordinate
y Y Coordinate
direction Direction the NPC will face:
NETURN_TOWARD - Will make the NPC turn toward the object.
NETURN_AWAY - Will make the NPC turn away from the object.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Commands the NPC to face away from / toward a coordinate
Return Values
Returns 1
 

AI_WakeUp

Parameters
(npc)
Name Type
npc The NPC that will receive the command.
Explanation
Sends an event to the NPC causing it to reset its idle ticks counter and leave sleep mode.
Return Values
Returns 1
 

AI_Wander

Parameters
(npc, no_wake:=WAKEUP, loop:=0)
Name Type
npc The NPC that will receive the command.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
loop Number of times to attempt to wander.
Note: Loop can be interrupted and end prematurely!
Explanation
Commands the NPC to wander one step in a random direction.
Return Values
Returns 1
 

AI_WarMode

Parameters
(npc, mode:=0, no_wake:=WAKEUP)
Name Type
npc The NPC that will receive the command.
mode 0 - Takes the NPC out of warmode and clears the opponent.
1 - Places the NPC into warmode.
no_wake WAKEUP - Will reset the NPC's idle ticks counter. If it is in sleep mode, it will wake it up.
NOWAKE - Will leave the NPC's idle counter and sleep status alone. 
Explanation
Toggles warmode on the NPC.
Setting to 0 also clears the opponent.
Note: It is probably better to do npc.WarMode(0|1)
Return Values
Returns 1