Target with keyboard

Content and general development discussion, including maps, quests, and server code from the development team.
Alderan
Peon
Peon
Posts: 59
Joined: 24 Jan 2006, 23:22
Location: Prague - Czech Republic
Contact:

Target with keyboard

Post by Alderan » 25 Mar 2006, 13:29

Hi,
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]
User avatar
knivey
Novice
Novice
Posts: 187
Joined: 05 Mar 2006, 04:01
Location: Your Base
Contact:

Post by knivey » 25 Mar 2006, 17:20

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
All your base are belong to us.
Alderan
Peon
Peon
Posts: 59
Joined: 24 Jan 2006, 23:22
Location: Prague - Czech Republic
Contact:

Post by Alderan » 25 Mar 2006, 21:43

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.
User avatar
Platyna
Former Dictator
Former Dictator
Posts: 2213
Joined: 19 Nov 2005, 14:19
Location: Poland
Contact:

Post by Platyna » 25 Mar 2006, 22:09

If it works as described it is a very good patch and should be included into official source.

Regards.
Zuzanna K. Filutowska
[The rest of this signature was censored by TMWC's "Freedom" and "Free speech".]
User avatar
knivey
Novice
Novice
Posts: 187
Joined: 05 Mar 2006, 04:01
Location: Your Base
Contact:

Post by knivey » 25 Mar 2006, 22:50

i think the patch could be easily made to work with mouse clicks like the middle mouse button
All your base are belong to us.
User avatar
haggard
Novice
Novice
Posts: 190
Joined: 20 Jan 2006, 04:27
Location: Ohio

Post by haggard » 26 Mar 2006, 05:53

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
User avatar
knivey
Novice
Novice
Posts: 187
Joined: 05 Mar 2006, 04:01
Location: Your Base
Contact:

Post by knivey » 26 Mar 2006, 06:16

yea but at least now you know who steals your items... if they are using the new version
All your base are belong to us.
User avatar
haggard
Novice
Novice
Posts: 190
Joined: 20 Jan 2006, 04:27
Location: Ohio

Post by haggard » 26 Mar 2006, 06:18

that is true.....and the item stealing is rather annoying
User avatar
knivey
Novice
Novice
Posts: 187
Joined: 05 Mar 2006, 04:01
Location: Your Base
Contact:

Post by knivey » 26 Mar 2006, 06:19

nothing a little player vs player can't solve hehe
All your base are belong to us.
User avatar
haggard
Novice
Novice
Posts: 190
Joined: 20 Jan 2006, 04:27
Location: Ohio

Post by haggard » 26 Mar 2006, 06:21

yes yes we are all awaiting the blood bath
Alderan
Peon
Peon
Posts: 59
Joined: 24 Jan 2006, 23:22
Location: Prague - Czech Republic
Contact:

Post by Alderan » 26 Mar 2006, 11:36

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?
User avatar
ElvenProgrammer
TMW Adviser
TMW Adviser
Posts: 2526
Joined: 13 Apr 2004, 20:11
Location: Italy
Contact:

Post by ElvenProgrammer » 26 Mar 2006, 13:06

The patch can be submitted to our tracker, check http://sf.net/projects/themanaworld.
About creating patches, well it depends, I use tortoisesvn to create mine.
User avatar
Tenche
Novice
Novice
Posts: 421
Joined: 14 Jun 2005, 21:21
Location: Reston
Contact:

Post by Tenche » 26 Mar 2006, 14:31

people can still steal your items none the less its just a little trickier
Alderan
Peon
Peon
Posts: 59
Joined: 24 Jan 2006, 23:22
Location: Prague - Czech Republic
Contact:

Post by Alderan » 26 Mar 2006, 15:01

ElvenProgrammer wrote:The patch can be submitted to our tracker, check http://sf.net/projects/themanaworld.
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.
LedStyle
Peon
Peon
Posts: 18
Joined: 30 Mar 2006, 21:24
Location: São Paulo - Brazil
Contact:

Post by LedStyle » 31 Mar 2006, 00:30

I would like target with my joypad. :roll:

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