Jump to content
  • 0

how to make script mob drop item?


Antares

Question


  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

Hello!

 

I want to make a custom mob for a server quest which drops an item when killed. I want to do this by script and not by adding a real custom mob (if possible). Is this possible? I have the following script:

-	script	Weird Plant	-1,{
	
OnInit:
	.mobid = 2135; //2135
	monster "prontera",0,0,"Weird Plant",.mobid,10,strnpcinfo(0)+"::OnMyMobDead";
	end;
OnMyMobDead:
	getmapxy(.@map$, .@x, .@y, 3);
	.@itemno = rand(2);
	for(set .@i,0; .@i<.@itemno; set .@i,.@i+1){
		makeitem(909, 1, .@map$, .@x+rand(2)-1, .@y+rand(2)-1);
	}
	monster "prontera",0,0,"Weird Plant",.mobid,1,strnpcinfo(0)+"::OnMyMobDead";
	end; 
}

Unfortunately, getmapxy neither with 3(monster) nor with 1(npc) as flag does return the position of the monster, so is it possible to get it in another way??

Link to comment
Share on other sites

7 answers to this question

Recommended Posts


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

Without mod

-	script	Weird Plant	-1,{
OnInit:
	.mobid = 2135; //2135
	for ( .@i = 0; .@i < 10; .@i++ ) {
		monster "prontera",0,0,"Weird Plant",.mobid,1,strnpcinfo(0)+"::OnMyMobDead"+ .@i;
		.mob_gid[.@i] = $@mobid[0];
	}
	end;
OnMyMobDead0: callsub S_Makeitem, 0,.mob_gid[0];
OnMyMobDead1: callsub S_Makeitem, 1,.mob_gid[1];
OnMyMobDead2: callsub S_Makeitem, 2,.mob_gid[2];
OnMyMobDead3: callsub S_Makeitem, 3,.mob_gid[3];
OnMyMobDead4: callsub S_Makeitem, 4,.mob_gid[4];
OnMyMobDead5: callsub S_Makeitem, 5,.mob_gid[5];
OnMyMobDead6: callsub S_Makeitem, 6,.mob_gid[6];
OnMyMobDead7: callsub S_Makeitem, 7,.mob_gid[7];
OnMyMobDead8: callsub S_Makeitem, 8,.mob_gid[8];
OnMyMobDead9: callsub S_Makeitem, 9,.mob_gid[9];

S_Makeitem:
	getunitdata getarg(1),.@array;
	// dispbottom "Coordonnée x : "+ .@array[6];
	// dispbottom "Coordonnée y : "+ .@array[7];
	for ( .@i = 0; .@i < rand(2); .@i++ )
		makeitem 909, 1, strcharinfo(3), ( .@array[6]+rand(2)-1 ), ( .@array[7]+rand(2)-1 );
	monster "alberta",94,54,"Weird Plant",.mobid,1,strnpcinfo(0)+"::OnMyMobDead"+ getarg(0);
	.mob_gid[ getarg(0) ] = $@mobid[0];
	end; 
}

It's true it would be better to return the mob unique id to use getunitdata. Maybe we should implement it

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

use player's position


use player's position

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

use player's position

use player's position

 

Currently I am using it, but it looks lame, and if a homunculus/pet/mercenary/summon/negative status kills the mob, the function will not work properly.  Is there any other way to give an existing monster a custom drop? I know about the item script bonus and custom mob methods, but is there a way to do this by scripting?

 

Btw, why getmapxy isn't working on mobs? What's the point of the flag then?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  663
  • Reputation:   671
  • Joined:  11/12/12
  • Last Seen:  

If you don't mind modifying your source, you can add the "killedgid" param on the OnMyMobDead event (which is the main problem of getmapxy, it doesn't know which mob to look for).
 

-	script	Weird Plant	-1,{
	
OnInit:
	.mobid = 2135; //2135
	monster("prontera",0,0,"Weird Plant",.mobid,10,strnpcinfo(0)+"::OnMyMobDead");
	end;
OnMyMobDead:
	if (!playerattached()) end;
	getunitdata killedgid, .@unitdata;
	.@x = .@unitdata[6];
	.@y = .@unitdata[7];
	.@itemno = rand(2);
	// announce "Spawning " + .@itemno + " items.", 0;
	for (.@i = 0; .@i < .@itemno; .@i++) {
		makeitem(909, 1, "prontera", .@x + rand(2) - 1, .@y + rand(2) - 1);
	}
	
	monster("prontera",0,0,"Weird Plant",.mobid,1,strnpcinfo(0)+"::OnMyMobDead");
	end; 
}

killedgid.patch

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  383
  • Reputation:   121
  • Joined:  03/31/12
  • Last Seen:  

I'll try with Tokei and with Capuche.

might this can be useful thank you both!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  74
  • Topics Per Day:  0.02
  • Content Count:  420
  • Reputation:   89
  • Joined:  01/30/12
  • Last Seen:  

Thanks Tokei and Capuche! For now, I'll go with the modless solution, but it would be good to be actually be able to use the killedgid in mapxy sime time in the future. There might be other cases where it would be neccessary :)

 

Btw it came to my mind that it would be pretty cool if we could add custom monsters through script (define sprite id, stats, elements, skills, drop, exp and finally spawn it). Just imagine the possibilities with dynamically created monsters! Ex: quest mobs that size themselves to the player, and get stronger for higher players, or change their behavior based on player's class and other fancy and fun things :)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  663
  • Reputation:   671
  • Joined:  11/12/12
  • Last Seen:  

Thanks Tokei and Capuche! For now, I'll go with the modless solution, but it would be good to be actually be able to use the killedgid in mapxy sime time in the future. There might be other cases where it would be neccessary :)

 

Btw it came to my mind that it would be pretty cool if we could add custom monsters through script (define sprite id, stats, elements, skills, drop, exp and finally spawn it). Just imagine the possibilities with dynamically created monsters! Ex: quest mobs that size themselves to the player, and get stronger for higher players, or change their behavior based on player's class and other fancy and fun things :)

 

rAthena can already do this with the setunitdata script method. You'll probably want to add more properties via source edit (like atk, matk, def, flee, etc) but otherwise most of them can be edited.

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