2 Prośby: Waga i Strzały
Aktualny czas: 28-04-26, 18:09 Witaj! Przejdź do zakładki Logowanie lub Rejestracja


Wątek zamknięty 
[VXAce] 2 Prośby: Waga i Strzały
Sharkingv2 Offline
*


Liczba postów: 79
Dołączył: 29-03-17

Pomógł: 0



Post: #4
RE: 2 Prośby: Waga i Strzały

Yoroiookami napisał(a):Amunicja:
http://rmrk.net/index.php?topic=45699.0

Co do wagi przedmiotu, to ten skrypt wydaje mi się lepszy:
#=======================================================
#         Lune Item Weight
# Author : Raizen
# Script Function:
# The scripts adds the function of items having weight on the game,
# Basically all item have weights and they can only be carried if below the limit
#=======================================================


module Lune_Weight
#=============================================================================#
#=========================   General Settings   ==============================#
#=============================================================================#

# To configure a weight for an item, go to Database,
# Inside the notetags after choosing an item or equipe, put the following.
# <weight n> where n is the weight value,
# Example an item weighting 60,
# <weight 60>

# In case there are no notetags on the Item, the script will
# choose a default value which is:

Default = 50

# Receive even if over weight?
# To prevent from the actor receiving important itens through the game,
# you can allow the player to receive itens even if they are over the
# weight limit.
Receive = true
# If false, you need to know how to event the important itens, putting
# conditions so that importat itens are not left out without being received.

# In case they are over the weight limit, you can lock the character movement.
Travar = true

# Below the variables that you can use to make the event conditions:

# Choose a variable to receive the value of amount of weight carried.
Var_C = 5
# Choose a variable to receive the value of amount of the weight limit.
Var_M = 6
# With both variables you can event the conditions of receiving items or even
# event conditions considering the weight carried and limit.

LimiteB = 8000 # Configure if you are using Lune Item Vault (My vault script)
# to have no limite, LimiteB = ""
#=============================================================================#
#=====================   Limit Weight Configuration   ========================#
#=============================================================================#

# Maximum amount of weight carried,
# to configure the weight limit, you can put a variable value, a constant value
# or strength value.
# To put the main actor strength value => :for1
# To put the sum of actors strength value => :all_for
# To be the main actor level => :lvl1
# To be the sum of all actors level => :all_lvl
# To be a variable => :var
# To be a constant => :fix


# Exemple Carry_Limit = lvl1 will make only the strength of the
# first actor to be put in the formula.
Carry_Limit = :all_for

# Now you need to configure the formula of the weight limit,
# Exemple, if I want to the limit be 2 times all the party members strength

# def self.weight_formula(at)
#   at * 2
# end

# at is the value of the atribute, and the multiply by 2 to get the total limit.

# In case its a variable or a constant number, just put the
# variable number, or the constant number.

# Exemple:

# def self.weight_formula(at)
#   20
# end

# The limit will be variable 20, ou if chosen a constant, will be 20.


def self.weight_formula(at)
  at * 2 + 1000
end


#===================== Vocabulary Settings ==========================#
# To Vocab, always put the text between commas '', or "".
# Weight name,
PS = ' Oz'

# Vocab on menu and shop
# Weight:
Peso = 'Weight:'

#Carrying =
Carregando = 'Carrying: '

# If Lune Vault System included
# Vault =
Bau = 'In Vault: '

# Vocabulary on item window

# Use =
Usar = 'Use'
# Dispose =
Descartar = 'Throw Away'

#=============================================================================#
#========================== Here starts the script ===========================#
#=============================================================================#

  #--------------------------------------------------------------------------
  # * Calculo do limite de peso
  #--------------------------------------------------------------------------
  def self.weight_limit
    return unless $game_party.members[0]
    case Carry_Limit
    when :for1
      weight = weight_formula($game_party.members[0].param(2))
    when :all_for
      weight = 0
      for members in 0...$game_party.members.size - 1
        weight += weight_formula($game_party.members[members].param(2))
      end
    when :lvl1
      weight = weight_formula($game_party.members[0].level)
    when :all_lvl
      weight = 0
      for members in 0...$game_party.members.size - 1
        weight += weight_formula($game_party.members[members].level)
      end
    when :fix
      weight = weight_formula(0)
    when :var
      weight = $game_variables[weight_formula(0)]
    end
    $game_variables[Var_M] = weight
    weight
  end
end



#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Esta classe gerencia o grupo. Contém informações sobre dinheiro, itens.
# A instância desta classe é referenciada por $game_party.
#==============================================================================

