Jump to content
  • 0
Sign in to follow this  
Alayne

Trouble understanding hooking skill methods

Question

Hi everybody.

 

I'm currently trying to write a hooking plugin enabling to hook skill use from players.

I've hooked (pre) the castend_pos2 and castend_nodamage method, which I've confirmed to be the two I need for my use.

 

If I use those initial methods to display the infos I need (id, x and y pos), the infos displayed are okay.

But on the other hand, if use my hooked ones, the castend_nodamage doesn't display the good coordinates.

 

On top of that, I'd like to add a check for players only, to prevent raise from mob skills.

But this doesn't work either, I don't get any output of the infos anymore, meaning my check isn't good, but I don't know why.

 

Can anybody help me?

 

Here's my code:

 


int skill_castend_nodamage_id_pre(struct block_list *src, struct block_list *bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag)
{
	//ShowInfo( "hook castend nodamage %i/%i", src->type, BL_PC );
	//	TBL_PC *sd = BL_CAST(BL_PC, src);
	//if ( src->type == BL_PC || sd ) {
		ShowInfo(" hook castend nodamage id %i: %i / %i", *skill_id, bl->x, bl->y);
		ShowInfo(" hook castend nodamage id %i: %i / %i", *skill_id, src->x, src->y);
	//}
	return 0;
}

/* run when server starts */
HPExport void plugin_init (void) {
	//init hook
	ShowInfo("[%s] I'm being run from the '%s' filename\n", SERVER_NAME);
	addHookPre( skill, castend_pos2, skill_castend_pos2_pre);
	addHookPre( skill, castend_nodamage_id, skill_castend_nodamage_id_pre);
}

Just to explain, the "sd" was used just in case, as the type must be okay. But as it doesn't, I've used to double check. Doesn't work either...I always get a "hook castend nodamage id 2006: 0 / -10368" (notice that the y may change, but I've never seen anything over than 0 for the x).

 

Thanks for any help you'd be able to give me!

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

In pre hooks you're working with pointers added to each argument, i.e.

 


int skill_castend_nodamage_id_pre(struct block_list **src, struct block_list **bl, uint16 *skill_id, uint16 *skill_lv, int64 *tick, int *flag)
{ (*src)->id; (*bl)->id; }

Share this post


Link to post
Share on other sites
  • 0

Well yeah, I know, but as there was already one one the src and bl params, didn't know you can double it.

Are you sure about that? The example I took (AnnieRuru OnPCUseEvent) doesn't do that, but I'll give it a try.

 

Thanks for answering anyway.

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

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