Question

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

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

 

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!

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

 

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?

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

pc.h

bool arealoot;

Share this post


Link to post
Share on other sites
  • 0

 

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

Share this post


Link to post
Share on other sites
  • 0

Are you using a different emulator? My code says sd->state.arealoot not struct s_state.

Share this post


Link to post
Share on other sites
  • 0

Are you using a different emulator? My code says sd->state.arealoot not struct s_state.

 

using rAthena only.

Share this post


Link to post
Share on other sites
  • 0

Then the code should work for you if you copied it correctly.

 

I copied it correctly, mind attaching .txt file for it?

Share this post


Link to post
Share on other sites
  • 0

It's going to be exactly what I already posted but okay.

 

I think its not on pc.c its on clif.c the one on the text.

Share this post


Link to post
Share on other sites
  • 0
On 17/02/2018 at 8:02 PM, Felipe Martins said:

guys help me !!!

error compiling.png

I get the same error as he does. Anything on that?!

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

@Metahego im currently using the latest rathena, and i can't compile my server it causes errors. Would you like to help me resolve this? tyvm

 

Share this post


Link to post
Share on other sites
  • 0

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

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.