Skorm

Freebie NPC v2

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