Jump to content
  • 0

A getunitdata question.


crazyarashi

Question


  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

OnMinionSummon:
.@minion_id = 1002;
.@minion_count = 20;
monster "prontera",255,55,"Pink Evil Minions",.minion_id,.minion_count,strnpcinfo(0)+"::OnMinionKill";
for (.@i = 0; .@i < .minion_count; .@i++){
	.gid[.@i] = $@mobid[.@i];
	//= store data
}
                         


		

Good day rathena, I have a question regarding getunitdata. I want to summon a multiple monster and get their data later on. ( specifically the x and y) during the KillEvent
Tried several ways to get the data and yet failed. hopefully anyone can enlighten me on what to do. Thanks in advance
 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

3 hours ago, crazyarashi said:

OnMinionSummon:
.@minion_id = 1002;
.@minion_count = 20;
monster "prontera",255,55,"Pink Evil Minions",.minion_id,.minion_count,strnpcinfo(0)+"::OnMinionKill";
for (.@i = 0; .@i < .minion_count; .@i++){
	.gid[.@i] = $@mobid[.@i];
	//= store data
}
                         


		

Good day rathena, I have a question regarding getunitdata. I want to summon a multiple monster and get their data later on. ( specifically the x and y) during the KillEvent
Tried several ways to get the data and yet failed. hopefully anyone can enlighten me on what to do. Thanks in advance
 

Here there might be a better way of doing this but this is the method I've come up with tested and it's working quite well.

prontera,260,69,1	script	monsterspawner	100,{

OnMinionSummon:
	.@minion_id = 1002;
	.@minion_count = 10;
	monster "prontera",255,55,"Pink Evil Minions",.@minion_id,.@minion_count,strnpcinfo(0)+"::OnMinionKill";
	copyarray .gid[getarraysize(.gid)], $@mobid[0], .@minion_count;
	end;

OnMinionKill:
	.@len = getarraysize(.gid);
	for(.@a = 0; .@a < .@len; .@a++) {
		if(unitexists(.gid[.@a])) {
			getunitdata(.gid[.@a],.@mobdata);
			if(!.@mobdata[UMOB_HP]) {
				dispbottom .@mobdata[UMOB_X]+" "+.@mobdata[UMOB_Y]+" HP:"+.@mobdata[UMOB_HP];
				deletearray .gid[.@a], 1;
				break;
			}
		} else {
			deletearray .gid[.@a], 1;
			.@len--;
		}
	}
	
}

 

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

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

1 hour ago, Skorm said:

Here there might be a better way of doing this but this is the method I've come up with tested and it's working quite well.


prontera,260,69,1	script	monsterspawner	100,{

OnMinionSummon:
	.@minion_id = 1002;
	.@minion_count = 10;
	monster "prontera",255,55,"Pink Evil Minions",.@minion_id,.@minion_count,strnpcinfo(0)+"::OnMinionKill";
	copyarray .gid[getarraysize(.gid)], $@mobid[0], .@minion_count;
	end;

OnMinionKill:
	.@len = getarraysize(.gid);
	for(.@a = 0; .@a < .@len; .@a++) {
		if(unitexists(.gid[.@a])) {
			getunitdata(.gid[.@a],.@mobdata);
			if(!.@mobdata[UMOB_HP]) {
				dispbottom .@mobdata[UMOB_X]+" "+.@mobdata[UMOB_Y]+" HP:"+.@mobdata[UMOB_HP];
				deletearray .gid[.@a], 1;
				break;
			}
		} else {
			deletearray .gid[.@a], 1;
			.@len--;
		}
	}
	
}

 

Big thanks! going to try it out :))

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

@crazyarashi Not sure if you suggested this one, but it's something I've been wanting for awhile, and it looks like @Capuche just added it. In anycase it would be much better to update your server and use the killedgid variable instead of all this mumbo jumbo.

 

https://github.com/rathena/rathena/commit/c856b07c45aed6c5842ee19a940f7e76f780221c

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