File: NPC.em
Description: Functions for manipulating non-player character mobiles. All (most?) these functions are limited to use in an NPC context (meaning an AI script).
Last Modified: 2/11/2003
GetProperty( propertyname ) |
---|
Parameters: |
---|
Name | Type |
propertyname | String |
Explanation |
---|
Deprecated. Equivalent to GetObjProperty( Self(), propertyname ) |
Return values |
---|
An unpacked object. See GetObjProperty in UO.EM |
Errors |
---|
"Property not found" |
"Invalid parameter type" |
Related |
---|
NPC |
IsLegalMove( move, boundingbox ) |
---|
Parameters: |
---|
Name | Type |
move | String, one of N, S, E, W, NW, NE, SW, SE |
boundingbox | Bounding box, from CreateBoundingBox |
Explanation |
---|
Given your position, and a tentative move, would it fall within a bounding box |
Return values |
---|
0 on invalid parameter, or illegal move. 1 on legal move |
Related |
---|
NPC |
MakeBoundingBox( areastring ) |
---|
Parameters: |
---|
Name | Type |
areastring | String, see explanation |
Explanation |
---|
Make a bounding box from an area string. An area string is a number of 'x1 y1 x2 y2' world coordinate entries. |
"1 1 4 4 2 5 3 7" would create a walk area something like this:
|
XXXX
XXXXXXX
XXXXXXX
XXXX
|
Used with Move() and IsLegalMove() functions |
Return values |
---|
boundingbox on success, empty string on invalid param (ick). Careful, not much error checking! |
Move( direction ) |
---|
Parameters: |
---|
Name | Type |
direction | Direction String, Facing Integer, or Bounding Box |
Explanation |
---|
A Direction String is one of: N, S, E, W, NW, NE, SW, SE |
A Facing Integer is 0 through 7 where 0 is North, 1 is NorthEast, etc. |
See MakeBoundingBox for info on the bounding box. |
Return values |
---|
Boolean for move success, or Direction String if bounding box was used |
Errors |
---|
none, returns 0 on failures |
Related |
---|
NPC |
Position() |
---|
Explanation |
---|
Deprecated. Use Self().x, Self().y, Self().z instead. |
Return values |
---|
A struct with x,y, and z members. |
Related |
---|
NPC |
RunAwayFrom( object ) |
---|
Parameters: |
---|
Name | Type |
object | UObject |
Explanation |
---|
Runs away from object one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
"Mobile specified cannot be seen" if object is a character and invisible |
Related |
---|
NPC |
UObject |
RunAwayFromLocation( x, y ) |
---|
Parameters: |
---|
Name | Type |
x | Integer World Coordinate |
y | Integer World Coordinate |
Explanation |
---|
Runs away from the given coordinates one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
RunToward( object ) |
---|
Parameters: |
---|
Name | Type |
object | UObject |
Explanation |
---|
Runs toward object one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
"Mobile specified cannot be seen" if object is a character and invisible |
Related |
---|
NPC |
UObject |
RunTowardLocation( x, y ) |
---|
Parameters: |
---|
Name | Type |
x | Integer World Coordinate |
y | Integer World Coordinate |
Explanation |
---|
Runs toward the given coordinates one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
Say( text ) |
---|
Parameters: |
---|
Name | Type |
text | String |
Explanation |
---|
Makes the NPC print text above its head. Uses the NPC member speech_font and speech_color. |
Return values |
---|
0 |
Errors |
---|
"NPC is squelched" |
Related |
---|
NPC |
Self() |
---|
Explanation |
---|
return a mobileref to self |
Return values |
---|
A Character Reference to this NPC |
Related |
---|
NPC |
SetAnchor( centerx, centery, distance_start, percent_subtract ) |
---|
Parameters: |
---|
Name | Type |
centerx | Integer world coordinate |
centery | Integer world coordinate |
distance_start | Integer |
percent_subtract | Integer |
Explanation |
---|
Sets the NPC's 'anchor' point. The NPC will have difficulty moving far away from this coordinate, and will generally stay near it. |
centerx and centery define the anchor point. |
distance_start is the distance away from the anchor point at which the npc may not be able to move beyond. Under this distance there is a 100% chance the move will succeed. If 0, it disables the anchor point. |
percent_subtract is how much to subtract from the normal 100% chance for each move beyond the distance_start boundary. So if this value is "20", the first move beyond the distance_start range (and away from the anchor point) will only have an 80% chance of succeeding. The next one will have a 60% chance. So the NPC will tend to move back toward its anchor point. |
The anchor point has no effect as long as the NPC is in war mode. |
Return values |
---|
1 on success |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
SetOpponent( character ) |
---|
Parameters: |
---|
Name | Type |
character | CharacterRef |
Explanation |
---|
Set your opponent. If you are in range (or are carrying a projectile weapon and have LOS), you will attack. If a player character is connected, the NPC will highlight. |
Implicitly sets war mode. |
pass 0 to clear the opponent. |
Return values |
---|
0 on invalid param or clear, 1 on successful set |
Related |
---|
Character |
NPC |
SetProperty( propertyname, propertyvalue ) |
---|
Parameters: |
---|
Name | Type |
propertyname | String |
propertyvalue | Packable script object (int, string, array, etc) |
Explanation |
---|
Deprecated. Equivalent to SetObjProperty( Self(), propertyname, propertyvalue ) |
Return values |
---|
1. See SetObjProperty in UO.EM |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
SetWarMode( warmode ) |
---|
Parameters: |
---|
Name | Type |
warmode | Integer 1/0 |
Explanation |
---|
Usually used to leave warmode, but can be used to enter warmode independently of setting an opponent. |
Setting war mode to 0 clears your opponent. |
Return values |
---|
1 on success, 0 on invalid param or clear |
Related |
---|
NPC |
TurnAwayFrom( object ) |
---|
Parameters: |
---|
Name | Type |
object | UObject |
Explanation |
---|
Adjust facing to turn away from object. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
"Mobile specified cannot be seen" if object is a character and invisible |
Related |
---|
NPC |
UObject |
TurnAwayFromLocation( x, y ) |
---|
Parameters: |
---|
Name | Type |
x | Integer World Coordinate |
y | Integer World Coordinate |
Explanation |
---|
Adjust facing to turn away from given coordinates one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
TurnToward( object ) |
---|
Parameters: |
---|
Name | Type |
object | UObject |
Explanation |
---|
Adjust facing to turn toward object. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
"Mobile specified cannot be seen" if object is a character and invisible |
Related |
---|
NPC |
UObject |
TurnTowardLocation( x, y ) |
---|
Parameters: |
---|
Name | Type |
x | Integer World Coordinate |
y | Integer World Coordinate |
Explanation |
---|
Adjust facing to turn toward given coordinates one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
WalkAwayFrom( object ) |
---|
Parameters: |
---|
Name | Type |
object | UObject |
Explanation |
---|
Walk away from object one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
"Mobile specified cannot be seen" if object is a character and invisible |
Related |
---|
NPC |
UObject |
WalkAwayFromLocation( x, y ) |
---|
Parameters: |
---|
Name | Type |
x | Integer World Coordinate |
y | Integer World Coordinate |
Explanation |
---|
Walk away from the given coordinates one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
WalkToward( object ) |
---|
Parameters: |
---|
Name | Type |
object | UObject |
Explanation |
---|
Walk toward object one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
"Mobile specified cannot be seen" if object is a character and invisible |
Related |
---|
NPC |
UObject |
WalkTowardLocation( x, y ) |
---|
Parameters: |
---|
Name | Type |
x | Integer World Coordinate |
y | Integer World Coordinate |
Explanation |
---|
Walk toward the given coordinates one tile. Puts the script to sleep for a period of time proportional to the NPC's run_speed (or dexterity if not defined). |
Note also, walking in range of your opponent may cause you to attack. |
See the NPC members run_speed and use_adjustments. If use_adjustments is 1 the NPC will adjust the direction of the move to attempt to avoid small obsticles. Also, this function will always return true as a result. If it is 0, the NPC will not attempt to adjust the move, and the function will return false. |
The success of this function is affected by the NPC's anchor point. See SetAnchor(). |
In the future, this function will activate a pathfinding system. |
Return values |
---|
Boolean for move success |
Errors |
---|
"Invalid parameter type" |
Related |
---|
NPC |
Wander() |
---|
Explanation |
---|
walk, usually forward, sometimes turning |
Return values |
---|
1 if the move succeeded, 0 if it failed |
Related |
---|
NPC |
If you know if any information is incorrect on these pages, mail your corrections to racalac@polserver.com
Copyright ©2003-2011 David Carpman, all rights reserved. DO NOT REPRODUCE, MIRROR, ALTER, SPINDLE, MUTILATE, OR SIT ON.