Jump to content
  • 0

global drop item


Blazing Spear

Question


  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  208
  • Reputation:   1
  • Joined:  01/06/12
  • Last Seen:  

how to make script like this?

 

1 monster = 1-10 item random

 

thanks!

 

Link to comment
Share on other sites

9 answers to this question

Recommended Posts


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

OnNPCKillEvent:
if( rand(100) < 10 )
    getitem  .item[ rand( .item_size ) ],1;
end;

OnInit:
setarray .item[0],607,608,512;
.item_size = getarraysize( .item );
end;
 

edit :

fixed OnPCKillEvent to OnNPCKillEvent

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  208
  • Reputation:   1
  • Joined:  01/06/12
  • Last Seen:  

ill try this

-	script	AllDrop	-1,{
OnPCKillEvent:
if( rand(100) < 10 )
	getitem .item[ rand( .item_size ) ],1;
end;
 
OnInit:
	setarray .item[0],607,608,512;
	.item_size = getarraysize( .item );
	end;
}
 

is this right?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  382
  • Reputation:   38
  • Joined:  01/17/12
  • Last Seen:  

OnPCKillEvent will only be executed when a player will kill another player so to achieve a global monster drop use OnNPCKillEvent

 

So the script should look like this:

OnNPCKillEvent:
if( rand(1000) < 10 ) // Chance: 10 = 1%, 100 = 10%, etc.
    getitem  .item[ rand( .item_size ) ],1;
end;

OnInit:
setarray .item[0],<item id1>,<item id2>,<item id3>,<more>;
.item_size = getarraysize( .item );
end;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  9
  • Reputation:   4
  • Joined:  12/15/11
  • Last Seen:  

If you want the mobs to actually DROP it (on your location, probably the easiest way), use makeitem though. Be aware that autoloot won't work on it and anyone can pick it up immediately.

 

 

if (getmapxy(.@map$,.@x,.@y,0,strcharinfo(0))!=1) {
   makeitem ID,amount,.@map$,.@x,.@y;
}

 

if it should drop a bit further from your character, you can add a number to x and y

like

 

.@x+1

or .@x+rand(2)

whatever

 

my 0.02$ :b

Edited by HollyEnix
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  208
  • Reputation:   1
  • Joined:  01/06/12
  • Last Seen:  

how about random amount of item per monster?? i want 1 monster = something like 50% item then 1-10 amount

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

1/

OnNPCKillEvent:
    if( rand(1000) < 500 ) // Chance: 10 = 1%, 100 = 10%, etc.
        getitem callfunc( "F_RandMes", 5, 501,502,503,504,505 ), rand( 1,10 ); // http://rathena.org/board/topic/78263-scripting-faqtipstricks/
    end;
 

 

how about random amount of item per monster?? i want 1 monster = something like 50% item then 1-10 amount

amount 1-10 : rand( 1,10 );

 

 

 

2/

If you want the mobs to actually DROP it (on your location, probably the easiest way), use makeitem though. Be aware that autoloot won't work on it and anyone can pick it up immediately.

 

 

if (getmapxy(.@map$,.@x,.@y,0,strcharinfo(0))!=1) {
   makeitem ID,amount,.@map$,.@x,.@y;
}

*getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"})

This function will locate a character object, NPC object or pet's coordinates
and place their coordinates into the variables specified when calling it. It
will return 0 if the search was successful, and -1 if the parameters given were
not variables or the search was not successful.

always != 1

 

OnNPCKillEvent:
	if( rand(1000) < 500 ) { // Chance: 10 = 1%, 100 = 10%, etc.
		getmapxy .@map$, .@x, .@y, 0;
		makeitem callfunc( "F_RandMes", 5, 501,502,503,504,505 ), rand( 1,10 ), .@map$, .@x, .@y; // <num item>, <item id1>,<item id2>,<item id3>
	}
	end;
Edited by Capuche
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  208
  • Reputation:   1
  • Joined:  01/06/12
  • Last Seen:  

1/

OnNPCKillEvent:
    if( rand(1000) < 500 ) // Chance: 10 = 1%, 100 = 10%, etc.
        getitem callfunc( "F_RandMes", 5, 501,502,503,504,505 ), rand( 1,10 ); // http://rathena.org/board/topic/78263-scripting-faqtipstricks/
    end;
 
i tried this but this is the error

6734gZI.png

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  382
  • Reputation:   38
  • Joined:  01/17/12
  • Last Seen:  

Have you fixed the npc header?

If you paste it here it has spaces but it should have tabs. Like this:

 

-<tab>script<tab>AllDrop<tab>-1,{
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  9
  • Reputation:   4
  • Joined:  12/15/11
  • Last Seen:  

having the npc named after an event label (OnNPCKillEvent) returns your error, I believe.

use another npc name, like bahmut did, and put the OnNPCKillEvent as a label within the npc

don't have a server to confirm atm

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