MapleCutter
Member
I have some problems with this script:
- When i change Eight_Way = true to false, the character still moves in eight directions.
- If the character or event cant move toward of away from the event it moves randomly.
- When i Call Script "$game_map.events[id].move_toward_event(id)" an error appears:
The script:
Someone can help me?
Thx!
- When i change Eight_Way = true to false, the character still moves in eight directions.
- If the character or event cant move toward of away from the event it moves randomly.
- When i Call Script "$game_map.events[id].move_toward_event(id)" an error appears:
Code:
ArgumentError occurred while running the script.
wrong number of arguments(0 of 1)
The script:
Code:
#==============================================================================
# Event dependent Movement Script v. 1.03
# by Caldaron (8.10.2006)
#==============================================================================
#==============================================================================
Eight_Way = false
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
def move_toward_event(id)
turn_toward_event(id)
move_forward
if not moving?
move_random
end
end
#--------------------------------------------------------------------------
def move_away_from_event(id)
turn_away_from_event(id)
move_forward
if not moving?
move_random
end
end
#--------------------------------------------------------------------------
def turn_toward_event(id)
sx = @x - $game_map.events[id].x
sy = @y - $game_map.events[id].y
if sx == 0 and sy == 0
return
end
if sx.abs == sy.abs and Eight_Way
sx > 0 ? sy > 0 ? turn_upper_left : turn_lower_left : sy > 0 ? turn_upper_right : turn_lower_right
elsif sx.abs > sy.abs
sx > 0 ? turn_left : turn_right
else
sy > 0 ? turn_up : turn_down
end
end
#--------------------------------------------------------------------------
def turn_away_from_event(id)
sx = $game_map.events[id].x - @x
sy = $game_map.events[id].y - @y
if sx == 0 and sy == 0
return
end
if sx.abs == sy.abs and Eight_Way
sx > 0 ? sy > 0 ? turn_upper_left : turn_lower_left : sy > 0 ? turn_upper_right : turn_lower_right
elsif sx.abs > sy.abs
sx > 0 ? turn_left : turn_right
else
sy > 0 ? turn_up : turn_down
end
end
#--------------------------------------------------------------------------
def turn_upper_left
unless @direction_fix
@direction = 4 #era 4
@stop_count = 0
end
end
#--------------------------------------------------------------------------
def turn_lower_left
unless @direction_fix
@direction = 4 # era 4
@stop_count = 0
end
end
#--------------------------------------------------------------------------
def turn_upper_right
unless @direction_fix
@direction =6 # era 6
@stop_count = 0
end
end
#--------------------------------------------------------------------------
def turn_lower_right
unless @direction_fix
@direction = 6 # era 6
@stop_count = 0
end
end
#--------------------------------------------------------------------------
def move_forward
case @direction
when 1
move_left (false) #era lower_left
when 2
move_down(false)
when 3
move_down (false) #era lower_right
when 4
move_left(false)
when 6
move_right(false)
when 7
move_up(false) #era upper left
when 8
move_up(false)
when 9
move_right(false) #era upper_right
end
end
#--------------------------------------------------------------------------
def move_random
case rand(8)
when 0
move_down(false) #era lower_left
when 1
move_down(false)
when 2
move_right(false) #era lower_right
when 3
move_left(false)
when 4
move_right(false)
when 5
move_left(false) #era upper left
when 6
move_up(false)
when 7
move_up(false) #era upper_right
end
end
#--------------------------------------------------------------------------
end
#=========================================================
Someone can help me?
Thx!