Jump to content
  • 0

Request: extra monster drop


frenzmu06

Question


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  326
  • Reputation:   47
  • Joined:  04/01/12
  • Last Seen:  

Hello good day, can anyone with good scripting knowledge help finish this script. so what the script does is it's triggered by killing a monster from the list and it'll give the specified zeny and cash point to the killer (100%), there is also a 10% chance that the killer gets the listed items (if there are).
i copied the array format from Stolao's DailyReward. 
 
-	script	ExtraDrop	-1,{
OnNPCKillEvent:
	if (killedrid == <monster id>)	{
			#CASHPOINTS += <cash points>;
			Zeny += <zeny amount>;
		}
		if ()rand(1000) < 10 ) 			//Chance: 100 = 10%, 10 = 1%, etc.
				getitem <item ids>, <item amounts>;
	end;
OnInit:
	//		Monster & Drop List:
	//		"<Monster ID>|<Zeny>|<Cash Points>|<itemID-1>|<amount-1>|<itemID-2>|<amount-2>...etc",
	setarray .mvpmonsterdrop$[1],
		"1112,5000,2,504,10",			//	Drake: 5000 Zeny + 2 Cash Points +10 White Potion
		"1115,3000,1,504,10,506,10",		//	Eddga: 3000 Zeny + 1 Cash Points +10 White Potion + 10 Green Potion
		"2098,4000,0,504,10,506,10,505,10",	//	Doppelganger: 4000 Zeny + 1 Cash Points +10 White Potion + 10 Green Potion + 10 Blue Potion
		"1120,1000";				// 	Ghostring:	1000 Zeny
	end;
}

hope you guys can help me. thnx 

Edited by frenzmu06
Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  927
  • Reputation:   169
  • Joined:  04/05/13
  • Last Seen:  

I don't think OnNPCKillEvent: would be good.

 

Because It's expensive to use like Monster died 100 times and script run per times. ( or not? )

 

Try using item that dropped by specific monster and change them into bonus on simple npc. ( Random item + zeny like your scripts too. )

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

Try

-	script	ExtraDrop	-1,{
OnInit:
	setarray .mon_list[0],1002,1101; // list of monster ids
	.mon_size = getarraysize(.mon_list);
	end;

OnNPCKillEvent:
	for( .@i = 0; .@i < .mon_size; .@i++ ) {
		if( killedrid == .mon_list[.@i] ) {
			#CASHPOINTS += 5;
			Zeny += 5;
			if( rand(100) < 10 ) getitem 501,1;
			break;
		}
	}
	end;
}

I didn't test it

Edited by Technoken
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  326
  • Reputation:   47
  • Joined:  04/01/12
  • Last Seen:  

Try

-	script	ExtraDrop	-1,{
OnInit:
	setarray .mon_list[0],1002,1101; // list of monster ids
	.mon_size = getarraysize(.mon_list);
	end;

OnNPCKillEvent:
	for( .@i = 0; .@i < .mon_size; .@i++ ) {
		if( killedrid == .mon_list[.@i] ) {
			#CASHPOINTS += 5;
			Zeny += 5;
			if( rand(100) < 10 ) getitem 501,1;
			break;
		}
	}
	end;
}

I didn't test it

thanks but what i need is the configurability of setting the drops and other rewards from the script

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

thanks but what i need is the configurability of setting the drops and other rewards from the script

-	script	ExtraDrop	-1,{
OnInit:
	setarray .mon_list[0],1002,1101; // list of monster ids
	.mon_size	= getarraysize(.mon_list);
	.cashpt		= 10; // How much cashpoints?
	.zeny		= 5000000; // How much zeny?
	.reward		= 501; // Reward item id
	.reward_amt	= 1; // Reward Amount
	end;

OnNPCKillEvent:
	for( .@i = 0; .@i < .mon_size; .@i++ ) {
		if( killedrid == .mon_list[.@i] ) {
			#CASHPOINTS += .cashpt;
			Zeny += .zeny;
			if( rand(100) < 10 ) getitem .reward,.reward_amt;
			break;
		}
	}
	end;
}
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  326
  • Reputation:   47
  • Joined:  04/01/12
  • Last Seen:  

 

