Jump to content

Question

Posted (edited)

So, I've looked at hercules' plugin for @arealoot and saw that it used greed's code to help do what it wanted. I decided to try and use it for myself and convert it over to rAthena but I'm having a bit of trouble. I don't dabble that much in the source, so I'm not very good at it but this is what I have so far:
 

Incorrect code removed.

It compiles but it does not change anything. It does give me a warning, though. This one: "1>c:\rathena\src\map\pc.c(4254): warning C4047: '==' : 'int (__cdecl *)(map_session_data *,flooritem_data *)' differs in levels of indirection from 'int'" I  think I understand what it means but I'm not sure how to fix it. Please help. =X

Edited by Dragonis1701

Recommended Posts

  • 0
Posted

Care to share?

 

I've been trying my hand at this on and off for months now.

 

 

Can you share your code?

Oh, hey guys. Sorry, I didn't know you replied to this topic. I'm quoting you both so you both get a notification. Here is the code:

void clif_parse_TakeItem(int fd, struct map_session_data *sd)
{
    struct flooritem_data *fitem;
    int map_object_id;
    int skill_greed(struct block_list *bl, va_list ap);

    //First we declare a variable that gets the return value
    int debug_i = 0;

    map_object_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);

    fitem = (struct flooritem_data*)map_id2bl(map_object_id);
    do {
        if (pc_isdead(sd)) {
            clif_clearunit_area(&sd->bl, CLR_DEAD);
            break;
        }

        if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
            break;

        if (pc_cant_act(sd))
            break;
        
        if (sd->state.arealoot == 1) {
        //Now we give the variable
        debug_i = map_foreachinrange(skill_greed,&sd->bl,3,BL_ITEM,&sd->bl);

        //Now we print it to the map-server console so you can see what it is while playing
        //ShowDebug("debug_i=%d", debug_i);

        //Give fail packet if no item was looted
        if(debug_i == 0)
            break;
        }
        else {
        if (!pc_takeitem(sd, fitem))
            break;
        }
        return;
    } while (0);
    // Client REQUIRES a fail packet or you can no longer pick items.
    clif_additem(sd,0,0,6);
}

That code is located in clif.c. I also added a command @arealoot in the atcommand.c. If you need that code as well, just let me know.

  • 0
Posted (edited)

So, I worked on it some more and found that using the already existing code was better. So, now I have it where the code is like this:

Incorrect code removed.

And now with this code, it will clear multiple items but it will not loot multiple items. Is there a command I'm missing that can provide this function?


Got it to work with Playtester's help. ^^

Edited by Dragonis1701
  • 0
Posted

 

Care to share?

 

I've been trying my hand at this on and off for months now.

 

 

Can you share your code?

Oh, hey guys. Sorry, I didn't know you replied to this topic. I'm quoting you both so you both get a notification. Here is the code:

 

void clif_parse_TakeItem(int fd, struct map_session_data *sd)
{
    struct flooritem_data *fitem;
    int map_object_id;
    int skill_greed(struct block_list *bl, va_list ap);

    //First we declare a variable that gets the return value
    int debug_i = 0;

    map_object_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);

    fitem = (struct flooritem_data*)map_id2bl(map_object_id);
    do {
        if (pc_isdead(sd)) {
            clif_clearunit_area(&sd->bl, CLR_DEAD);
            break;
        }

        if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
            break;

        if (pc_cant_act(sd))
            break;
        
        if (sd->state.arealoot == 1) {
        //Now we give the variable
        debug_i = map_foreachinrange(skill_greed,&sd->bl,3,BL_ITEM,&sd->bl);

        //Now we print it to the map-server console so you can see what it is while playing
        //ShowDebug("debug_i=%d", debug_i);

        //Give fail packet if no item was looted
        if(debug_i == 0)
            break;
        }
        else {
        if (!pc_takeitem(sd, fitem))
            break;
        }
        return;
    } while (0);
    // Client REQUIRES a fail packet or you can no longer pick items.
    clif_additem(sd,0,0,6);
}

That code is located in clif.c. I also added a command @arealoot in the atcommand.c. If you need that code as well, just let me know.

 

 

Can you post the full code or share it via message? Thanks!

  • 0
Posted (edited)

atcommand.c

/*==========================================
 * @arealoot
 *------------------------------------------*/
ACMD_FUNC(arealoot) {
    if (sd->state.arealoot) {
        sd->state.arealoot = 0;
        clif_displaymessage(sd->fd,"Arealoot is now disabled.");
        return 0;
    }

    sd->state.arealoot = 1;
    clif_displaymessage(sd->fd,"Arealoot is now enabled.");
    return 0;
}
void atcommand_basecommands(void) {
 
AtCommandInfo atcommand_base[] = {
 
ACMD_DEF(arealoot),
Edited by Dragonis1701
  • 0
Posted

 

atcommand.c

/*==========================================
 * @arealoot
 *------------------------------------------*/
ACMD_FUNC(arealoot) {
    if (sd->state.arealoot) {
        sd->state.arealoot = 0;
        clif_displaymessage(sd->fd,"Arealoot is now disabled.");
        return 0;
    }

    sd->state.arealoot = 1;
    clif_displaymessage(sd->fd,"Arealoot is now enabled.");
    return 0;
}

 

The first 2 post goes to pc.c? the void code goes to clif.c and last one is atcommand.c?

  • 0
Posted (edited)

 

pc.h

bool arealoot;

 

where do you add this?

Nah, the pc.c codes are not right. You just do the last two codes I posted: the one in clif.c and the one in atcommand.c

 

Jr2JFgv.jpg

 

i'm having error because of the state->arealoot 

Edited by Meister
  • 0
Posted (edited)

Finally i make this .diff manualy, it work on my rathena's version

Edit: Resolved some issues, and added possibility to config range in battle_conf
But don't know why, when i put range to 10 that make not difference with 3

 

@arealoot.diff

Edited by Metahego
  • 0
Posted

@Metahego i already fixed the compiling part, then i stumbled on this error which i think is critical.

if the command @arealoot is disabled and you drop an item example a red potion and pick it up the item will be duplicated and there will be an error on the console like this one.

164781473_errorofserver.jpg.a6f166dba8fb738993ef4dd8abc51c9b.jpg

now if the command @arealoot is enabled there will be no errors on the console and there will be no item duplication.

I hope this will be fixed asap as this command is very helpful.

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