ID:1391000
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
The other day I came across BYOND's luminosity, see_in_dark, and all those other fun little vars related to limiting vision within the game. They really show to have a lot of room for awesome, however I can't help but notice they're a bit limited.

I am working on a multi-player RTS style game, and want to accomplish the use of luminosity to give each unit unique viewing distances, and maybe even have some 'invisible' units that can only be seen by units with infra-red view or something exciting like that, however by the way these variables are setup it's only really possible to accomplish this in a single-player single-unit game, as we have no choice to share multiple mobs' visual distance to other mobs. The ability to do so would unlock a fair bit of capability to designing games based around controlling more than one unit, as well as any co-operative games that you maybe want to allow the ability to view your ally's location and situation but not allowing your enemies to do so.

I would like a simple "shared_sight" var, where you can set a list of mobs to grant you additional vision, though not extending beyond your true 'view' limit. Allowing you to see the other side of that wall if someone in your "shared_sight" had the capability to do so.

There are fog of war libraries out there that can accomplish a similar task, but they all appear to run on the use of complicated operations related to the use of calculating images to the clients at extreme CPU costs.

Not the end of the world if it's not possible but it would unlock a lot of new capabilities within BYOND. (and frankly it's exactly what my project needs to become awesome..)
Image handling doesn't sound expensive at all if you divide up the images into a couple of lists and only loop through client.images when it's absolutely necessary.

It would be nice if there was better way to custom-handle view() viewers() hearers() etc.
Issue is the game I'm working with uses a rather massive map, and a player often has more than 50 units at once. For starters the only way I really found possible to have the entire map be covered in black images, as in forum_account's fog of war library, and then have them be recalculated each time a unit takes a step. (Or have a client looping proc re-calculating all visable areas every 3 seconds or so)

The first issue I encounter is covering an entire map with images in the first place takes a huge amount of time when we're talking 1000x1000x4, (4 million). Then we have to link those images out to the clients, and recalculate if an image should or should not be visible whenever a unit who can see a tile leaves viewing distance of that tile. When working with 4 million images BYOND seems to enjoy crashing utterly. I managed to pull it off before though, only issue is, the best CPU usage I was able to come up with with the most simple code I could come up with was a 70% CPU usage on 5 units walking around, which admit ably would be fine in a single player game but I'm hoping for at least 20+ players at once.

Currently BYOND's luminosity and basic sight limiting built-in system for one guy doesn't even take 1% CPU when there's opacity turning on and off and moving at extreme speeds across the map and we still get a quality output, if we use any work-around image system we end up costing a hell of a lot more with a far more glichy output. Managing with images indeed works, but it doesn't work well, and only functions in a limited number of situations. I'm hoping for something that's far more... capable, and simple. We shouldn't have to make a huge complicated work around to accomplish something that in nature is pretty simple, and has been seen so commonly in the past in games as old as Age of Empires with no issues.

Edit:
Sorry about the length, I have a habit of ranting, and didn't actually notice how long this was..
Instead of having a black-out image that covers the map, why not let the players see the entire map (or, well, the entire chunk that fits in their view), but use selectively-displayed images for each unit they can see?
I don't mean to sound rude, but doesn't that seem a bit extreme to you? Should we really have to 'settle' for such a dramatic work around to accomplish a lesser version of something found so commonly found elsewhere? And even if we did use that method, and I might even be desperate enough to if I could... but it would still require massive constant calculations to get accurate non-lagged visual results, by testing oviewers(MAX_VIEW_DISTANCE) on the mob in question whenever relevant, and then doing tests on the mobs in oviewers() to see if they provide sight to anyone. That can result in 1000s of calls to oviewers() every frame, that alone costing a huge amount of processing, without even counting the extra calculations related to determining display. Even if our computers can handle that it leaves little room for any customization to the viewing rules.
In response to Felix Rose
I don't mean to sound rude, but I think you're doing it wrong.
In response to SuperSaiyanGokuX
SuperSaiyanGokuX wrote:
Instead of having a black-out image that covers the map, why not let the players see the entire map (or, well, the entire chunk that fits in their view), but use selectively-displayed images for each unit they can see?

