Solarus-Games English Forum

Solarus => Development => Topic started by: Max on June 06, 2018, 10:28:12 PM

Title: How does the hero know if they're in a steam?
Post by: Max on June 06, 2018, 10:28:12 PM
So I'm working with some stream entities in a dungeon, and I'm realizing that my dash item allows you to bypass them pretty easily. I might just design around this, but is there a way for code to know if the hero is on a stream? I'd been thinking streams were just a type of ground and I could handle them the same way I handle dashing across holes or deep water, but since they're a map entity, that won't work.

I guess I could run code every 1ms or so that gets all the steams in a map with map:get_entities_by_type, and then checks their coordinates against the hero's. Or try map:get_entities_in_ractangle, the rectangle being the hero's 16x16 box. But running either of these constantly whenever dashing just to check for streams seems inelegant. Is there a better way?
Title: Re: How does the hero know if they're in a steam?
Post by: Christopho on June 06, 2018, 11:02:11 PM
For now you have to check as you suggest, in a timer that repeats every 10 ms (1 ms is useless because the steps are 10 ms).
map:get_entities_in_rectangle() will be the fastest solution.

In 1.6, I will add a function hero:is_moved_by_stream(). Thanks for the feedback :)
Title: Re: How does the hero know if they're in a steam?
Post by: Max on June 07, 2018, 07:11:36 PM
No problem, that'll do :D

By the way, I didn't see it on the website anywhere, do you guys have a release window for 1.6?
Title: Re: How does the hero know if they're in a steam?
Post by: Max on June 08, 2018, 05:21:27 AM
Ah, and a related question! It seems like streams continue pushing the hero even when she is in the falling state? Is this intended?

I'm using stream entities that are wind from fans where you're supposed to place a bomb on them and it'll blow across a hole to get a switch. But if the hero stands in the wind, she will blow into the hole and fall... except while she's falling she'll blow to the other side and be fine.

Something like hero:get_movement():stop() won't work to stop this either, because even if the hero has no movement, the streams continue to act upon the hero. Anybody know a way to keep a falling hero from being effected by streams?
Title: Re: How does the hero know if they're in a steam?
Post by: Christopho on June 08, 2018, 09:12:39 AM
Streams should not have an effect when the hero is falling. This sounds like a bug.