Jump to content
  • 0

MVP kill reward via random item with chances


Question

4 answers to this question

Recommended Posts

  • 0
Posted
Quote

 

//Created Date: 04/07/2022
-    script    AEOUS_MVP_DROP    FAKE_NPC,{
    end;
OnNPCKillEvent:
    .@rnd = rand(1,100);
    if( getmonsterinfo( killedrid,MOB_MVPEXP ) ) {
    for( .@i = 0; .@i < getarraysize(.item_arrays); .@i += 3 ) {
        if( .@rnd < .item_arrays[.@i+2] ) {
            getitem .item_arrays[.@i], .item_arrays[.@i+1];
            announce "Congratulations! Player "+ strcharinfo(0) +" has obtained "+ getitemname( .item_arrays[.@i] ) +" ["+ .item_arrays[.@i+1] +"] from "+ getmonsterinfo(killedrid, 0) +" (chance: "+.item_arrays[.@i+2]+"%) MVP Drop(s).",bc_all,0x00FF00;
        }
    }
    end;
}

OnInit:
//    (<structure,<item_id>,<chances>)
    setarray .item_arrays[0],
        7179,    1,    5,
        7227,    1,    25,
        7539,    1,    50;
    end;
}

 

 

  • 0
Posted

Hello,

try this:

 

-	script	MVP_DROP	FAKE_NPC,{
    OnNPCKillEvent:
		if(!getmonsterinfo(killedrid, MOB_MVPEXP)) end;

		.@rowCount = getarraysize(.itemInfos) / .columnCount;

		for (.@i = 0; .@i < .@rowCount; .@i++) {
			.@index = .@i * .@rowCount;
			.@randIndex = rand(.@i, .@rowCount - 1) * .@rowCount;

			copyarray .tmpItemInfo[0], .itemInfos[.@randIndex], .columnCount;
			copyarray .itemInfos[.@randIndex], .itemInfos[.@index], .columnCount;
			copyarray .itemInfos[.@index], .tmpItemInfo[0], .columnCount;
		}

		for(.@i = 0; .@i < getarraysize(.itemInfos); .@i += .columnCount) {
			if(rand(1, 100) <= .itemInfos[.@i + 2]) {
				getitem .itemInfos[.@i], .itemInfos[.@i + 1];
				announce "Congratulations! Player " + strcharinfo(0) + " has obtained "+ getitemname(.itemInfos[.@i]) +" [" + .itemInfos[.@i + 1] + "] from "+ getmonsterinfo(killedrid, 0) +" (chance: " + .itemInfos[.@i + 2] + "%) MVP Drop(s).", bc_all, 0x00FF00;
				
				if(.onlyOneDrop) end;
			}
		}
    end;

    OnInit:
		// item id, item amount, item chance in %
        setarray .itemInfos[0],
		7179, 1, 5,
		7227, 1, 25,
		7539, 1, 50;

		.onlyOneDrop = true;

		.columnCount = 3;
}

 

  • Upvote 1

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...