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.

Need help with V.4 of Near's View Range

Though I have searched and found similar topics, I cannot understand how to implement Near's View Range like the old non-SDK view range script.

Here is the script:

Code:
#==============================================================================
# â–  View Range Module
#==============================================================================
# Near Fantastica
# Version 4
# 29.11.05
#==============================================================================

#--------------------------------------------------------------------------
# * SDK Log Script
#--------------------------------------------------------------------------
SDK.log("View Range", "Near Fantastica", 4, "29.11.05")

#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.state("View Range") == true
  module VR
    #----------------------------------------------------------------------------
    def VR.in_range?(element, object, range)
      x = (element.x - object.x) * (element.x - object.x)
      y = (element.y - object.y) * (element.y - object.y)
      r = x + y
      if r <= (range * range)
        return true
      else
        return false
      end
    end
    #----------------------------------------------------------------------------
    def VR.range(element, object)
      x = (element.x - object.x) * (element.x - object.x)
      y = (element.y - object.y) * (element.y - object.y)
      r = x + y
      r = Math.sqrt(r)
      return r.to_i
    end
  end
  
  #==============================================================================
  class Interpreter
    #----------------------------------------------------------------------------
    def event
      return $game_map.events[@event_id]
    end
  end
  
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

Can someone please demonstrate how to implement the following features that I used to use, based on the knowledge I understand scripting 0%.

1 The Sound Range

What do I need to put into the event box to have various sound effects play dependant on what event you are near to i.e river, fire, waterfall. So when you are standing near none of them, no SFX plays, and when you approach them, depending on the range you have set the SFX for it gets louder and louder.

2 The Sight Range

I need to implement it where a sentry is on patrol, and if he sees you within the range you have set, a self switch is triggered and he approaches/game over etc. This should only be within a semi circle in front of him [so you can sneak past behind him].

Many thanks to anyone who helps, but I really need a demonstration on what to write in the call script, could you please demonstrate it as if it was in an event box.
 
That is the SDK version SLB, I know how to use the non-sdk one, i just don't know how to make the sam events with this SDK version. Please help here someone! That's three confused people now!
 
i think the sound is done like this:

i didnt test it, but it should work.
Code:
range = VR.range($game_player, $game_map.events[event_id_of_sound])
volume = 100 - (10 * range) # lowers sound by 10 every tile away from sound event
audio = RPG::AudioFile.new("name", volume)
$game_system.bgm_play(audio)
 

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