That's close, but it's not really what he wants. We are talking about a fog of war here! You should first be thinking about the turfs, not the mobs. For the purpose of making a fog effect, we care about the turfs in view, not the mobs. Once you have the turfs, then you can worry about mobs that exist in the contents of those turfs. Limit the searching that will be done as much as possible, without sacrificing functionality.

I would also wonder why anyone thinks it's a good idea to cover the entire map with images, when only a limited number of them will be seen at a given time. An excessive number of images can easily take up large amounts of CPU. You should only need as many images at a given time as it takes to fill the view's area. This means there will be less images and unit mobs you have to worry about, which will also result in less CPU. Why have any images past the client's view if the player will never actually see them?

Basically what I mean is something like this:
mob/player
Move(NewLoc, Dir, step_x, step_y)
..()
// If the player mob's next step will extend past the current tile:
if((src.step_x + src.step_size > world.icon_size) || (src.step_y + src.step_size > world.icon_size))
RecalculateFogDisplay()

This is just an example. It might not actually work correctly. When you recalculate the display, essentially what you would do is maintain 2 lists of turfs. The first list will contain references to the turfs that were in view before your last step. The second list will display the turfs that are currently in view. You would then remove any images found in the turfs in the first list, then add the necessary images to the turfs in the second list. You can make this even more efficient if you compare the lists to only add and remove images to and from the turfs that have recently entered and left the view. Hopefully this makes sense.

I think Forum_account's Fog of War library desperately needs optimization, which is too bad, because I don't plan on using it. As usual, no library out there is capable of doing what I want, so I will be writing my own fog of war from the ground up, when the time comes.
I've rarely used them, but if I understand their use correctly, each client has a list of images that will be displayed to them, and you can add/remove these images from the list, case-by-case, as required.

I'm not entirely certain about this next statement, but I believe that the system handles the case where an image (or rather, it's location/attached atom comes into view. If there's an image in the world that is in a client's images list, they will be sent that image automatically when it comes into their view. Again, I'm only basing this on assumption. I'm not experienced enough with them to know that for sure.

But if that is indeed the case, then all you need to do is add/remove the images from the client.images list based on circumstantial changes (unit gains ability to see infrared, add all infrared images to their list; unit engages in shared sight with another unit, then add that unit's visible images to the first unit; etc.), and you can forget about having to do checks on oviewers() with every movement (but again, only if I'm correct that the engine handles that automatically).
Hmmm. I'd be more concerned with which mobs/units can be seen vs which turfs. I'd say that it should be reasonably plausible that you'd "know" all of the terrain around you (maps, recon, etc.; no one goes into a battle without at least knowing the lay of the land...), but just not necessarily know where enemy units are located within that terrain.
In response to SuperSaiyanGokuX
SuperSaiyanGokuX wrote:
I'd say that it should be reasonably plausible that you'd "know" all of the terrain around you (maps, recon, etc.; no one goes into a battle without at least knowing the lay of the land...), but just not necessarily know where enemy units are located within that terrain.

After you have passed through the fog the first time, you will forever be able to see the terrain and other features. Enemy mobs will be selectively hidden with visibility vars, relative to the turfs in view. I'm sure there are other ways to implement this though.
Yeah, I know the idea behind fog of war. I just think it's pointless...lol Any army worth anything will already know the terrain before the active combat (or even just troop movement) comes up. There should be no need to hide any of the terrain, at any time (even if it's just temporary, only until they travel through it for the first time)
That does make a viable method of fog of war Mr.Multiverse7, by determining the entire visible set of turfs within view of your centre we can have code to say reveal units as they enter the turfs visible by player rather than calculating all oviewers() every step, making a much more CPU efficient system. We can even use this stored player data to call recalculates whenever opacity changes occur on the turf, or objects within the turf. I will admit it's the best plan I've heard yet for the fog of war system, but honestly I'm not even looking for fog of war.

