Trouble understanding hooking skill methods

Alayne

New member
Messages
345
Points
0
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!

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

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)
{ (*src)->id; (*bl)->id; }
 
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.

 
Allright thanks. I'll give a try tonight, when coming home, and I'll tell you the results.

 
Back
Top