ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Tue Aug 21, 2018 11:32 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Nov 06, 2015 2:10 pm 
Offline
Cornac

Joined: Sat Jan 31, 2015 6:34 am
Posts: 37
In Maj'Eyal, lines sort of avoid obstacles to some extent when you're using projectile/beam spells. Is it a feature of Maj'Eyal or of the TE4 Engine?

I'd like to know where to find the code for this feature or the broad logic behind it. It would be really helpful.


Top
 Profile  
 
PostPosted: Sat Nov 07, 2015 8:14 pm 
Offline
Perspiring Physicist

Joined: Thu Feb 17, 2011 5:20 am
Posts: 889
The Selfish Gene wrote:
In Maj'Eyal, lines sort of avoid obstacles to some extent

Only sort of?! It doesn't avoid obstacles that the user can't see or doesn't know about, but it should do a good job otherwise! Heh, although it may try to shoot through tiles such as friendly units. Do you have examples where this doesn't perform as expected?

The Selfish Gene wrote:
Is it a feature of Maj'Eyal or of the TE4 Engine?

The engine. In C.

The Selfish Gene wrote:
I'd like to know where to find the code for this feature or the broad logic behind it. It would be really helpful.

Heh, I wouldn't assume the code will be helpful. It is not for the feint of heart. Do you want to use this feature, understand it, reproduce the behavior elsewhere, or what?

The bulk of the code is here:
http://git.net-core.org/tome/t-engine4/ ... /fov/fov.c

The following code is used to determine the line start and end positions, angle, etc. There is different code that is run, for example, when a projectile is actually flying along the specified path.

Consider yourself warned, but I will try to step you through the relevant parts. Let me know if you have any questions. I wrote this code (sorry gentle readers!).

This block uses functions defined by macros and creates the line in a given octant. It is a reasonable place to start:
http://git.net-core.org/tome/t-engine4/ ... L2543-2578

The functions are defined by the macros here:
http://git.net-core.org/tome/t-engine4/ ... L2207-2214

This is the main macro:
http://git.net-core.org/tome/t-engine4/ ... ov.c#L2011

The code that runs when the line finishes is here. It has special logic if the line is blocked or not:
http://git.net-core.org/tome/t-engine4/ ... ov.c#L1877

The macros use this macro, which determines the optimal boundary of vision:
http://git.net-core.org/tome/t-engine4/ ... fov.c#L598

Hmm, the definition of the fov line struct may also be useful:
http://git.net-core.org/tome/t-engine4/ ... h#L133-173

There are similar functions/macros that do this for hexagonal maps too.

Good luck!

_________________
darkgod wrote:
OMFG tiger eye you are my hero!


Top
 Profile  
 
PostPosted: Sat Nov 07, 2015 8:22 pm 
Offline
Perspiring Physicist

Joined: Thu Feb 17, 2011 5:20 am
Posts: 889
Also, if you want to know more about the FOV algorithm used in ToME, see here:
viewtopic.php?f=45&t=35232

Creating "smart lines" for the basic recursive shadowcasting algorithm is much simpler. Perhaps you should start here:
http://git.net-core.org/tome/t-engine4/ ... L2579-2722

_________________
darkgod wrote:
OMFG tiger eye you are my hero!


Top
 Profile  
 
PostPosted: Sun Nov 08, 2015 1:54 am 
Offline
Cornac

Joined: Sat Jan 31, 2015 6:34 am
Posts: 37
I didn't mean "sort of" as criticism. I meant it stays on plausible sight lines and only avoid walls. (as it should!)

Thank you so much for the reply. I did not expect to get so much information. It's also kind to offer to help. I'll study what you gave me here tomorrow and see if I can understand some of it. :)

I'd like to reproduce it, but I also want to understand it. I could maybe get something similar by using smooth pathfinding to a target while using the source's current FOV minus walls as walkable tiles. However, I'm assuming it's maybe not the best way to do it.

I've played Maj'Eyal quite a bit, and didn't notice how amazing the feature is until I saw it missing in action. lol


Top
 Profile  
 
PostPosted: Thu Nov 12, 2015 5:03 am 
Offline
Sher'Tul Godslayer

Joined: Sat Apr 26, 2003 7:38 pm
Posts: 1970
Location: GMT-8:00
tiger_eye wrote:
The Selfish Gene wrote:
In Maj'Eyal, lines sort of avoid obstacles to some extent

Only sort of?! It doesn't avoid obstacles that the user can't see or doesn't know about, but it should do a good job otherwise! Heh, although it may try to shoot through tiles such as friendly units. Do you have examples where this doesn't perform as expected?


Obstacles the user can't see and doesn't know about aren't the same thing. It doesn't handle dark corridors intelligently. There's a valid path in which there are known to be no obstacles (because otherwise the target wouldn't be visible) adjacent to a path with obstacles that the player knows are there because corridors are always one tile wide. The "smart" targeting cuts through unknown tiles that are obviously obstructed but not actually seen rather than taking the legal path down tiles that are known to be unobstructed. Assuming all never seen tiles are obstructed might work better if seeing through a tile with infravision marked it as clear. Or maybe make infravision see any walls that are partially occluding a visible monster. Something like that.

_________________
Digitochracy
n. 1. technocracy. 2. government by the numbers. 3. rule by people with the longest fingers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group