Map effects should refresh more often than every game tick

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Map effects should refresh more often than every game tick

#1 Post by Nagyhal »

I had actually fixed this one earlier, with code that DarkGod described as "insane".

Now, I've pared everything back to beautiful, readable basic code. And, fingers crossed, it works pretty well! Save for this problem.

Hundreds of lines of bloat were caused by my earlier insistence on avoiding this problem!

This time, I want to fix it with code that is clean, general-purpose, and available to all.

Now, and while the problem is particularly bad for Beholder, I've also had this happen with knockbacks and other stuff that could reasonably occur with any character, which is why I propose an all-purpose fix. Essentially, though: My Beholder has a continually projected gaze. It also has an instant movement ability. This is what happens when you use it:

(The gaze is very faint, but that's because it's the default "off" gaze effect! I broke off refactoring the other stuff to investigate this, so no talent-invested techincolour gazes. Bear with me.)

Image Image

My instinct would be to refactor the processEffects function in default/engine/Map.lua. This function has the dual purpose of updating any map effects that require updating, and also ticking down their durations while deleting any with a remaining duration of 0.

I propose splitting this function, having it call a new function, updateEffect on each effect present. Ticking down durations will still be handled by processEffects, but we can also use updateEffect from outside of this function. Then, we throw in a condition - for any entity that moves without expending energy - to update the desired effects.

It might be prudent to update all effects present on the map in this scenario, given that an actor moving in front of a projection ought to block that projection, but in the above case the projection would not be updated, so no block.

I can also think of a number of other situations aside from instant teleportation in which my class would benefit from being able to access updateEffect! And maybe, if you also code for ToME, then you can too.

What you do?

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: Map effects should refresh more often than every game ti

#2 Post by Marson »

Yeah, this is a general problem. Shield graphics don't update if they turn on or run out at certain offsets; rogues won't display their icon on the map even though you have spotted them and can mouse-over them; etc.

Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Re: Map effects should refresh more often than every game ti

#3 Post by Nagyhal »

Marson, that's a concerning problem, especially as I'm so interested in fixing stealth!

This is not a graphical issue we have here though, but a case of the actual state of the game world failing to accomodate the instanteous movements of actors. The cone doesn't appear at the character's new location because the game world hasn't put it there yet.

I would describe it as presentational (though others may wish to interpret that as graphical) because the failure of map effects to update intra-turn doesn't actually have any gameplay effect I can think of - UNTIL you consider something like my Beholder class which has abilities where the result depends on which actors are present within an effect's area.

This does mean we can fix it easily by altering game logic, without needing to delve into the complicated graphics handling and without needing to consider the horrible, obscure-to-locate bugs you have listed above!

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: Map effects should refresh more often than every game ti

#4 Post by Marson »

In the case of stealth/invisibility, if your character can't see a monster, a tooltip does not appear when you mouse over the square they are on. It just looks like a normal empty grid. If your character spots the monster, there are many times when the map display still shows an empty square, but you can now get a tooltip to display (and if you are using my UI mod, they now appear in the NPC list). To me this says that the display hasn't caught up with the true state of the game. The same applies to how the shield display is out of sync with whether it is active or not. That seems different from your cone issue, as the gaze hasn't moved yet in the game state (if I understand you correctly).

Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Re: Map effects should refresh more often than every game ti

#5 Post by Nagyhal »

Marson, that's right! I hope we can fix those problems too - see you in one of the stealth threads!

Well, in the absence of any real interest, I'm going to go rogue, and drastically alter the way effects are handled within my addon code!

If DarkGod deems the re-implementation to be worthwhile, and efficient enough, then it can go in the mainline code I guess.

My decision was made when I realized that - and this is absolutely insane - that map effects only update once per game turn! And not every tick (which is the only reasonable way to ensure they synchronize with all actor's movements.)

So, then, if you take a player casting one of the abilities that works similarly to my gazes in the current vanilla ToME, like Poison Storm, then you have this crazy divergence of behaviour depending on the player's movement speed. At normal speed, the AoE seems to follow the character as normal. If the player's movement speed increases, then suddenly it loses synch with the character and will appear to lag whenever two (or more) of the player's turns fall within one game turn.

If there's inefficiency caused by updating the effects >10 times more often than they are already, I can simply implement the improvements in a way that encourages creators of effects not to re-draw them when there isn't any need.

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Map effects should refresh more often than every game ti

#6 Post by darkgod »

[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Marson
Uruivellas
Posts: 645
Joined: Thu Jan 16, 2014 4:56 am

Re: Map effects should refresh more often than every game ti

#7 Post by Marson »

I haven't looked through the new code yet, but...

YAY!

Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Re: Map effects should refresh more often than every game ti

#8 Post by Nagyhal »

(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)
(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)
(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)
(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)
(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)
(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)
(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)
(ˇ_ˇ”) ?(˘?˘)? ?(˘?˘)? ?(˘?˘)?
?(˘?˘)??(˘?˘)? ?(˘?˘)? (”ˇ_ˇ)

DarkGod, hearty thanks!

You're making me delete a lot of lines of code, with the pace at which you're making the engine / ToME class system more efficient!

Nagyhal
Wyrmic
Posts: 282
Joined: Tue Feb 15, 2011 12:01 am

Re: Map effects should refresh more often than every game ti

#9 Post by Nagyhal »

DarkGod, if you are listening, can I make one more request?

Could you make it possible to remove map effects from the middle of the update_fct?

In the current implementation, either they are deleted, or the update_fct runs leaving the effect to remain - one or the other. Setting the duration to 0 leaves the effect to persist for a full extra turn.

However I have map effects which are contingent upon certain conditions, and can be shut down if those conditions are removed.

So essentially in my addon I still have to superload, which is no big deal, but if you get the chance just have a look at it. It might be too much pain to change, ultimately.

EDIT: I might be able to just set the effect to having zero grids, which would be a decent solution for one turn. In which case I feel a little foolish. But nonetheless, it would be nice!

Post Reply