Jump to content
  • 0

REQUEST: monster spawn fuction with rate for a custom item


Question

Posted

hello, I am trying to create a fuction, to use in my custom branch to spawn, diferent mvps, with a specific chance for each one, I want to create a version that is more easy to implement, or use with a biger number of MVPs

this is the current script that I made.

 

function	script	active_branch	{
set .tw,0;
set .@ms,0;
setarray .mob_id[0],1582,1112,1492,1147;
setarray .mob_c[0],80,60,20,10;
		for(set .@i,0; .@i< (getarraysize(.mob_c)); set .@i,.@i+1) {
		.tw += .mob_c[.@i];
		}
set .rnum, rand(.tw);
debugmes "total weight is: "+.tw;
debugmes .rnum;
freeloop(1);
		for(set .@i,0; .@i< (getarraysize(.mob_c)); set .@i,.@i+1) {
			if(.rnum <= .mob_c[.@i]){
			if(.@ms==0){
			debugmes .mob_id[.@i];
			monster "this", -1,-1, "--ja--",.mob_id[.@i], 1, "";
			.@ms = 1;
			}
			//			
			}
			else
			{
			//debugmes .rnum + "substracted by: "+.mob_c[.@i];
			.rnum -= .mob_c[.@i];	
			}
		}
freeloop(0);
}

 

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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