Solarus-Games English Forum

Solarus => Development => Topic started by: MetalZelda on January 23, 2016, 04:03:12 PM

Title: Getting the tile id bellow the hero ?
Post by: MetalZelda on January 23, 2016, 04:03:12 PM
Hi.

I know that it already exist but it only return the built-in ground that the hero is walking on.

My idea about it is to create custom interaction behaviors for certain tile, and the Tileset Editor manage all the tiles by id, it should be cool if this should be accessible in the API
Title: Re: Getting the tile id bellow the hero ?
Post by: Diarandor on January 23, 2016, 04:22:41 PM
Just by curiosity, what is your purpose?
Is it for some special ground type?
Title: Re: Getting the tile id bellow the hero ?
Post by: Christopho on January 23, 2016, 05:47:08 PM
In 1.5 there is a new function dynamic_tile:get_pattern_id() :)
Title: Re: Getting the tile id bellow the hero ?
Post by: MetalZelda on January 23, 2016, 06:52:48 PM
Quote from: Christopho on January 23, 2016, 05:47:08 PM
In 1.5 there is a new function dynamic_tile:get_pattern_id() :)

Oh that's cool, that should do the thing.

Quote from: Diarandor on January 23, 2016, 04:22:41 PM
Just by curiosity, what is your purpose?
Is it for some special ground type?

Mostly things like walking on lava for a certain time if a tunic is wear by the hero, and other stuffs like that
Title: Re: Getting the tile id bellow the hero ?
Post by: Diarandor on January 23, 2016, 07:32:55 PM
I think you can make the hero walk on lava with some trick.
I use a custom entity with solid ground following the hero to simulate the jump (this allows to jump over holes, water and lava). A similar trick might work using ground detection, but I am not sure of this (maybe the hero would fall on lava before the entity is created, so I don't know if this is possible).

I was planning to make a wizard that can swim in lava too (if he possess certain item, the phoenix feather, and otherwise he would sink in lava as usual) so I requested customization of new types of ground to allow swimming on custom lava; this could be a different solution if Christopho implements this in Solarus 1.5. This might be better and simpler than using the custom entity trick with the change of animation. Anyway, I have a similar problem. Other uses of custom grounds could be to make breakable grounds (that become holes when walking over them), snow grounds that leave footsteps, acid grounds that you cannot traverse even with the goron cape or phoenix feather, etc.
Title: Re: Getting the tile id bellow the hero ?
Post by: Diarandor on January 23, 2016, 07:44:59 PM
This is the request I made:
https://github.com/christopho/solarus/issues/812

This probably is something hard to do, so I don't know if Christopho will do it.
Title: Re: Getting the tile id bellow the hero ?
Post by: Christopho on January 23, 2016, 08:58:29 PM
I don't know either, especially because all of this is already possible with custom entities.
Title: Re: Getting the tile id bellow the hero ?
Post by: Diarandor on January 23, 2016, 09:54:27 PM
I am not sure if everything is possible with custom entities. For instance:

-If we allow to swim or walk in lava, and we want to make a different kind of ground where that is not possible (like acid ground), we would need new types of ground. I plan to use some kind of ground like this. (Maybe this can still be done getting the id of the lava tile.)

-To make a cracked ground that breaks (changing into hole) if the hero stays for a while, we need not to save solid ground over it, or otherwise the hero would reappear over the hole if he falls. Some kind of ground that does not save position (i.e., bad ground) would be necessary. This could be a property used when defining custom grounds. (The only solution I see is to redefine the function that saves last position on solid ground and get the tile id.)

-The last point is that this would make the code simpler , from the Lua part, when quest makers need custom grounds.
Title: Re: Getting the tile id bellow the hero ?
Post by: Diarandor on January 23, 2016, 10:07:45 PM
Well... I am starting to think that Christopho is right. Maybe all of this is possible (but untested). So maybe it is better to close my request of custom grounds...
Title: Re: Getting the tile id bellow the hero ?
Post by: MetalZelda on January 23, 2016, 10:22:42 PM
Quote-To make a cracked ground that breaks (changing into hole) if the hero stays for a while, we need not to save solid ground over it, or otherwise the hero would reappear over the hole if he falls. Some kind of ground that does not save position (i.e., bad ground) would be necessary. This could be a property used when defining custom grounds. (The only solution I see is to redefine the function that saves last position on solid ground and get the tile id.)

Oh, this one is totally do-able through custom entities. Like the others, but for your lava swimming idea this should be faster (reading a tile id and overwrite it manually. (Or, you dynamic tile your lava and make 2 lava in the tileset editor : one for the lava, one for swim-able lava=
Title: Re: Getting the tile id bellow the hero ?
Post by: Diarandor on January 23, 2016, 10:44:09 PM
@MetalZelda: Yes, I agree, the problem with lava is easier to solve than I thought.

However, for the cracked ground and other grounds that should not save solid ground position, the solution could be to get the id of the ground each time the position of the hero changes (using the event hero:on_position_changed), and then calling hero:save_solid_ground() with the new position, but only in case there is good ground (in the case of a cracked ground or other "bad" ground we will not save the position).

To summarize, we need to save the last solid ground position each time the hero changes position, except if the ground is bad or if the tile id corresponds to bad grounds that are not bad grounds for the engine (like cracked grounds).

EDIT: I closed my github request since it won't be needed anymore with these solutions.