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.

View Range type script

Hello fellow members, I may need your help...

I am making a 8-way movement system, and instead of
your hero moving, he has an event move for him.
This is because I can't disable his movement through
scripting.

So what I need is a view range type script where
in an event you put comments to set the amount of
spaces he can see to.
EX: Comment: View = 5
And that will make the event see everything within a
5 space radius of it. Yes radius, it sees in
a full circle.

then you use comments to set a list of events for
it to act upon seeing.

Ex: Comment: [T] EV001 = switch 1 on

the sight commands i need are as follows:
switch [number] on
variable [operand] [number]
call event [common event id]

so thats basically what I need, and if you help with this,
you will get big credits.
 

poccil

Sponsor

This function determines whether an event is within a circular range of another event.  It is meant to be put into a new script section.
Code:
class Game_Event
 def inRange?(evt,viewRange)
   event=$game_map.events[evt]
   if !event
     self.need_refresh=true
     return false
   end
   x1=self.x
   x2=event.x
   y1=self.y
   y2=event.y
   x1-=x2
   x1*=x1
   y1-=y2
   y1*=y1
   if (x1+x2)>(viewRange*viewRange)
     self.need_refresh=true
     return false
   end
   return true     
 end
end

Using my script enabling script-based switches, you can create an event page like the one below:

Event Page XXX
Condition: Switch "s:inRange?(2,5)" is ON; Switch 's:tsOff?("A")' is ON
Trigger: Autorun
Commands [just an example]:
Code:
@>Text: Gotcha!
@>Comment: Following command ends the event
@>Script: setTempSwitchOn("A")

The switch's name "s:inRange?(2,5)" is a script-based switch.  It runs as soon as the event with this event page is within a 5-tile radius of the event with ID 2.  The commands within the event page itself are arbitrary.  The switch 's:tsOff?("A")' determines whether the temporary self-switch A is off.
 

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