From 695f17f4940ba1f616376f06833317dfab2c1c63 Mon Sep 17 00:00:00 2001 From: gumi Date: Mon, 23 Jul 2018 15:55:10 -0400 Subject: update the documentation for local functions --- doc/script_commands.txt | 89 +++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 33 deletions(-) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 3b77aeb2c..9dcf21978 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -1942,58 +1942,64 @@ will result in error and termination of the script. --------------------------------------- -*function ; -*{(, ...)}; -*function { +{public | private} *function ; +{public | private} *function { } -This works like callfunc(), and is used for cleaner and faster scripting. -The function must be defined and used within a script, and works like a -label with arguments. -Note that the name may only contain alphanumeric characters and underscore. +In its first form, this syntax declares a local function so it can later be +defined. In its second form, the syntax both declares and defines a local +function. Local functions must be defined before being used. Note that the name +may only contain alphanumeric characters and underscore. Once defined, they can +be called from the current script as if they were regular built-in commands, and +can also be called from other scripts if they are marked as public. Local +functions may be marked as public by simply adding "public" prior to the +function definition. Functions not marked as public are private by default and +cannot be called from another script. Usage: 1. Declare the function. function ; 2. Call the function anywhere within the script. - It can also return a value when used with parentheses. - ; - 3. Define the function within the script. + (); + 3. Define the function by adding its script. {} + Step 1 is optional if the function is defined prior to being called. + Example: -prontera,154,189,4 script Item Seller 767,{ /* Function declaration */ - function SF_Selling; + function MyFunction; - if (Zeny > 50) { - mes("Welcome!"); - /* Function call */ - SF_Selling(); - } else { - mes("You need 50z, sorry!"); - } - close(); + /* Function call */ + MyFunction(); /* Function definition */ - function SF_Selling { - mes("Would you like to buy a phracon for 50z?"); - next(); - if (select("Yes", "No, thanks") == 1) { - Zeny -= 50; - getitem(Phracon, 1); - mes("Thank you!"); - } + function MyFunction { + // (do something) return; } -} + + +Example with public functions: + + /* Function declaration + definition */ + public function myFunction { + /* notice the "public" before the "function" keyword */ + return; + } + + /* Local call */ + myFunction(); + + /* Call from another script */ + "npc name"::myFunction(); + Example with parameters and return value: -prontera,150,150,0 script TestNPC 123,{ /* Function declaration */ function MyAdd; @@ -2002,18 +2008,35 @@ prontera,150,150,0 script TestNPC 123,{ input(.@a); input(.@b); /* Function call */ - mes(.@a+" + "+.@b+" = "+MyAdd(.@a, .@b)); + mesf("%i + %i = %i", .@a, .@b, MyAdd(.@a, .@b)); close(); /* Function definition */ function MyAdd { - return(getarg(0)+getarg(1)); + return (getarg(0) + getarg(1)); } -} --------------------------------------- +*({...}) +*""::({...}) +*callfunctionofnpc("", ""{, ...}); + +In its first form, calls a previously defined local function. In its second +form, calls a previously defined public local function of another NPC. If the +name of the target NPC or the name of the local function is not known +beforehand, callfunctionofnpc() can be used instead of the second form. +See function() above for more details. + +Example: + + MyFunction(arg1, arg2, arg3); + "MyNPC"::MyFunction(arg1, arg2, arg3); + callfunctionofnpc("MyNPC", "MyFunction", arg1, arg2, arg3); + +--------------------------------------- + *is_function("") This command checks whether or not a function exists and returns its type. -- cgit v1.2.3-70-g09d2 From 944d8489f1bcca93e6b2ff06a159084f064dce12 Mon Sep 17 00:00:00 2001 From: "Hercules.ws" Date: Mon, 4 May 2020 16:04:29 +0200 Subject: Constants Documentation Sync Signed-off-by: HerculesWSAPI --- doc/constants.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'doc') diff --git a/doc/constants.md b/doc/constants.md index 509764424..09ff61381 100644 --- a/doc/constants.md +++ b/doc/constants.md @@ -381,6 +381,7 @@ ### Cell checks +- `cell_gettype`: 0 - `cell_chkwall`: 1 - `cell_chkwater`: 2 - `cell_chkcliff`: 3 @@ -388,6 +389,7 @@ - `cell_chkreach`: 5 - `cell_chknopass`: 6 - `cell_chknoreach`: 7 +- `cell_chkstack`: 8 - `cell_chknpc`: 9 - `cell_chkbasilica`: 10 - `cell_chklandprotector`: 11 -- cgit v1.2.3-70-g09d2 From ef2564a4e826b24aeef704654dacc0ecf9959206 Mon Sep 17 00:00:00 2001 From: gumi Date: Sat, 28 Mar 2020 19:21:24 -0400 Subject: add documentation for the octal and binary literals --- doc/script_commands.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 392aa0c1f..64ba17ab7 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -434,12 +434,27 @@ marked as usable in pet scripts to work in there reliably. Numbers ------- +The Hercules scripting engine supports 4 types of number literals: + +type base syntax +---------------------------------------------- +decimal 10 255 +hexadecimal 16 0xFF +octal 8 0o377 +binary 2 0b11111111 + Beside the common decimal numbers, which are nothing special whatsoever (though do not expect to use fractions, since ALL numbers are integer in this language), the script engine also handles hexadecimal numbers, which are otherwise identical. Writing a number like '0x' will make it recognized as a hexadecimal value. Notice that 0x10 is equal to 16. -Also notice that if you try to 'mes 0x10' it will print '16'. +Also notice that if you try to 'mes 0x10' it will print '16'. If you wish +to make calculations in base 8, you can also use the octal notation like +'0o'. To make calculations in base 2 (binary), you can use +the binary notation like '0b'. + +The following are all equivalent: + 255 == 0xFF == 0o377 == 0b11111111 Number values can't exceed the limits of an integer variable: Any number greater than INT_MAX (2147483647) or smaller than INT_MIN (-2147483648) will -- cgit v1.2.3-70-g09d2 From 554101ef7ff2e4d8e9991b0ef72b38adcbbabec9 Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 3 May 2020 23:10:59 -0400 Subject: add documentation for the number separators --- doc/script_commands.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 64ba17ab7..a15baf2c2 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -460,6 +460,13 @@ Number values can't exceed the limits of an integer variable: Any number greater than INT_MAX (2147483647) or smaller than INT_MIN (-2147483648) will be capped to those values and will cause a warning to be reported. +Underscores can also be used as visual separators for digit grouping purposes: + 2_147_483_647 + 0x7FFF_FFFF + +Keep in mind that number literals cannot start or end with a separator and no +more than one separator can be used in a row (so 12_3___456 is illegal). + Variables --------- -- cgit v1.2.3-70-g09d2 From 66f9a2a1bc2fd509d13729ad6bc586a3b7ad2347 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 1 May 2020 21:38:00 +0200 Subject: Update doc/script_commands.txt * Add note about maximum length of a string variable's value * Add note about maximum length of a string read by input() script command --- doc/script_commands.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 3b77aeb2c..3c0b37a85 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -536,7 +536,9 @@ variables or an empty string ("", nothing between the quotes) for string variables. Once you set it to that, the variable is as good as forgotten forever, and no trace remains of it even if it was stored with character or account data. The maximum length of variable name including prefix and -suffix is 32. +suffix is 32. Permanent string variables (name$, $name$, #name$, ##name$) +can store text with a maximum length of 255 characters. All other string +type variables have no such limitation. Some variables are special, that is, they are already defined for you by the scripting engine. You can see the full list somewhere in @@ -1710,7 +1712,8 @@ The default value of 'min' and 'max' can be set with 'input_min_value' and For numeric inputs the value is capped to the range [min, max]. Returns 1 if the value was higher than 'max', -1 if lower than 'min' and 0 otherwise. For string inputs it returns 1 if the string was longer than 'max', -1 is -shorter than 'min' and 0 otherwise. +shorter than 'min' and 0 otherwise. Note that an input string has a maximum +length of 70 characters. --------------------------------------- -- cgit v1.2.3-70-g09d2 From cfe2d8527ecc8eb8e6dfacc7e661c5ed1f08ddd9 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Wed, 13 May 2020 04:51:13 +0200 Subject: Update documentation of enable_items() and disable_items() script commands --- doc/script_commands.txt | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 3b77aeb2c..f4d09ec09 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -5637,21 +5637,32 @@ Example: --------------------------------------- -*enable_items() -*disable_items() - -These commands enable/disable changing of equipments while an NPC is -running. When disable_items() is run, equipments cannot be changed -during scripts until enable_items() is called or the script has -terminated. To avoid possible exploits, when disable_items() is invoked, -it will only disable changing equips while running that script in -particular. Note that if a different script also calls disable_items(), -it will override the last call (so you may want to call this command at -the start of your script without assuming the effect is still in -effect). -If 'item_enabled_npc' option is set to true in 'conf/map/battle/items.conf' all -NPC are allowing changing of equipment by default except for those have been -set with 'disable_items'. +*enable_items({}) +*enableitemuse({}) +*disable_items({}) +*disableitemuse({}) + +These commands enable/disable item actions while interacting with a NPC. +When disable_items() is invoked, item actions defined by are disabled +during scripts until enable_items() is called or the script has terminated. +To avoid possible exploits, when disable_items() is invoked, it will only +disable item actions while running that script in particular. +Note that if a different script also invokes disable_items(), it will override +the last call so you may want to call this command at the start of your +script without assuming the effect is still in effect. +If is omitted all item actions will be disabled. +The enable_items() command enables item actions defined by during +scripts until disable_items() is invoked or the script has terminated. +If is omitted it defaults to 'item_enabled_npc' battle flag. +For a list of supported flags have a look at the description of +'item_enabled_npc' battle flag in 'conf/map/battle/items.conf'. +Unless disable_items() or enable_items() is invoked the script will use +'item_enabled_npc' battle flag by default. + +Example: + + // This will disable changing equipment during this script. + disable_items(ITEMENABLEDNPC_EQUIP); --------------------------------------- -- cgit v1.2.3-70-g09d2 From aa44b976cb7a512c2ad89c2e8974f525e77f1a7b Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 22 May 2020 05:04:21 +0200 Subject: Add MSC_MAGICATTACKED to doc/mob_skill_db.md --- doc/mob_skill_db.md | 1 + 1 file changed, 1 insertion(+) (limited to 'doc') diff --git a/doc/mob_skill_db.md b/doc/mob_skill_db.md index 12d3649de..8198446d3 100644 --- a/doc/mob_skill_db.md +++ b/doc/mob_skill_db.md @@ -175,6 +175,7 @@ MSC_MASTERHPLTMAXRATE | The monster master's HP in percent is less than `Conditi MSC_MASTERATTACKED | The monster's master is attacked. MSC_ALCHEMIST | The monster was summoned by an Alchemist class character. MSC_SPAWN | The monster spawns. +MSC_MAGICATTACKED | The monster has received magic damage. ### ConditionData Additional cast condition data. Meaning depends on the situation. See `CastCondition` table. -- cgit v1.2.3-70-g09d2 From cc4956cb356e61eeab85431a07746a70c6348f19 Mon Sep 17 00:00:00 2001 From: "Hercules.ws" Date: Wed, 27 May 2020 13:21:42 +0200 Subject: Constants Documentation Sync Signed-off-by: HerculesWSAPI --- doc/constants.md | 1 + 1 file changed, 1 insertion(+) (limited to 'doc') diff --git a/doc/constants.md b/doc/constants.md index 09ff61381..5feb3736d 100644 --- a/doc/constants.md +++ b/doc/constants.md @@ -5095,6 +5095,7 @@ - `MSC_MASTERATTACKED`: 20 - `MSC_ALCHEMIST`: 21 - `MSC_SPAWN`: 22 +- `MSC_MAGICATTACKED`: 23 ### monster skill targets -- cgit v1.2.3-70-g09d2 From c54623866cc7764ce6b2c0844c7d98a80b5f0592 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sun, 31 May 2020 23:35:39 +0200 Subject: Add loudhailer() script command to doc/script_commands.txt --- doc/script_commands.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index a597dfaa2..a3a0e5673 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -7494,6 +7494,16 @@ if GID is not given use the attached player. //===================================== --------------------------------------- +*loudhailer(""{, ""}) + +Announces a colored text in ' Shouts : ' format. + must be a string in "RRGGBB" format. If is omitted, +white ("FFFFFF") will be used. +This command is specially created for the Megaphone_ item (12221), +but will work in NPCs, too. + +--------------------------------------- + *announce("", {, {, {, {, {, }}}}}) This command will broadcast a message to all or most players, similar to -- cgit v1.2.3-70-g09d2 From cd95e95a41a9d9f3cecd9efa0aaa52eb6f4ec7ea Mon Sep 17 00:00:00 2001 From: "Hercules.ws" Date: Mon, 1 Jun 2020 04:21:58 +0200 Subject: Constants Documentation Sync Signed-off-by: HerculesWSAPI --- doc/constants.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc') diff --git a/doc/constants.md b/doc/constants.md index 5feb3736d..c44654b71 100644 --- a/doc/constants.md +++ b/doc/constants.md @@ -5133,6 +5133,18 @@ - `PCBLOCK_COMMANDS`: 128 - `PCBLOCK_NPC`: 256 +### NPC item action constants + +- `ITEMENABLEDNPC_NONE`: 0 +- `ITEMENABLEDNPC_EQUIP`: 1 +- `ITEMENABLEDNPC_CONSUME`: 2 + +### NPC allowed skill use constants + +- `SKILLENABLEDNPC_NONE`: 0 +- `SKILLENABLEDNPC_SELF`: 1 +- `SKILLENABLEDNPC_ALL`: 2 + ### private airship responds - `P_AIRSHIP_NONE`: 0 -- cgit v1.2.3-70-g09d2