Skorm

Freebie NPC v2.3

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