Quest, Shops, Functions & Algorithms

Sign in to follow this  
Followers 0

Scripts that rewards players for hunting monsters and/or gathering items, shops, or simply want to show simple functions and algorithms of scripting.
Example: Headgear exchanger, Quest scripts, Mall NPC, Weapon dealer, Decimal Point System, Sorting Algorithm

11 files

  1. function

    This script provides functions to easily calculate date and time. More functions might be added in the future.
     
     
    now()
    a shorthand function to get the current time
    > returns the number of seconds elapsed since the Unix epoch
    now() // => 1497119219 (example, increments every second)


    time_from_ms(<delta>)
    calculates a Unix timestamp relative to the current time
    > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> ms
    time_from_ms(0) // => 1497119219 (example, increments every second) time_from_ms(+1000) // => 1497119220 time_from_ms(-1000) // => 1497119218


    time_from_seconds(<delta>)
    calculates a Unix timestamp relative to the current time
    > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> seconds
    time_from_seconds(0) // => 1497119219 (example, increments every second) time_from_seconds(+1) // => 1497119220 time_from_seconds(-1) // => 1497119218


    time_from_minutes(<delta>)
    calculates a Unix timestamp relative to the current time
    > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> minutes
    time_from_minutes(0) // => 1497119219 (example, increments every second) time_from_minutes(+1) // => 1497119279 time_from_minutes(-1) // => 1497119159


    time_from_hours(<delta>)
    calculates a Unix timestamp relative to the current time
    > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> hours
    time_from_hours(0) // => 1497119219 (example, increments every second) time_from_hours(+1) // => 1497122819 time_from_hours(-1) // => 1497115619


    time_from_days(<delta>)
    calculates a Unix timestamp relative to the current time
    > returns the number of seconds elapsed since the Unix epoch, plus or minus <delta> days
    time_from_days(0) // => 1497119219 (example, increments every second) time_from_days(+1) // => 1497205619 time_from_days(-1) // => 1497032819


    FuzzyTime(<unix timestamp>)
    converts a Unix timestamp to a human-readable format
    > returns human-friendly relative time
    FuzzyTime(0) // => 47 years, 172 days, 18 hours, 52 minutes, and 28 seconds ago FuzzyTime(time_from_hours(+28)) // => in 1 day and 4 hours

     
    --------------------------------------------------------------------------------------
    This script was made by me, for The Mana World + Evol.
    License: public domain (CC0)

    17 downloads

    0 comments

    Updated

  2. function

    This script provides various array manipulation functions, and more might be added in the future.
    All of those functions (except the arithmetic ones) work with both integer and string arrays.
    The start of the array is always implicitly index 0, unless an index is specified, ie @array[index]



    array_pad(<array>, <size>, <value>)
    pads the array left or right with <value> until it reaches <size> size. If <size> is negative it will pad left.
    > returns the number of added entries
    setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_pad([email protected], 8, 69); // => 3 // array is now: 1, 2, 3, 4, 5, 69, 69, 69 setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_pad([email protected], -8, 69); // => 3 // array is now: 69, 69, 69, 1, 2, 3, 4, 5


    array_replace(<array>, <needle>, <replacement>{, <neq>})
    finds every occurrence of <needle> within the array and replaces it with <replacement>. if <neq> is true, finds entries that do not match instead
    > returns the number of changed entries setarray([email protected], 1, 1, 3, 1, 5); // initialize the array array_replace([email protected], 1, 69); // => 3 // array is now: 69, 69, 3, 69, 5


    array_find(<array>, <needle>{, <neq>})
    finds the first occurrence of <needle> within the array. if <neq> is true, finds entries that do not match instead
    > returns the index, or if none is found returns -1 setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_find([email protected], 3); // => 2 array_find([email protected], 1); // => 0 array_find([email protected], 6); // => -1


    array_rfind(<array>, <needle>{, <neq>})
    like array_find, but finds the last occurrence. if <neq> is true, finds entries that do not match instead
    > returns the index, or if none is found returns -1 setarray([email protected], 1, 2, 3, 4, 3); // initialize the array array_rfind([email protected], 3); // => 4 array_rfind([email protected], 4); // => 3 array_rfind([email protected], 6); // => -1


    array_exists(<array>, <needle>{, <neq>})
    very similar to array_find() but it instead just checks if it exists or not. if <neq> is true, finds entries that do not match instead > returns true or false setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_exists([email protected], 3); // => true array_exists([email protected], 6); // => false


    array_count(<array>, <needle>{, <neq>})
    similar to array_find() but iterates through the whole array. if <neq> is true, finds entries that do not match instead
    > returns the total number of occurrences of <needle> setarray([email protected], 1, 69, 3, 69, 5); // initialize the array array_count([email protected], 69); // => 2


    array_entries(<array>)
    a wrapper around array_count(). behaves similarly to getaraysize() but does not count holes
    > returns the number of non-empty entries setarray([email protected], 1, 2, 0, 0, 5); // initialize the array getarraysize([email protected]); // => 5 array_entries([email protected]); // => 3



    array_remove(<array>, <needle>{, <neq>})
    finds and removes every occurrence of <needle> from the array, while shifting left. if <neq> is true, finds entries that do not match instead
    > returns the number of removed entries setarray([email protected], 1, 69, 3, 69, 5); // initialize the array array_remove([email protected], 69); // => 2 // array is now: 1, 3, 5


    array_reverse(<array>)
    reverses the array
    > returns true setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_reverse([email protected]); // => true // array is now: 5, 4, 3, 2, 1


    array_sum(<array>)
    iterates through the whole array to perform an arithmetic addition
    > returns the sum of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_sum([email protected]); // ((((1 + 2) + 3) + 4) + 5) => 15


    array_difference(<array>)
    iterates through the whole array to perform an arithmetic subtraction
    > returns the difference of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_difference([email protected]); // ((((1 - 2) - 3) - 4) - 5) => -13


    array_product(<array>)
    iterates through the whole array to perform an arithmetic multiplication
    > returns the product of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_product([email protected]); // ((((1 * 2) * 3) * 4) * 5) => 120


    array_quotient(<array>)
    iterates through the whole array to perform an arithmetic division
    > returns the quotient of every entries of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_quotient([email protected]); // ((((1 / 2) / 3) / 4) / 5) => 0


    array_shift(<array>)
    removes the first entry of the array, while shifting left
    > returns the value of the removed entry setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_shift([email protected]); // => 1 // array is now: 2, 3, 4, 5


    array_unshift(<array>, <value>)
    adds <value> to the start of the array, while shifting right
    > returns the new size of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_unshift([email protected], 69); // => 6 // array is now: 69, 1, 2, 3, 4, 5


    array_pop(<array>)
    removes the last entry of the array
    > returns the value of the removed entry setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_pop([email protected]); // => 5 // array is now: 1, 2, 3, 4


    array_push(<array>, <value>)
    adds <value> to the end of the array
    > returns the new size of the array setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_push([email protected], 69); // => 6 // array is now: 1, 2, 3, 4, 5, 69


    array_shuffle(<array>)
    shuffles the array
    > returns true setarray([email protected], 1, 2, 3, 4, 5); // initialize the array array_shuffle([email protected]); // => true // array is now: 1, 4, 2, 3, 5 (example, unpredictable)


    array_unique(<array>{, <threshold>})
    allows array entries to appear up to <threshold> times (1 by default) and removes the extraneous ones. useful to remove duplicate entries
    > returns the number of removed entries
    setarray([email protected], 1, 3, 3, 4, 5); // initialize the array array_unique([email protected]); // => 1 // array is now: 1, 3, 4, 5


    array_diff(<base array>, <array>{, <array>...}, <result array>)
    compares the base array against one or more other arrays and fills the result array with the entries in base array that are not present in any of the other arrays
    > returns the number of entries not found in other arrays
    setarray([email protected], 1, 2, 3, 4, 5, 6, 7, 8); // initialize the base array // fill the arrays to compare with the base array: setarray([email protected], 2, 3, 4, 5, 6, 7, 8); // missing "1" setarray([email protected], 1, 2, 3, 4, 6, 7, 8); // missing "5" setarray([email protected], 1, 2, 3, 4, 5, 6, 7); // missing "8" // compare foo, bar and baz against base, and fill result: array_diff([email protected], [email protected], [email protected], [email protected], [email protected]); // => 3 // [email protected] is now: 1, 5, 8



    Requires Hercules of June 24 2017 or newer version


     
    --------------------------------------------------------------------------------------
    This script was made by me, for The Mana World + Evol.
    License: public domain (CC0)

    70 downloads

    10 comments

    Updated

  3. This script provides helper functions for argument randomization.
     
     
    any(<arg>{, <arg>{, ...}})
    returns a random argument from the passed arguments
    emotion(any(e_hmm, e_grat, e_yawn)); // do any of those 3 emotes    
    any_of(<array>)
    returns a random member from the passed array
    setarray([email protected], 1, 2, 3, 4); // build the array // ... later in the code: mes(any_of([email protected])); // print any number from the array    
     
    Those commands work with both strings and integers; you can pass anything to it
     
     
    --------------------------------------------------------------------------------------
    This script was made by me, for The Mana World + Evol.
    License: public domain (CC0)

    12 downloads

    0 comments

    Updated

  4. This script provides safe string manipulation functions that do not require PCRE to be enabled at compile time, making your scripts more portable.



    startswith("<string>", "<substring>")
    returns true if <string> begins with <substring>
    startswith("hypothermia", "hypo") // true startswith("hypothermia", "hyper") // false


    endswith("<string>", "<substring>")
    returns true if <string> ends with <substring> endswith("hypothermia", "thermia") // true endswith("hypothermia", "glycemia") // false


    capitalize("<string>")
    returns <string> with its first letter being capitalized capitalize("the quick brown fox") // The quick brown fox


    titlecase("<string>")
    returns <string> with the first letter of every word capitalized titlecase("the quick brown fox") // The Quick Brown Fox


    camelcase("<string>")
    returns <string> concatenated in a camelCase fashion camelcase("the quick brown fox") // theQuickBrownFox


    zfill("<string>"{, <width>{, "<padding>"}})
    returns <string> padded to the left up to <width> with <padding> zfill(69, 6, "0"); // 000069 zfill(1337, 6, "0"); // 001337


    format_number(<number>{, "<separator>"})
    formats a number with <separator> format_number(50) // 50 format_number(50000) // 50,000 format_number(5000000) // 5,000,000


    strip("<string>")
    returns <string> without spaces at the beginning or end strip(" the quick brown fox") // "the quick brown fox" strip("the quick brown fox ") // "the quick brown fox" strip(" the quick brown fox ") // "the quick brown fox"


    reverse("<string>")
    returns <string> reversed reverse("Hello world!") // !dlrow olleH


    repeat("<string>", <multiplier>)
    repeats <string> <multiplier> times repeat("Foo", 4) // FooFooFooFoo


    shuffle("<string>")
    returns <string> shuffled
    shuffle("abcdefg") // dgabefc (example, unpredictable)
     

    6 downloads

    0 comments

    Updated

  5. This script provides functions to add (or remove) timers to every player in the area or map.
     
     
     
    areatimer("<map>", <x1>, <y1>, <x2>, <y2>, <tick>, "<event>")
    makes all players in the square area call <event> after <tick> ms
    > returns the number of affected players
    areatimer("prontera", 55, 60, 150, 180, 500, "MyNPC:MyEvent");
     
     
    areatimer2("<map>", <x1>, <y1>, <x2>, <y2>, <tick>, "<event>")
    identical to areatimer, but also removes any existing timer before adding the new one
    > returns the number of affected players
    areatimer2("prontera", 55, 60, 150, 180, 500, "MyNPC:MyEvent");
     
     
    areadeltimer("<map>", <x1>, <y1>, <x2>, <y2>, "<event>")
    makes all players in the square area remove their timers for <event>
    > returns the number of affected players
    areadeltimer("prontera", 55, 60, 150, 180, "MyNPC:MyEvent");
     
     
    maptimer("<map>", <tick>, "<event>")
    makes all players in the map call <event> after <tick> ms
    > returns the number of affected players
    maptimer("prontera", 500, "MyNPC:MyEvent");
     
     
    maptimer2("<map>", <tick>, "<event>")
    identical to maptimer() but also removes any existing timer before adding the new one
    > returns the number of affected players
    maptimer2("prontera", 500, "MyNPC:MyEvent");
     
     
    mapdeltimer("<map>", "<event>")
    makes all players on the map remove their timers for <event>
    > returns the number of affected players
    mapdeltimer("prontera", "MyNPC:MyEvent");
     
     
     
    Requires Hercules of April 8th 2017 or newer version
     
     
    --------------------------------------------------------------------------------------
    This script was made by me, for The Mana World + Evol.
    License: public domain (CC0)

    12 downloads

    0 comments

    Updated

  6. Origanal post: http://herc.ws/board/topic/6541-function-random-itemvariable/
    Author: Dastgir
    Just fix some bug and reup.

    44 downloads

    0 comments

    Updated

  7. [YGGPB] Exchanger
     
     
    So what exactly is the [YGGPB] Exchanger? (Yggdrasil and Poison Bottle Exchanger)
     
     
    Exactly what you think.
     
    It will exchange your Yggdrasil Berry's at a rate of 100 for a 1 Yggdrasil box.
    It will exchange Poison Bottles at a rate of 30 for 1 Poison Bottle box.
     
    NOTE:
    IF there's more exchanges you guys know of (I never focused on boxes) Please tell me, I will include them in this exchanger NPC.
     
    View screenshots for more idea of this NPC, simple but useful! You're welcome NewbieNewb

    57 downloads

    0 comments

    Updated


  8. //===== Description: =========================================================//= Rotates each month. January (Capricorn) to December (Sagittarius)//= Counts and displays required items and how much you miss//= Player can choose to make diadem or crown//============================================================================
     
    the sprites of the zodiac crowns/diadems are not in kro's data.grf, so I uploaded them here too.

    145 downloads

    0 comments

    Updated

  9. Guild package Redeemer NPC
    [NPC Information]
    Includes:
    1.Package Code Generator
    2.Package Code ( for Guild with Players of the same IP )
    3.Different Package set for Guild Master.
    4.Different Package set for Guild Member.
     
    To Redeem the guild package:
    1.Should be a Guild Master
    2.Required Minimum Guild Member. (8 default)
    3.All Guild Members should be Online
    4.Non Duplicate IP Check ( to avoid multiple login of single player )
    5.Duplicate IP Check ( Use the code to bypass IP check )
    6.Online Status Check
    7.First time to Redeem GPack (IP Based)

    136 downloads

    0 comments

    Submitted

  10. [Zeny & Cash Gambler NPC v1.2]
    Explanation:
    /* Zeny & Cash Gambler NPCCreated by: AeromesiVersion 1.21.2 Features:Added in Second Chance Option (Edit .S_Chance to to Enable/Disable the Second Chance)Second chance only applies if you LOSE the gambleEdit .S_ChanceRate to change the % Rate at which players have the opportunity for a Second Chance.Default is set to 50% for a Second Chance and is enabled by default!Also fixed a bug where users could input 0 Zeny or Cash Points, didn't effect anything but the check for an input of 0 needed to be added in.Enjoy 1.2 Hercules! ~ AeromesiVersion: 1.11.1 Features (Massive Update)Control the Winning rates at the bottom of the OnInit.zWinningRate handles the winning rate for Zeny.cWinningRate handles the winning rate for Cash PointsNow you're able to input what you want to bet for Zeny and Cash PointsExample: You have 100 Zeny, you bet 100 Zeny (It takes 100 Zeny from you, in hopes you double your bet, gaining a total of 200 Zeny.Same goes for Cash Points, you spend 50 Cash points in hopes you get 100 Cash Points total.)Special thanks to GmOcean's Script "Slot Machine" for the cutins and wav files for this script.Special thanks to my girlfriend for helping me with the equation, and Max on the Hercules forum for the suggestion!Enjoy another release Hercules!If you like my work, please rep up my profile or consider viewing my Scripting services */
     
    How to install:
    Unrar the attachment "zeny_cash_gambler.rar".
    Merge "gambler.grf" with your custom GRF so the sound effects and illustrations display correctly.
    Install "zeny_cash_gambler.txt" into your servers NPC folder.
    Edit the header of the script to your own map coordinates.
     
    And after that's all done, enjoy!
     
    Remember, if you like my work, it wouldn't hurt to rep me up or view my Scripting Services!

    283 downloads

    0 comments

    Updated

  11. This Function does something which is useful for some scripts.
    This function gives you item or adds/substract the variable value.
     
    Example:
    mes "Random between 7227,1 and 502,2 and 7227,2"; callfunc "rand_add",1,7227,1,502,2,7227,2; next; mes "Random between 1 Cash Points and 2 PvP Points"; callfunc "rand_add",2,"#CASHPOINTS","Cash Points",1,"pvp_points","PvP Points",2; next; mes "Random items that are mentioned in function"; callfunc "rand_add",0; close;
     
    Setting the value negative for variables will decrease them, while doing so for items, will not delete the item.

    112 downloads

    0 comments

    Submitted

Sign in to follow this  
Followers 0