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.

[Resolved] Event-turn-to-event script

Hi everyone. Somebody could not understand me, 'couse i'm not very good in english language ;p

I was looking on rmxp.org for script that i really need... and not found. And that's the reason I writing this topic.

I looking for script
that allows turning one event in direction to second event...
that allows turn event1 in direction to event2...
If somebody know script like that, pls give link or something.

I'm not sure somebody understand me ;p but, if you do, pls help me.
 
Simple enough.

Code:
class Game_Character
  def turn_towards_event(event_id = 1)
    c = event_id == 0 ? $game_player  : $game_map.events[event_id]
    turn_towards_target(c.x, c.y)
  end
  def turn_towards_target(x, y)
    sx, sy = @x - x, @y - y
    return if sx == 0 and sy == 0
    if sx.abs > sy.abs
      sx > 0 ? turn_left : turn_right
    else
      sy > 0 ? turn_up : turn_down
    end
  end
end

To use:
Code:
e1 = $game_map.events[event_id1]
e2 = $game_map.events[event_id2]
e1.turn_towards_event(e2)
 
I made new class in script editor and put first code you give into it...

In event I made this:
Code:
e1 = $game_map.events[26]
e2 = $game_map.events[1]
e1.turn_towards_event(e2)

Events with that ID really exist... i don't know what to do :(
 

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