Skorm

Freebie NPC v1

Jun 15th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.97 KB | None | 0 0
  1. //Version 1
  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 --Disable for speed up! )
  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. //End
  16.  
  17. //NPC Dialogue
  18. if(.@blvl>=.@rblvl) {
  19.     for(set .@s,0;.@s<(.@getitm_len-3);set .@s,.@s+1){
  20.         set .@op$, callfunc("dispmes_func",getd(.@getitm$+"["+(.@s+3)+"]"));
  21.         if(.@op$=="next;"||.@op$=="Next;") { set .@op$, ""; next; }
  22.         if(.@op$=="menu;"||.@op$=="Menu;") { if(select("Yes:No")&2) close; set .@op$, ""; }
  23.         if(.@op$=="close;"||.@op$=="Close;") { set .@op$, ""; close; }
  24.         if(.@op$=="item;"||.@op$=="Item;") { set .@op$, ""; getitem atoi(getd(.@getitm$)),atoi(getd(.@getitm$+"[1]")); set #itmget,#itmget+1; }
  25.         if(.@op$=="npc;"||.@op$=="Npc;") { set .@op$, @npc$; }
  26.         if(.@op$!="") mes .@op$;
  27.     }
  28. }
  29.  
  30. mes @npc$;
  31. set .@message$, (.@blvl<=.@rblvl )?
  32.         "You have already received this item, please come back when you are level "+.@rblvl+" for a special item."
  33.     :
  34.         ((.@rblvl<.@blvl )?
  35.                 "Sorry, I don't have anymore items to give you!"
  36.             :
  37.                 "");
  38. mes .@message$;
  39. close;
  40. //End
  41.  
  42.  
  43. end;
  44. OnInit:
  45.     waitingroom "Free items!",0;
  46.  
  47. //Configure NPC Items & Dialogue HERE!
  48.     //                  ItemID  Amount  Required-BaseLevel
  49.     setarray .itm0$,    "501""10",   "1",
  50.         "Npc;",
  51.         "Hello, strcharinfo(0), do you want this free item?",
  52.         "next;",    "menu;",
  53.         "Alright!", "item;",
  54.         "Goodbye.", "close;";
  55.  
  56.     setarray .itm1$,    "502""20",   "70",
  57.         "Npc;",
  58.         "Wow, strcharinfo(0), you're really strong!",
  59.         "I won't keep you waiting.",
  60.         "Here is your item- You've earned it!",
  61.         "item;", "Until we meet again.", "close;";
  62.  
  63.     setarray .itm2$,    "1599", "1",    "180",
  64.         "Npc;",
  65.         "You, sir, are a true god!",
  66.         "Hh-h-here is your getitemname(1599).",
  67.         "item;", "close;";
  68. //End
  69.  
  70. /*Explanation:
  71.     The first three values in each row are the only constant numbers.
  72.     First is the item_id then the amount you want to give then the level you give it at.
  73.     Every line after that is lucid. You can type what the npc is going to say.
  74.     You can also use optional commands that I will list below to display information.
  75.     Add new conditions by following my example just remember to change .itm<#>$ to the next value.
  76.     I hope everyone can understand this x.x Keep in mind this is just the first version.
  77.     It's still a little slow. You can change upper-case to ignore for speedup.
  78.    
  79. Commands Explained:
  80.     Commands that takeup one line:
  81.         "Npc;", -> This will display the npcs name.
  82.         "Item;", -> Will give the player item and increase quest value.
  83.         "Menu;", -> This will display a Yes and No menu.
  84.         "Close;", -> This will close the script.
  85.         "Next;", -> This will refresh chat window and display Next button.
  86.    
  87.     Commands that can be used in chat:
  88.         getitemname(<itemid>) -> Shows item name in chat.
  89.         getcharid(<type>) -> Will return character id number.
  90.         strcharinfo(<type>) -> displays information from charinfo. EX: strcharinfo(0) = Characters Name
  91.  
  92. Skorm
  93. */
  94.  
  95. }
  96.  
  97.  
  98.  
  99. function    script  dispmes_func    {
  100.     set .@len,callfunc("str_explode2","@explosion$",getarg(0), 3, " ", "(", ")");
  101.     for(set .@a,0;.@a<.@len;set .@a,.@a+1) {
  102.         for(set .@b,0;.@b<getarraysize(@cmds$);set .@b,.@b+1){
  103.             if (compare(@explosion$[.@a],@cmds$[.@b])){
  104.                 set .@output$, callfunc("commands_func",.@b,@explosion$[(.@a+1)]);
  105.                 set @explosion$[.@a], .@output$;
  106.                 set @explosion$[(.@a+1)], "";
  107.             }
  108.         }
  109.         if(!.@a&&@c) {
  110.             callfunc "str_toarray", @explosion$[.@a], "@tmp$[0]";
  111.             set @tmp$[0],callfunc("str_changecase", @tmp$[0], 1);
  112.             set @explosion$[.@a],""; set .@i,0;
  113.             while(getstrlen(@explosion$[.@a])<getarraysize(@tmp$)){
  114.                 set @explosion$[.@a],@explosion$[.@a]+@tmp$[.@i];
  115.                 set .@i,.@i+1;
  116.             }
  117.         }
  118.         set .@message$, .@message$+ ((@explosion$[.@a]!=""&&.@a<(.@len-1))?
  119.                 @explosion$[.@a]+" "
  120.             :
  121.                 @explosion$[.@a]+"");
  122.     }
  123.     return .@message$;
  124. }
  125.  
  126.  
  127.  
  128. function    script  commands_func   {
  129.     switch(getarg(0)){
  130.         case 0:
  131.             return getitemname(atoi(getarg(1)));
  132.         case 1:
  133.             return getcharid(atoi(getarg(1)));
  134.         case 2:
  135.             return strcharinfo(atoi(getarg(1)));
  136.     }
  137. }
  138.  
  139.  
  140.  
  141. /// callfunc "str_explode2" , "<array output>", "<string>"{, <Amount of Delemiter>{, "<Delemiter>"{, "<Delemiter>"}}};
  142. function    script  str_explode2    {
  143.     if ( !getarg(2) )
  144.         return callfunc("str_toarray", getarg(1), getarg(0) );
  145.     sleep2 1;
  146.     setarray .@char$[0],
  147.         " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
  148.         "e", "i", "a", "s", "r", "n", "t", "o", "u", "l", "c",
  149.         "p", "m", "d", "v", "h", "g", "f", "b", "y", "q", "k",
  150.         "z", "x", "j", "w", "_", "-", "(", ")", ";", ",", ":",
  151.         ".", "*", "!", "?", "'";
  152.     set .@charsize, getarraysize(.@char$);
  153.     set .@tmp$, "|~key~|";
  154.     set .@str$, .@tmp$ + getarg(1) ;
  155.     set .@len,  getstrlen(getarg(1));
  156.     set .@delem_len,    getarg(2);
  157.     for( set .@g,0;.@g<.@delem_len;set .@g,.@g+1 ){
  158.         setd(".@parse_len"+.@g, getstrlen(getarg(3+.@g)));
  159.     }
  160.     while( .@len > .@s ) {
  161.         set .@i, 0 ;
  162.         while( .@i < .@charsize  ) {
  163.             if ( ! ( set(.@l,.@l+1) % 600) )
  164.                 sleep2 1;
  165.             if ( compare( .@str$ , .@tmp$ + .@char$[.@i] ) ) {
  166.                 set .@tmp$, .@tmp$ + .@char$[.@i];
  167.                 set .@g, 0;
  168.                 while( .@g < .@delem_len ) {
  169.                     if ( ! ( set(.@l,.@l+1) % 600) )
  170.                         sleep2 1;
  171.                     if ( .@char$[.@i] == getarg((3+.@g)) ) {
  172.                         set .@p, .@p + 1;
  173.                         set .@s, .@s + (getd(".@parse_len"+.@g)-1) ;
  174.                         break;
  175.                     }
  176.                     set .@g,.@g+1;
  177.                 }
  178.                 if ( .@delem_len == .@g )
  179.                     set .@arr$[.@p], .@arr$[.@p] + .@char$[.@i];
  180.                 break;
  181.             }
  182.             set .@i, .@i+1 ;
  183.         }
  184.         if ( .@i == .@charsize ) return 0;
  185.         else set .@s, .@s+1 ;
  186.     }
  187.     deletearray getd(getarg(0));
  188.     copyarray getd(getarg(0)), .@arr$, .@p+1;
  189.     return .@p+1;
  190. }
  191.  
  192.  
  193.  
  194. function    script  str_changecase  {
  195.     sleep2 1;
  196.     if ( getarg(1) ) {
  197.         setarray .@char$[ 0 ],
  198.             " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
  199.             "E", "I", "A", "S", "R", "N", "T", "O", "U", "L", "C",
  200.             "P", "M", "D", "V", "H", "G", "F", "B", "Y", "Q", "K",
  201.             "Z", "X", "J", "W", "_", "-", "(", ")", ";", ",", ":",
  202.             ".", "*", "!", "?", "'";
  203.     }
  204.     else {
  205.         setarray .@char$[ 0 ],
  206.             " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
  207.             "e", "i", "a", "s", "r", "n", "t", "o", "u", "l", "c",
  208.             "p", "m", "d", "v", "h", "g", "f", "b", "y", "q", "k",
  209.             "z", "x", "j", "w", "_", "-", "(", ")", ";", ",", ":",
  210.             ".", "*", "!", "?", "'";
  211.     }
  212.     set .@charsize, getarraysize(.@char$);
  213.     set .@str$, "|~key~|" + getarg(0) ;
  214.     set .@len, getstrlen(getarg(0));
  215.     while( .@len>.@s ) {
  216.         set .@i,0;
  217.         while( .@i<.@charsize ) {
  218.             if ( ! ( set(.@l,.@l+1) % 650) )
  219.                 sleep2 1;
  220.             if ( compare( .@str$ , "|~key~|" + .@tmp$ + .@char$[.@i] ) ) {
  221.                 set .@tmp$, .@tmp$ + .@char$[.@i];
  222.                 break;
  223.             }
  224.             set .@i, .@i+1;
  225.         }
  226.         if ( .@i == .@charsize ) return "";
  227.         else set .@s, .@s+1;
  228.     }
  229.     return .@tmp$;
  230. }
  231.  
  232.  
  233.  
  234. function    script  str_toarray {
  235.     sleep2 1;
  236.     if ( getstrlen( getarg(0) ) > 128 ) return 0;
  237.     setarray .@char$[ 0 ],
  238.         " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
  239.         "e", "i", "a", "s", "r", "n", "t", "o", "u", "l", "c",
  240.         "p", "m", "d", "v", "h", "g", "f", "b", "y", "q", "k",
  241.         "z", "x", "j", "w", "_", "-", "(", ")", ";", ",", ":",
  242.         ".", "*", "!", "?", "'";
  243.  
  244.     set .@charsize, getarraysize(.@char$);
  245.     set .@tmp$, "|~key~|";
  246.     set .@str$, .@tmp$ + getarg(0) ;
  247.     set .@len, getstrlen(getarg(0));
  248.     while( .@len>.@s ) {
  249.         set .@i,0;
  250.         while( .@i<.@charsize ) {
  251.             if ( ! ( set(.@l,.@l+1) % 650) )
  252.                 sleep2 1;
  253.             if ( compare( .@str$ , .@tmp$ + .@char$[.@i] ) ) {
  254.                 set .@tmp$, .@tmp$ + .@char$[.@i];
  255.                 set .@arr$[.@s], .@char$[.@i];
  256.                 break;
  257.             }
  258.             set .@i, .@i+1;
  259.         }
  260.         if ( .@i == .@charsize ) return 0;
  261.         else set .@s, .@s+1;
  262.     }
  263.     deletearray getd(getarg(1));
  264.     copyarray getd(getarg(1)), .@arr$, .@len;
  265.     return .@len;
  266. }
Add Comment
Please, Sign In to add comment