Jump to content

Question

Posted

Hi, I want to add a feature to the @autoattack ( https://rathena.org/board/topic/71297-autoattack/ )

 

I want to set a certain limit to how many mobs you can kill using this custom command. For example, you can only kill at least 500 commands then the command automatically breaks.

Somehow like this

OnLimit:

... disable autoattack here

 

I just want to know how to add to a counter to every mob you kill.

2 answers to this question

Recommended Posts

Posted (edited)

I think this is more of a source request :)

I looked at the diff patch given from the link you gave.

try this and please do not just copy and paste, understand what I did so

you can do the changes better if you find something wrong. here's what I did:

1. changed the func type from void to int of autoattack_motion

2. restructured the if-loop to for-loop and added a counter

//replace void with int so that it can return a value
int autoattack_motion(struct map_session_data* sd)
{
int i, target_id;
for(i=0;i<=9;i++)
{
target_id=0;
map_foreachinarea(buildin_autoattack_sub, sd->bl.m, sd->bl.x-i, sd->bl.y-i, sd->bl.x+i, sd->bl.y+i, BL_MOB, &target_id);
if(target_id)
{
unit_attack(&sd->bl,target_id,1);
break; 
}
target_id=0;
//add a return value if it killed something
return 1;
}
if(!target_id)
{
unit_walktoxy(&sd->bl,sd->bl.x+(rand()%2==0?-1:1)*(rand()%10),sd->bl.y+(rand()%2==0?-1:1)*(rand()%10),0);
}
// default: return 0 if it killed nothing
return 0;
}
int autoattack_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct map_session_data *sd=NULL;


sd=map_id2sd(id);
if(sd==NULL)
return 0;


/* Replace this
 * if(sd->sc.option & OPTION_AUTOATTACK)
 * {
 * autoattack_motion(sd);
 * add_timer(gettick()+2000,autoattack_timer,sd->bl.id,0);
 * }
 * return 0;
 */


 // With this and add a counter for kill count (i)
for(int i=0;(sd->sc.option & OPTION_AUTOATTACK)&&(i<500){
i += autoattack_motion(sd);
add_timer(gettick()+2000,autoattack_timer,sd->bl.id,0);
}
// End 


}
Edited by jezznar

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...