Author Topic: Getting the tile id bellow the hero ?  (Read 3357 times)

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Getting the tile id bellow the hero ?
« 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

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #1 on: January 23, 2016, 04:22:41 pm »
Just by curiosity, what is your purpose?
Is it for some special ground type?
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1182
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #2 on: January 23, 2016, 05:47:08 pm »
In 1.5 there is a new function dynamic_tile:get_pattern_id() :)

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #3 on: January 23, 2016, 06:52:48 pm »
In 1.5 there is a new function dynamic_tile:get_pattern_id() :)

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

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
« Last Edit: January 23, 2016, 06:54:45 pm by MetalZelda »

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #4 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.
« Last Edit: January 23, 2016, 07:35:55 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #5 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.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1182
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #6 on: January 23, 2016, 08:58:29 pm »
I don't know either, especially because all of this is already possible with custom entities.

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #7 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.
« Last Edit: January 23, 2016, 09:58:35 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #8 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...
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #9 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=

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Getting the tile id bellow the hero ?
« Reply #10 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.
« Last Edit: January 23, 2016, 10:51:51 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”