Hello,
I'm newbie to RGSS (and Ruby), but I consider myself as good programmer.
I've read all the FAQ and searched forum, but I couldn't find answer to my question.
I'm creating my own game system (ABS / CMS / HUD) from scratch. Everything is going fine (as I've found many solutions on this great forum). But now I encountered problem, which is unsolvable for me.
I need to determine if tile on map blocks line of sight (LoS):
- tile with other character blocks LoS
- tile with something on middle layer (like tree) blocks LoS
- tile with something blocking movement doesn't need to block LoS (for example: water)
- tile with event doesn't need to block LoS (events without graphics, events which doesn't block movement)
All I need is to write method which takes two parameters (coordinates of tile) and returns true (when tile blocks LoS) or false (when it doesn't).
Any help will be appreciated
Edit:
I solved it (partially):
Now I have problem with events. I think I need to view game map events array and check every event coordinates. But it shall return true only if through parameter is false. But I have no idea how to check value of this parameter...
(sorry if my English is poor, it isn't my native language)
I'm newbie to RGSS (and Ruby), but I consider myself as good programmer.
I've read all the FAQ and searched forum, but I couldn't find answer to my question.
I'm creating my own game system (ABS / CMS / HUD) from scratch. Everything is going fine (as I've found many solutions on this great forum). But now I encountered problem, which is unsolvable for me.
I need to determine if tile on map blocks line of sight (LoS):
- tile with other character blocks LoS
- tile with something on middle layer (like tree) blocks LoS
- tile with something blocking movement doesn't need to block LoS (for example: water)
- tile with event doesn't need to block LoS (events without graphics, events which doesn't block movement)
All I need is to write method which takes two parameters (coordinates of tile) and returns true (when tile blocks LoS) or false (when it doesn't).
Any help will be appreciated
Edit:
I solved it (partially):
Code:
def tile_is_blocked(x, y)
tile_id = $game_map.data[x, y, 1]
if tile_id > 0
pass = $tileset.passages[tile_id]
return true if ((pass & 1) == 1) and @dir = 0
return true if ((pass & 2) == 2) and @dir = 1
return true if ((pass & 4) == 4) and @dir = 2
return true if ((pass & 8) == 8) and @dir = 3
end
return false
end
(sorry if my English is poor, it isn't my native language)