Jump to content
  • 0

Need NPC that give 1 of 3 items with different percent


Question

Posted (edited)

-Hi... i've about 3~4 days looking for this kind of npc but alot of em are outdate i need a NPC for 100,000,000 Zeny gives you a item i want that npc can give

gold coin (671)with 10% to get this

silver coin (676) 40%

bronze coin (673) 70%

 

 

(just 1 of 3 items listed b4)

 

 

-also i need a NPC that count kill on X map and with each kill give +1 point with an exchange points for Y item.

 

i guess are kinda "easy" npc for some people here so plz help & thx for at least read.

 

 

- also i need kinda help about a NPC that change an item to "costume equipment" i guess you know what im talking about...

 

PD: sorry if i put this on incorrect place move if is necesary.

Edited by ItsFree

8 answers to this question

Recommended Posts

  • 0
Posted
On 4/15/2015 at 2:08 AM, Kurofly said:

I think he wanted his script to be able to give mutliple rewards since the total of chances for the 3 items are 120%

 

If it's the case try this:


prontera,137,201,4	script	Random Girl	725,{

	.@npcName$ = "[" + strnpcinfo(1) + "]";
	
	mes .@npcName$;
	mes "Hello, for 100,000,000 zeny, you have a chance to obtain one of these items :";
	for (.@i = 0; .@i < getarraysize(.items); .@i++) {
		mes "^008000~ " + getitemname(.items[.@i]) + "^000000";
	}
	next;
	
	switch(select("Gamble!:Leave")) {
		case 1:
			if (Zeny < 100000000) {
				mes .@npcName$;
				mes "I'm afraid you don't have enough to gamble.";
				close;
			}
			
			Zeny -= 100000000;
			.@rand = rand(1,100);
			for (.@i = 0 ; .@i < getarraysize(.items) ; .@i++) {
				if (.@rand <= .percents[.@i]) { getitem .items[.@i],1 ; dispbottom "Congrats! You won 1 "+getitemname(.items[.@i])+" !"  ; .@won = 1; }
			}
			if (!.@won) dispbottom "You lost !";
			mes .@npcName$;
			mes "There you go!";
			break;
		case 2:
			break;
	}
	
	close;
OnInit:
	setarray .items,671,676,673;
	setarray .percents,10,40,70;
	end;
}

If you have errors post a screen of your mapserv plz

HI there. The script works fine except that if you win the 10% chance instead of getting 1pc 671 you will get all the items in the setarray. So if you won the 10% item you will also get the 40% and 70% items. Same with winning 40% you will also get the 70% item.
If im not mistaken you should only 1 item. If you won the 10% item, thats the only thing youll get. 
I hope someone would help me fix this. Thank you!

PS. This is my edited script.
 

amatsu,198,109,4    script    Random Girl    725,{

    .@npcName$ = "[" + strnpcinfo(1) + "]";
    
    mes .@npcName$;
    mes "Hello, for 1,000,000 zeny you have a chance to obtain one of these items :";
    for (.@i = 0; .@i < getarraysize(.items); .@i++) {
        mes "^008000~ " + getitemname(.items[.@i]) + "^000000";
    }
    next;
    
    switch(select("Gamble!:Leave")) {
        case 1:
            if (Zeny < 1000000) {
                mes .@npcName$;
                mes "I'm afraid you don't have enough to gamble.";
                close;
            }
            
            Zeny -= 1000000;
            .@rand = rand(1,100);
            for (.@i = 0 ; .@i < getarraysize(.items) ; .@i++) {
                if (.@rand <= .percents[.@i]) { getitem .items[.@i],1 ; dispbottom "Congrats! You won 1 "+getitemname(.items[.@i])+" !"  ; .@won = 1; }
            }
            if (!.@won) dispbottom "You lost !";
            mes .@npcName$;
            mes "There you go!";
            break;
        case 2:
            break;
    }
    
    close;
OnInit:
    setarray .items,14296,20764,20285,31178,14003,671;
    setarray .percents,1,2,3,4,30,60;
    end;
}

Posted (edited)

Well, for the first question... you could start with this script :

