Jump to content
goddameit

@AutoAttack

Recommended Posts

Hi! I'm new to this kind of stuff. How do i install this?

I have no programming background, sorry.

can you give me a step-by-step instruction?

Share this post


Link to post
Share on other sites

I use Git to install but pop up error message with "The patch does not apply cleanly to D:/.......... and no version information is given. patching is not possible"

any one can help me on this?

Thanks

 

Share this post


Link to post
Share on other sites

It can kill the bots, why not let it kill monster in entire map? using @autoloot 

it will be very good!

 

is it possible?

Share this post


Link to post
Share on other sites

How to apply this into newest rAthena?

 

I got this issue when trying to manually implement it:

atcommand.cpp: In function 'int autoattack_timer(int, unsigned int, int, intptr_t)':
atcommand.cpp:9270:28: error: invalid conversion from 'int (*)(int, unsigned int, int, intptr_t)' {aka  int (*)(int, unsigned int, int, long int)'} to 'TimerFunc' {aka 'int (*)(int, long int, int, long int)'} [-fpermissive]
   add_timer(gettick()+2000,autoattack_timer,sd->bl.id,0);
                            ^~~~~~~~~~~~~~~~
In file included from ../common/mmo.hpp:13,
                 from atcommand.hpp:8,
                 from atcommand.cpp:4:
../common/timer.hpp:54:38: note:   initializing argument 2 of 'int add_timer(t_tick, TimerFunc, int, intptr_t)'
 int add_timer(t_tick tick, TimerFunc func, int id, intptr_t data);


Any idea how can it be implemented in latest rAthena?

Share this post


Link to post
Share on other sites
On 10/28/2019 at 4:55 AM, OscarScorp said:

I got this issue when trying to manually implement it:

atcommand.cpp: In function 'int autoattack_timer(int, unsigned int, int, intptr_t)':
atcommand.cpp:9270:28: error: invalid conversion from 'int (*)(int, unsigned int, int, intptr_t)' {aka  int (*)(int, unsigned int, int, long int)'} to 'TimerFunc' {aka 'int (*)(int, long int, int, long int)'} [-fpermissive]
   add_timer(gettick()+2000,autoattack_timer,sd->bl.id,0);
                            ^~~~~~~~~~~~~~~~
In file included from ../common/mmo.hpp:13,
                 from atcommand.hpp:8,
                 from atcommand.cpp:4:
../common/timer.hpp:54:38: note:   initializing argument 2 of 'int add_timer(t_tick, TimerFunc, int, intptr_t)'
 int add_timer(t_tick tick, TimerFunc func, int id, intptr_t data);


Any idea how can it be implemented in latest rAthena?

I think it is not possible to latest revision nomore update to this post since 2013

Share this post


Link to post
Share on other sites
On 10/28/2019 at 3:55 AM, OscarScorp said:

I got this issue when trying to manually implement it:

atcommand.cpp: In function 'int autoattack_timer(int, unsigned int, int, intptr_t)':
atcommand.cpp:9270:28: error: invalid conversion from 'int (*)(int, unsigned int, int, intptr_t)' {aka  int (*)(int, unsigned int, int, long int)'} to 'TimerFunc' {aka 'int (*)(int, long int, int, long int)'} [-fpermissive]
   add_timer(gettick()+2000,autoattack_timer,sd->bl.id,0);
                            ^~~~~~~~~~~~~~~~
In file included from ../common/mmo.hpp:13,
                 from atcommand.hpp:8,
                 from atcommand.cpp:4:
../common/timer.hpp:54:38: note:   initializing argument 2 of 'int add_timer(t_tick, TimerFunc, int, intptr_t)'
 int add_timer(t_tick tick, TimerFunc func, int id, intptr_t data);


Any idea how can it be implemented in latest rAthena?

Quote

// Auto Attack --- put before all command
static int buildin_autoattack_sub(struct block_list *bl,va_list ap)
{
    int *target_id=va_arg(ap,int *);
    *target_id = bl->id;
    return 1;
}
 
void autoattack_motion(struct map_session_data* sd)
{
    int i, target_id;
    if( pc_isdead(sd) || !sd->state.autoattack ) return;

    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;
    }
    if(!target_id && !pc_isdead(sd) && sd->state.autoattack){
        unit_walktoxy(&sd->bl,sd->bl.x+(rand()%2==0?-1:1)*(rand()%25),sd->bl.y+(rand()%2==0?-1:1)*(rand()%25),0);
    }
    return;
}

static TIMER_FUNC(autoattack_timer)
{
    struct map_session_data *sd=NULL;

    sd=map_id2sd(id);
    if(sd==NULL || pc_isdead(sd) || !sd->state.autoattack )
        return 0;

    if(sd->state.autoattack)
    {
        unit_stop_attack(&sd->bl);
        autoattack_motion(sd);
        if(DIFF_TICK(sd->autoattack_delay,gettick())> 0){
            clif_authfail_fd(sd->fd, 15);
            return 0;
        }
        else{
            add_timer(gettick()+1000,autoattack_timer,sd->bl.id,0);    // 1000 is delay
            sd->autoattack_delay = gettick() + 1000;    // 1000 is delay
        }
    }
    return 0;
}

ACMD_FUNC(autoattack)
{
    nullpo_retr(-1, sd);
    if (sd->state.autoattack)
    {
        sd->state.autoattack = 0;
        unit_stop_attack(&sd->bl);
        clif_displaymessage(fd, "Auto Attack has been deactivated.");
    }
    else
    {
        sd->state.autoattack = 1;
        add_timer(gettick()+1000,autoattack_timer,sd->bl.id,0);
        clif_displaymessage(fd, "Auto Attack activated.");
    }
    return 0;
}

try this

  • MVP 1

Share this post


Link to post
Share on other sites

nice dont forget to put in the variables in the pc.hpp -> struct map_session_data

 

struct map_session_data {
	struct block_list bl;
	struct unit_data ud;
	struct view_data vd;
	struct status_data base_status, battle_status;
	struct status_change sc;
	struct regen_data regen;
	struct regen_data_sub sregen, ssregen;
	unsigned int autoattack_delay;  // autoattack timer
		unsigned int killable : 1;
		unsigned int doridori : 1;
		unsigned int ignoreAll : 1;
		unsigned int autoattack : 1; // autoattack
		unsigned int debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
		unsigned int buyingstore : 1;
		unsigned int lesseffect : 1;
		unsigned int vending : 1;

 

Share this post


Link to post
Share on other sites

where i should put this ?? 

 

Share this post


Link to post
Share on other sites

 

Compile Error 

 

rAthena update new

 

 

Request a solution urgently

error.png

Share this post


Link to post
Share on other sites

still works on latest revision? 

Share this post


Link to post
Share on other sites

Hello, back to this old post again.
Now I seek to make it so users are able to autoattack a specific monster ID, as JulianChz suggested:

On 5/22/2017 at 8:24 AM, JuLiAnChz said:

 

static int buildin_autoattack_sub(struct block_list *bl, va_list ap) {
	int *target_id = va_arg(ap, int *);
	*target_id = bl->id;
	struct mob_data* *md2 = va_arg(ap, struct mob_data* *);
	*md2 = BL_CAST(BL_MOB, bl);
	return 1;
}

void autoattack_motion(struct map_session_data* sd, int mob_id){
	int i, target_id;
	struct mob_data* md2;
	
	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, &md2);
		if (target_id) {
			if (mob_id != 0 && mob_id == md2->mob_id) {
				unit_attack(&sd->bl, target_id, 1);
			} else if (mob_id == 0) {
				unit_attack(&sd->bl, target_id, 1);
			} else {
				target_id = 0;
			}
			break;
		}
		target_id = 0;
	}
	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);
	}
	return;
}

