[Script] [ACE] [MAP] Directional Arrow

nhoxboy73nhoxboy73 Posts: 776Registered
GIỚI THIỆU:

Script hiện một mũi tên trỏ vào một event nào đó, mũi tên tự xoay khi player di chuyển ở những vị trí khác nhau so với event. Thường sử dụng khi bạn muốn hướng dẫn player đi đến nơi nào đó do bạn chỉ định.
SCREENSHOT:
77941933.jpg
96321390.jpg
53493834.jpg
Demo: Link
FIX:

Các bạn thay script trong demo bằng script này:
#==============================================================================
# ¦ Game_Arrow ||| Original Author: Dang_Khoa
#------------------------------------------------------------------------------
# This class defines arrow's attributes
#==============================================================================

class Game_Arrow
#--------------------------------------------------------------------------
# ? CONFIG HERE
#--------------------------------------------------------------------------
SWITCH_ID = 1 # Switch ID
EVENT_ID = 1 # Varaiable ID control Event ID
PI = 3.14 # DO NOT CHANGE

#--------------------------------------------------------------------------
# ? Attributes
#--------------------------------------------------------------------------
attr_reader :angle
attr_reader :visible
#--------------------------------------------------------------------------
# ? Initialize
#--------------------------------------------------------------------------
def initialize
@angle = 0
@visible = false
end
#--------------------------------------------------------------------------
# ? Check if Arrow is Visible?
#--------------------------------------------------------------------------
def visible?
event_id = $game_variables[EVENT_ID]
return @visible = false if $game_switches[SWITCH_ID] == false
return @visible = false if event_id <= 0
return @visible = false if $game_map.events[event_id] == nil
return @visible = true
end
#--------------------------------------------------------------------------
# ? Convert Radian to Degree
#--------------------------------------------------------------------------
def to_deg(rad)
return ((rad*180)/PI).round
end
#--------------------------------------------------------------------------
# ? Frame Update
#--------------------------------------------------------------------------
def update
return if !visible?
update_angle
end
#--------------------------------------------------------------------------
# ? Update Arrow's Angle
#--------------------------------------------------------------------------
def update_angle
event_id = $game_variables[EVENT_ID]
x = $game_map.events[event_id].real_x - $game_player.real_x
y = $game_map.events[event_id].real_y - $game_player.real_y
rad = Math.atan2(x,y) + PI
@angle = to_deg(rad)
end
end



#==============================================================================
# ¦ Game_Map
#==============================================================================

class Game_Map
#--------------------------------------------------------------------------
# ? Attributes
#--------------------------------------------------------------------------
attr_reader :arrow
#--------------------------------------------------------------------------
# ? Initialize
#--------------------------------------------------------------------------
alias initialize_arrow initialize
def initialize
initialize_arrow
@arrow = Game_Arrow.new
end
#--------------------------------------------------------------------------
# ? Frame Update
#--------------------------------------------------------------------------
alias update_events_arrow update_events
def update_events
@arrow.update
update_events_arrow
end
end

TÁC GIẢ:Dang_Khoa
Dùng thì nhớ credit nha ^^

Comments

Sign In or Register to comment.