function	script	wRand	{
	for (.@i = 0; .@i < getarraysize(getarg(0)); .@i++) {
		.@cummulative[.@i] = .@total += getelementofarray(getarg(1), .@i);
	}
	
	.@rnd = rand(0, .@total - 1);
	
	for (.@i = 0; .@i < getarraysize(getarg(0)); .@i++) {
		if (.@rnd < .@cummulative[.@i]) {
			return getelementofarray(getarg(0), .@i);
		}
	}
	
	return -1;
}

prontera,137,201,4	script	Random Girl	4_F_JOB_ASSASSIN,{
	.@npcName$ = "[" + strnpcinfo(1) + "]";
	
	mes .@npcName$;
	mes "Hello, for 100,000,000 zeny, you have a chance to obtain one of these items :";
	for (.@i = 0; .@i < getarraysize(.items); .@i++) {
		mes "^008000~ " + getitemname(.items[.@i]) + "^000000";
	}
	next;
	
	switch(select("Gamble!:Leave")) {
		case 1:
			if (Zeny < 100000000) {
				mes .@npcName$;
				mes "I'm afraid you don't have enough to gamble.";
				close;
			}
			
			Zeny -= 100000000;
			getitem callfunc("wRand", .items, .weight),1;
			mes .@npcName$;
			mes "There you go!";
			break;
		case 2:
			break;
	}
	
	close;
OnInit:
	setarray .items,671,676,673;
	setarray .weight,10,40,70;
	end;
}

You might also want to have a look into groupranditem, getrandgroupitem or getgroupitem if you're going for more... advanced uses I guess.

Edited by Tokei
  • Upvote 2
Posted

Hi, thx for reply i tried to test it but doesnt works :c then i try to edit moving:

 

 

function script wRand {

for (.@i = 0; .@i < getarraysize(getarg(0)); .@i++) {
.@cummulative[.@i] = .@total += getelementofarray(getarg(1), .@i);
}
 
.@rnd = rand(0, .@total - 1);
 
for (.@i = 0; .@i < getarraysize(getarg(0)); .@i++) {
if (.@rnd < .@cummulative[.@i]) {
return getelementofarray(getarg(0), .@i);
}
}
 
return -1;
}
 

 to another place but still not work sorry alot of time that i dont touch any script so atm im kinda new :P

Posted

I think he wanted his script to be able to give mutliple rewards since the total of chances for the 3 items are 120%

 

If it's the case try this:

prontera,137,201,4	script	Random Girl	725,{

	.@npcName$ = "[" + strnpcinfo(1) + "]";
	
	mes .@npcName$;
	mes "Hello, for 100,000,000 zeny, you have a chance to obtain one of these items :";
	for (.@i = 0; .@i < getarraysize(.items); .@i++) {
		mes "^008000~ " + getitemname(.items[.@i]) + "^000000";
	}
	next;
	
	switch(select("Gamble!:Leave")) {
		case 1:
			if (Zeny < 100000000) {
				mes .@npcName$;
				mes "I'm afraid you don't have enough to gamble.";
				close;
			}
			
			Zeny -= 100000000;
			.@rand = rand(1,100);
			for (.@i = 0 ; .@i < getarraysize(.items) ; .@i++) {
				if (.@rand <= .percents[.@i]) { getitem .items[.@i],1 ; dispbottom "Congrats! You won 1 "+getitemname(.items[.@i])+" !"  ; .@won = 1; }
			}
			if (!.@won) dispbottom "You lost !";
			mes .@npcName$;
			mes "There you go!";
			break;
		case 2:
			break;
	}
	
	close;
OnInit:
	setarray .items,671,676,673;
	setarray .percents,10,40,70;
	end;
}

If you have errors post a screen of your mapserv plz

Posted

You know, 100,000,000 zeny is quite an amount /$

 

Don't you want to make it a bit more funky? Adding effect, announces, jokes, or even cutins?

 

Check out these! I think you could make something pretty cool with this:

s2_n6.bmp

s3_n6.bmp

s1_n5.bmp

 

I'm not the original owner of these cutins so I will try to find its owner to ask him if I can make use of them.

I had to stop making them a while ago so I will need time get this over if you want me to do it.

 

Tell me if you want to do anything /no1 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...