diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-04-09 13:33:57 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-04-09 13:33:57 -0300 |
commit | cf18ce071c79ae37e14ea38943e0b1d88da70a7b (patch) | |
tree | f9159c9b60b3018300dd22ffba0d797bc5e828e5 /npc/functions/main.txt | |
parent | 8a4bf716002a017de77fe7df301ef8e4aaf00a2e (diff) | |
download | serverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.tar.gz serverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.tar.bz2 serverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.tar.xz serverdata-cf18ce071c79ae37e14ea38943e0b1d88da70a7b.zip |
Override
Diffstat (limited to 'npc/functions/main.txt')
-rw-r--r-- | npc/functions/main.txt | 445 |
1 files changed, 0 insertions, 445 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt deleted file mode 100644 index 8029f3eb..00000000 --- a/npc/functions/main.txt +++ /dev/null @@ -1,445 +0,0 @@ -// Evol functions. -// Authors: -// 4144 -// Jesusalva -// Travolta -// Description: -// Build in functions. - -/** - * checks whether the given argument is a char name or account id - * and tries to convert it to an account id - * - * @arg 0 - char name or account id - * @return the account id - */ -function script nameid2id { - if ((getdatatype(getarg(0, "")) & DATATYPE_STR) != 0) { - if (getarg(0, "") == "") { - return playerattached(); - } else { - return getcharid(CHAR_ID_ACCOUNT, getarg(0)); - } - } else if (getarg(0) == 0) { - return playerattached(); - } else { - return getarg(0); - } -} - -function script menuimage { - return getarg(0) + "|" + getarg(1); -} - -function script menuaction { - return "[" + getarg(0) + "]"; -} - -function script mesn { - if (getargcount() > 0) - { - .@s$ = "[" + getarg(0) + "]"; - } - else - { - .@s$ = "[" + strnpcinfo(1) + "]"; - } - mes .@s$; - return; -} - -function script mesq { - mes "\"" + getarg(0)+ "\""; - return; -} - -function script g { - consolemes(CONSOLEMES_ERROR, "Deprecated function \"g\" used, results are not reliable."); - return rand(1000) % 2 ? getarg(0) : getarg(1); -} - -function script b { - return "##B" + getarg(0) + "##b"; -} - -function script col { - .@color = getarg(1); - if (.@color < 0) .@color = 0; - if (.@color > 9) .@color = 9; - return "##" + .@color + getarg(0) + "##0"; -} - -function script mesc { - return mes(col(getarg(0, ""), getarg(1, 9))); -} - -// *showimage("<file>"); -// Displays an image in the NPC window. If no file extension is provided, it is -// assumed to be a PNG file. The image path is relative to client-data/graphics. -// example: -// showimage("guiicons/flags/fr"); -function script showimage { - .@file$ = getarg(0); - - if (!endswith(getarg(0), ".jpg") && !endswith(getarg(0), ".png")) { - .@file$ += ".png"; - } - - if (charat(getarg(0), 0) == "/") { - .@file$ = delchar(.@file$, 0); // absolute path from root of client-data - } else if (!startswith(getarg(0), "help/") && !startswith(getarg(0), "graphics/") ) { - .@file$ = "graphics/" + .@file$; // assume relative to graphics/ - } - - return mesf("~~~%s~", .@file$); -} - -function script adddefaultskills { - if (getskilllv(NV_BASIC) < 6) - { - skill NV_BASIC, 6, 0; - } - return; -} - -function script addremovemapmask { - setmapmask getarg(0), (getmapmask(getarg(0)) | (getarg(1) + getarg(2))) ^ getarg(2); - return; -} - -// Function to show narrator text. Accepts string args. -// If first arg is a number N, then it represents bit flags. -// Bit flags : -// S_FIRST_BLANK_LINE -- blank line at beginning -// S_LAST_BLANK_LINE -- blank line at the end -// S_LAST_NEXT -- use last "next();" -// S_NO_NPC_NAME -- don't use first "mesn();" -// S_LAST_CLOSE -- use last "close2(); -function script narrator { - .@start = 0; - .@argc = getargcount(); - .@flags = 0; - - if (.@argc > 1 && (getdatatype(getarg(0)) & DATATYPE_INT) != 0) { - .@start = 1; - .@flags = getarg(0); - } - - if ((.@flags & S_FIRST_BLANK_LINE) != 0) { - mes(""); - } - - if ((.@flags & S_NO_NPC_NAME) == 0) { - mesn(l("Narrator")); - } - - for (.@i = .@start; .@i < .@argc; .@i++) { - mes(col(getarg(.@i), 9)); - - if (.@i < .@argc - 1) { - next(); - } - } - - if ((.@flags & S_LAST_BLANK_LINE) != 0) { - mes(""); - } - - if ((.@flags & S_LAST_NEXT) != 0) { - next(); - } else if ((.@flags & S_LAST_CLOSE) != 0) { - close2(); - } - - return; -} - -// Function to show NPC speech. Accepts string args. -// If first arg is a number N, then it represents bit flags. -// Bit flags : -// 0x1 -- blank line at beginning -// 0x2 -- blank line at the end -// 0x4 -- use last "next;" -// 0x8 -- don't use first "mesn;" -function script speech { - .@start = 0; - .@argc = getargcount(); - .@flags = 0; - - if (.@argc > 1 && !isstr(getarg(0))) - { - .@start = 1; - .@flags = getarg(0); - } - - if (.@flags & 0x1) - mes ""; - - if (!(.@flags & 0x8)) - mesn; - - for (.@i = .@start; .@i < .@argc; .@i++) - { - mesq getarg(.@i); - - if (.@i < .@argc - 1) - next; - } - - if (.@flags & 0x4) - next; - else if (.@flags & 0x2) - mes ""; - - return; -} - -// Show debug message if .debug variable of NPC is set to 1 -function script npcdebug { - if (getvariableofnpc(.debug, strnpcinfo(3))) - consolemes(CONSOLEMES_DEBUG, strnpcinfo(3) + ": " + getarg(0)); - return; -} - -function script askyesno { - .@sel = select(menuaction(l("Yes")), - menuaction(l("No"))); - mes ""; - return .@sel; -} - -// Argument: -// 0 Quest variable -// 1 Current value -// 2 Next value -function script compareandsetq { - if (getq(getarg(0)) == getarg(1)) - { - setq getarg(0), getarg(2); - return true; - } - return false; -} - -// Use a delay to prevent spams from NPC that display text without the -// use of (a) close/next function(s). -// Argument: -// 0 Text to display -// 1 Lock delay (default = 1) -// 2 Message function: (default = 0) -// 0 = npctalk3 -// 1 = npctalk -// 2 = message -function script npctalkonce { - // lock mechanism - switch (getarg(2, 0)) - { - case 1: - if (gettimetick(2) <= getvariableofnpc(.talk_lock, strnpcinfo(NPC_NAME_UNIQUE))) - return false; - set(getvariableofnpc(.talk_lock, strnpcinfo(NPC_NAME_UNIQUE)), gettimetick(2) + getarg(1, 1)); - break; - default: - if (gettimetick(2) <= @NPC_TALK_LOCK[getnpcid()]) - return false; - @NPC_TALK_LOCK[getnpcid()] = gettimetick(2) + getarg(1, 1); - } - - // talk mechanism - switch (getarg(2, 0)) - { - case 0: npctalk3(getarg(0)); break; - case 1: npctalk(getarg(0)); break; - case 2: message(strcharinfo(0), getarg(0)); - } - - return true; -} - -function script getquestlink { - return "[@@q" + getarg(0) + "|@@]"; -} - -function script getmonsterlink { - return "[@@m" + getarg(0) + "|@@]"; -} - -function script getpetlink { - return "[@@p" + getarg(0) + "|@@]"; -} - -function script getmercenarylink { - return "[@@M" + getarg(0) + "|@@]"; -} - -function script gethomunculuslink { - return "[@@h" + getarg(0) + "|@@]"; -} - -// Returns the player race in plain text -// GETRACE_RACE - returns player race (default) -// GETRACE_SKIN - returns player skin -// GETRACE_FULL - returns player skin + race -// Can take an optional 2nd param with the class -// get_race( {Flag, {Class}} ) -function script get_race { - .@m=getarg(0, GETRACE_RACE); - .@g=getarg(1, Class); - - // We also allow this to run without player attached for... science. - if (playerattached()) - { - setarray .@allraces$, l("Human"), l("Human"), l("Human"), - l("Ukar"), l("Ukar"), - l("Tritan"), l("Tritan"), - l("Raijin"), l("Raijin"), - l("Kralog"), l("Kralog"); - setarray .@allskins$, l("Kaizei"), l("Argaes"), l("Tonori"), - l("Cave"), l("Mountain"), - l("Sea"), l("Lake"), - l("Light"), l("Dark"), - l("Fire"), l("Frost"); - } - else - { - setarray .@allraces$, ("Human"), ("Human"), ("Human"), - ("Ukar"), ("Ukar"), - ("Tritan"), ("Tritan"), - ("Raijin"), ("Raijin"), - ("Kralog"), ("Kralog"); - setarray .@allskins$, ("Kaizei"), ("Argaes"), ("Tonori"), - ("Cave"), ("Mountain"), - ("Sea"), ("Lake"), - ("Light"), ("Dark"), - ("Fire"), ("Frost"); - } - - if (.@m == GETRACE_RACE) - return .@allraces$[.@g]; - else if (.@m == GETRACE_SKIN) - return .@allskins$[.@g]; - else - return .@allskins$[.@g] + " " + .@allraces$[.@g]; -} - -// Clear output of getinventorylist() -// delinventorylist() -function script delinventorylist { - deletearray @inventorylist_id; - deletearray @inventorylist_amount; - deletearray @inventorylist_equip; - deletearray @inventorylist_refine; - deletearray @inventorylist_identify; - deletearray @inventorylist_attribute; - deletearray @inventorylist_card1; - deletearray @inventorylist_card2; - deletearray @inventorylist_card3; - deletearray @inventorylist_card4; - deletearray @inventorylist_expire; - deletearray @inventorylist_bound; - @inventorylist_count=0; - return; -} - -// isin( map, x1, y1, {[x2, y2][radius]} ) -function script isin { - if (getmapxy(.@mapName$, .@xpos, .@ypos, 0) != 0) - return false; - if (.@mapName$ != getarg(0)) - return false; - - if (getarg(4,-1) < 0) { - // Radius Based - if (.@xpos >= getarg(1)-getarg(3) && .@xpos <= getarg(1)+getarg(3) && .@ypos >= getarg(2)-getarg(3) && .@ypos <= getarg(2)+getarg(3)) - return true; - } else { - // Coordinate based - if (.@xpos >= getarg(1) && .@xpos <= getarg(3) && .@ypos >= getarg(2) && .@ypos <= getarg(4)) - return true; - } - return false; -} - -// Shortcut for getmapname() -function script getmap { - return getmapname(); -} - -// Quest Rewards -// quest_xp(maxLevel, reward, {multiplier=1}) -function script quest_xp { - //.@minLevel=getarg(0); - .@maxLevel=getarg(0); - .@reward=getarg(1); - .@mult=getarg(2, 1); - if (BaseLevel <= .@maxLevel) { - getexp .@reward*.@mult, 0; - return; - } - // You'll forsake 2% every over level - .@mult*=100; - .@mult-=((BaseLevel - .@maxLevel) * 2); - .@mult=max(10, .@mult); - getexp .@reward*.@mult/100, 0; - return; -} - -// quest_jxp(maxLevel, reward, {multiplier=1}) -function script quest_jxp { - //.@minLevel=getarg(0); - .@maxLevel=getarg(0); - .@reward=getarg(1); - .@mult=getarg(2, 1); - if (BaseLevel < .@maxLevel) { - getexp 0, .@reward*.@mult; - return; - } - // You'll forsake 2% every over level - .@mult*=100; - .@mult-=((BaseLevel - .@maxLevel) * 2); - .@mult=max(10, .@mult); - getexp 0, .@reward*.@mult/100; - return; -} - -// quest_gp(maxLevel, reward, {multiplier=1}) -function script quest_gp { - //.@minLevel=getarg(0); - .@maxLevel=getarg(0); - .@reward=getarg(1); - .@mult=getarg(2, 1); - if (BaseLevel <= .@maxLevel) { - Zeny+=.@reward*.@mult; - return; - } - // You'll forsake 2% every over level - .@mult*=100; - .@mult-=((BaseLevel - .@maxLevel) * 2); - .@mult=max(10, .@mult); - Zeny+=.@reward*.@mult/100; - return; -} - -// quest_item(maxLevel, item, {amount=1}, {bound=0}) -function script quest_item { - //.@minLevel=getarg(0); - .@maxLevel=getarg(0); - .@reward=getarg(1); - .@mult=getarg(2, 1); - .@bind=getarg(3, 0); - // Item will not be obtained if you are overlevel - if (BaseLevel > .@maxLevel && .@mult <= 1) - return; - // If it comes in pairs, you'll only get 1 - if (BaseLevel > .@maxLevel) - .@mult=1; - // Obtain item bound if needed - if (.@bind) - getitembound .@reward, .@mult, .@bind; - else - getitem .@reward, .@mult; - return; -} - - - |