I have tomoaky's warp script but the help text is gibberish
i'd like to know how the plugin commands work..
i like to make the character move to where the mouse cursor position is.
i like to make the character move to where the mouse cursor position is.
Ruby:
#==============================================================================
# ■ RGSS2_Warp Ver1.0
# tomoaky ‚Ђ«‚à‹L(http://hikimoki.sakura.ne.jp/)
#------------------------------------------------------------------------------
# ¡‚¢‚éƒ}ƒbƒvã‚Ì’Ês‰Â”\ƒZƒ‹‚Öƒ‰ƒ“ƒ_ƒ€ˆÚ“®‚·‚é‹@”\‚ð’ljÁ‚µ‚Ü‚·A
# ˆÚ“®æ‚ÌŒó•â‚Æ‚µ‚Ä‹éŒ`—̈æ‚ðŽw’è‚·‚邱‚Æ‚à‚Å‚«‚Ü‚·B
#
# [email protected] ŒöŠJ
#
# EŽg‚¢•û
# ƒCƒxƒ“ƒgƒRƒ}ƒ“ƒhwƒXƒNƒŠƒvƒgx‚É warp ‚Æ‘‚‚¾‚¯‚ÅOK‚Å‚·A
# ˆêu‚ňړ®‚ªŠ®—¹‚µ‚Ü‚·A‰‰o“™‚͉½‚à‚È‚¢‚̂ŃCƒxƒ“ƒgƒRƒ}ƒ“ƒh‚Å
# Œø‰Ê‰¹‚âƒAƒjƒ[ƒVƒ‡ƒ“AƒEƒFƒCƒg‚ð•t‚¯‚Ä‚‚¾‚³‚¢B
#
# warp(id) ‚Ń[ƒv‚·‚é‘ÎÛ‚ðŽw’è‚Å‚«‚Ü‚·A-1 ‚È‚çƒvƒŒƒCƒ„[A
# 0 ‚Ȃ炱‚̃Cƒxƒ“ƒgA1ˆÈã ‚Å‚»‚ÌID‚ð‚à‚ƒCƒxƒ“ƒg‚ª‘ÎۂƂȂè‚Ü‚·B
#
# warp(id, x, y, width, height) ‚Æ‚·‚ê‚ÎÀ•W(x, y)‚ð¶ã‚Æ‚µ‚½
# cwidthƒZƒ‹A‰¡heightƒZƒ‹‚Ì‹éŒ`‚ðˆÚ“®æŒó•â‚Æ‚µ‚Ü‚·B
#
# warp ‚Ì‘ã‚í‚è‚É warp_jump ‚ðŽg‚¤‚ÆAuŠÔˆÚ“®‚ªƒWƒƒƒ“ƒv‚ɕω»‚µ‚Ü‚·B
#
# E’ˆÓ
# ‘ÎÛ‚ª¡‚¢‚éÀ•W‚ƃCƒxƒ“ƒg‚ª‚¢‚éÀ•W‚ÍŽ©“®“I‚ÉŒó•â‚©‚眊O‚³‚ê‚Ü‚·‚ªA
# ’nŒ`“I‚ɂǂ±‚É‚à‚‚Ȃª‚Á‚Ä‚¢‚È‚¢À•W‚ÍŒó•â‚Ɋ܂܂ê‚Ü‚·A‚±‚¤‚¢‚Á‚½ƒ}ƒbƒv‚Å‚Í
# ‹éŒ`—̈æ‚ÌŽw’è‹@”\‚ð—˜—p‚µ‚Ä‚‚¾‚³‚¢B
#
# Žw’肵‚½‹éŒ`—̈æ‚Ì‚·‚ׂẴZƒ‹‚ªƒ[ƒv•s‰ÂƒZƒ‹i’Ês•s‰ÂorƒCƒxƒ“ƒg‚ª‚¢‚éj
# ‚¾‚Á‚½ê‡‚Í¡‚¢‚éÀ•W‚ªƒ[ƒvæ‚É‘I‚΂ê‚Ü‚·B
#==============================================================================
#==============================================================================
# ¡ ƒRƒ}ƒ“ƒh
#==============================================================================
module TWARP
module Commands
module_function
def warp(id = -1, x = nil, y = nil, width = 1, height = 1)
character = $game_map.interpreter.get_character(id)
x, y = $game_map.warp_pos(character, x, y, width, height)
character.moveto(x, y)
$game_player.clear_target # ターゲットを解除
#$game_player.set_target_pos_screen(mouse_x, mouse_y)
end
def warp_jump(id = -1, x = nil, y = nil, width = 1, height = 1)
character = $game_map.interpreter.get_character(id)
x, y = $game_map.warp_pos(character, x, y, width, height)
character.jump(x - character.x, y - character.y)
$game_player.clear_target # ターゲットを解除
#$game_player.set_target_pos_screen(mouse_x, mouse_y)
end
end
end
#==============================================================================
# ¡ Game_Interpreter
#==============================================================================
class Game_Interpreter
include TWARP::Commands
end
#==============================================================================
# ¡ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# œ alias setup
#--------------------------------------------------------------------------
alias twarp_game_map_setup setup
def setup(map_id)
twarp_game_map_setup(map_id)
@twarp_pos = []
for x in 0...width
for y in 0...height
for i in [2, 1, 0] # ƒŒƒCƒ„[‚Ìã‚©‚燂ɒ²‚ׂé
tile_id = @map.data[x, y, i] # ƒ^ƒCƒ‹ ID ‚ðŽæ“¾
next if tile_id == nil # ƒ^ƒCƒ‹ ID Žæ“¾Ž¸”s : ’Ês•s‰Â
pass = @passages[tile_id] # ’Ês‘®«‚ðŽæ“¾
next if pass & 0x10 == 0x10 # [™] : ’Ês‚ɉe‹¿‚µ‚È‚¢
@twarp_pos.push([x, y]) unless pass & 0x01 == 0x01
break
end
end
end
end
#--------------------------------------------------------------------------
# › warp pos
#--------------------------------------------------------------------------
def warp_pos(character, x, y, width, height)
if x == nil
begin
pos = @twarp_pos[rand(@twarp_pos.size)]
end while !can_warp?(character, pos[0], pos[1])
else
a = []
for i in x...x + width
for j in y...y + height
a.push([i, j]) if can_warp?(character, i, j)
end
end
return character.x, character.y if a.empty?
pos = a[rand(a.size)]
end
return pos[0], pos[1]
end
#--------------------------------------------------------------------------
# › can warp?
#--------------------------------------------------------------------------
def can_warp?(character, x, y)
return false unless events_xy(x, y).empty?
return false if $game_player.pos?(x, y)
return true
end
end