• 0
Sign in to follow this  
jame156

compile error @autoattack

Question

Hi, i try to install @autoattack command in rathena April 2019 version (offline ver)

but compile error

error around this two line

            add_timer(gettick()+1000,autoattack_timer,sd->bl.id,0);    // 1000 is delay
and

           add_timer(gettick()+1000,autoattack_timer,sd->bl.id,0);
 

here is the full code, it work in 2018 version

thank you, and sorry for my english 🙂


Index: src/map/atcommand.c
===================================================================
--- src/map/atcommand.c    (revision 504)
+++ src/map/atcommand.c    (working copy)
@@ -5217,7 +5217,78 @@
 
// 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;
}

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 || 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;
}

// below just insert between
 /*==========================================
  * @broadcast by [Valaris]
  *------------------------------------------*/
@@ -10184,6 +10255,7 @@
         ACMD_DEF(autoloottype),
         ACMD_DEF(mobinfo),
         ACMD_DEF(exp),
+        ACMD_DEF(autoattack),
         ACMD_DEF(version),
         ACMD_DEF(mutearea),
         ACMD_DEF(rates),
Index: src/map/pc.c
===================================================================
--- src/map/pc.c    (revision 505)
+++ src/map/pc.c    (working copy)
@@ -701,6 +701,7 @@
         sd->canlog_tick = gettick();
     //Required to prevent homunculus copuing a base speed of 0.
     sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED;
+    sd->state.autoattack = 0; // Keitenai
 }
 
 /**
Index: src/map/pc.h
===================================================================
--- src/map/pc.h    (revision 504)
+++ src/map/pc.h    (working copy)
@@ -245,6 +245,7 @@
         unsigned int lesseffect : 1;
         unsigned int vending : 1;
         unsigned int noks : 3; // [Zeph Kill Steal Protection]
+        unsigned autoattack : 1; // Keitenai
         unsigned int changemap : 1;
         unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
         short pmap; // Previous map on Map Change
@@ -347,6 +348,7 @@
     unsigned int canskill_tick; // used to prevent abuse from no-delay ACT files
     unsigned int cansendmail_tick; // [Mail System Flood Protection]
     unsigned int ks_floodprotect_tick; // [Kill Steal Protection]
+    unsigned int autoattack_delay;    // Keitenai
 
     struct s_item_delay {
         unsigned short nameid;
 

Untitled-1.jpg

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 1

Open ../src/map/atcommand.cpp and change:

int autoattack_timer(int tid, unsigned int tick, int id, intptr_t data)

to:

static TIMER_FUNC(autoattack_timer)

 

  • Upvote 1

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

Loading...
Sign in to follow this