Jump to content
  • 0

npc surprises machine


ADM Ytallo

Question


  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  98
  • Reputation:   3
  • Joined:  09/02/18
  • Last Seen:  

I need to control the rate of each item that this machine will generate

prontera,141,226,4    script    Maquina de Promoções    2_DROP_MACHINE,{
    mes .npc_n$;
    mes "Você precisa de apenas "+.itm_a+" "+.itm_n$+" para poder usar a maquina de promoção.!";
    mes "Você gostaria de usar-la..?"; next;
    if(select("^0084ff[ • ]^000000 Sim:^CD3278[ • ]^000000 Não:^0084ff[ • ]^000000 O que posso ganhar?")&2) {
        if(@menu-2) {
            set .@mes$, "Você pode ganhar: ";
            for(set(.@a,1);.@a<=.len_i;set(.@a,.@a+1)) {
                set .@itm$, getitemname(.itm_l[(.@a-1)]);
                if(.@a%10&&.@a<=.len_i&&.@a!=.len_i) {
                    set .@mes$, .@mes$+((!((.@a%10)-9)&&.@a<=.len_i)?
                            "and "+.@itm$+".":.@itm$+", ");
                } else {
                    mes .npc_n$;
                    if(.@a<.len_i) {
                        mes .@mes$; set .@mes$, "Você também pode ganhar: "+.@itm$+", "; next;
                        if(select("Seguir:Fechar")&2) close;
                    } else {
                        mes .@mes$+"e "+.@itm$+"."; close;
                    }
                }
            }
        } else close;
    }
    if (countitem(.itm_p) < .itm_a) {
        mes .npc_n$;
        mes "Você não tem "+.itm_a+" "+.itm_n$;
        close;
    }
    mes .npc_n$;
    mes "Aqui está!";
    delitem .itm_p,.itm_a;
    set .@get, .itm_l[rand(.len_i-1)];
    if(compare(.itm_a$,""+.@get)) announce strnpcinfo(0)+": "+strcharinfo(0)+" Obteve ["+getitemname(.@get)+"] da Máquina de Promoções!",bc_all|bc_yellow;
    getitem .@get,1;
    close;

    OnInit:
        set         .npc_n$,    "[^4B0082Maquina de Promoções^000000]"; //Nome NPC.
        setarray    .itm_l ,    502, 678, 607 ,608 ,508 ,509 ,510 ,2132 ,555;// Lista de Itens
        set         .itm_a$,    "555";//IDs de item nesta cadeia são anunciados.
        set         .len_i ,    getarraysize(.itm_l); //Comprimento da matriz.
        set         .itm_a ,    1; //Custo do NPC.
        set         .itm_p ,    7608; //Item usado como moeda.
        set         .itm_n$,    getitemname(.itm_p); //Nome do item.
}

 

Edited by Akkarin
Use codebox next time.
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.01
  • Content Count:  24
  • Reputation:   3
  • Joined:  04/10/19
  • Last Seen:  

On 4/4/2019 at 10:42 PM, YtalloNv said:

I need to control the rate of each item that this machine will generate


