Language: 
To browser these website, it's necessary to store cookies on your computer.
The cookies contain no personal information, they are required for program control.
  the storage of cookies while browsing this website, on Login and Register.

Author Topic:  Auto Pickup  (Read 5167 times)

0 Members and 1 Guest are viewing this topic.

lackland

« on: 07, July 2014, 00:21:40 »
I am officially starting to develop for Daimonin!

For my first project i have decided to implement an Auto Pickup feature. This will allow players to select which items they would like to auto pickup, and auto pickup will work when a corpse is applied.

I am still learning my way around the client source code. Today i got the client compiled, then i created an elseif for my /ap command in client.c. I then created two source files: pickup.h and pickup.c which has one function ap_command, which parses the input of of the /ap command. I will host my stream on my own server which will be accessible to anyone until i am granted svn write access to my own stream on the Daimonin Sourceforge if i may be so honored.

One problem that i am encountering is that it is running my code fine, but also returning /ap is not a valid command. I am wondering if that is the server parsing it? If so i want to make this command client side only as the server doesn't need to use it. Unless perhaps it would be better organizationally for the server to know what the client wants to auto pickup, rather than the client 'getting' those items. I have not had enough time to study the Daimonin source to make that determination.

So far my code is just organizational and verbose, by the end of the week i plan on learning enough to have statically coded pickup functionality. Then i will work on a dynamic command system of adding and removing items to be auto picked up. Then i will create a checkbox gui menu using the already in place system (similar to skill list etc) for users to easially select which types of items they want to pickup.

I look forward to developing many features for the Daimonin project and it's wonderful community!
~lackland

client.c:
Code: [Select]
else if (!stricmp(cmd, "/ap"))
    {
        ap_command(params);
    }

pickup.h:
Code: [Select]
#ifndef __PICKUP_H
#define __PICKUP_H

void ap_command(char *cmd);
#endif /* ifndef __PICKUP_H */

pickup.c:
Code: [Select]
#include <include.h>

void ap_command(char *cmd)
{
    int i;

    /* trim string - remove all white spaces */
    cmd[60]=0;
    while (isspace(*cmd))
        cmd++;
    i = strlen(cmd)-1;
    while (isspace(cmd[i--]))
        cmd[i+1]=0;

    if(*cmd == 0)
        textwin_showstring(COLOR_HGOLD, "Auto Pickup");
    else if (!stricmp(cmd, "on"))
    {
        textwin_showstring(COLOR_HGOLD, "AP: ON");
    }
    else if (!stricmp(cmd, "off"))
    {
        textwin_showstring(COLOR_HGOLD, "AP: Off");
    }

}

Here is my progress so far:

smacky

« Reply #1 on: 07, July 2014, 17:29:09 »
Nice start. :)

Ultimately auto pickup probably won't be handled quite like this -- it'll be done more server-side with the new pickup code in 0.10.7. But that doesn't matter for now. It's more important that you're doing something and thereby learning your way round the code.

client.c:
Code: [Select]
else if (!stricmp(cmd, "/ap"))
    {
        ap_command(params);
    }

I assume this is in CommandCheck()? You need to return 1; here. That means it is a client-side command.

And therefore you can strip out half of ap_command() (the lines I've prefixed with -). All this stuff (and a bit more) is already done in send_game_command().

Also it is less confusing if you name the parameter to ap_command() as params, not cmd.

Quote
pickup.c:
Code: [Select]
#include <include.h>

void ap_command(char *cmd)
{
-    int i;
-
-    /* trim string - remove all white spaces */
-    cmd[60]=0;
-    while (isspace(*cmd))
-        cmd++;
-    i = strlen(cmd)-1;
-    while (isspace(cmd[i--]))
-        cmd[i+1]=0;
-
    if(*cmd == 0)
        textwin_showstring(COLOR_HGOLD, "Auto Pickup");
    else if (!stricmp(cmd, "on"))
    {
        textwin_showstring(COLOR_HGOLD, "AP: ON");
    }
    else if (!stricmp(cmd, "off"))
    {
        textwin_showstring(COLOR_HGOLD, "AP: Off");
    }

}

_people_

« Reply #2 on: 08, July 2014, 00:55:42 »
Keep in mind that we do (or did) have old CF (or maybe Angelion?) code in the server for auto-pickup/drop. It's been #if'ed out and it's probably not ready for server use anyway (last time it was reused was before LOADS of rewrites), so we'll want to remove that.

I'm glad you're getting to work on stuff, since lazy ol' Person hasn't finished the MySQL stuff yet. I meant to work on it Saturday and Sunday, but my laptop's hard drive is super-borked (not just borked). I'm installing Linux on my desktop for the time being (which should have been done when I built it a few months ago but I had other projects on my plate). I've got the disk burned now and am working on installing it, I should be up and running tonight.
-- _people_ :)

