public class 0601_Unit_Related extends Object
=============================== |0601.- Unit-related commands.| ===============================
| 构造器和说明 |
|---|
0601_Unit_Related() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
geteleminfo()
geteleminfo <type>{,<char_id>};
Get info of elemental of attached player or player by char_id.
|
void |
getunitdata()
getunitdata <GID>,<arrayname>;
setunitdata <GID>,<parameter>,<new value>;
This is used to get and set special data related to the unit.
|
void |
getunitname()
getunitname <GID>;
Gets the name of the given unit.
|
void |
getunittype()
getunittype <GID>;
Returns the type of object from the given Game ID.
|
void |
setunitname()
setunitname <GID>,"<new name>";
Changes the name of the given unit to the new name given.
|
void |
unitattack()
unitattack <GID>,<Target ID>{,<action type>};
unitattack <GID>,"<Target Name>"{,<action type>};
This command will make a <GID> attack the specified target.
|
void |
unitexists()
unitexists <GID>;
Checks if the given Game ID exists.
|
void |
unitkill()
unitkill <GID>;
This command will kill a <GID>.
|
void |
unitskilluseid()
unitskilluseid <GID>,<skill id>,<skill lvl>{,<target id>,<casttime>};
unitskilluseid <GID>,"<skill name>",<skill lvl>{,<target id>,<casttime>};
unitskillusepos <GID>,<skill id>,<skill lvl>,<x>,<y>{,<casttime>};
unitskillusepos <GID>,"<skill name>",<skill lvl>,<x>,<y>{,<casttime>};
This is the replacement of the older commands, these use the same values for
GID as the other unit* commands (See 'GID').
|
void |
unitstopattack()
unitstopattack <GID>;
This command will make a <GID> stop attacking.
|
void |
unitstopwalk()
unitstopwalk <GID>{,<flag>};
This command will make a <GID> stop moving.
|
void |
unittalk()
unittalk <GID>,"<text>"{,flag};
This command will make a <GID> say a message.
|
void |
unitwalk()
unitwalk <GID>,<x>,<y>{,"<event label>"};
unitwalkto <GID>,<Target GID>{,"<event label>"};
This command will tell a <GID> to walk to a position, defined either as a set of
coordinates or another object.
|
void |
unitwarp()
unitwarp <GID>,"<map name>",<x>,<y>;
This command will warp a <GID> to the specified map and coordinates.
|
unitwalk <GID>,<x>,<y>{,"<event label>"};
unitwalkto <GID>,<Target GID>{,"<event label>"};
This command will tell a <GID> to walk to a position, defined either as a set of
coordinates or another object. The command returns a 1 for success and 0 upon failure.
If coordinates are passed, the <GID> will walk to the given x,y coordinates on the
unit's current map. While there is no way to move across an entire map with 1 command
use, this could be used in a loop to move long distances.
If an object ID is passed, the initial <GID> will walk to the <Target GID> (similar to
walking to attack). This is based on the distance from <GID> to <Target ID>. This command
uses a hard walk check, so it will calculate a walk path with obstacles. Sending a bad
target ID will result in an error.
An optional Event Label can be passed as well which will execute when the <GID> has reached
the given coordinates or <Target GID>.
Examples:
// Makes player walk to the coordinates (150,150).
unitwalk getcharid(3),150,150;
// Performs a conditional check with the command and reports success or failure to the player.
if (unitwalk(getcharid(3),150,150))
dispbottom "Walking you there...";
else
dispbottom "That's too far away, man.";
// Makes player walk to another character named "WalkToMe".
unitwalkto getcharid(3),getcharid(3,"WalkToMe");
unitattack <GID>,<Target ID>{,<action type>};
unitattack <GID>,"<Target Name>"{,<action type>};
This command will make a <GID> attack the specified target. It returns true upon
success and false for all failures.
If <GID> is a player and a non-zero <action type> is given, the unit will perform a
continuous attack instead of a single attack.
Note:
Using unitattack with <GID> 0 means that it will use the currently attached unit.
For players any attack requests will fail, because talking to an NPC prevents attacking a monster.
Therefore you need to detach the player from the NPC before using this command.
unitkill <GID>;
This command will kill a <GID>.
unitwarp <GID>,"<map name>",<x>,<y>;
This command will warp a <GID> to the specified map and coordinates.
If <GID> is zero, the command runs for the unit that invoked the script. This can be
used with "OnTouch" to warp monsters:
OnTouch:
unitwarp 0,"this",-1,-1;
unitstopattack <GID>;
This command will make a <GID> stop attacking.
unitstopwalk <GID>{,<flag>};
This command will make a <GID> stop moving.
Note: If this is called from OnTouch, then the walktimer attached to the unit is
removed from OnTouch which causes this command to not stop the unit from walking.
Suggest to use 'unitblockmove' to forcefully stop the unit with OnTouch.
The <flag> value affects how the unit is stopped. The following flags are bitwise
values (can be combined using the pipe operator):
USW_NONE = Unit will keep walking to their original destination.
USW_FIXPOS = Issue a fixpos packet afterwards.
USW_MOVE_ONCE = Force the unit to move one cell if it hasn't yet.
USW_MOVE_FULL_CELL = Enable moving to the next cell when unit was already half-way there (may cause on-touch/place side-effects, such as a scripted map change).
USW_FORCE_STOP = Force stop moving.
unittalk <GID>,"<text>"{,flag};
This command will make a <GID> say a message. The display name of the <GID> won't get appended in front of the message.
flag: Specify target
bc_area - Message is sent to players in the vicinity of the source (default).
bc_self - Message is sent only to player attached.
unitskilluseid <GID>,<skill id>,<skill lvl>{,<target id>,<casttime>};
unitskilluseid <GID>,"<skill name>",<skill lvl>{,<target id>,<casttime>};
unitskillusepos <GID>,<skill id>,<skill lvl>,<x>,<y>{,<casttime>};
unitskillusepos <GID>,"<skill name>",<skill lvl>,<x>,<y>{,<casttime>};
This is the replacement of the older commands, these use the same values for
GID as the other unit* commands (See 'GID').
Skill ID is the ID of the skill, skill level is the level of the skill.
Cast time is the amount of seconds to add or remove from the skill. Use a positive value to
add and negative value to subtract. Using 0 or no value will use the default skill cast time.
For the position, the x and y are given in the UnitSkillUsePos.
unitexists <GID>;
Checks if the given Game ID exists. Returns false if the object doesn't exist, or true if
it does.
getunittype <GID>;
Returns the type of object from the given Game ID. Returns -1 if the given GID does not
exist.
Return values:
BL_PC - Character object
BL_MOB - Monster object
BL_PET - Pet object
BL_HOM - Homunculus object
BL_MER - Mercenary object
BL_NPC - NPC object
BL_ELEM - Elemental object
getunitname <GID>;
Gets the name of the given unit. Supported types are monster, homunculus, pet, and NPC.
Mercenary and Elemental don't support custom names.
Returns "Unknown" if unit is not found.
setunitname <GID>,"<new name>";
Changes the name of the given unit to the new name given. Supported types are monster,
homunculus, and pet. To change an NPC's name, see 'setnpcdisplay'. Mercenary and
Elemental don't support custom names.
Changing a homunculus or pet name will be permanent.
Returns "Unknown" if unit is not found.
getunitdata <GID>,<arrayname>;
setunitdata <GID>,<parameter>,<new value>;
This is used to get and set special data related to the unit.
With getunitdata, the array given will be filled with the current data. In setunitdata
the indexes in the array would be used to set that data on the unit.
Both getunitdata and setunitdata will return -1 if the given GID does not exist.
Note: When adjusting a unit's stat (STR, AGI, etc) the unit's respective statuses are
recalculated (HIT, FLEE, etc) automatically. Keep in mind that some stats don't
affect a unit's status and will have to directly be modified.
Parameters (indexes) for monsters are:
UMOB_SIZE
UMOB_LEVEL
UMOB_HP
UMOB_MAXHP
UMOB_MASTERAID
UMOB_MAPID
UMOB_X
UMOB_Y
UMOB_SPEED
UMOB_MODE
UMOB_AI
UMOB_SCOPTION
UMOB_SEX
UMOB_CLASS
UMOB_HAIRSTYLE
UMOB_HAIRCOLOR
UMOB_HEADBOTTOM
UMOB_HEADMIDDLE
UMOB_HEADTOP
UMOB_CLOTHCOLOR
UMOB_SHIELD
UMOB_WEAPON
UMOB_LOOKDIR
UMOB_CANMOVETICK
UMOB_STR
UMOB_AGI
UMOB_VIT
UMOB_INT
UMOB_DEX
UMOB_LUK
UMOB_SLAVECPYMSTRMD
UMOB_DMGIMMUNE
UMOB_ATKRANGE
UMOB_ATKMIN
UMOB_ATKMAX
UMOB_MATKMIN
UMOB_MATKMAX
UMOB_DEF
UMOB_MDEF
UMOB_HIT
UMOB_FLEE
UMOB_PDODGE
UMOB_CRIT
UMOB_RACE
UMOB_ELETYPE
UMOB_ELELEVEL
UMOB_AMOTION
UMOB_ADELAY
UMOB_DMOTION
UMOB_TARGETID
-----
Parameter (indexes) for homunculi are:
UHOM_SIZE
UHOM_LEVEL
UHOM_HP
UHOM_MAXHP
UHOM_SP
UHOM_MAXSP
UHOM_MASTERCID
UHOM_MAPID
UHOM_X
UHOM_Y
UHOM_HUNGER
UHOM_INTIMACY
UHOM_SPEED
UHOM_LOOKDIR
UHOM_CANMOVETICK
UHOM_STR
UHOM_AGI
UHOM_VIT
UHOM_INT
UHOM_DEX
UHOM_LUK
UHOM_DMGIMMUNE
UHOM_ATKRANGE
UHOM_ATKMIN
UHOM_ATKMAX
UHOM_MATKMIN
UHOM_MATKMAX
UHOM_DEF
UHOM_MDEF
UHOM_HIT
UHOM_FLEE
UHOM_PDODGE
UHOM_CRIT
UHOM_RACE
UHOM_ELETYPE
UHOM_ELELEVEL
UHOM_AMOTION
UHOM_ADELAY
UHOM_DMOTION
UHOM_TARGETID
-----
Parameter (indexes) for pets are:
UPET_SIZE
UPET_LEVEL
UPET_HP
UPET_MAXHP
UPET_MASTERAID
UPET_MAPID
UPET_X
UPET_Y
UPET_HUNGER
UPET_INTIMACY
UPET_SPEED
UPET_LOOKDIR
UPET_CANMOVETICK
UPET_STR
UPET_AGI
UPET_VIT
UPET_INT
UPET_DEX
UPET_LUK
UPET_DMGIMMUNE
UPET_ATKRANGE
UPET_ATKMIN
UPET_ATKMAX
UPET_MATKMIN
UPET_MATKMAX
UPET_DEF
UPET_MDEF
UPET_HIT
UPET_FLEE
UPET_PDODGE
UPET_CRIT
UPET_RACE
UPET_ELETYPE
UPET_ELELEVEL
UPET_AMOTION
UPET_ADELAY
UPET_DMOTION
-----
Parameter (indexes) for mercenaries are:
UMER_SIZE
UMER_HP
UMER_MAXHP
UMER_MASTERCID
UMER_MAPID
UMER_X
UMER_Y
UMER_KILLCOUNT
UMER_LIFETIME
UMER_SPEED
UMER_LOOKDIR
UMER_CANMOVETICK
UMER_STR
UMER_AGI
UMER_VIT
UMER_INT
UMER_DEX
UMER_LUK
UMER_DMGIMMUNE
UMER_ATKRANGE
UMER_ATKMIN
UMER_ATKMAX
UMER_MATKMIN
UMER_MATKMAX
UMER_DEF
UMER_MDEF
UMER_HIT
UMER_FLEE
UMER_PDODGE
UMER_CRIT
UMER_RACE
UMER_ELETYPE
UMER_ELELEVEL
UMER_AMOTION
UMER_ADELAY
UMER_DMOTION
UMER_TARGETID
-----
Parameter (indexes) for elementals are:
UELE_SIZE
UELE_HP
UELE_MAXHP
UELE_SP
UELE_MAXSP
UELE_MASTERCID
UELE_MAPID
UELE_X
UELE_Y
UELE_LIFETIME
UELE_MODE
UELE_SPEED
UELE_LOOKDIR
UELE_CANMOVETICK
UELE_STR
UELE_AGI
UELE_VIT
UELE_INT
UELE_DEX
UELE_LUK
UELE_DMGIMMUNE
UELE_ATKRANGE
UELE_ATKMIN
UELE_ATKMAX
UELE_MATKMIN
UELE_MATKMAX
UELE_DEF
UELE_MDEF
UELE_HIT
UELE_FLEE
UELE_PDODGE
UELE_CRIT
UELE_RACE
UELE_ELETYPE
UELE_ELELEVEL
UELE_AMOTION
UELE_ADELAY
UELE_DMOTION
UELE_TARGETID
-----
Parameter (indexes) for NPCs are:
UNPC_DISPLAY
UNPC_LEVEL
UNPC_HP
UNPC_MAXHP
UNPC_MAPID
UNPC_X
UNPC_Y
UNPC_LOOKDIR
UNPC_STR
UNPC_AGI
UNPC_VIT
UNPC_INT
UNPC_DEX
UNPC_LUK
UNPC_PLUSALLSTAT
UNPC_DMGIMMUNE
UNPC_ATKRANGE
UNPC_ATKMIN
UNPC_ATKMAX
UNPC_MATKMIN
UNPC_MATKMAX
UNPC_DEF
UNPC_MDEF
UNPC_HIT
UNPC_FLEE
UNPC_PDODGE
UNPC_CRIT
UNPC_RACE
UNPC_ELETYPE
UNPC_ELELEVEL
UNPC_AMOTION
UNPC_ADELAY
UNPC_DMOTION
Notes:
- *_SIZE: small (0); medium (1); large (2)
- *_MAPID: this refers to the map_data index (from src/map/map.cpp), not the mapindex_db index (from src/common/mapindex.cpp)
-- For 'setunitdata', map name can also be passed in as a valid value instead of map ID
- *_SPEED: 20 - 1000
- *_MODE: see doc/mob_db_mode_list.txt
- *_LOOKDIR: north (0), northwest (1), west (2), etc
- *_CANMOVETICK: seconds * 1000 the unit will be unable to move
- *_DMGIMMUNE: unit will be immune to damage (1), or will receive damage (0)
- *_HUNGER: 0 - 100
- *_INTIMACY: 0 - 1000
- *_LIFETIME: seconds * 1000 the unit will be 'alive' for
- *_AMOTION: see doc/mob_db.txt
- *_ADELAY: see doc/mob_db.txt
- *_DMOTION: see doc/mob_db.txt
- UMOB_AI: none (0); attack (1); marine sphere (2); flora (3); zanzou (4); legion (5); faw (6)
- UMOB_SCOPTION: see the 'Variables' section at the top of this document
- UMOB_SLAVECPYMSTRMD: make the slave copy the master's mode (1), or not (0)
- UNPC_PLUSALLSTAT: same as 'bAllStats'; increases/decreses all stats by given amount
Example:
// Spawn some Porings and save the Game ID.
// - Keep in mind, when the 'monster' script command is used,
// - all the spawned monster GID's are stored in an array
// - called $@mobid[].
monster "prontera",149,190,"Poring",1002,10;
.GID = $@mobid[9]; // Store and modify the 10th Poring spawned to make him stronger!
// Save the strong Poring's mob data in the @por_arr[] variable. (@por_arr[1] being level, @por_arr[13] being class, etc.)
// With this data we can have the NPC display or manipulate it how we want. This does not have to be ran before 'setunitdata'.
getunitdata .GID,@por_arr;
// Set the max HP of the Poring to 1000 (current HP will also get updated to 1000).
setunitdata .GID,UMOB_MAXHP,1000;
geteleminfo <type>{,<char_id>};
Get info of elemental of attached player or player by char_id.
Other info can be obtained by 'getunitdata' command.
Valid types are:
0: Elemental ID
1: Elemental Game ID
Copyright © 工程的初始时间(可选)–2019. All rights reserved.