Fog of War - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Games Development (https://www.save-point.org/forum-4.html) +--- Forum: Code Support (https://www.save-point.org/forum-20.html) +--- Thread: Fog of War (/thread-10856.html) |
RE: Fog of War - DerVVulfman - 11-12-2024 Well, as I previously stated... (11-12-2024, 01:13 AM)DerVVulfman Wrote: It needs some cleanup by my standing, and I want an optional means to flag events besides within the config page. So not done yet. BUT it is performing the options you've requested... and more. So additional work will be performed. I was able to apply your options TO my demo, only the mild correction to the 'check_adjacent' method within Spriteset_Map being necessary. Why my version has an altered 'check_adjacent' method However, whilst it worked with your edits, I encountered an issue. When the player moved about on the map, the player erased the fog within the 3-tile range prescribed by the FOW_RANGE_DEFAULT configuration variable. After standing for some time, the area around the player erased more, returning to the 5-tile range defined within the FOG_MAPS array for map 3. So it did not properly erase the area around the player whilst moving as it should, only that around the player when standing still. The update_fow_tilemap section does have long code, some quite similar to one another. Do note that he has comments that his work is designed to 'only process fow currently on the screen'. And for that, he used routines that had lines such as:
if @fow_tilemap.map_data[x, y, 1] == 96 Now while it ensured that the data within the coordinates of x/y became whatever value it demanded, it only performed the data change if the x/y coordinate data wasn't. Odd as it sounds, performing the check and skipping takes slightly less time than arbitrarily changing it every time. Go figure. Some of the content you 'removed' thinking redundant within the update_fow_tilemap was was actually present to prevent errors and map glitches, particularly around the static secondary static map section when it indeed needed to see if areas needed to be SKIPped. The SKIP flag is called into play both within this area and tested for when a map is initialize or re-initialized, this to reduce more lag and fog processing. And further below is the area that updates the tileset based on 'range'... likely where it sees (at least within mine) the proper area range for the player or the NPCs and the area to erase. Meanwhile, changes I made to update_fow_tilemap include both the request of x/y coordinates of the target character (player or any event), and a speciic range for said player or event. The range passed into it directly related to the area you erased near the bottom of the method. Again, I do state it needs some cleaning up. But some facets of the script need remain in place, or optimized rather than wholly removed. RE: Fog of War - Tepe - 11-12-2024 You're probably right, but at the moment we have two different scripts and I don't have as much experience in RGSS programming as you do. So of course it may work differently in your script than in mine. But there has to be optimization in fow_update_tilemap. In the original code there are large fps drops. The difference is at least 2x in favor of my version of the script. Of course, as I mentioned earlier, I still have frequent drops but it doesn't reach less than 16 on a large map with more events, and in my case the additional load is generated by other scripts, some of which are for a specific fix. I will also add that in my case there are drops only when the fields are undiscovered, but if they are uncovered, the fps normalize, because in such a case the visibility is limited to the screen size and not the entire map. The maximum number of frames is about 36 but with frequent fluctuations, while in yours I have a stable 8-9 fps in all time. RE: Fog of War - DerVVulfman - 11-13-2024 (11-12-2024, 09:53 PM)Tepe Wrote: But there has to be optimization in fow_update_tilemap. In the original code there are large fps drops. The difference is at least 2x in favor of my version of the script. Of course, as I mentioned earlier, I still have frequent drops but it doesn't reach less than 16 on a large map with more events, and in my case the additional load is generated by other scripts, some of which are for a specific fix. (11-12-2024, 05:10 PM)DerVVulfman Wrote: THAT... is why I crafted the customized moving? method, one that checks to see if any NPC just 'starts' moving from one tile to another. (11-12-2024, 09:53 PM)Tepe Wrote: The maximum number of frames is about 36 but with frequent fluctuations, while in yours I have a stable 8-9 fps in all time. I gotta wonder... how are you getting that low a FPS with this? I had to make 23 events all clean the map (300x250 tiles) at the same time. Not one or two, but 23... and that's quite a number cleaning the map on your behalf. Under normal circumstances, it is 40fps, but switches to 30 FPS when the defined events move and clear out the map. And that FPS reduction changes (increases faster) as the map is cleared. But that is with 32 events flagged to clear the fog, a rather unusually high number indeed. Again, I am still working. Video difference of your version, and mine. Yours with the FPS showing significant drops down to as low as 3. Mine with a red fog with FPS drops no lower than 29. Both using the same map with 23 keyed events that erase the fog. 2024-11-13 18-56-38_Segment_0_x264_x264_x264_x264.mp4 (Size: 924.15 KB / Downloads: 1) RE: Fog of War - Tepe - 11-14-2024 Hmmm its really strange... So, I must test this again. Your code is without any changes? RE: Fog of War - DerVVulfman - 11-14-2024 My code is as I last posted. And your code is as you sent to me... though you did neglect the Scene_Map portion. I basically made a COPY of my project bosting the 23 walking 'fog-erasing' sprites, and pasted yours in. Then added the additional NPC entries into your array, so yours would use the same 23 NPCs as mine. That's all. RE: Fog of War - Tepe - 11-14-2024 In that case I don't know why my situation was/is the other way around. In that case I would have to send you my entire private project for review via PM. By the way, maybe you could help me with a few other things, but I don't want to impose on you either. :) RE: Fog of War - DerVVulfman - 11-16-2024 More work was done. First, I revised the way the map is revealed. Originally, it used to be revealed by the player, whereby he updates the entire grid, checks to see if the events are hidden unless in X-range tiles, and then redraws the remaining static and dynamic fogs within the field-map's spriteset. The mechanics also worked for events, and each event... when it moved.. would do the same. But with a large number of events, it would likely slow down (a little or a lot depending on the code). Imagine if ten events moved in unison... it would attempt to refresh the fog ten times! So I thought... the field map gets updated after every event... Hrm..... Well, each event COULD... update the grid, sure enough. It would perform the math of what map areas were erased or not. But after that, I would have it set a form of "REFRESH THE MAP" flag. So now, IF an event moves and erases some fog, it merely sets a flag rather than forcing the field to update. And if five or eight events move and erase some fog, that one flag STILL gets set. Executed within Game_Map itself, the fog will only be updated once no matter HOW many events have moved to trigger it. Now in the demo, I set the opacity of the STATIC fog to something less than solid, whereby I can barely see the trees underneath. However, I found that there was an area around my player that was a bit... tile wary. It appears that Wachunga thought to 'erase/remove' the fog of the dynamic map where the static map existed with a scant amount of overlap. However, the removal was ... in my opinion... JANKY! So I made a new configuration variable to DISABLE the 'dynamic-fog-removal' feature. Or precisely, to enable it as it is a feature wachunga put in by default. Yes, allowing both the dynamic and static fog will make the static area darker and more solid, but it is a hella better trade-off. I renamed a few CONFIG variables, but I did so much more in breaking up the system into bite-size pieces for easier observation and study. Soon... to release (I guess?) I hate writing instructions... even if already partially written... Fog of War Demo.zip (Size: 953.81 KB / Downloads: 1) RE: Fog of War - Tepe - 11-16-2024 Okay i must see this. :D EDIT: I tested Your code and yea it work better but still we have two problems: 1. I signalized you earlier: Change in Game_Character method update_move to Code: def update_move 2. When player reveal fog then fps still drops but it is level up because in my project fps drops only then player move and reveal fog. Change Class Game_Player < Game_Character to this Code: class Game_Player < Game_Character RE: Fog of War - DerVVulfman - 11-16-2024 The changes recommended actually do nothing. Allow me to explain. Within the Game_Character class, the code already reads:
def update_move
Minor note: I used @last_fow_x and @last_fow_x, an alteration if another Game_Character script uses like variables, these specific for the FOG script alone.# # Perform the original method wachunga_fow_gch_update_move # # Perform only for dynamic maps (must be FOW) if $game_map.fow_dynamic # If character moved and not game player if (@x != @last_fow_x or @y != @last_fow_y) and self != $game_player # Check if character entered or exited player's visual range $scene.spriteset.update_event_transparency(self) end end # # Record last position @last_fow_x = @x @last_fow_y = @y # end By the fact that it first must check that the $game_map.fow_dynamic flag must be on, the map must have fog-of-war engaged. As such, the inclusion of your if $game_map.fow condition is actually unnecessary. Insofar as the changes to GAME_PLAYER, combining the $game_map.fow and @jump_count == 0 upon a single line within the update_jump method offers no actual change except cosmetic. For the update_move method within GAME_PLAYER, your line that handles $game_map.fow, the X/Y coordinates and the jumping? test does the same as within this version, so it too is only cosmetic. The inclusion of...
# Update last recorded FOW position
... actually means nothing. Its already been taken care of.@last_fow_x, @last_fow_y = @x, @y Do recall that before this line, it has the line reading "super". This means that this method inherits from its superclass, the Game_Character class. And within Game_Character's own update_move, this update of the player's position is already handled. Ergo, these changes would do nothing. EDIT: I just found out that Wachunga released a version after what had been discussed, minor changes within Game Player to accommodate anyone 'else' adding code to the move and jump methods. An easy update. Also, stack-error preventative code has been added to Game_Map and Game_Player to what I now have RE: Fog of War - Tepe - 11-16-2024 I see that I have to show you in a video and actually prove that they do something since thanks to them the fps meter in my specific case went up a lot. I wouldn't have turned it on if it really didn't do anything... but that's OK, nobody has to use it anyway... however, as I mentioned earlier in my specific case it makes a significant difference. |