Aldeia RPG

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Suporte ao desenvolvimento de jogos


3 participantes

    LM² - Input Action

    LeonM²
    LeonM²
    Lenda
    Lenda


    Mensagens : 1802
    Créditos : 153

    LM² - Input Action Empty LM² - Input Action

    Mensagem por LeonM² Qui Out 22, 2020 9:32 pm

    LM² - Input Action
    Uma edição simples que permite separar interação com eventos do botão de ataque.


    Como instalar:
    Cliente:
    Para instalar é bem simples, insira no módulo [VS] Configs no cliente o seguinte código.
    Código:
     # Tecla de Ação
      ACTION_KEY = :LETTER_E #LM² - Input Action
      ACTION_TIME = 0.5

    De preferencia abaixo de: 

     # Tecla de ataque
     ATTACK_KEY = :CTRL
    Vá para o script [VS] Enums, abaixo de:
    NET_SWITCHES
    Insira:
    Código:
    PLAYER_ACTION
    Vá para o script [VS] Send_Data, abaixo de:
     def send_player_attack
       return unless @socket
       buffer = Buffer_Writer.new
       buffer.write_byte(Enums::Packet::PLAYER_ATTACK)
       @socket.send(buffer.to_s)
     end
    Insira:
    Código:
     #LM² - Input Action
      def send_player_action
        return unless @socket
        buffer = Buffer_Writer.new
        buffer.write_byte(Enums::Packet::PLAYER_ACTION)
        @socket.send(buffer.to_s)
      end
    Vá para o script [VS] Game_Player, abaixo de:

    select_nearest_enemy if Input.trigger?(Configs::SELECT_ENEMY_KEY)
    Coloque:
    Código:
    $network.send_player_action if Input.press?(Configs::ACTION_KEY) && !$game_map.interpreter.running? && !$typing #LM² - Input Action
    Vá para o script [VS] Window_Message, troque:
    @show_fast = true if Input.trigger?(Configs::ATTACK_KEY)
    Por:
    Código:
    @show_fast = true if Input.trigger?(Configs::ACTION_KEY) #LM² - Input Action
    Vá até o script [VS] Sprite_Character, procure por def create_tip, troque a linha:

    tip = "#{Vocab::Press} #{Configs::ATTACK_KEY.to_s.gsub('LETTER_', '').capitalize}"

    Por:

    Código:
    tip = "#{Vocab::Press} #{Configs::ACTION_KEY.to_s.gsub('LETTER_', '').capitalize}" #LM² - Input Action

    Servidor:
    Para instalar é bem simples, vá ao script handle_data.rb. Abaixo de:
       when Enums::Packet::PLAYER_ATTACK
         handle_player_attack(client)
    Insira:
    Código:
       when Enums::Packet::PLAYER_ACTION #LM² - Input Action
          handle_player_action(client) #LM² - Input Action
    Ainda nesse mesmo script, troque:
     def handle_player_attack(client)
       return if client.attacking?
       if client.using_range_weapon?
         client.attack_range
       elsif client.using_normal_weapon?
         client.attack_normal
       end
       # Interage com evento embaixo e em frente independentemente de
       #o jogador ter atacado algum inimigo
       if client.movable?
         client.check_event_trigger_here([0])
         client.check_event_trigger_there([0, 1, 2])
       end
     end
    Por:
    Código:
     def handle_player_attack(client)
        return if client.attacking?
        if client.using_range_weapon?
          client.attack_range
        elsif client.using_normal_weapon?
          client.attack_normal
        end
      end
      #LM² - Input Action
      def handle_player_action(client)
        return if client.interacting?
        # Interage com evento embaixo e em frente independentemente de
        #o jogador ter atacado algum inimigo
        if client.movable?
          client.check_event_trigger_here([0])
          client.check_event_trigger_there([0, 1, 2])
        end
        client.interaction_time = Time.now + Configs::ACTION_TIME
      end
    Vá ao script game_client.rb, abaixo de: 
    attr_accessor :guild
    Coloque:
    Código:
      attr_accessor :interaction_time #LM² - Input Action
    Ainda nesse mesmo script, abaixo de:
    def attacking?
       @weapon_attack_time > Time.now
    end
    Coloque 
    Código:
      #LM² - Input Action
      def interacting?
        @interaction_time > Time.now
      end
    Vá em game_account.rb, abaixo de:
    @weapon_attack_time = Time.now
    Coloque:
    Código:
    @interaction_time = Time.now #LM² - Input Action
    Log:
    22/10/2020 - Tópico Criado
    19/11/2020 - Adicionado Cooldown para evitar spam.
    05/04/2021 - Atualizado uma falha que poderia levar a bugs
    Agradecimentos:

    Valentine pelo VXA-OS.
    LeonM² por fazer essa modificação.

    Qualquer erro ou duvida, comentar no tópico ou deixar no server do VXA-OS.


    Última edição por LeonM² em Seg Abr 05, 2021 11:44 am, editado 3 vez(es)

    Valentine, DevWithCoffee e Kincy gostam desta mensagem

    Kincy
    Kincy
    Membro Ativo
    Membro Ativo


    Mensagens : 288
    Créditos : 31

    Ficha do personagem
    Nível: 1
    Experiência:
    LM² - Input Action Left_bar_bleue0/0LM² - Input Action Empty_bar_bleue  (0/0)
    Vida:
    LM² - Input Action Left_bar_bleue30/30LM² - Input Action Empty_bar_bleue  (30/30)

    LM² - Input Action Empty Re: LM² - Input Action

    Mensagem por Kincy Qui Out 22, 2020 11:11 pm

    Mais uma excelente contribuição para o desenvolvimento de jogos, parabéns!
    Valentine
    Valentine
    Administrador
    Administrador


    Medalhas : LM² - Input Action ZgLkiRU
    Mensagens : 5336
    Créditos : 1163

    LM² - Input Action Empty Re: LM² - Input Action

    Mensagem por Valentine Sex Out 23, 2020 10:09 am

    Boa.

    + 1 crédito
    LeonM²
    LeonM²
    Lenda
    Lenda


    Mensagens : 1802
    Créditos : 153

    LM² - Input Action Empty Re: LM² - Input Action

    Mensagem por LeonM² Qui Nov 19, 2020 8:58 am

    Tópico atualizado com melhoria do sistema, adicionado um Cooldown para evitar spam.
    LeonM²
    LeonM²
    Lenda
    Lenda


    Mensagens : 1802
    Créditos : 153

    LM² - Input Action Empty Re: LM² - Input Action

    Mensagem por LeonM² Seg Abr 05, 2021 11:44 am

    Atualizado, uma falha que poderia levar a bugs

    Conteúdo patrocinado


    LM² - Input Action Empty Re: LM² - Input Action

    Mensagem por Conteúdo patrocinado


      Data/hora atual: Sex Abr 19, 2024 2:56 pm