Author Topic: How does the hero know if they're in a steam?  (Read 66 times)

Max

  • Full Member
  • ***
  • Posts: 101
    • View Profile
How does the hero know if they're in a steam?
« 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?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1103
    • View Profile
Re: How does the hero know if they're in a steam?
« Reply #1 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 :)

Max

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: How does the hero know if they're in a steam?
« Reply #2 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?

Max

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: How does the hero know if they're in a steam?
« Reply #3 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?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1103
    • View Profile
Re: How does the hero know if they're in a steam?
« Reply #4 on: June 08, 2018, 09:12:39 am »
Streams should not have an effect when the hero is falling. This sounds like a bug.