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:  Better mouse movement  (Read 200 times)

0 Members and 0 Guests are viewing this topic.

asuratva

« on: 30, January 2023, 11:01:15 »
Hi all,

I tried out the game for the first time only yesterday. Really enjoyed it! (Shout out to Dolfo for showing me the ropes :)

But I'm using a laptop without the numpad and playing with the mouse is not that great. So, I decided to take a crack at changing the code to improve movement with mouse.

I've modified it to have the player move to the location clicked to (roughly, up to 8 tiles obviously). I am additionally thinking of adding some pathfinding code so it's easier for players walk around obstacles to reach their destination.

All changes are in the function mouse_moveHero() in src/event.c

Please have a look, I would appreciate some feedback :)

I am attaching the event.c file for anyone who is interested. It's modified off of the 0.10.9 client sources from here: https://www.daimonin.org/downloads/sa/view/down/23/

Dolfo

« Reply #1 on: 30, January 2023, 12:30:24 »
Looked in theoretically. Looks very impressing. You rebuilded and extended the old logic and also memorize a direction, where the char continues to go, if there are no new clicks. Looks like you also increased the balance in x/y movement. Old logic was dominated by one coordinate, so logic always first tried to do this coordinate.

Sadly i still not have build a compiler environment for the client. I am to lazy and unmotivated to to this. But from theoretically view, this looks like a great improvement for mouse movement.

Hope _people_ find this thread, between all the current forum action, we have.  ;)
« Last Edit: 30, January 2023, 12:54:07 by Dolfo »
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

asuratva

« Reply #2 on: 30, January 2023, 12:34:51 »

Sadly i still not have build a compiler environment for the client. I am to lazy and unmotivated to to this. But from theoretically view, this looks like a great improvement for mouse movement.


I can send you the binary I generated on my system if you want to test it out :)

I'm running linux though, so if you're on windows, no luck.

Dolfo

« Reply #3 on: 30, January 2023, 13:03:57 »
My current system is windows. Have also two linux systems, but one is next house working for my mother and one is experimental console linux on a very old computer. Also my linux abilities need to be improved more, before i would switch to linux completly. I wait for next client update. :P Only joking perhaps i compile client at some point. But my time is also limited. My focus is still to be a player, to keep the connection to the game. And i have still plans for my archwizard idea. Also a lot of scripts and server coding ideas, where i can go on. So i think deep inside me, something is saying. NO NO. Don't build the client enviroment.The day has only 24 hours. ;)
Don't believe the shit, you hear in mainstream. Believe your own body. Your body is speaking always the true to you. But you need to understand your body. Hear to your body, not to your ego. And when body is calling to you: "Hey something is wrong!" find the reason(s) for that. Man in White don't go for that, they don't want to heal you. They want earn money and sell you medicine, you should take rest of your life. You are not the patient, you are their customer. Never forget this!

_people_

« Reply #4 on: 31, January 2023, 02:26:18 »
I won't be able to look at the code until I get home tomorrow, but thanks for looking into it! :)

Unfortunately pathfinding capabilities will be rather limited for now. The client currently has no knowledge of the no_pass flag, so you can't navigate around walls/decor/etc. The client does have a limited knowledge of mobs - the sprite ID sent to the client when the NPC is sent to the client has the 0x8000 flag set. This is how infravision works - the client simply colors all sprites with that ID flag red. Unfortunately I think players also have this flag set, so you'd have to use the player name data sent in the same packet to determine whether it's a monster or player blocking your path.

Eventually I plan on giving the client a lot more info (especially for items, so we don't have to rely on /examine). I think a lot of this would require a protocol version change, meaning old clients won't be able to connect to the server anymore. If you want to look into sending more data from the server you can check view_map.c, or I can look into it later this week.
-- _people_ :)

asuratva

« Reply #5 on: 31, January 2023, 03:20:22 »
Yep, I ran into that roadblock, looks like all blocking checks are handled server-side :(

I guess client-side pathfinding will have to be put on hold till a later date. I will try and decipher view_map.c but dunno how far I'll get :)
« Last Edit: 31, January 2023, 03:27:54 by asuratva »

_people_

« Reply #6 on: 02, February 2023, 04:10:30 »
Oops, I had meant to reply yesterday but must have forgotten to submit the post.

I looked at your code and tested in-game, and was impressed. :)

Yeah the view_map code is a bit rough to read. I wrote a breakdown in the new client's source, you can find it: https://sourceforge.net/p/daimonin/unity/ci/master/tree/Assets/Scripts/Map/Viewport.cs line 353.

Unfortunately the mask's datatype is too small to support adding more flags, so notifying the client of blocked tiles won't be possible until a Y-release.

It should be possible to add a client->server command to have the server do the pathfinding, though. That might be the easiest solution, since we could probably use the server's existing A* pathfinding code from mob movement.
-- _people_ :)

asuratva

« Reply #7 on: 06, February 2023, 15:45:42 »
Minor fix to the code.

I realised that fire spell/fire range code was also making use of the movement code. My added code was causing the fire command to spam up to 8 times (depending on how far you clicked). Fixed now so it only sends the fire command once per ctrl+click.

This probably won't have any noticeable effects for the user, since server won't let you spam range skills off cooldown anyway, but the code is more correct now.

I'm attaching the revised version of event.c

_people_

« Reply #8 on: 18, February 2024, 00:17:59 »
I have finished a change for 0.11.1 which will hopefully be the last mouse movement change for a long time.

Asuratva's update is very good, but I broke it somewhat by fixing player movement speed. Before 0.11.0 movement was capped only by the server's limit of 8 socket commands per tick per player. This was plenty for client-side pathfinding, but breaks if the player's movement speed is limited as it is now.

0.11.1 uses server-side pathfinding to navigate the player to the tile they click on. This means players use the same pathfinding as NPC's, which includes heuristics so the player can automatically avoid terrain which will slow their movement. However, currently only 1 pathfinding attempt is generated per socket command so if the player's path becomes blocked after their first movement the player will stop moving.

This change also presents the possibility of tile-targeted spells/skills, where previously they could only be performed either in a direction or at a target mob (including players for healing). We can also call player_path_update() from anywhere on the server, which may be useful for scripters who want to move the player naturally (rather than teleporting) to a specific position via Lua.

I'm targeting Monday evening for this alongside 0.11.1.
-- _people_ :)

Tags:
 

Related Topics

  Subject / Started by Replies Last post
3 Replies
1319 Views
Last post 22, May 2010, 20:30:22
by _people_
3 Replies
4141 Views
Last post 25, June 2011, 18:35:46
by smacky
1 Replies
3157 Views
Last post 25, June 2011, 20:23:59
by _people_
5 Replies
936 Views
Last post 15, November 2015, 16:27:40
by Shroud
0 Replies
84 Views
Last post 28, June 2021, 18:16:53
by Clort