Jump to content
  • 0

Mob and collision in skill


Tio Akima

Question


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  191
  • Reputation:   138
  • Joined:  09/24/12
  • Last Seen:  

Hello guys
I've been trying to do a skill for a few days, but without success.
I'm almost giving up .. So if anyone can help me, please ...

About the skill:

The skill makes a MOB walk on a line ... Then the skill checks cell by cell ...
Upon reaching the end of this line, the MOB dies.
But ... as this loooping is very fast, the MOB dies before reaching the end of the path ....

I have a FOR () looping
Walking from cell to cell ..

               for( i = 1; i <= qnt; i++ ){
                    sx = md->bl.x - i;
                    sy = md->bl.y;
                    unit->walktoxy(&md->bl,sx,sy,0);
    
                            if (map->count_oncell(md->bl.m, sx, sy, BL_PC | BL_NPC | BL_MOB, 0) || 
                                        map->getcell(md->bl.m, &md->bl, sx, sy, CELL_CHKWALL) || 
                                        map->getcell(md->bl.m, &md->bl, sx, sy, CELL_CHKNOPASS)) {
                                
                                md->deletetimer = timer->add(timer->gettick() + skill->get_time(skill_id,skill_lv), mob->timer_delete, md->bl.id, 0);
                                        
                                break; //end
                            }
                                
                }

In this FOR() I put a condition:

If the mob is interrupted during the way (finding a "non-moveable" cell, some wall, or player, or another mob, etc ...) then the mob disappears (or dies)

I did the tests and logic is working perfectly ...
When encountering an obstacle, the code enters the condition and deletes the mob ..

But, the mob disappears before reaching the end of the path ...
this is the problem...

In counting the cells, collision occurs.
But, the mob dies long before it collides

the summon mob example:

int mob_id = 1102;   // mob example
struct mob_data *md;

md = mob->once_spawn_sub(src, src->m, x, y, clif->get_bl_name(src), mob_id, "", SZ_BIG, AI_SPHERE);

mob->spawn (md);	//summon the mob


I tried using the skill-> addtimerskill ()

example:

skill->addtimerskill(src,timer->gettick() + (140 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2);

But it's not right ..
What it does is call this function to show a pre-defined layout
so, show this layout at set time intervals.

So I do not know how to use it within my purpose.


I thought about putting the condition (of the obstacles)
In unit.c within the unit-> walktoxy
But I do not know how to reference the mob there in unit.c
And I do not know if it would solve ..
Or if the mob would also die before reaching the obstacle.


 

Sorry for the huge text,
But I'm almost giving up, I've tried everything.

If anyone can help me.
Thank you.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

Since we don't know where you put your for loop, we can't really help you.

 

I can tell you this much though: You will not want to iterate over a for loop in a skill usage that checks for md movement. You much rather want to implement a structure within the md that keeps track of this debuff (using a SC for example) and do all the checking in the default unit movement procedure.

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  191
  • Reputation:   138
  • Joined:  09/24/12
  • Last Seen:  

5 hours ago, Jonne said:

Since we don't know where you put your for loop, we can't really help you.

 

I can tell you this much though: You will not want to iterate over a for loop in a skill usage that checks for md movement. You much rather want to implement a structure within the md that keeps track of this debuff (using a SC for example) and do all the checking in the default unit movement procedure.

 

Thanks for the message, my friend, I'll think about what you said.

I'm still in the search for help.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  350
  • Reputation:   43
  • Joined:  09/07/12
  • Last Seen:  

There is a function that is called on timer tick, (something like walkto) you can try finding and putting the code there, 

Putting the code in the walkto function will affect all the units that uses that,

I suggest putting something to identify that only this unit will die when reached an obstacle, sc status would be helpful for this,

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