int autoattack_timer(int tid, unsigned int tick, int id, intptr_t data) {
	struct map_session_data *sd = NULL;
	int mob_id = (int *)data;
	sd = map_id2sd(id);

	if (sd == NULL)
		return 0;
	if (sd->sc.option & OPTION_AUTOATTACK) {
		autoattack_motion(sd, mob_id);
		add_timer(gettick() + 1000, autoattack_timer, sd->bl.id, (intptr_t)mob_id);
	}
	return 0;
}
ACMD_FUNC(autoattack) {
	nullpo_retr(-1, sd);
	int mob_id = 0;
	char monster[NAME_LENGTH];

	memset(monster, '\0', sizeof(monster));
	
	if (message || *message) {
		if (sscanf(message, "%23s", monster) > 0) {
			if ((mob_id = mobdb_searchname(monster)) == 0)
				mob_id = mobdb_checkid(atoi(monster));
			
			if (mob_id == 0) {
				clif_displaymessage(fd, msg_txt(sd, 40)); // Invalid monster ID or name.
				return -1;
			}
		}
	}

	if (sd->sc.option & OPTION_AUTOATTACK) {
		sd->sc.option &= ~OPTION_AUTOATTACK;
		unit_stop_attack(&sd->bl);
		clif_displaymessage(fd, "Has desactivado AutoAtaque");
	} else {
		sd->sc.option |= OPTION_AUTOATTACK;
		add_timer(gettick() + 200, autoattack_timer, sd->bl.id, (intptr_t)mob_id);
		clif_displaymessage(fd, "Has Activado AutoAtaque");
	}
	clif_changeoption(&sd->bl);
	return 0;
}

@autoattack - All
@autoattack poring - Only poring
@autoattack 1002 - Only poring

Problem is I can't make it work due to two different lines. My basic autoattack command (without specific mob ID) works like:

static TIMER_FUNC(autoattack_timer)
{
	struct map_session_data *sd=NULL;
	int mob_id = data;
	sd=map_id2sd(id);
	...

while Julian's is:

int autoattack_timer(int tid, unsigned int tick, int id, intptr_t data) {
	struct map_session_data *sd = NULL;
	int mob_id = (int *)data;
	sd = map_id2sd(id);
	...

If I change my code to int autoattack_timer(int tid, unsigned int tick, int id, intptr_t data), the code won't run in my rAthena, forcing me to use TIMER_FUNC as LearningRO suggested (works).

Is there any way to obtain the intptr_t data variable through a static TIMER_FUNC ?

Thanks in advance!

Share this post


Link to post
Share on other sites

Hello,

Is there any possibilities for using @autoattack like @autotrade? Players will be logged out but character still on game and doing autoattack.

I've tried to put state.autotrade = 1; but the result was the character didn't walking for monsters. So, is there a code/variable to make the client only logged out but character still on the game?

Share this post


Link to post
Share on other sites

hello is there a step by step guide for this?

Share this post


Link to post
Share on other sites

Where put the diff ? help pls :c!!!

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
Reply to this topic...

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

Important Information

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