Jump to content
  • 0
ffman22

REQUEST: monster spawn fuction with rate for a custom item

Question

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

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.