Jump to content
  • 0
Mr SumBaXs Gamin

Can I Get Script @Autoattack For Rathena Latest Version 2020???

Question

4 answers to this question

Recommended Posts

  • 0

 

On 4/22/2021 at 4:10 AM, hmwater001 said:

why when i type @autoattack its said unknown command?

@autoattack is custom source. its not included in the latest git.

Link to comment
Share on other sites

  • 0
Quote

PC.CPP

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;
    ++struct autoattack_delay;  // autoattack timer
    //NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
    //status_calc_pc, while special_state is recalculated in each call. [Skotlex]
    struct s_state {
        unsigned int active : 1; //Marks active player (not active is logging in/out, or changing map servers)
        unsigned int menu_or_input : 1;// if a script is waiting for feedback from the player
        unsigned int dead_sit : 2;
        unsigned int lr_flag : 3;//1: left h. weapon; 2: arrow
-------------------------------------------------------------------------------------------------
pc.hpp

        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
-------------------------------------------------------------------------------------------------
    int invincible_timer;
    t_tick canlog_tick;
    t_tick canuseitem_tick;    // [Skotlex]
    t_tick canusecashfood_tick;
    t_tick canequip_tick;    // [Inkfish]
    t_tick cantalk_tick;
    t_tick canskill_tick; // used to prevent abuse from no-delay ACT files
    t_tick cansendmail_tick; // [Mail System Flood Protection]
    t_tick ks_floodprotect_tick; // [Kill Steal Protection]
    ++t_tick autoattack_delay;    // Keitenai
    t_tick equipswitch_tick; // Equip switch


----------------------------------

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

I already to the src modification and recompile the server.

But the result same as mention. unknown commands. maybe there are some step i missing?

Link to comment
Share on other sites

  • 0

You forgot to add this at atcommand.cpp

     AtCommandInfo atcommand_base[] = {
+        ACMD_DEF(autoattack),

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

Important Information

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