PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Move at Event



OneEyeShadow
18.06.2009, 15:20
Hallo, es gibt ja den Move befehl: Move to Player, lässt sich sowas auch zu einem bestimmten Event machen, also, dass das Event nicht zum Spieler sondern zu einem bestimmten Event geht?

Shining Advances
18.06.2009, 16:24
du kannst die koordinaten des events einfach in einer variable speichern und diese dann als ziel koordinaten des teleports benutzen.

edit:
ah sry wohl nen bisl falsch verstanden
dachte du meintest set event location

Kelven
18.06.2009, 17:32
Ich denke OneEyeShadow meint eher "Move toward player" für ein beliebiges Event. Hab mal die "Move toward player"-Methode adaptiert. Vielleicht geht es aber noch besser.



class Game_Character
def move_to_event(event_id)
# Get difference in event coordinates
sx = @x - $game_map.events[event_id].x
sy = @y - $game_map.events[event_id].y
# If coordinates are equal
if sx == 0 and sy == 0
return
end
# Get absolute value of difference
abs_sx = sx.abs
abs_sy = sy.abs
# If horizontal and vertical distances are equal
if abs_sx == abs_sy
# Increase one of them randomly by 1
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
# If horizontal distance is longer
if abs_sx > abs_sy
# Move towards event, prioritize left and right directions
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
# If vertical distance is longer
else
# Move towards event, prioritize up and down directions
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
end
end


Aufgerufen wird sie durch:

$game_map.events[Nr. des Events].move_to_event(Nr. des Zieles)

OneEyeShadow
18.06.2009, 17:54
Hey, danke für das Skript, werds gleich mal ausprobieren.