Skorm

Freebie NPC v1.5

Jun 19th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.75 KB | None | 0 0
  1. //Version 1.5 rAthena Only
  2. prontera.gat,149,180,5  script  Freebie NPC 753,{
  3. //Configurable Char Variables
  4. set @c, 1; // This is a variable for first letter Case-change. ( 1=on/0=off )
  5. set @npc$,  "[^0000FFFreebie NPC^000000]";
  6. setarray @cmds$,    "getitemname""getcharid",    "strcharinfo";
  7. //End
  8.  
  9. //Character Vars
  10. set .@blvl, BaseLevel;
  11. set .@getitm$, ".itm"+#itmget+"$";
  12. set .@getitm_len, getarraysize(getd(.@getitm$));
  13. set .@nxtrblvl, atoi(getd(".itm"+(#itmget+1)+"$[2]"));
  14. set .@rblvl,    atoi(getd(.@getitm$+"[2]"));
  15. set .@itmid,    atoi(getd(.@getitm$));
  16. set .@itmam,    atoi(getd(.@getitm$+"[1]"));
  17. //End
  18.  
  19. //NPC Dialogue
  20. if(.@blvl>=.@rblvl) {
  21.     for(set .@s,0;.@s<(.@getitm_len-3);set .@s,.@s+1){
  22.         set .@op$, callfunc("dispmes_func",getd(.@getitm$+"["+(.@s+3)+"]"));
  23.         if(compare(.@op$,"next;")) { set .@op$, ""; next; }
  24.         if(compare(.@op$,"menu;")) { if(select("Yes:No")&2) close; set .@op$, ""; }
  25.         if(compare(.@op$,"close;")) { set .@op$, ""; close; }
  26.         if(compare(.@op$,"item;")) { set .@op$, ""; getitem .@itmid,.@itmam; set #itmget,#itmget+1; }
  27.         if(compare(.@op$,"npc;")) { set .@op$, @npc$; }
  28.         if(.@op$!="") mes .@op$;
  29.     }
  30. }
  31.  
  32. mes @npc$;
  33. set .@message$, (.@blvl<=.@rblvl )?
  34.         "You have already received this item, please come back when you are level "+.@rblvl+" for a special item."
  35.     :
  36.         ((.@rblvl<.@blvl )?
  37.                 "Sorry, I don't have anymore items to give you!"
  38.             :
  39.                 "");
  40. mes .@message$;
  41. close;
  42. //End
  43.  
  44.  
  45. end;
  46. OnInit:
  47.     waitingroom "Free items!",0;
  48.  
  49. //Configure NPC Items & Dialogue HERE!
  50.     //                  ItemID  Amount  Required-BaseLevel
  51.     setarray .itm0$,    "501""10",   "1",
  52.         "Npc;",
  53.         "Hello, strcharinfo(0), do you want this free item?",
  54.         "next;",    "menu;",
  55.         "Alright!", "item;",
  56.         "Goodbye.", "close;";
  57.  
  58.     setarray .itm1$,    "502""20",   "70",
  59.         "Npc;",
  60.         "Wow, strcharinfo(0), you're really strong!",
  61.         "I won't keep you waiting.",
  62.         "Here is your item- You've earned it!",
  63.         "item;", "Until we meet again.", "close;";
  64.  
  65.     setarray .itm2$,    "1599", "1",    "180",
  66.         "Npc;",
  67.         "You, sir, are a true god!",
  68.         "Hh-h-here is your getitemname(1599).",
  69.         "item;", "close;";
  70. //End
  71.  
  72. /*Explanation:
  73.     The first three values in each row are the only constant numbers.
  74.     First is the item_id then the amount you want to give then the level you give it at.
  75.     Every line after that is lucid. You can type what the npc is going to say.
  76.     You can also use optional commands that I will list below to display information.
  77.     Add new conditions by following my example just remember to change .itm<#>$ to the next value.
  78.     I hope everyone can understand this x.x Keep in mind this is just the first version.
  79.     It's still a little slow. You can change upper-case to ignore for speedup.
  80.    
  81. Commands Explained:
  82.     Commands that takeup one line:
  83.         "Npc;", -> This will display the npcs name.
  84.         "Item;", -> Will give the player item and increase quest value.
  85.         "Menu;", -> This will display a Yes and No menu.
  86.         "Close;", -> This will close the script.
  87.         "Next;", -> This will refresh chat window and display Next button.
  88.    
  89.     Commands that can be used in chat:
  90.         getitemname(<itemid>) -> Shows item name in chat.
  91.         getcharid(<type>) -> Will return character id number.
  92.         strcharinfo(<type>) -> displays information from charinfo. EX: strcharinfo(0) = Characters Name
  93.  
  94. Skorm
  95. */
  96.  
  97. }
  98.  
  99.  
  100. function    script  dispmes_func    {
  101.     set .@len,callfunc("str_explode2","@explosion$",getarg(0), 3, " ", "(", ")");
  102.     for(set .@a,0;.@a<.@len;set .@a,.@a+1) {
  103.         for(set .@b,0;.@b<getarraysize(@cmds$);set .@b,.@b+1){
  104.             if (compare(@explosion$[.@a],@cmds$[.@b])){
  105.                 set .@output$, callfunc("commands_func",.@b,@explosion$[(.@a+1)]);
  106.                 set @explosion$[.@a], .@output$;
  107.                 set @explosion$[(.@a+1)], "";
  108.             }
  109.         }
  110.         if(!.@a&&@c) {
  111.             set .@tmp$, charat(@explosion$[.@a],0);
  112.             set .@tmp$, strtoupper(.@tmp$);
  113.             set @explosion$[.@a], setchar(@explosion$[.@a], .@tmp$, 0);
  114.         }
  115.         set .@message$, .@message$+ ((@explosion$[.@a]!=""&&.@a<(.@len-1))?
  116.                 @explosion$[.@a]+" "
  117.             :
  118.                 @explosion$[.@a]+"");
  119.     }
  120.     return .@message$;
  121. }
  122.  
  123.  
  124.  
  125. function    script  commands_func   {
  126.     switch(getarg(0)){
  127.         case 0:
  128.             return getitemname(atoi(getarg(1)));
  129.         case 1:
  130.             return getcharid(atoi(getarg(1)));
  131.         case 2:
  132.             return strcharinfo(atoi(getarg(1)));
  133.     }
  134. }
  135.  
  136.  
  137.  
  138. /// callfunc "str_explode2" , "<array output>", "<string>"{, <Amount of Delemiter>{, "<Delemiter>"{, "<Delemiter>"}}};
  139. function    script  str_explode2    {
  140.     if ( !getarg(2) )
  141.         return callfunc("str_toarray", getarg(1), getarg(0) );
  142.     sleep2 1;
  143.     setarray .@char$[0],
  144.         " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
  145.         "e", "i", "a", "s", "r", "n", "t", "o", "u", "l", "c",
  146.         "p", "m", "d", "v", "h", "g", "f", "b", "y", "q", "k",
  147.         "z", "x", "j", "w", "_", "-", "(", ")", ";", ",", ":",
  148.         ".", "*", "!", "?", "'";
  149.     set .@charsize, getarraysize(.@char$);
  150.     set .@tmp$, "|~key~|";
  151.     set .@str$, .@tmp$ + getarg(1) ;
  152.     set .@len,  getstrlen(getarg(1));
  153.     set .@delem_len,    getarg(2);
  154.     for( set .@g,0;.@g<.@delem_len;set .@g,.@g+1 ){
  155.         setd(".@parse_len"+.@g, getstrlen(getarg(3+.@g)));
  156.     }
  157.     while( .@len > .@s ) {
  158.         set .@i, 0 ;
  159.         while( .@i < .@charsize  ) {
  160.             if ( ! ( set(.@l,.@l+1) % 600) )
  161.                 sleep2 1;
  162.             if ( compare( .@str$ , .@tmp$ + .@char$[.@i] ) ) {
  163.                 set .@tmp$, .@tmp$ + .@char$[.@i];
  164.                 set .@g, 0;
  165.                 while( .@g < .@delem_len ) {
  166.                     if ( ! ( set(.@l,.@l+1) % 600) )
  167.                         sleep2 1;
  168.                     if ( .@char$[.@i] == getarg((3+.@g)) ) {
  169.                         set .@p, .@p + 1;
  170.                         set .@s, .@s + (getd(".@parse_len"+.@g)-1) ;
  171.                         break;
  172.                     }
  173.                     set .@g,.@g+1;
  174.                 }
  175.                 if ( .@delem_len == .@g )
  176.                     set .@arr$[.@p], .@arr$[.@p] + .@char$[.@i];
  177.                 break;
  178.             }
  179.             set .@i, .@i+1 ;
  180.         }
  181.         if ( .@i == .@charsize ) return 0;
  182.         else set .@s, .@s+1 ;
  183.     }
  184.     deletearray getd(getarg(0));
  185.     copyarray getd(getarg(0)), .@arr$, .@p+1;
  186.     return .@p+1;
  187. }
Add Comment
Please, Sign In to add comment