Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Fishing while facing water script

I'm gonna clarify this.

I would like a script that lets the player use an item only while facing or ON a specified terrain tag. Otherwise, the item cannot be used. Can someone please do this for me?

P.S. If you know of any other way to do this please tell me :D
 
This shouldn't be too difficult. Get hero position and facing, add/minus 1 to x/y to get the tile he/she is facing, set up a condition to see if the terrain tag for that tile is equal to whatever you want (I had a line for this but lost it).

Edit:
Code:
$game_map.terrain_tag(x, y)

Sorry about the double-post, but I whipped a method up quick:
Code:
class Game_Map

def fishable?(fishable_terrain_tag)
  if $game_player.direction == 2
    x = $game_player.x
    y = $game_player.y + 1
  elsif $game_player.direction == 4
    x = $game_player.x - 1
    y = $game_player.y
  elsif $game_player.direction == 6
    x = $game_player.x + 1
    y = $game_player.y
  elsif $game_player.direction == 8
    x = $game_player.x
    y = $game_player.y - 1
  end
  if terrain_tag(x, y) == fishable_terrain_tag
    return true
  else
    return false
  end
end

end
Create a new script just above Main, paste this in. I haven't tested it, but it should work in theory. I'm not sure if Game_Map is the best class to place this method in, so if anyone has any other suggestions it'd be welcome :P

To check if the tile you are facing is "fishable", set up a conditional branch, go to the 4th tab, click "Script" and put in something like:
Code:
$game_map.fishable?(terrain_tag) == true
Replace terrain_tag with the terrain tag you want to use for fishable tiles (ie. your water tiles). Now you have control over what happens when the tile in front of you is fishable or not.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top