Pomógł: 1 raz Dołączył: 21 Gru 2009 Posty: 85 Skąd: Nie pamiętam
Wysłany: Sro 20 Sty, 2010 23:57
Chodzenie w 8 kierunkach
~ Chodzenie w 8 kierunkach XP ~
Krótki opis
Skrypt umożliwia chodzenie po mapie w 8 kierunkach.
Autor skryptu
nieznany
Kompatybilność
Tylko XP
Skrypt
Spoiler:
Kod:
#----------------------------------------------------------------------------
# Chodzenie w 8 kierunkach [XP]
# Autor: nieznany
#----------------------------------------------------------------------------
# Instalacja: Umieść skrypt nad Main
#----------------------------------------------------------------------------
class Game_Player < Game_Character
CENTER_X = (320 - 16) * 4
CENTER_Y = (240 - 16) * 4
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
unless $game_map.valid?(new_x, new_y)
return false
end
if $DEBUG and Input.press?(Input::CTRL)
return true
end
super
end
def center(x, y)
max_x = ($game_map.width - 20) * 128
max_y = ($game_map.height - 15) * 128
$game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max
$game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max
end
def moveto(x, y)
super
center(x, y)
make_encounter_count
end
def increase_steps
super
unless @move_route_forcing
$game_party.increase_steps
if $game_party.steps % 2 == 0
$game_party.check_map_slip_damage
end
end
end
def encounter_count
return @encounter_count
end
def make_encounter_count
if $game_map.map_id != 0
n = $game_map.encounter_step
@encounter_count = rand(n) + rand(n) + 1
end
end
def refresh
if $game_party.actors.size == 0
@character_name = ""
@character_hue = 0
return
end
actor = $game_party.actors[0]
@character_name = actor.character_name
@character_hue = actor.character_hue
@opacity = 255
@blend_type = 0
end
def check_event_trigger_here(triggers)
result = false
if $game_system.map_interpreter.running?
return result
end
for event in $game_map.events.values
if event.x == @x and event.y == @y and triggers.include?(event.trigger)
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
def check_event_trigger_there(triggers)
result = false
if $game_system.map_interpreter.running?
return result
end
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
for event in $game_map.events.values
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
if result == false
if $game_map.counter?(new_x, new_y)
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
for event in $game_map.events.values
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
def check_event_trigger_touch(x, y)
result = false
if $game_system.map_interpreter.running?
return result
end
for event in $game_map.events.values
if event.x == x and event.y == y and [1,2].include?(event.trigger)
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
return result
end
def update
last_moving = moving?
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
case Input.dir8
when 2
$game_actors[1].set_graphic("001-Fighter01",0,"001-Fighter01",0)
$game_player.refresh
move_down
when 4
$game_actors[1].set_graphic("001-Fighter01",0,"001-Fighter01",0)
$game_player.refresh
move_left
when 6
$game_actors[1].set_graphic("001-Fighter01",0,"001-Fighter01",0)
$game_player.refresh
move_right
when 8
$game_actors[1].set_graphic("001-Fighter01",0,"001-Fighter01",0)
$game_player.refresh
move_up
when 1
$game_actors[1].set_graphic("3",0,"001-Fighter01",0)
$game_player.refresh
move_lower_left
when 3
$game_actors[1].set_graphic("4",0,"001-Fighter01",0)
$game_player.refresh
move_lower_right
when 7
$game_actors[1].set_graphic("2",0,"001-Fighter01",0)
$game_player.refresh
move_upper_left
when 9
$game_actors[1].set_graphic("1",0,"001-Fighter01",0)
$game_player.refresh
move_upper_right
end
end
last_real_x = @real_x
last_real_y = @real_y
super
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
$game_map.scroll_down(@real_y - last_real_y)
end
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
$game_map.scroll_left(last_real_x - @real_x)
end
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
$game_map.scroll_right(@real_x - last_real_x)
end
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
$game_map.scroll_up(last_real_y - @real_y)
end
unless moving?
if last_moving
result = check_event_trigger_here([1,2])
if result == false
unless $DEBUG and Input.press?(Input::CTRL)
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
if Input.trigger?(Input::C)
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end
Demo
Dodatki
Skrypt wymaga umieszczenia w folderze Graphics/Characters poniższych obrazków:
Spoiler:
1.png
2.png
3.png
4.png
Instrukcja
1. Wklej skrypt nad "Main" w Edytorze Skryptu.
2. Reszta instrukcji znajduje się w treści skryptu.
// Post edytowany przez Ayene
________________________ _________________
_________________
Jak kraść to milinony...
Jak ruchać to księżniczki...
_________________
_________________
_________________
Pomogła: 232 razy Dołączyła: 18 Wrz 2007 Posty: 2424
Wysłany: Sob 13 Lut, 2010 19:55
Wyświetla komunikat o błędzie, bo spino333 nie dodał, że do skryptu wymagane jest umieszczenie w folderze Graphics/Characters dodatkowych obrazków, 1.png, 2.png, 3.png i 4.png, które są grafikami postaci, gdy idzie w innym niż domyślnie kierunku.
Pomogła: 232 razy Dołączyła: 18 Wrz 2007 Posty: 2424
Wysłany: Nie 14 Lut, 2010 18:15
Malian, a po co masz obrabiać? Ten skrypt automatycznie nadaje wygląd postaci, która chodzi po mapie. Niezależnie od tego kogo będziesz miał w drużynie i tak po mapie będziesz chodził "001-Fighter01".
Musicie zmienić tylko nazwy obrazków na zwykle cyfry jak pójdziecie na północny wschód wyskoczy wam błąd z numerem wtedy wstawcie nazwę numeru w odpowiedni obrazek i tak każdy kierunek i po problemie...
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum