The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Acolyte on February 18, 2014, 05:48:25 AM

Title: [VXA] Trigonometry values
Post by: Acolyte on February 18, 2014, 05:48:25 AM
This may be somewhat of a weird request, and I'm not even sure it really counts as a "script", but I've been trying to recreate this rm2k3 event system (http://rpgmaker.net/tutorials/479/) in vx ace for quite some time. Even after painstakingly recreating every event, I couldn't get it to work. After thinking about it some more, I realized that there's probably already a way to have rgss do the math instead, without having to worry about creating a huge lookup table in a common event.

After a bit of searching, I found this (http://www.scribd.com/doc/95067279/RPG-Maker-VX-Ace-Help-RGSS3-Reference-Manual). (pg. 284, under math, module functions.)

I don't have much experience at all with RGSS3, or ruby in general, so I have no idea how I would utilize this. Would I use a script call, or would it need some sort of code snippet? Any guidance would be appreciated.

Basic description of what I want: I'd like to be able to calculate angles from numbers stored in variables, and then pass the angle into a different variable for eventing purposes.
Title: Re: [VXA] Trigonometry values
Post by: D&P3 on February 18, 2014, 09:50:45 AM
Spoiler for:
Code: [Select]
class Game_Interpreter
  def calculate_angle
    ax = $game_variables[?]
    ay = $game_variables[?]
    bx = $game_variables[?]
    by = $game_variables[?]

    deltaX = bx - ax
    deltaY = by - ay

    angle = Math.atan2(deltaY, deltaX) * 180.0 / Math::PI
    $game_variables[?] = angle
  end
end

Place that in a new script slot and edit the $game_variables for the ones you want to use; then you can use
Code: [Select]
calculate_angle
in a script call which will place the result into the Game_Variable.



A brief explanation of scripting for you:
Anything inside of the Game_Interpreter class can be used directly through an event's script call.
Notice how the method is called calculate_angle, and you can now use calculate_angle in a script call.

That's pretty much the basics of that. If you want to modify it or add to it, video tutorials 2~4 should cover what you need in my playlist (http://www.youtube.com/playlist?list=PLu_gesZsbQQ50g3Y302dN0sq6DuErvcJy)
Title: Re: [VXA] Trigonometry values
Post by: Acolyte on February 18, 2014, 04:45:51 PM
Awesome, thank you so much  :tpg:
Title: Re: [VXA] Trigonometry values
Post by: yuyu! on February 18, 2014, 09:59:52 PM
All hail D&P3! ;_;