Page 1 of 2

Target with keyboard

Posted: 25 Mar 2006, 13:29
by Alderan
I relly don't like targeting with mouse. Since I use arrows (in game and on keyboard :-)) It isn't comfortable to move right hand from keyboard to mouse.
So I created targeting on keyboard. It is only a simple targeting of nearest living enemy. The code is here. It goes to game.cpp around line 650 :-)

Code: Select all

        // Target the nearest monster
        if (keys[SDLK_a])
            Being *target = 0;
            int      dist = 0;

            Beings* all = beingManager->getAll();

            // cycle all monsters
            for (BeingIterator i = all->begin(); i != all->end(); i++)
                Being *being = (*i);
                int d = abs(being->x - x) + abs(being->y - y);

                if (being->getType() == Being::MONSTER &&
                    being->action != Being::MONSTER_DEAD &&
                    (d < dist || target == 0))
                    dist = d;
                    target = being;
            if (target)
                player_node->attack(target, true);
The code is working. But has some disadvatages. Like if you want to target only green slimes but definitely not red scorpions, this dosn't help much.
On the other hand in mine where all monsters attack you this is quite useful.

Maybe there could be some list of monsters and plyer may choose wich monsters will be targeted and which wont be.
What you think?[/code]

Posted: 25 Mar 2006, 17:20
by knivey
You can use ctrl+shift and kinda walk into a monster to target it then holding ctrl will keep attacking automatically. Someone had the idea to make attacking with the mouse get the monster nearest the pointer o_0

Posted: 25 Mar 2006, 21:43
by Alderan
Walking into monster has one great disadvatage. It is that you need to be close to the monster. And if the monster is aggressive - like snake, you get hit. Targeting from distance save you a lot of HP. Selecting nearest monster to the click is also a good idea. It is not very easy to target exact square with mouse. Usually I have to click more times until I target. I guess that I could program ot if I allready have nearest monster to the player.

Posted: 25 Mar 2006, 22:09
by Platyna
If it works as described it is a very good patch and should be included into official source.


Posted: 25 Mar 2006, 22:50
by knivey
i think the patch could be easily made to work with mouse clicks like the middle mouse button

Posted: 26 Mar 2006, 05:53
by haggard
i enjoy the mouse clicking...i dont really enjoy the new way of picking up items. i liked how you could be miles away and pick up an item now you have to walk up to it and pick it up. not good when your in the cave surrounded by spiders, it leads to death

Posted: 26 Mar 2006, 06:16
by knivey
yea but at least now you know who steals your items... if they are using the new version

Posted: 26 Mar 2006, 06:18
by haggard
that is true.....and the item stealing is rather annoying

Posted: 26 Mar 2006, 06:19
by knivey
nothing a little player vs player can't solve hehe

Posted: 26 Mar 2006, 06:21
by haggard
yes yes we are all awaiting the blood bath

Posted: 26 Mar 2006, 11:36
by Alderan
Ok - so I made also middle click to target nearest enemy.
For mouse users I created that when you click you don't have to click the exact square but +- 1 is still OK to "do action" with NPC. It is more comfortable for me.

I also tried that player is walking as you press button and don;t release it - the char is still going. But had some problem with server refresh? The character was walking but there were no data from server probably? simply the beings around didn't apear. Or with some delay.

Where I should send the patch? [and anyway how to create patch?] I mean what and wehere I should send?

Posted: 26 Mar 2006, 13:06
by ElvenProgrammer
The patch can be submitted to our tracker, check
About creating patches, well it depends, I use tortoisesvn to create mine.

Posted: 26 Mar 2006, 14:31
by Tenche
people can still steal your items none the less its just a little trickier

Posted: 26 Mar 2006, 15:01
by Alderan
ElvenProgrammer wrote:The patch can be submitted to our tracker, check
About creating patches, well it depends, I use tortoisesvn to create mine.
OK. I tryed somehow decribe what should be placed where. Please let me know if any problems or if you accept the patch :-) The patch is submitted to the tracker.

Posted: 31 Mar 2006, 00:30
by LedStyle
I would like target with my joypad. :roll:

Im using the patch to target and its very good to use in Keyboard.