prontera,141,226,4    script    Maquina de Promoções    2_DROP_MACHINE,{
    mes .npc_n$;
    mes "Você precisa de apenas "+.itm_a+" "+.itm_n$+" para poder usar a maquina de promoção.!";
    mes "Você gostaria de usar-la..?"; next;
    if(select("^0084ff[ • ]^000000 Sim:^CD3278[ • ]^000000 Não:^0084ff[ • ]^000000 O que posso ganhar?")&2) {
        if(@menu-2) {
            set .@mes$, "Você pode ganhar: ";
            for(set(.@a,1);.@a<=.len_i;set(.@a,.@a+1)) {
                set .@itm$, getitemname(.itm_l[(.@a-1)]);
                if(.@a%10&&.@a<=.len_i&&.@a!=.len_i) {
                    set .@mes$, .@mes$+((!((.@a%10)-9)&&.@a<=.len_i)?
                            "and "+.@itm$+".":.@itm$+", ");
                } else {
                    mes .npc_n$;
                    if(.@a<.len_i) {
                        mes .@mes$; set .@mes$, "Você também pode ganhar: "+.@itm$+", "; next;
                        if(select("Seguir:Fechar")&2) close;
                    } else {
                        mes .@mes$+"e "+.@itm$+"."; close;
                    }
                }
            }
        } else close;
    }
    if (countitem(.itm_p) < .itm_a) {
        mes .npc_n$;
        mes "Você não tem "+.itm_a+" "+.itm_n$;
        close;
    }
    mes .npc_n$;
    mes "Aqui está!";
    delitem .itm_p,.itm_a;
    set .@get, .itm_l[rand(.len_i-1)];
    if(compare(.itm_a$,""+.@get)) announce strnpcinfo(0)+": "+strcharinfo(0)+" Obteve ["+getitemname(.@get)+"] da Máquina de Promoções!",bc_all|bc_yellow;
    getitem .@get,1;
    close;

    OnInit:
        set         .npc_n$,    "[^4B0082Maquina de Promoções^000000]"; //Nome NPC.
        setarray    .itm_l ,    502, 678, 607 ,608 ,508 ,509 ,510 ,2132 ,555;// Lista de Itens
        set         .itm_a$,    "555";//IDs de item nesta cadeia são anunciados.
        set         .len_i ,    getarraysize(.itm_l); //Comprimento da matriz.
        set         .itm_a ,    1; //Custo do NPC.
        set         .itm_p ,    7608; //Item usado como moeda.
        set         .itm_n$,    getitemname(.itm_p); //Nome do item.
}

 

You can try this see if it works, i havent tested it yet

the idea is put the array .itm_l with item,rate,item,rate, after that create a loop to see if the .chance is less than the rate, if yes set the item as reward and quit the loop.

prontera,141,226,4    script    Maquina de Promoções    2_DROP_MACHINE,{
    mes .npc_n$;
    mes "Você precisa de apenas "+.itm_a+" "+.itm_n$+" para poder usar a maquina de promoção.!";
    mes "Você gostaria de usar-la..?"; next;
    if(select("^0084ff[ • ]^000000 Sim:^CD3278[ • ]^000000 Não:^0084ff[ • ]^000000 O que posso ganhar?")&2) {
        if(@menu-2) {
            set .@mes$, "Você pode ganhar: ";
            for(set(.@a,0);.@a<.len_i;set(.@a,.@a+2)) {
                set .@itm$, getitemname(.itm_l[(.@a)]);
                mes .@itm$;
            } close;
        } else close;
    }
    if (countitem(.itm_p) < .itm_a) {
        mes .npc_n$;
        mes "Você não tem "+.itm_a+" "+.itm_n$;
        close;
    }
    mes .npc_n$;
    mes "Aqui está!";
    delitem .itm_p,.itm_a;
	
	
	set .chance, rand(1000);
	for(set .@i,1; .@i<=.len_i; set .@i,.@i+2) {
		if(.chance < .itm_l[.@i]){
			set .@get, .itm_l[.@i-1];
			break;
		}
	}
	
    if(compare(.itm_a$,""+.@get)) announce strnpcinfo(0)+": "+strcharinfo(0)+" Obteve ["+getitemname(.@get)+"] da Máquina de Promoções!",bc_all|bc_yellow;
    getitem .@get,1;
    close;

    OnInit:
        set         .npc_n$,    "[^4B0082Maquina de Promoções^000000]"; //Nome NPC.
        setarray    .itm_l ,    502,200,678,300,607,400,608,500,508,600,509,700,510,800,2132,900,555,1000;// Lista de Itens <ItemID>,<Rate>,<ItemID>,<Rate>.....
        set         .itm_a$,    "555";//IDs de item nesta cadeia são anunciados.
        set         .len_i ,    getarraysize(.itm_l); //Comprimento da matriz.
        set         .itm_a ,    1; //Custo do NPC.
        set         .itm_p ,    7608; //Item usado como moeda.
        set         .itm_n$,    getitemname(.itm_p); //Nome do item.
}

 

NOTE: This will not work if there is multiple items with same rate. It will always take the first one with the same rate.

Edited by KidoSang
Script have some issue so i change a new one
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...