thanks but what i need is the configurability of setting the drops and other rewards from the script

-	script	ExtraDrop	-1,{
OnInit:
	setarray .mon_list[0],1002,1101; // list of monster ids
	.mon_size	= getarraysize(.mon_list);
	.cashpt		= 10; // How much cashpoints?
	.zeny		= 5000000; // How much zeny?
	.reward		= 501; // Reward item id
	.reward_amt	= 1; // Reward Amount
	end;

OnNPCKillEvent:
	for( .@i = 0; .@i < .mon_size; .@i++ ) {
		if( killedrid == .mon_list[.@i] ) {
			#CASHPOINTS += .cashpt;
			Zeny += .zeny;
			if( rand(100) < 10 ) getitem .reward,.reward_amt;
			break;
		}
	}
	end;
}

 

thanks but i think you don't get what i'm saying, 

 

i need EACH and every monster I list to drop their specific zeny amount, cash amount, items and value (which can be read from the array)

 

still i am very grateful for helping me bro

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  927
  • Reputation:   169
  • Joined:  04/05/13
  • Last Seen:  

 

thanks but what i need is the configurability of setting the drops and other rewards from the script

-	script	ExtraDrop	-1,{
OnInit:
	setarray .mon_list[0],1002,1101; // list of monster ids
	.mon_size	= getarraysize(.mon_list);
	.cashpt		= 10; // How much cashpoints?
	.zeny		= 5000000; // How much zeny?
	.reward		= 501; // Reward item id
	.reward_amt	= 1; // Reward Amount
	end;

OnNPCKillEvent:
	for( .@i = 0; .@i < .mon_size; .@i++ ) {
		if( killedrid == .mon_list[.@i] ) {
			#CASHPOINTS += .cashpt;
			Zeny += .zeny;
			if( rand(100) < 10 ) getitem .reward,.reward_amt;
			break;
		}
	}
	end;
}

 

 

 

To

 

-    script    ExtraDrop    -1,{
OnNPCKillEvent:
        if( killedrid == 1002 ) {
            #CASHPOINTS += 10000;
            Zeny += 9999;
            if( rand(100) < 10 ) getitem 501,.1;
        }else if( killedrid == 1003 ) {
            #CASHPOINTS += 20000;
            Zeny += 99999;
            if( rand(100) < 10 ) getitem 502,.1;
        }
    end;
}
 
 
I tried my best, It's hardcode : ) . lol
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  326
  • Reputation:   47
  • Joined:  04/01/12
  • Last Seen:  

 

 

thanks but what i need is the configurability of setting the drops and other rewards from the script

-	script	ExtraDrop	-1,{
OnInit:
	setarray .mon_list[0],1002,1101; // list of monster ids
	.mon_size	= getarraysize(.mon_list);
	.cashpt		= 10; // How much cashpoints?
	.zeny		= 5000000; // How much zeny?
	.reward		= 501; // Reward item id
	.reward_amt	= 1; // Reward Amount
	end;

OnNPCKillEvent:
	for( .@i = 0; .@i < .mon_size; .@i++ ) {
		if( killedrid == .mon_list[.@i] ) {
			#CASHPOINTS += .cashpt;
			Zeny += .zeny;
			if( rand(100) < 10 ) getitem .reward,.reward_amt;
			break;
		}
	}
	end;
}

 

 

 

To

 

-    script    ExtraDrop    -1,{
OnNPCKillEvent:
        if( killedrid == 1002 ) {
            #CASHPOINTS += 10000;
            Zeny += 9999;
            if( rand(100) < 10 ) getitem 501,.1;
        }else if( killedrid == 1003 ) {
            #CASHPOINTS += 20000;
            Zeny += 99999;
            if( rand(100) < 10 ) getitem 502,.1;
        }
    end;
}
 
 
I tried my best, It's hardcode : ) . lol

 

 

yup dude, my basic knowledge can read what you have made even without testing it, i myself can do basic script too but this time i can't do it (i can do it with a looping script but hell that would be lines of code everytime i add monster and its drop)

 

