Target with keyboard

Content and general development discussion, including quest scripts and server code. TMW Classic is a project comprising the Legacy tmwAthena server & the designated improved engine server based on evolHercules.


Forum rules

This forum houses many years of development, tracing back to some of the earliest posts that exist on the board.

Its current use is for the continued development of the server and game it has always served: TMW Classic.

Alderan
Novice
Novice
Posts: 59
Joined: 24 Jan 2006, 22:22
Location: Prague - Czech Republic

Target with keyboard

Post by Alderan »

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, 03:01

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

Post 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.
User avatar
Platyna
Grand Knight
Grand Knight
Posts: 2215
Joined: 19 Nov 2005, 13:19
Location: Poland
Contact:

Post by Platyna »

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

Regards.
User avatar
knivey
Novice
Novice
Posts: 187
Joined: 05 Mar 2006, 03:01

Post by knivey »

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, 03:27
Location: Ohio

Post 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
User avatar
knivey
Novice
Novice
Posts: 187
Joined: 05 Mar 2006, 03:01

Post by knivey »

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, 03:27
Location: Ohio

Post by haggard »

that is true.....and the item stealing is rather annoying
User avatar
knivey
Novice
Novice
Posts: 187
Joined: 05 Mar 2006, 03:01

Post by knivey »

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, 03:27
Location: Ohio

Post by haggard »

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

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

Post by ElvenProgrammer »

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
Warrior
Warrior
Posts: 421
Joined: 14 Jun 2005, 20:21
Location: Reston
Contact:

Post by Tenche »

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

Post by Alderan »

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, 20:24
Location: São Paulo - Brazil
Contact:

Post by LedStyle »

I would like target with my joypad. :roll:

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