smacky

« Reply #3 on: 08, July 2014, 12:11:20 »
The old code is sh*t. ;) Well that's a bit harsh. The old auto pickup code is very old and is/was based around string commands. IIRC it has always been disabled in Dai, but definitely since B3/B4 when MT implemented binary commands.

In any case I removed that code entirely in 0.10.7 (IDR if that's the version on dev noow or my local one).

PS, that MySQL stream looks like a good idea (I know nothing of MySQL).

Shroud

« Reply #4 on: 08, July 2014, 12:52:29 »
I apologise if I'm now introducing specification creep but when thinking a bit about auto pickup I did remember another feature that would be quite useful to be automated (or done on a passive basis).

Find/Remove Traps is practically never used primarily cause it's too much hassle to check every corpse. If introduced in this project skill could be theoretically usable (it's still ridiculously expensive to train...)
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.

petarkiller

« Reply #5 on: 08, July 2014, 14:16:33 »
Well if traps skill becomes auto skill, it will be worthwhile money sink, but if i remember correctly its over 20m to train it, that's kinda too much maybe 10-15m would be ok.

_people_

« Reply #6 on: 08, July 2014, 19:09:09 »
Problem with traps as a money sink is that IMO it sinks TOO much money (haha, coming from _rantsabouteconomyalot_). While a money sink for traps isn't too bad, I think that some of the cost (IIRC in B4 it was ~36m for both F/R traps?) should be reduced a bit and possibly give players another way to level it.

At some point we could implement detect traps (a later-game skill which obsoletes find traps), which is a passive skill. So after you learned detect traps you'd know where a trap was (<= your DT level) before you opened the corpse, so you'd be given the opportunity to disarm it without having to search for it.
-- _people_ :)

Shroud

« Reply #7 on: 08, July 2014, 20:21:03 »
Actually issue about find/remove traps is two fold. Firstly it's not really an essential skills as once you get over lvl 40 no traps are fatal and players carry potions as mobs poison etc anyway. Second problem is that using skill isn't very convenient so that it takes about the same time to heal to full HP as it does to check every corpse
Doesn't matter, you'd die anyway. ;D Shroud's a hacker. After many hours of deep thought I have came to that conclusion.

petarkiller

« Reply #8 on: 09, July 2014, 08:12:06 »
People, exactly what joe said. Why would i pay 36m so that have to activate it on my own every time, its really annoying maybe make it auto with 0,5 sec cooldown, it would be worth getting to some extent if it was like that, When i farm in maus i gather like 20 mobs or so, kill them all with fire/ice storm if the cooldown was too long for it, i wouldn't wait to check, i can always spam some food/rest or use potions as shroud said. It doesn't pay off to wait or activate the skill, if i can kill 5 mobs in the time it took me to activate the skill to check all corpses, it isn't worth it.

Tags:
 

Related Topics

  Subject / Started by Replies Last post
5 Replies
2359 Views
Last post 20, September 2005, 17:05:48
by michtoen
4 Replies
5997 Views
Last post 14, June 2010, 18:30:57
by smacky
7 Replies
19946 Views
Last post 26, November 2011, 18:50:31
by blingking114
2 Replies
117 Views
Last post 28, January 2022, 16:44:48
by Dolfo
9 Replies
488 Views
Last post 12, September 2023, 14:27:48
by Dolfo