what i need is lines of code from stolao's daily reward, my brain just can't fucking understand them,

		if(#DRewardCon >= getarraysize(.Rewards$)){
			if(.Reset){ #DRewardCon = 1; }
			else { .@g = getarraysize(.Rewards$)-1; }
		} else {	.@g = #DRewardCon;	}
		explode(.@XT$,.Rewards$[.@g],",");
		for(.@x = 0; .@x < getarraysize(.@XT$); .@x++){
			.@TT[.@x] = atoi(.@XT$[.@x]);
		}
		if(.Mode & 1 && .@TT[4] > 0){
			for(.@x = 4; .@x <= getarraysize(.@TT) - 1 ; .@x += 2){
				.@itms[getarraysize(.@itms)] = .@TT[.@x];
				.@qnts[getarraysize(.@qnts)] = .@TT[.@x + 1];
			}
			if(checkweight2(.@itms,.@qnts)){
				for(.@x = 0; .@x < getarraysize(.@itms) && .@x < getarraysize(.@qnts); .@x++){
					getitem  .@itms[.@x], .@qnts[.@x];
				}
			} else {
				message strcharinfo(0),"[Daily Rewards]: You cannot carry the prizes, please use storage and relog.";
				if(#DRewardCon) #DRewardCon -= 1;
				end;
			}
		}
		if(.Mode & 16){
			cutin .Cutins$[#DRewardCon],4;
		}
		if(.Mode & 2){
			if(.@TT[0]){
				Zeny += .@TT[0];
				message strcharinfo(0),"[Daily Rewards]: Recieved "+ .@TT[0] +"z";
			}
			if(.@TT[1]){
				setd getd(.Points$[0]),getd(.Points$[0]) + .@TT[1];
				message strcharinfo(0),"[Daily Rewards]: Recieved "+ .@TT[1] +" "+.Points$[1];
			}
		}
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

Try this one didn't test it though

-	script	ExtraDrop	-1,{
OnInit:
	setarray .list[0], // <monsterid>,<cash point>,<zeny>,<reward item id>,<reward item amount>... and so on
		1002,5,1000000,501,1, // Poring, gives 5 cashpoint, 1m zeny, red potion 1x
		1101,6,2000000,502,1; 
	.size = getarraysize(.mon_list)/5;
	end;

OnNPCKillEvent:
	for( .@i = 0; .@i < .size; .@i+=5 ) {
		if( killedrid == .list[.@i] ) {
			#CASHPOINTS += .list[.@i+1];
			Zeny += .list[.@i+2];
			if( rand(100) < 10 ) getitem .list[.@i+3],.list[.@i+4];
			break;
		}
	}
	end;
}
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  141
  • Reputation:   45
  • Joined:  08/14/12
  • Last Seen:  

It really depends on how optimized you want it to be.

Let's say the size is N long.

 

The problem with looping through the list, is that EVERY time ANY monster dies, it'll look through the list, checking N times.

This means that the script takes O(N) time.

If N = 1, then it's not too big of a problem. But if N = 100, then it starts becoming a huge problem.

 

You can reduce it to O(1), by using a map (or a dictionary, you can call it what you like). Unfortunately, the Athena scripting language don't have these structures. Instead, we must use arrays.

This idea works by putting the cash/zeny rewards in a huge array, then accessing the array using the mob id.

If there isn't a reward, then it's zero. If there is a reward, it's non-zero(the actual reward).

 

The OnNPCKillEvent would look like this:

OnNPCKillEvent:
	Zeny += .zeny_list[killedrid];
	#CASHPOINTS += .cash_list[killedrid];
	end;

When you initialize the NPC, however, you need to fill those lists. We can use a similar system as Stolao's, but here's mine.

//mobid, zeny, cash
setarray .rewards[0], 
1002, 10000, 100,
1003, 20000, 230;

I don't like strings, integers are easier.

We then need to add the rewards into the arrays.

for (.@i = 0, .@i < getarraysize(.rewards); .@i += 3) {
	.zeny_list[.rewards[.@i]] = .rewards[.@i + 1];
	.cash_list[.rewards[.@i]] = .rewards[.@i + 2];
}

This way, initialization takes O(N) time.

The tradeoff, however, is memory. You now have two arrays of the size of the highest monster id you've given a reward to.

We can make a few optimizations and we end up with this:

-	script	#extra_drop	-1,{
OnNPCKillEvent:
	Zeny += .zeny_list[killedrid - .minId];
	#CASHPOINTS += .cash_list[killedrid - .minId];
	end;

OnInit:
	//mobid, zeny, cash
	.minId = 1001;
	setarray .rewards[0], 
	1002, 10000, 100,
	1003, 20000, 230;
	.@rsize = getarraysize(.rewards);
	for (.@i = 0, .@i < .@rsize; .@i += 3) {
		.zeny_list[.rewards[.@i] - .minId] = .rewards[.@i + 1];
		.cash_list[.rewards[.@i] - .minId] = .rewards[.@i + 2];
	}
	deletearray .rewards[0], .@rsize;
	end;
}

If you want to add items with drop rates and things, I'd recommend doing it in source (which is what I did for my project).

I haven't tested this, but it should work. I got halfway through this script then decided to switch to source.

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

  1. you need to loop trough the list
  2. and check each variable contents
  3. then assign the rewards if any matches found.

https://pastebin.com/xTsWM9Gv

Edited by Emistry
Update missing line.
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  326
  • Reputation:   47
  • Joined:  04/01/12
  • Last Seen:  

 

  1. you need to loop trough the list
  2. and check each variable contents
  3. then assign the rewards if any matches found.

https://pastebin.com/xTsWM9Gv

 

 

i've requested the same script @ hercules and a good hearted one helped me http://herc.ws/board/topic/13126-request-extra-monster-drop/#entry75620 , but i really din't test it yet since i haven't finished all the list of drops i want.

 

i found yours the most exact way i want it to be done, thanks

i'll try them later. thanks all

 

  1. you need to loop trough the list
  2. and check each variable contents
  3. then assign the rewards if any matches found.

https://pastebin.com/xTsWM9Gv

 

tested it, killed drake and he dropped so many Rapiers (item ID 1112) which is same as Drake's monster id, only the zeny and cash works 

 

can you make it also separate drop % for each item drop?

 

 

edit: thanks for everyone who helped, i'm fine now, edited it like this

-	script	Sample	FAKE_NPC,{

	OnNPCKillEvent:
		.@killedrid = killedrid;
		while ( .@i < .monster_drop_size ) {
			if ( compare( "#"+.monster_drop$[.@i],"#"+.@killedrid+"," ) ) {
				.@size = explode( .@reward$,.monster_drop$[.@i],"," );
				if ( .@size > 1 ) {
				
					// Zeny + Cash rewards
					Zeny += atoi( .@reward$[1] );
					#CASHPOINTS += atoi( .@reward$[2] );
					
					// item rewards
					if ( rand( 100 ) < 50 ) {
							getitem atoi( .@reward$[3] ),atoi( .@reward$[4] );
					}
					// item rewards
					if ( rand( 100 ) < 50 ) {
							getitem atoi( .@reward$[5] ),atoi( .@reward$[6] );
					}
				}
				end;
			}
			.@i++;
		}
		end;
		
	OnInit:
	//		Monster & Drop List:
	//		"<Monster ID>|<Zeny>|<Cash Points>|<itemID-1>|<amount-1>|<itemID-2>|<amount-2>...etc",
		setarray .monster_drop$,

			"1511,5000,1,18900,1,5759,1",		// AMON_RA: 5000 Zeny + 1 Cash + Weisswurst + Noah_Hat	
			"1502,5000,1,18844,1,18839,1";		// PORING_V: 5000 Zeny + 1 Cash + Blue_Poring_Bubble + Poring_Sunglasses	

		.monster_drop_size = getarraysize( .monster_drop$ );
		end;
	
}

and its working fine.

Edited by frenzmu06
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...