class Game_Party < Game_Unit
alias :lune_weight_gain :gain_item
  #--------------------------------------------------------------------------
  # * Quantidade de itens carregados mais os itens equipados
  #--------------------------------------------------------------------------
  def carried_items
    @all_carried_items = 0
    all_items.each {|item| get_weight(item)}
    for i in 0...4
      members.each {|actor| @all_carried_items += calc_weight(actor.equips[i], 1)}
    end
    $game_variables[Lune_Weight::Var_C] = @all_carried_items
    @all_carried_items
  end
  #--------------------------------------------------------------------------
  # * Calculo do peso de um item no inventário
  #--------------------------------------------------------------------------
  def get_weight(item)
    if item.note =~ /<weight (.*)>/i
      @all_carried_items += $1.to_i * item_number(item)
    else
      @all_carried_items += Lune_Weight::Default * item_number(item)
    end
  end
  #--------------------------------------------------------------------------
  # * Calculo do peso de um item relativo a quantidade
  #--------------------------------------------------------------------------
  def calc_weight(item, amount)
    return 0 unless item
    if item.note =~ /<weight (.*)>/i
      carried_itens = $1.to_i * amount
    else
      carried_itens = Lune_Weight::Default * amount
    end
    carried_itens
  end
  #--------------------------------------------------------------------------
  # * Acrescentar item (redução)
  #     item          : item
  #     amount        : quantia alterada
  #     include_equip : incluir itens equipados
  #--------------------------------------------------------------------------
  def gain_item(item, amount, include_equip = false)
    if Lune_Weight::Receive
      lune_weight_gain(item, amount, include_equip = false)
      return
    end
    return if item == nil
    weight = calc_weight(item, amount) + carried_items
    while weight > Lune_Weight.weight_limit
      amount -= 1
      weight = calc_weight(item, amount) + carried_items
      return if amount == 0
    end
    lune_weight_gain(item, amount, include_equip = false)
  end
end

#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
#  Esta classe executa o processamento da tela de loja.
#==============================================================================

class Scene_Shop < Scene_MenuBase
alias :lune_max_buy :max_buy
  #--------------------------------------------------------------------------
  # * Aquisição do número máximo disponível para compra
  #--------------------------------------------------------------------------
  def max_buy
    max = lune_max_buy
    weight = $game_party.calc_weight(@item, max) + $game_party.carried_items
    while weight > Lune_Weight.weight_limit && max > 0
      max -= 1
      weight = $game_party.calc_weight(@item, max) + $game_party.carried_items
    end
    max
  end
  #--------------------------------------------------------------------------
  # * Criação da janela de ajuda.
  #--------------------------------------------------------------------------
  def create_help_window
    @help_window = Window_Weight_Help.new
    @help_window.viewport = @viewport
    @get_item_num = $game_party.carried_items
  end
  #--------------------------------------------------------------------------
  # * Atualização da janela de peso
  #--------------------------------------------------------------------------
  def update
    super
    if @get_item_num != $game_party.carried_items
      @help_window.refresh
      @get_item_num = $game_party.carried_items
    end
  end
end

#==============================================================================
# ** Window_ShopBuy
#------------------------------------------------------------------------------
#  Esta janela exibe bens compráveis na tela de loja.
#==============================================================================

class Window_ShopBuy < Window_Selectable
alias :lune_enable_item :enable?
  #--------------------------------------------------------------------------
  # * Definição de habilitação do item
  #     item : item
  #--------------------------------------------------------------------------
  def enable?(item)
    return false if $game_party.calc_weight(item, 1) + $game_party.carried_items > Lune_Weight.weight_limit
    lune_enable_item(item)
  end
end


#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
#  Esta janela exibe explicação de habilidades e itens e outras informações.
#==============================================================================

class Window_Weight_Help < Window_Base
include Lune_Weight
  #--------------------------------------------------------------------------
  # * Inicialização do objeto
  #     line_number : número de linhas
  #--------------------------------------------------------------------------
  def initialize(line_number = 2, bau = false)
    @bau = bau
    super(0, 0, Graphics.width, fitting_height(line_number))
  end
  #--------------------------------------------------------------------------
  # * Configuração de texto
  #     text : texto
  #--------------------------------------------------------------------------
  def set_text(text)
    if text != @text
      @text = text
      refresh
    end
  end
  def on_bau(bau = false)
    @bau = bau
  end
  #--------------------------------------------------------------------------
  # * Limpeza
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # * Definição de item
  #     item : habilidades, itens, etc.
  #--------------------------------------------------------------------------
  def set_item(item)
    @item = item
    set_text(item ? item.description : "")
  end
  #--------------------------------------------------------------------------
  # * Renovação
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text_ex(4, 0, @text)
    if @item
      text = Peso + $game_party.calc_weight(@item,1).to_s + PS
      draw_text(4, line_height, 200, line_height, text, 0)
      if @bau == true
        LimiteB == "" ? text_lim = "????" : text_lim = LimiteB
        text = Bau + $game_party.items_on_vault.to_s + "/" + text_lim.to_s + PS
      else
        text = Carregando + $game_party.carried_items.to_s + "/" + Lune_Weight.weight_limit.to_s + PS
      end
      draw_text(- 20, line_height, Graphics.width, line_height, text, 2)
    end
  end
