UltimaForum

Skrypty [XP] - G±sienica II [XP]

Ayene - Nie 25 Kwi, 2010 11:05
Temat postu: G±sienica II [XP]
~ G±sienica II [XP] ~

Krótki opis
Jest to skrypt g±sienicy - podobny do skryptu z tego tematu. Różnica jednak jest taka, że usuwa z g±sienicy bohatera, który nie żyje.

Autor skryptu
fukuyama

Kompatybilno¶ć
Tylko XP

Skrypt
Spoiler:

Kod:
# G±sienica [XP] ~ Train Actor
# Copyright © 2005 fukuyama
# Tłumaczenie by Ayene

#==============================================================================
# KONFIGURACJA
#==============================================================================
module Train_Actor
  # NIWIDZIALNO¦Ć? (true / false)
  # Umożliwia aktywację niewidzialno¶ci bohaterów w g±sienicy
  TRANSPARENT_SWITCH = false
 
  # PRZEَCZNIK NIWIDZIALNO¦CI
  # Kiedy TRANSPARENT_SWITCH jest 'true', po aktywacji tego przeł±cznika
  # bohaterowie w g±sienicy stan± się niewidzialni.
  TRANSPARENT_SWITCHES_INDEX = 20
 
  # MAKSYMALNA ILO¦Ć BOHATERÓW W DRUŻYNIE
  TRAIN_ACTOR_SIZE_MAX = 4
 
  # STAŁE
  DOWN_LEFT = 1
  DOWN_RIGHT = 3
  UP_LEFT = 7
  UP_RIGHT = 9
  JUMP = 5
end

#==============================================================================
# Spriteset_Map_Module
#==============================================================================

module Train_Actor

  module Spriteset_Map_Module
    def setup_actor_character_sprites?
      return @setup_actor_character_sprites_flag != nil
    end
   
    def setup_actor_character_sprites(characters)
      if !setup_actor_character_sprites?
        for character in characters.reverse
          @character_sprites.unshift(
          Sprite_Character.new(@viewport1, character)
          )
        end
        @setup_actor_character_sprites_flag = true
      end
    end
  end 
end

class Spriteset_Map
  include Train_Actor::Spriteset_Map_Module
end

#==============================================================================
# Scene_Map_Module
#==============================================================================

module Train_Actor
  module Scene_Map_Module
    def setup_actor_character_sprites(characters)
      @spriteset.setup_actor_character_sprites(characters)
    end
  end
end

class Scene_Map
  include Train_Actor::Scene_Map_Module
end

#==============================================================================
# Game_Party_Module
#==============================================================================

