Jump to content
  • 0
Sign in to follow this  
Easycore

Array in scourge

Question

Hi,
I tried put an array in skill.c (specifically in skill_castend_id) ,that makes certain skills trigger a specialeffect when target received damage.
 
I put the follow:

 

int skilleffects[5] = {7, 5, 8,370, 371}; //skill_id that trigger specialeffect

But I don't know how check this array, in my ignorance I tried this:

 

if (skill_id == skillseffects[5])clif->specialeffect(src, 722, AREA);

 

 

But it is severely wrong.

 

PS: I wrote it after this:

 

 

int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) {	struct map_session_data *sd = NULL;	struct status_data *tstatus;	struct status_change *sc;	if (skill_id > 0 && !skill_lv) return 0;	nullpo_retr(1, src);	nullpo_retr(1, bl);	if (src->m != bl->m)		return 1;	if (bl->prev == NULL)		return 1;	sd = BL_CAST(BL_PC, src); 

 

 

 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

cheap method without array

if ( skill_id == SM_MAGNUM || skill_id == SM_BASH || skill_id == SM_ENDURE || skill_id == CH_PALMSTRIKE || skill_id == CH_TIGERFIST )clif->specialeffect(src, 722, AREA);
this method allows to use constant which makes your code easy to read

 

and the array

int i;for ( i = 0; i < 5; ++i )if ( skilleffects[i] == skill_id ) {clif->specialeffect(src, 722, AREA);break;}
.

EDITING, there is 1 more, wait I dig it out

OK

int i;ARR_FIND( 0, 5, i, skilleffects[i] == skill_id );if ( i < 5 )clif->specialeffect(src, 722, AREA);
Edited by AnnieRuru

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

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