end


#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  Esta classe gerencia o jogador.
# A instância desta classe é referenciada por $game_player.
#==============================================================================

class Game_Player < Game_Character
alias :lune_move_by :move_by_input
  #--------------------------------------------------------------------------
  # * Processamento de movimento através de pressionar tecla
  #--------------------------------------------------------------------------
  def move_by_input
    return if Lune_Weight::Travar && $game_party.carried_items > Lune_Weight.weight_limit
    lune_move_by
  end
end


#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  Esta classe executa o processamento da tela de item.
#==============================================================================
class Scene_Item < Scene_ItemBase
alias raizen_combine_start start
  def start
    raizen_combine_start
    @combine_item = Window_Item_Combine.new
    @combine_item.viewport = @viewport
    @combine_item.set_handler(:new_game, method(:command_use))
    @combine_item.set_handler(:continue, method(:command_combine))
  end
  def on_item_ok
    if item == nil
      @item_window.activate
      return
    end
    if @combine_item.close?
      @combine_item.open
      @combine_item.activate
    else
      determine_item    
    end
  end

  def update
    super
    if @number_window and @number_window.nitens == true
        @number_window.nitens = false
        @combine_item.close
        @item_window.refresh
        @help_window.refresh
        @item_window.activate
    end
    if Input.trigger?(:B) and !@combine_item.close?
      Sound.play_cancel
      if @number_window and !@number_window.close?
        @number_window.close
        @combine_item.activate
      else
        @combine_item.close
        @item_window.activate
      end
    end
  end
  def command_use
    determine_item
  end

  def command_combine
    if @number_window and !@number_window.close?
      @combine_item.activate
      return
    end
    @number_window = Window_NumberInputInner.new(Window_Base.new(0,0,0,0), item, @item_window.index)
    @number_window.viewport = @viewport
    @number_window.start
  end
  def create_help_window
    @help_window = Window_Weight_Help.new
    @help_window.viewport = @viewport
  end
end

#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  Esta janela exibe os parâmetros dos membros do grupo na tela de menu.
#==============================================================================

class Window_Item_Combine < Window_Command
include Lune_Weight
  #--------------------------------------------------------------------------
  # * Inicialização do objeto
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    self.z = 9999
    self.x = (Graphics.width / 2) - (window_width / 2)
    self.y = Graphics.height / 2
    self.openness = 0
  end
  #--------------------------------------------------------------------------
  # * Aquisição da largura da janela
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Criação da lista de comandos
  #--------------------------------------------------------------------------
  def make_command_list
    add_main_commands

  end
  #--------------------------------------------------------------------------
  # * Adição dos comandos principais
  #--------------------------------------------------------------------------
  def add_main_commands
    add_command(Usar,   :new_game,   true)
    add_command(Descartar,  :continue,  true)
  end
end




#==============================================================================
# ** Scene_ItemBase
#------------------------------------------------------------------------------
#  Esta é a superclasse das classes que executam as telas de itens e
# habilidades.
#==============================================================================

class Scene_ItemBase < Scene_MenuBase
  def determine_item
    @combine_item.close
    if item.is_a?(RPG::Item) and item.for_friend?
      show_sub_window(@actor_window)
      @actor_window.select_for_item(item)
    else
      item.is_a?(RPG::Item) ? use_item : Sound.play_buzzer
      activate_item_window
    end
  end
end

#==============================================================================
# ** Window_NumberInputInner
#------------------------------------------------------------------------------
#  Esta janela é utilizada para o comando de eventos [Armazenar Número]
#==============================================================================

class Window_NumberInputInner < Window_NumberInput
attr_accessor :nitens
def initialize(message_window, item, index_2)
  @index_2 = index_2
  @item = item
  @get_lost_itens = 0
  super(message_window)