module Train_Actor
  module Game_Party_Module
    attr_reader :characters
    def actors_dead?     
      for actor in actors
        if actor.dead?
          return true
        end
      end
      return false
    end
   
    def update_party_order
      if not actors_dead?
        return actors
      end
      alive_actors = []
      dead_actors = []
      for actor in actors
        if actor.dead?
          dead_actors.push actor
        else
          alive_actors.push actor
        end
      end
      return alive_actors + dead_actors
    end
   
    def setup_actor_character_sprites
      if @characters.nil?
        @characters = []
        for i in 1 ... TRAIN_ACTOR_SIZE_MAX
          @characters.push(Game_Party_Actor.new)
        end
      end
      setup_actors = update_party_order
      for i in 1 ... TRAIN_ACTOR_SIZE_MAX
        @characters[i - 1].setup(setup_actors[i])
      end
      if $scene.class.method_defined?('setup_actor_character_sprites')
        $scene.setup_actor_character_sprites(@characters)
      end
    end
   
    def update_party_actors
      update_party_order
      setup_actor_character_sprites
      transparent = $game_player.transparent
      if transparent == false
        if TRANSPARENT_SWITCH
        transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
        end
      end
      for character in @characters
        character.transparent = transparent
        character.move_speed = $game_player.move_speed
        character.step_anime = $game_player.step_anime
        character.update
      end
    end
   
    def moveto_party_actors( x, y )
      setup_actor_character_sprites
      for character in @characters
        character.moveto( x, y )
      end
      if @move_list == nil
        @move_list = []
      end
      move_list_setup
    end
   
    def move_party_actors
      if @move_list == nil
        @move_list = []
        move_list_setup
      end
      @move_list.each_index do |i|
      if @characters[i] != nil
        case @move_list[i].type
        when Input::DOWN
          @characters[i].move_down(@move_list[i].args[0])
        when Input::LEFT
          @characters[i].move_left(@move_list[i].args[0])
        when Input::RIGHT
          @characters[i].move_right(@move_list[i].args[0])
        when Input::UP
          @characters[i].move_up(@move_list[i].args[0])
        when DOWN_LEFT
          @characters[i].move_lower_left
        when DOWN_RIGHT
          @characters[i].move_lower_right
        when UP_LEFT
          @characters[i].move_upper_left
        when UP_RIGHT
          @characters[i].move_upper_right
        when JUMP
          @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
        end
      end
    end
  end
 
  class Move_List_Element
    def initialize(type,args)
      @type = type
      @args = args
    end
    def type() return @type end
    def args() return @args end
  end
   
  def move_list_setup
    for i in 0 .. TRAIN_ACTOR_SIZE_MAX
    @move_list[i] = nil
    end
    end
    def add_move_list(type,*args)
    @move_list.unshift(Move_List_Element.new(type,args)).pop
    end
    def move_down_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::DOWN,turn_enabled)
    end
    def move_left_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::LEFT,turn_enabled)
    end
    def move_right_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::RIGHT,turn_enabled)
    end
    def move_up_party_actors(turn_enabled = true)
    move_party_actors
    add_move_list(Input::UP,turn_enabled)
    end
    def move_lower_left_party_actors
    move_party_actors
    add_move_list(DOWN_LEFT)
    end
    def move_lower_right_party_actors
    move_party_actors
    add_move_list(DOWN_RIGHT)
    end
    def move_upper_left_party_actors
    move_party_actors
    add_move_list(UP_LEFT)
    end
    def move_upper_right_party_actors
    move_party_actors
    add_move_list(UP_RIGHT)
    end
    def jump_party_actors(x_plus, y_plus)
    move_party_actors
    add_move_list(JUMP,x_plus, y_plus)
    end
  end
end

class Game_Party
  include Train_Actor::Game_Party_Module
end

#==============================================================================
# Game_Player_Module
#==============================================================================

