diff options
-rw-r--r-- | db/constants.conf | 10 | ||||
-rw-r--r-- | doc/constants.md | 4 | ||||
-rw-r--r-- | doc/script_commands.txt | 227 | ||||
-rw-r--r-- | npc/quests/quests_rachel.txt | 2 | ||||
-rw-r--r-- | src/map/script.c | 41 |
5 files changed, 171 insertions, 113 deletions
diff --git a/db/constants.conf b/db/constants.conf index 598bc89c4..2e379cb14 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -3853,8 +3853,14 @@ constants_db: { UDT_MAXSP: 6 UDT_MASTERAID: 7 UDT_MASTERCID: 8 - UDT_MAPIDXY: 9 - UDT_WALKTOXY: 10 + UDT_MAPIDXY: { + Value: 9 + Deprecated: true // for setunitdata use *unitwarp, for getunitdata use *getmapxy + } + UDT_WALKTOXY: { + Value: 10 + Deprecated: true // use *unitwalk + } UDT_SPEED: 11 UDT_MODE: 12 UDT_AI: 13 diff --git a/doc/constants.md b/doc/constants.md index 5a98d18bb..9225ce924 100644 --- a/doc/constants.md +++ b/doc/constants.md @@ -3773,8 +3773,8 @@ - `UDT_MAXSP`: 6 - `UDT_MASTERAID`: 7 - `UDT_MASTERCID`: 8 -- `UDT_MAPIDXY`: 9 -- `UDT_WALKTOXY`: 10 +- `UDT_MAPIDXY`: 9 **(DEPRECATED)** +- `UDT_WALKTOXY`: 10 **(DEPRECATED)** - `UDT_SPEED`: 11 - `UDT_MODE`: 12 - `UDT_AI`: 13 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index f2852e93e..a03fb1768 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -266,8 +266,8 @@ direction across Y. Walking into that area will trigger the NPC. If no 'OnTouch:' special label is present in the NPC code, the execution will start from the beginning of the script, otherwise, it will start from the 'OnTouch:' label. Monsters can also trigger the NPC, though the label -'OnTouchNPC:' is used in this case. If player left area npc will called -if present label 'OnUnTouch'. +'OnTouchNPC:' is used in this case, and using mobattached() will return +monster GID. If player left the area will trigger the label 'OnUnTouch'. The code part is the script code that will execute whenever the NPC is triggered. It may contain commands and function calls, descriptions of @@ -6507,6 +6507,14 @@ other number for this parameter won't be recognized. --------------------------------------- +*killmonstergid(<GID>); + +This command will kill the specific monster GID. The difference between +this command and 'unitkill', is this command does not trigger monster's +event label. + +--------------------------------------- + *strmobinfo(<type>, <monster id>) This function will return information about a monster record in the @@ -6595,6 +6603,17 @@ will run as if by donpcevent(). --------------------------------------- +*mobattached() + +This command will return RID of the monster running from 'OnTouchNPC:' label. + + +// Kill any monster entering npc's trigger area +OnTouchNPC: + killmonstergid mobattached(); + +--------------------------------------- + *homevolution() This command will try to evolve the current player's homunculus. @@ -10043,131 +10062,127 @@ Returns the amount of still-available <Item_ID> in the shop (on a NST_MARKET tra --------------------------------------- -*setunitdata(<GUID>, <DataType>, <Val1> {,<Val2>,<Val3>}) +*setunitdata(<GID>, <DataType>, <Val>) Sets or alters the data in real-time for game objects of the following types - NPCs, Pets, Monsters, Homunuculus', Mercenaries, Elementals. Applicable Data Types (available as constants) - Data Types Description (parameter type) - UDT_SIZE: Unit Size (int) - UDT_LEVEL: Level (int) - UDT_HP: Current HP (int) - UDT_MAXHP: Max HP (int) - UDT_SP: SP (int) - UDT_MAXSP: MAX SP (int) - UDT_MASTERAID: Master Account ID (for Summons) (int) - UDT_MASTERCID: Master Char ID (for Summons) (int) - UDT_MAPIDXY: Warp a Unit to a map. (Val1 = (string) MapName, Val2 = (int) x, Val3 = (int) y) - UDT_WALKTOXY: Make a unit walk to certain co-ordinates. (Val1 = (int) x, Val2 = (int) y) - UDT_SPEED: Unit Speed. (int) - UDT_MODE: Mode (Mobs only) (int) + UDT_SIZE: Unit Size + UDT_LEVEL: Level + UDT_HP: Current HP + UDT_MAXHP: Max HP + UDT_SP: SP + UDT_MAXSP: MAX SP + UDT_MASTERAID: Master Account ID (for Summons) + UDT_MASTERCID: Master Char ID (for Summons) + UDT_SPEED: Unit Speed. + UDT_MODE: Mode (Mobs only) UDT_AI: Unit AI Type (see doc/constants.md for Unit AI Types) UDT_SCOPTION: Status Options. (see doc/constants.md for Unit Option Types) UDT_SEX: Gender of the unit. (see doc/constants.md for Genders) - UDT_CLASS: Class of the unit. (Monster ID) (int) - UDT_HAIRSTYLE: Hair Style ID. (int) - UDT_HAIRCOLOR: Hair Color ID. (int) - UDT_HEADBOTTOM: Headgear Bottom Sprite ID. (int) - UDT_HEADMIDDLE: Headgear Middle Sprite ID. (int) - UDT_HEADTOP: Headgear Top Sprite ID. (int) - UDT_CLOTHCOLOR: Cloth Color ID. (int) - UDT_SHIELD: Shield Sprite ID. (int) - UDT_WEAPON: Weapon Sprite ID. (int) - UDT_LOOKDIR: Face direction. (int) - UDT_CANMOVETICK: Stop a unit from move for n seconds. (int) - UDT_STR: Unit STR. (int) - UDT_AGI: Unit AGI. (int) - UDT_VIT: Unit VIT. (int) - UDT_INT: Unit INT. (int) - UDT_DEX: Unit DEX. (int) - UDT_LUK: Unit LUK. (int) - UDT_ATKRANGE: Attack range of a unit. (int) - UDT_ATKMIN: Min Atk of a unit. (int) - UDT_ATKMAX: Max Atk of a unit. (int) - UDT_MATKMIN: Min MATK of a unit. (int) - UDT_MATKMAX: Max MATK of a unit. (int) - UDT_DEF: DEF. (int) - UDT_MDEF: MDEF. (int) - UDT_HIT: HIT. (int) - UDT_FLEE: FLEE. (int) - UDT_PDODGE: Perfect Dodge. (int) - UDT_CRIT: Critical Rate. (int) - UDT_RACE: Race. (Eg. string constants RC_DemiHuman or Integer 7). - UDT_ELETYPE: Element. (Eg. string constants Ele_Neutral or Integer 0). - UDT_ELELEVEL: Element Level (int). - UDT_AMOTION: AMotion Rate (int). - UDT_ADELAY: ADelay Rate (int). - UDT_DMOTION: DMotion Rate (int). - UDT_HUNGER: Hunger Rate (int) - for summons. - UDT_INTIMACY: Intimacy Rate (int) - for summons. - UDT_LIFETIME: LifeTime (int) - for summons. - UDT_MERC_KILLCOUNT: Kill count for mercenaries (int). - UDT_STATADD: Status Points (int) - for NPCs. + UDT_CLASS: Class of the unit. (Monster ID) + UDT_HAIRSTYLE: Hair Style ID. + UDT_HAIRCOLOR: Hair Color ID. + UDT_HEADBOTTOM: Headgear Bottom Sprite ID. + UDT_HEADMIDDLE: Headgear Middle Sprite ID. + UDT_HEADTOP: Headgear Top Sprite ID. + UDT_CLOTHCOLOR: Cloth Color ID. + UDT_SHIELD: Shield Sprite ID. + UDT_WEAPON: Weapon Sprite ID. + UDT_LOOKDIR: Face direction. + UDT_CANMOVETICK: Stop a unit from move for n seconds. + UDT_STR: Unit STR. + UDT_AGI: Unit AGI. + UDT_VIT: Unit VIT. + UDT_INT: Unit INT. + UDT_DEX: Unit DEX. + UDT_LUK: Unit LUK. + UDT_ATKRANGE: Attack range of a unit. + UDT_ATKMIN: Min Atk of a unit. + UDT_ATKMAX: Max Atk of a unit. + UDT_MATKMIN: Min MATK of a unit. + UDT_MATKMAX: Max MATK of a unit. + UDT_DEF: DEF. + UDT_MDEF: MDEF. + UDT_HIT: HIT. + UDT_FLEE: FLEE. + UDT_PDODGE: Perfect Dodge. + UDT_CRIT: Critical Rate. + UDT_RACE: Race. (Eg. constants RC_DemiHuman or Integer 7). + UDT_ELETYPE: Element. (Eg. constants Ele_Neutral or Integer 0). + UDT_ELELEVEL: Element Level. + UDT_AMOTION: AMotion Rate. + UDT_ADELAY: ADelay Rate. + UDT_DMOTION: DMotion Rate. + UDT_HUNGER: Hunger Rate - for summons. + UDT_INTIMACY: Intimacy Rate - for summons. + UDT_LIFETIME: LifeTime - for summons. + UDT_MERC_KILLCOUNT: Kill count for mercenaries + UDT_STATADD: Status Points - for NPCs. returns 0 if value could not be set, 1 if successful. --------------------------------------- -*getunitdata (<GUID>,<DataType>{,<Variable>}) +*getunitdata (<GID>,<DataType>) -Retrieves real-time data of a game object. For data with multiple return values, -an array variable may be passed to store the data in. +Retrieves real-time data of a game object. Applicable Data types (available as constants) - Data Types Description (return type) - UDT_SIZE: Unit Size (int) - UDT_LEVEL: Level (int) - UDT_HP: Current HP (int) - UDT_MAXHP: Max HP (int) - UDT_SP: SP (int) - UDT_MAXSP: MAX SP (int) - UDT_MASTERAID: Master Account ID (for Summons) (int) - UDT_MASTERCID: Master Char ID (for Summons) (int) - UDT_MAPIDXY: Warp a Unit to a map. (Val1 = (string) MapName, Val2 = (int) x, Val3 = (int) y) - UDT_SPEED: Unit Speed. (int) - UDT_MODE: Mode (Mobs only) (int) + UDT_SIZE: Unit Size + UDT_LEVEL: Level + UDT_HP: Current HP + UDT_MAXHP: Max HP + UDT_SP: SP + UDT_MAXSP: MAX SP + UDT_MASTERAID: Master Account ID (for Summons) + UDT_MASTERCID: Master Char ID (for Summons) + UDT_SPEED: Unit Speed. + UDT_MODE: Mode (Mobs only) UDT_AI: Unit AI Type (see doc/constants.md for Unit AI Types) UDT_SCOPTION: Status Options. (see doc/constants.md for Unit Option Types) UDT_SEX: Gender of the unit. (see doc/constants.md for Genders) - UDT_CLASS: Class of the unit. (Monster ID) (int) - UDT_HAIRSTYLE: Hair Style ID. (int) - UDT_HAIRCOLOR: Hair Color ID. (int) - UDT_HEADBOTTOM: Headgear Bottom Sprite ID. (int) - UDT_HEADMIDDLE: Headgear Middle Sprite ID. (int) - UDT_HEADTOP: Headgear Top Sprite ID. (int) - UDT_CLOTHCOLOR: Cloth Color ID. (int) - UDT_SHIELD: Shield Sprite ID. (int) - UDT_WEAPON: Weapon Sprite ID. (int) - UDT_LOOKDIR: Face direction. (int) - UDT_CANMOVETICK: Stop a unit from move for n seconds. (int) - UDT_STR: Unit STR. (int) - UDT_AGI: Unit AGI. (int) - UDT_VIT: Unit VIT. (int) - UDT_INT: Unit INT. (int) - UDT_DEX: Unit DEX. (int) - UDT_LUK: Unit LUK. (int) - UDT_ATKRANGE: Attack range of a unit. (int) - UDT_ATKMIN: Min Atk of a unit. (int) - UDT_ATKMAX: Max Atk of a unit. (int) - UDT_MATKMIN: Min MATK of a unit. (int) - UDT_MATKMAX: Max MATK of a unit. (int) - UDT_DEF: DEF. (int) - UDT_MDEF: MDEF. (int) - UDT_HIT: HIT. (int) - UDT_FLEE: FLEE. (int) - UDT_PDODGE: Perfect Dodge. (int) - UDT_CRIT: Critical Rate. (int) - UDT_RACE: Race. (Eg. string constants RC_DemiHuman or Integer 7). - UDT_ELETYPE: Element. (Eg. string constants Ele_Neutral or Integer 0). - UDT_ELELEVEL: Element Level (int). - UDT_AMOTION: AMotion Rate (int). - UDT_ADELAY: ADelay Rate (int). - UDT_DMOTION: DMotion Rate (int). - UDT_HUNGER: Hunger Rate (int) - for summons. - UDT_INTIMACY: Intimacy Rate (int) - for summons. - UDT_LIFETIME: LifeTime (int) - for summons. - UDT_MERC_KILLCOUNT: Kill count for mercenaries (int). + UDT_CLASS: Class of the unit. (Monster ID) + UDT_HAIRSTYLE: Hair Style ID. + UDT_HAIRCOLOR: Hair Color ID. + UDT_HEADBOTTOM: Headgear Bottom Sprite ID. + UDT_HEADMIDDLE: Headgear Middle Sprite ID. + UDT_HEADTOP: Headgear Top Sprite ID. + UDT_CLOTHCOLOR: Cloth Color ID. + UDT_SHIELD: Shield Sprite ID. + UDT_WEAPON: Weapon Sprite ID. + UDT_LOOKDIR: Face direction. + UDT_CANMOVETICK: Stop a unit from move for n seconds. + UDT_STR: Unit STR. + UDT_AGI: Unit AGI. + UDT_VIT: Unit VIT. + UDT_INT: Unit INT. + UDT_DEX: Unit DEX. + UDT_LUK: Unit LUK. + UDT_ATKRANGE: Attack range of a unit. + UDT_ATKMIN: Min Atk of a unit. + UDT_ATKMAX: Max Atk of a unit. + UDT_MATKMIN: Min MATK of a unit. + UDT_MATKMAX: Max MATK of a unit. + UDT_DEF: DEF. + UDT_MDEF: MDEF. + UDT_HIT: HIT. + UDT_FLEE: FLEE. + UDT_PDODGE: Perfect Dodge. + UDT_CRIT: Critical Rate. + UDT_RACE: Race. (Eg. constants RC_DemiHuman or Integer 7). + UDT_ELETYPE: Element. (Eg. constants Ele_Neutral or Integer 0). + UDT_ELELEVEL: Element Level. + UDT_AMOTION: AMotion Rate. + UDT_ADELAY: ADelay Rate. + UDT_DMOTION: DMotion Rate. + UDT_HUNGER: Hunger Rate - for summons. + UDT_INTIMACY: Intimacy Rate - for summons. + UDT_LIFETIME: LifeTime - for summons. + UDT_MERC_KILLCOUNT: Kill count for mercenaries. returns -1 if value could not be retrieved. diff --git a/npc/quests/quests_rachel.txt b/npc/quests/quests_rachel.txt index 43e4beadb..1cc002d80 100644 --- a/npc/quests/quests_rachel.txt +++ b/npc/quests/quests_rachel.txt @@ -3210,7 +3210,7 @@ OnTouch: OnTouchNPC: emotion e_an; - //emotion e_gg,1; //Emote on monster - unsupported + unitemote mobattached(), e_gg; end; OnMyMobDead: diff --git a/src/map/script.c b/src/map/script.c index b0a3b6929..17b93af37 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11095,6 +11095,21 @@ static BUILDIN(killmonsterall) return true; } +static BUILDIN(killmonstergid) +{ + int mobgid = script_getnum(st, 2); + struct mob_data *md = map->id2md(mobgid); + + if (md == NULL) { + ShowWarning("buildin_killmonstergid: Error in finding monster GID '%d' or the target is not a monster.\n", mobgid); + return false; + } + + md->state.npc_killmonster = 1; + status_kill(&md->bl); + return true; +} + /*========================================== * Creates a clone of a player. * clone map, x, y, event, char_id, master_id, mode, flag, duration @@ -11730,6 +11745,18 @@ static BUILDIN(playerattached) } /*========================================== + * Used by OnTouchNPC: label to return monster GID + *------------------------------------------*/ +static BUILDIN(mobattached) +{ + if (st->rid == 0 || map->id2md(st->rid) == NULL) + script_pushint(st, 0); + else + script_pushint(st, st->rid); + return true; +} + +/*========================================== *------------------------------------------*/ static BUILDIN(announce) { @@ -18652,6 +18679,10 @@ static BUILDIN(getunittype) * @param4 Value#2 Optional int value to be passed for certain data types. * @param5 Value#3 Optional int value to be passed for certain data types. * @return 1 on success, 0 on failure. + + Note: Please make this script command only modify ONE INTEGER value. + If need to modify string type data, or having multiple arguments, please + introduce a new script command. */ static BUILDIN(setunitdata) { @@ -18677,7 +18708,7 @@ static BUILDIN(setunitdata) return false; } - /* Mandatory Argument 3 */ + /* Mandatory Argument 3. Subject to deprecate. */ if (type == UDT_MAPIDXY) { if (!script_isstringtype(st, 4)) { ShowError("buildin_setunitdata: Invalid data type for argument #3.\n"); @@ -19769,6 +19800,10 @@ static BUILDIN(setunitdata) * @param2 DataType Type of Data to be set for the unit. * @param3 Variable array reference to store data into. (used for UDT_MAPIDXY) * @return 0 on failure, <value> on success + + Note: Please make this script command only return ONE INTEGER value. + If the unit data having multiple arguments, or need to return in array, + please introduce a new script command. */ static BUILDIN(getunitdata) { @@ -19796,7 +19831,7 @@ static BUILDIN(getunitdata) return false; } - /* Argument checks */ + /* Argument checks. Subject to deprecate */ if (type == UDT_MAPIDXY) { if (data == NULL || !data_isreference(data)) { ShowWarning("buildin_getunitdata: Error in argument 3. Please provide a reference variable to store values in.\n"); @@ -25354,6 +25389,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(areamonster,"siiiisii???"), BUILDIN_DEF(killmonster,"ss?"), BUILDIN_DEF(killmonsterall,"s?"), + BUILDIN_DEF(killmonstergid, "i"), BUILDIN_DEF(clone,"siisi????"), BUILDIN_DEF(doevent,"s"), BUILDIN_DEF(donpcevent,"s"), @@ -25370,6 +25406,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(attachnpctimer,"?"), // attached the player id to the npc timer [Celest] BUILDIN_DEF(detachnpctimer,"?"), // detached the player id from the npc timer [Celest] BUILDIN_DEF(playerattached,""), // returns id of the current attached player. [Skotlex] + BUILDIN_DEF(mobattached, ""), BUILDIN_DEF(announce,"si?????"), BUILDIN_DEF(mapannounce,"ssi?????"), BUILDIN_DEF(areaannounce,"siiiisi?????"), |