end
  #--------------------------------------------------------------------------
  # * Inicialização do processo
  #--------------------------------------------------------------------------
  def start
    @digits_max = 2
    @number = @get_lost_itens
    @number = [[@number, 0].max, 10 ** @digits_max - 1].min
    @index = 0
    update_placement
    create_contents
    refresh
    open
    activate
  end
  #--------------------------------------------------------------------------
  # * Atualização da posição da janela
  #--------------------------------------------------------------------------
  def update_placement
    self.width = @digits_max * 20 + padding * 2
    self.height = fitting_height(1)
    self.x = (Graphics.width - width) / 2
    self.y = Graphics.height/2 - height
    self.z = 150
  end

  #--------------------------------------------------------------------------
  # * Definição de resultado ao pressionar o botão de confirmação
  #--------------------------------------------------------------------------
  def process_ok
    Sound.play_ok
    number = $game_party.item_number(@item)
    if @number <= number
    make_icon
    end
    deactivate
    @nitens = true
    close
  end
  def make_icon
    @nitens = true
    $game_party.lose_item(@item, @number)
  end
end

#==============================================================================
# ** Window_ItemList
#------------------------------------------------------------------------------
#  Esta janela exibe a lista de itens possuidos na tela de itens.
#==============================================================================

class Window_ItemList < Window_Selectable
  #--------------------------------------------------------------------------
  # * Definição de habilitação do item
  #     item : item
  #--------------------------------------------------------------------------
  def enable?(item)
    true
  end
end

$lune_weight_script = true
Aby ustawić wagę przedmiotu, wchodzisz w bazę danych w przedmioty lub w opancerzenie i wstawiasz w notatkach "<weight n>". N to twoja waga, czyli na przykład "<weight 1>".
Powstrzymałbym się od bawienia się przecinkami w stylu wagi 0.5, bo nie jestem pewien czy zadziała. Szczególnie, że nie ma ku temu powodu bo limit możesz ustalić jaki ci się podoba.

"Default = 50" powyżej w skrypcie masz taką ustawioną domyślną wagę przedmiotów, które zapomnisz ustawić. Zmień wedle upodobania. smiles

# Choose a variable to receive the value of amount of weight carried.
Var_C = 5
# Choose a variable to receive the value of amount of the weight limit.
Var_M = 6

W zmiennej 5 będzie przechowywana wartość twojej obecnej wagi. A w zmiennej 6 będzie przechowywany limit wagi. Możesz ustawić, jakie zmienne wolisz.

# Receive even if over weight?
# To prevent from the actor receiving important itens through the game,
# you can allow the player to receive itens even if they are over the
# weight limit.
Receive = true

Czy gracz będzie dalej mógł podnosić przedmioty po przekroczeniu wagi? Jeżeli tak, to zostaw jak jest. Jeżeli nie, to zmień true na false.

# In case they are over the weight limit, you can lock the character movement.
Travar = true

Jeżeli gracz przekroczy limit wagi, możesz zatrzymać poruszanie się. Jeżeli tak chcesz, to zostaw true, jeżeli nie to zmień na false.

A żeby ustawić limit wagi możesz wywołać skrypt podczas gry i wpisać:
"Carry_Limit = :all_for"
Przynajmniej według instrukcji, bo pewności nie mam. :lol2:
Może ktoś jeszcze wyjaśni co autor miał na myśli.
I zależnie od czego ma zależeć limit wagi, wpisujesz jedną z tych rzeczy.
Siła (strength) pierwszego bohatera => :for1
Sila wszystkich bohaterów łącznie => :all_for
Poziom głównego bohatera => :lvl1
Łączne poziomy wszystkich bohaterów => :all_lvl
Zmienna => :var
Stała => :fix

Na przykład jeżeli chcemy żeby waga zależała od zmiennej, wywołujemy:
"Carry_Limit = :var"
Ale jak to działa? Do końca nie jestem pewien. :ehe:

Ten twój skrypt ma jeszcze bardziej namieszane.
Dziękuję :)

Jak chcę uruchomić grę to wyskakuje mi taki błąd w linijce 353 tego skryptu na wagę.
return if Lune_Weight::Travar && $game_party.carried_items > Lune_Weight.weight_limit
O co tutaj chodzi? Może mi ktoś wytłumaczyć? Nie jestem za dobry ze skryptów ruby ;D
(Ten post był ostatnio modyfikowany: 17-05-17 22:19 przez Sharkingv2.)
17-05-17 22:07
Znajdź wszystkie posty użytkownika
"Pomógł" przyznał(a):
Wątek zamknięty 


Wiadomości w tym wątku
RE: 2 Prośby: Waga i Strzały - Sharkingv2 - 17-05-17 22:07

Skocz do:


Użytkownicy przeglądający ten wątek: 1 gości

Kontakt | Ultima Forum | Wróć do góry | Wróć do forów | Wersja bez grafiki | RSS
Powered By MyBB. © 2013 MyBB Group. All Rights Reserved.
Skórka by Ayene.