module Train_Actor
  module Game_Player_Module
    attr_reader :move_speed
    attr_reader :step_anime

    def update_party_actors
      $game_party.update_party_actors
      $game_party.actors.each do |actor|
        if actor.dead?
          next
        end
        @character_name = actor.character_name
        @character_hue = actor.character_hue
        break
      end
    end
    def update
      update_party_actors
      super
    end
   
    def moveto( x, y )
      $game_party.moveto_party_actors( x, y )
      super( x, y )
    end
    def move_down(turn_enabled = true)
      if passable?(@x, @y, Input::DOWN)
        $game_party.move_down_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_left(turn_enabled = true)
      if passable?(@x, @y, Input::LEFT)
        $game_party.move_left_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_right(turn_enabled = true)
      if passable?(@x, @y, Input::RIGHT)
        $game_party.move_right_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_up(turn_enabled = true)
      if passable?(@x, @y, Input::UP)
        $game_party.move_up_party_actors(turn_enabled)
      end
      super(turn_enabled)
    end
    def move_lower_left
      if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
        (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
        $game_party.move_lower_left_party_actors
      end
      super
    end
    def move_lower_right
      if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
        (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
        $game_party.move_lower_right_party_actors
      end
      super
    end
    def move_upper_left
      if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
        (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
        $game_party.move_upper_left_party_actors
      end
      super
    end
    def move_upper_right
      if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
        (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
        $game_party.move_upper_right_party_actors
      end
      super
    end
    def jump(x_plus, y_plus)
      new_x = @x + x_plus
      new_y = @y + y_plus
      if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
        $game_party.jump_party_actors(x_plus, y_plus)
      end
      super(x_plus, y_plus)
    end
  end
end

class Game_Player
  include Train_Actor::Game_Player_Module
end

#==============================================================================
# Game_Event_Module
#==============================================================================

module Train_Actor
  module Game_Event_Module   
    def passable?(x, y, d)
      result = super(x, y, d)
      if result
        new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
        new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
        for actor in $game_party.characters
          if not actor.character_name.empty?
            if actor.x == new_x and actor.y == new_y
              if self != $game_player
                return false
              end
            end
          end
        end
      end
      return result
    end
  end
end

class Game_Event
  include Train_Actor::Game_Event_Module
end

#==============================================================================
# Game_Party_Actor
#==============================================================================

module Train_Actor

  class Game_Party_Actor < Game_Character
    attr_writer :move_speed
    attr_writer :step_anime
   
    def initialize
      super()
      @through = true
    end
    def setup(actor)
      if actor != nil and (not actor.dead?)
        @character_name = actor.character_name
        @character_hue = actor.character_hue
      else
        @character_name = ""
        @character_hue = 0
      end
      @opacity = 255
      @blend_type = 0
    end
   
    def screen_z(height = 0)
      if $game_player.x == @x and $game_player.y == @y
        return $game_player.screen_z(height) - 1
      end
      super(height)
    end
 
    def move_down(turn_enabled = true)
      if turn_enabled
        turn_down
      end
      if passable?(@x, @y, Input::DOWN)
        turn_down
        @y += 1
      end
    end
   
    def move_left(turn_enabled = true)
      if turn_enabled
        turn_left
      end
      if passable?(@x, @y, Input::LEFT)
        turn_left
        @x -= 1
      end
    end
   
    def move_right(turn_enabled = true)
      if turn_enabled
        turn_right
      end
      if passable?(@x, @y, Input::RIGHT)
        turn_right
        @x += 1
      end
    end
   
    def move_up(turn_enabled = true)
      if turn_enabled
        turn_up
      end
      if passable?(@x, @y, Input::UP)
        turn_up
        @y -= 1
      end
    end
   
    def move_lower_left
      unless @direction_fix
        @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
      end
      if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
        (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
        @x -= 1
        @y += 1
      end
    end
   
    def move_lower_right
      unless @direction_fix
        @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
      end
      if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
        (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
        @x += 1
        @y += 1
      end
    end
   
    def move_upper_left
      unless @direction_fix
        @direction = (@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
      end
      if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
        (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
        @x -= 1
        @y -= 1
      end
    end
   
    def move_upper_right
      unless @direction_fix
        @direction = (@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
      end
      if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
        (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
        @x += 1
        @y -= 1
      end
    end
  end
end


Demo
niepotrzebne

Screenshot
Spoiler:


Instrukcja
1. Wklej skrypt nad "Main" w Edytorze Skryptu.
2. Reszta instrukcji znajduje się w tre¶ci skryptu.

Piszcie w razie problemów.

HESEE - Nie 25 Kwi, 2010 13:11

To działa i jest dobre ale
np. mam g±sienice i ABS ale jak atakuje stworka to ta druga osoba sobie stoi i czeka dopiero można ni± zaatakować kiedy tamta zginie.
Help może jest jaki¶ skrypt na to?

Ayene - Nie 25 Kwi, 2010 17:54

Nie ma, to już bł±d kompatybilno¶ci. ABS, z którego korzystasz zapewne ma już wbudowan± g±sienice (co¶ podobnego), w której bohaterowie poruszaj± się w różny sposób - zależny od sytuacji, bo albo id± przy Tobie, albo atakuj± stwory, albo wracaj± do Ciebie. Dlatego ten skrypt nie jest wskazany przy ABS'ie.
Czeliosss - Nie 25 Kwi, 2010 18:01

W Mr.Mo ABS nie ma g±sienicy. Sam kiedy¶ go używałem.
Co do skryptu to ¶wietny. Na pewno go użyję.
Pzdr.

HESEE - Nie 25 Kwi, 2010 18:05

A jest może takie co¶ że w menu się wybiera który będzie atakował
kiedy¶ taki co¶ wydziałem ale już nie pamiętam.

Ayene - Nie 25 Kwi, 2010 18:07

HESEE, daj linka do swojego ABS'a... w wolnej chwili sprawdzę, o co chodzi.
HESEE - Nie 25 Kwi, 2010 18:12

http://www.rmxpunlimited....ads&showfile=75
Ayene - Wto 27 Kwi, 2010 09:52

HESEE, to w takim razie nic nie poradzę. To taka specyfika skryptu. Osoby do pomocy deklaruje się za pomoc± komentarzy...
Faktycznie można zrobić skrypt, który będzie zmieniał kolejno¶ć bohaterów w menu, ale to już jest zamówienie. Je¶li chcesz to możesz założyć nowy temat w odpowiednim dziale, a wtedy na pewno kto¶ taki skrypt napisze albo poda linka do gotowca.

HESEE - Sob 01 Maj, 2010 13:56

Da rade jako¶ skonfigurować t± g±sienice ponieważ mam ring menu i jak kliknę esc to postacie znikaj± tylko pozostaje główna.
Może to jest wina ring menu.

Ayene - Sob 01 Maj, 2010 14:54

Tak to wina Ring menu. Wejdż w skrypt i znajdĽ:
Kod:
@spriteset = Spriteset_Map.new

po tym dodaj:
Kod:
@spriteset.setup_actor_character_sprites($game_party.characters)

HESEE - Sob 01 Maj, 2010 20:51

Ale jak kliknę Esc to jest ok nie znikaj± ale jak wyjdę z tego to oni na sec. albo krócej znikaj± i się pojawiaj±.
Ayene - Nie 02 Maj, 2010 11:45

To wejdĽ w Scene_Map i też znajdĽ:
Kod:
@spriteset = Spriteset_Map.new

po tym dodaj:
Kod:
@spriteset.setup_actor_character_sprites($game_party.characters)

HESEE - Nie 02 Maj, 2010 11:50

Dzięki działa już wszystko.
shiwt - Wto 10 Sie, 2010 14:28

sorry że od¶wieżam, ale jak zrobić, żeby oni byli widzialni. Tzn, że jak ich dotknę to nie mogę przez nich przej¶ć. Jak ustawiam TRANSPARENT_SWITCH na false to nie działa :/
I jeszcze jedno. Jaka jest w tym skrypcie komenda na warunek czy dotkniemy t± g±sienicę. Chodzi mi oto:
if dotykamy g±sienicę?
Show text: co¶ tam
end

Jest mi to bardzo potrzebne ;) Proszę o pomoc jak najszybsz±.

Yoroiookami - Wto 17 Sie, 2010 11:41

Czy w skrypcie osoby które za nami id± maj± jakie¶ ID? >_>
Bo nie mog± mieć 1,2,3 i tak dalej...w końcu na mapie s± inne zdarzenia o tym samym ID.

Pomoże kto¶? :roll:

Ayene - Wto 17 Sie, 2010 13:37

Nie maj± ID jako zdarzenia. To tylko grafika.
janczar1212 - Pi± 25 Lut, 2011 16:08

Fajny skrypt, na pewno mi się przyda do mojej gry. ;-)
¦liwka - Pon 16 Maj, 2011 17:08

Ten skrypt jest ¶wietny, thanks :)
mic2311 - Sob 20 Sie, 2011 15:22

Ja nie wiem jak wł±czyć niewidzialno¶ć tych postaci podczas gry???
Domilos - Sob 20 Sie, 2011 16:46


Pepczak - Nie 28 PaĽ, 2012 19:50
Temat postu: Re: G±sienica II [XP]
A ja mam pytanie. Czy da się zrobić co¶ takiego, żęby odległo¶ci pomiędzy postaciami były wieksze?
Nex - Pon 29 PaĽ, 2012 07:32

raczej nie :-/

Powered by phpBB modified by Przemo © 2003 phpBB Group