I'm simply asking to expand the built in processes of illumination and dark vision to be able to be shared between multiple mobs. The system in place is extremely CPU efficient, and frankly any display code we can make in BYOND doesn't stand a straw against its efficiency. I cannot say I know enough to say for sure, but I would guess it wouldn't take all that much work for those in a position to do so to install a feature, even if using it would boost the CPU usage of view by a tiny bit. As good as your idea for display is, it still couldn't be used in a game such as what I'm working on per the extreme CPU costs if for example players were to decide to scroll across view, especially thanks to my preferential large view size and the huge numbers of units I wish to work with. I'm not really asking for a work around, because I've concluded any work around that is possible does not suit the specifications of my game. I'm simply asking if BYOND could incorporate an additional feature so my game, and other games that may wish to attempt a similar result could accomplish their goal without having to go through dramatic work-arounds that severely limit their options in game design.
(Again, sorry about the length.. I'm REALLY bad at communicating a point with a small number of words)
Don't get me wrong, any features that extend functionality in useful ways would be more than welcome.

However, I guess I'm not really understanding your problem, then...

If the main ability you want is to share one mob's sight capabilities with others, then surely all you need to do is simply set the same flags on the "connected" mobs (if you want a mob to share infrared sight, then just give the connected mobs infrared sight, etc.)...?

I guess this won't work for illumination, because illumination basically works on a range, so mobs outside of that range still won't see those mobs even if one of their allies can.

But it seems like this is becoming a dangerously "niche" feature...
In response to SuperSaiyanGokuX
Most people in ancient times probably didn't know the details of the terrain a thousand miles away, unless they were frequent sailors. You have to consider that in some RTS games, units and buildings are way out of proportion compared to the land, so a given area might look small when it actually isn't.

I think a fog of war is relatively justified for games that take place before modern times, but not past that, for very obvious reasons. Realistically, for people in ancient times, anything outside of a 1-2 thousand mile radius would have been mostly unknown. I am talking about people who believed the Earth was flat, so I don't think fog of war is going to hurt anything there.

However, I will admit that in games like Age of Empires, the total starting view radius is ridiculously small.
In response to Felix Rose
Felix Rose wrote:
my preferential large view size

huge numbers of units

Maybe that combination just doesn't work that well with BYOND's network model. You might want to consider reducing the view, if the CPU usage is as scary as you make it sound.

I'm not sure how a native "combined" view would even work. It might be nice to have, but it just seems pretty niche. So as they say, "look for a more general solution", because that's the only way that I could see this working. I don't know what such a solution might be though.
Niche? I'll give it that. It does only truly benefit RTS style games, as well as a few team-based action games, which does not encompass all of BYOND.

However, my argument is that it's something that BYOND can't accomplish efficiently as is, and it 'in theory' would be easy to accomplish in a similar manner to as is.

Allow me to explain my theory: As I said, I was playing around with the illumination, dark vision, infra-red, and all that. I noticed that if I could make my player capable of seeing through solid objects on his own, the illumination system in place would be perfect for what I want to accomplish, in a single player game however. I however want to accomplish a multi-player game, and don't want my enemies seeing what I see. In theory it wouldn't be hard to apply the same process for illumination, but make it so that illumination was capable of being set to be mob-specific, so that you could say it only illuminated for if you were in its list of applicable mobs. This would allow us to set illumination to the mobs we control in an RTS game, and have them set to only give illumination to ourselves and our allies within the game. That is the basis of my theory, and theoretically it would work smoothly based on how effective the current illumination system is.

A further theory however, which admit-ably logically speaking could be harder being it would actually go through operations we don't already see.. would be to instead of having per-player illumination, simply root the dark_vision of mobs in a list on the player to the player as needed, in addition to the dark_vision of the player object himself if he had any. This theory however does not logically run on the same operations as anything already built into the game, and might not work as it would sound.

My first theory however appears to me to be logically sound in easiness to accomplish, and if it is indeed as easy as it would appear I would see no reason not to include it, even if it is a tad focused onto the RTS field.
With further thought though, is it truly that niche? I mean, even in an RPG, maybe you want to have the ability to cast light into darkness a small distance away and have it be only visible to you. Maybe you want to have it so that when an enemy attacks you, 'you' (not every player in the world) suddenly gain the ability to see that NPC's location if he's outside of your dark vision, if only for a moment.
In response to Felix Rose
By per-player dark-vision, I think you're asking for mob.see_in_dark.
Er.. yeah. That's what I mean. Sorry, I tend to get mixed up. As it turns out this is the 3rd time I've ever really wrote anything on a forum so I'm rather stressed out! :D Always kinda evaded them but figured I'd been on BYOND for about 8 or 9 years now so I might as well put down some of my ideas.
Page: 1 2