Functions for manipulating non-player character mobiles. All (most?) these functions are limited to use in an NPC context (meaning an AI script). 08/31/2015 // Constants for texttype flags in the Say() function const SAY_TEXTTYPE_DEFAULT := "default"; const SAY_TEXTTYPE_WHISPER := "whisper"; const SAY_TEXTTYPE_YELL := "yell"; // Constant for Unicode Language flag in the SayUC() function const SAY_LANG := "ENU"; // Constants for doevent flag in Say() function const SAY_DOEVENT_DISABLE := 0x0; const SAY_DOEVENT_ENABLE := 0x1; const FACE_NORMAL := 0x0; const FACE_FORCE := 0x1; SetAnchor( centerx, centery, distance_start, percent_subtract ) 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. 1 on success "Invalid parameter type" "Invalid Coordinates for Realm" NPC Self() return a mobileref to self A Character Reference to this NPC NPC Wander() walk, usually forward, sometimes turning 1 if the move succeeded, 0 if it failed NPC Move( direction ) 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. Boolean for move success, or Direction String if bounding box was used none, returns 0 on failures NPC WalkToward( object ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Mobile specified cannot be seen" if object is a character and invisible NPC UObject servspecopt.cfg WalkAwayFrom( object ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Mobile specified cannot be seen" if object is a character and invisible NPC UObject servspecopt.cfg RunToward( object ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Mobile specified cannot be seen" if object is a character and invisible NPC UObject servspecopt.cfg RunAwayFrom( object ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Mobile specified cannot be seen" if object is a character and invisible NPC UObject servspecopt.cfg TurnToward( object, flags := FACE_NORMAL ) 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). See Face() for flags explanation const FACE_NORMAL := 0x0; const FACE_FORCE := 0x1; Boolean for move success "Invalid parameter type" "Mobile specified cannot be seen" if object is a character and invisible NPC UObject servspecopt.cfg TurnAwayFrom( object, flags := FACE_NORMAL ) 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). See Face() for flags explanation const FACE_NORMAL := 0x0; const FACE_FORCE := 0x1; Boolean for move success "Invalid parameter type" "Mobile specified cannot be seen" if object is a character and invisible NPC UObject servspecopt.cfg WalkTowardLocation( x, y ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Invalid Coordinates for Realm" NPC servspecopt.cfg WalkAwayFromLocation( x, y ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Invalid Coordinates for Realm" NPC servspecopt.cfg RunTowardLocation( x, y ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Invalid Coordinates for Realm" NPC servspecopt.cfg RunAwayFromLocation( x, y ) 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. servspecopt.cfg NpcMinimumMovementDelay setting controls the maximum speed of NPC. Boolean for move success "Invalid parameter type" "Invalid Coordinates for Realm" NPC servspecopt.cfg TurnTowardLocation( x, y, flags := FACE_NORMAL ) 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). See Face() for flags explanation const FACE_NORMAL := 0x0; const FACE_FORCE := 0x1; Boolean for move success "Invalid parameter type" "Invalid Coordinates for Realm" NPC TurnAwayFromLocation( x, y, flags := FACE_NORMAL ) 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). See Face() for flags explanation const FACE_NORMAL := 0x0; const FACE_FORCE := 0x1; Boolean for move success "Invalid parameter type" "Invalid Coordinates for Realm" NPC SetOpponent( character ) 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. 0 on invalid param or clear, 1 on successful set Character NPC SetWarMode( warmode ) 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. 1 on success, 0 on invalid param or clear NPC Say( text, text_type:=SAY_TEXTTYPE_DEFAULT, do_event:=SAY_DOEVENT_DISABLE ) Makes the NPC print text above its head. Uses the NPC member speech_font and speech_color. If do_event is enabled with SAY_DOEVENT_ENABLE, it will send a speech event to nearby npcs. Notes: npc.em constant for this function: // Constants for texttype flags in the Say() function const SAY_TEXTTYPE_DEFAULT := "default"; const SAY_TEXTTYPE_WHISPER := "whisper"; const SAY_TEXTTYPE_YELL := "yell"; // Constants for doevent flag in Say() function const SAY_DOEVENT_DISABLE := 0x0; const SAY_DOEVENT_ENABLE := 0x1; 0 "NPC is squelched" "texttype string param must be either 'default', 'whisper', or 'yell'" NPC SayUC( uc_text, text_type:=SAY_TEXTTYPE_DEFAULT, langcode:=SAY_LANG, do_event:=SAY_DOEVENT_DISABLE ) Makes the NPC print text above its head. Uses the NPC member speech_font and speech_color. If do_event is enabled with SAY_DOEVENT_ENABLE, it will send a speech event to nearby npcs. uc_text MUST be an array of integers representing unicode characters. Integers must be "Big Endian" (0x1234) and not "Little Endian" (0x3412). Integers will be clipped internally to 2-bytes (value masked with 0xFFFF) The Array must be terminated with zero. (0x0000) 0 "A parameter was invalid" "NPC is squelched" "texttype string param must be either 'default', 'whisper', or 'yell'" "Unicode array exceeds maximum size." "langcode must be a 3-character code." "Invalid value in Unicode array." NPC GetProperty( propertyname ) Deprecated. Equivalent to GetObjProperty( Self(), propertyname ) An unpacked object. See GetObjProperty in UO.EM "Property not found" "Invalid parameter type" NPC SetProperty( propertyname, propertyvalue ) Deprecated. Equivalent to SetObjProperty( Self(), propertyname, propertyvalue ) 1. See SetObjProperty in UO.EM "Invalid parameter type" NPC MakeBoundingBox( areastring ) 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 boundingbox on success, empty string on invalid param (ick). Careful, not much error checking! IsLegalMove( move, boundingbox ) Given your position, and a tentative move, would it fall within a bounding box. This function ignores facing. It checks explicity for moving in a given direction, regardless of facing. 0 on invalid parameter, or illegal move. 1 on legal move NPC CanMove( direction ) Given current position and direction, would it be possible to move there? 0 on invalid parameter, or illegal move. 1 on legal move NPC Face( direction, flags := FACE_NORMAL ) Sets Facing to given direction. If FACE_FORCE is set frozen/paralysed is not checked. const FACE_NORMAL := 0x0; const FACE_FORCE := 0x1; 0 on invalid parameter, illegal direction, or failed to face. New direction on success. NPC