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...
_________________
_________________
_________________
Pomógł: 3 razy Dołączył: 22 Gru 2009 Posty: 262 Skąd: Warszawa
Wysłany: Sro 10 Lut, 2010 16:10
Mam jeden problem. Kiedy idÄ w kierunku PĂłĹnocno-wschodnim/zachodnim lub PoĹudniowo-wschodnim/zachodnim to wyĹwietla mi siÄ bĹÄ d, nie wiem co zrobiÄ.
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...
Mam pytanie czy ten skrypt da rade tak przerobiÄ aby dziaĹaĹ na systemie z myszkÄ bo mi wtedy postaÄ na myszce nie chce chodziÄ a na strzaĹki tak.
________________________ http://www.poomoc.pl/
Kilka klikniÄÄ a pomoĹźesz innym!
Czy naprawdÄ to jest duĹźa strata czasu?
W ten sposĂłb pomoĹźesz innym!
________________________ http://www.poomoc.pl/
Kilka klikniÄÄ a pomoĹźesz innym!
Czy naprawdÄ to jest duĹźa strata czasu?
W ten sposĂłb pomoĹźesz innym!
________________________ http://www.poomoc.pl/
Kilka klikniÄÄ a pomoĹźesz innym!
Czy naprawdÄ to jest duĹźa strata czasu?
W ten sposĂłb pomoĹźesz innym!
Pomagam bezinteresownie!
Ostatnio zmieniony przez Nhadala Sob 01 Maj, 2010 09:46, w całości zmieniany 1 raz
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