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


Odpowiedz 
[VXAce] 2 Prośby: Waga i Strzały
Sharkingv2 Offline
*


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

Pomógł: 0



Post: #1
wykrzyknik 2 Prośby: Waga i Strzały

Witam, miałbym 2 prośby do was.
1 Prośba jest taka, czy jest jakiś skrypt który dodaje system strzał. Chodzi mi o to, że np. nasz bohater ma w ekwipunku 50 strzał i jak wystrzeli z łuku 1 strzałę (np. we wroga) to się usuwa z ekwipunku 1 strzała.
A 2 Prośba jest taka, że chciałbym dodać do mojego projektu gry, system wagi. Mam nawet skrypt, ten skrypt jest przetłumaczony na polski. Ale dalej nie rozumiem jak go użyć. Podam teraz przykład jak chciałbym użyć tego skryptu i czy da się go tak użyć. Powiedzmy, że chciałbym żeby przedmiot ryba miał 0.5 udźwigu i, że z 200 udźwigu zostaje 199.5 udźwigu. Jak to zrobić. I, że jak udźwig jest powyżej 200 to postać porusza się wolniej powiedzmy o 80%.

Tutaj podaje skrypt:

#==============================================================================
# XaiL System - Inventory Weight
# Author: Nicke
# Stworzony: 02/05/2012
# Edytowany: 12/05/2012
# Tłumaczenie: Saskio
# Specjalnie dla Ultimateam.pl
# Wersja: 1.0b
#==============================================================================
# Instrukcja
# -----------------------------------------------------------------------------
# Aby zainstalować ten skrypt, należy otworzyć Edytor Skryptów i wkleić
# go w wolny slot poniżej 'Materials' ale nad 'Main'. Pamiętaj o zapisie!
#
# Ten skrypt umożliwia ustawienie wagi przedmiotów.
# Maksymalna waga ekwipunku wrasta wraz ze zdobyciem poziomu.
# Zobacz szczegóły i ustaw je, według własnych potrzeb!
#
# Domyślna waga przedmiotu to 0.0 jednak możesz to zmienić, wpisując w komentarz
# danej rzeczy:
# <WEIGHT|weight: numer>
#
# Przykłady:
# <weight: 15.5>
# <WEIGHT: 4.5>
#
# Maksymalny udźwig na początku wynosi 0.0. Aby odświeżyć udźwig należy wywołać
# skrypt:
# $game_party.refresh_weight
#
# Dużym minusem jest to, że musimy manualnie powiększyć obciążenie.
# Aby dodać/usunąć wagę przedmiotu musisz wywołać następujący skrypt:
# $game_party.weight_item(ID, ilość = 1, typ = :item, weight_type = :gain)
#
# Examples:
# $game_party.weight_item(1) # // Dodaje wagę jednego przedmiotu z ID_1
# $game_party.weight_item(1, 2, :weapon) # // Dodaje wagę 2 broni z ID_1
# $game_party.weight_item(1, 1, :armor, :lose)# // Usuwa wagę jednego pancerza z ID_1
#
# *** Jedynie na RPG Maker VX Ace. ***
#==============================================================================
($imported ||= {})["XAIL-INVENTORY-WEIGHT"] = true

module XAIL
module INV_WEIGHT
#--------------------------------------------------------------------------#
# * Ustawienia
#--------------------------------------------------------------------------#
# Czy masa zwiększa się, jeśli stackujesz przedmioty?
# i.e jeśli masz 2 lub więcej itemów [???]
# STACK_WEIGHT = true/false
STACK_WEIGHT = true

# Max MAX_WEIGHT_TYPE = :symbol
# :default = Maksymalny udźwig bazowany na poziomie.
# :str = Maksymalny udźwig bazowany na ataku.
# :custom = Maksymalny udźwig bazowany na własnej opcji
MAX_WEIGHT_TYPE = :default

# Formuła na maksymalny udźwig bazowany na poziomie.
def self.weight_level
case $game_party.leader.level
when 1..10 ; weight = 20.0
when 11..19 ; weight = 40.0
when 20..30 ; weight = 60.0
when 31..40 ; weight = 80.0
when 41..50 ; weight = 99.0
end
return weight
end

# Inna formuła. Obecnie bazuje na ataku i zręczności bohatera podzielonych
# przez 2
# Wybierz tu, co chcesz.
def self.weight_custom
$game_party.leader.atk.to_f + $game_party.leader.agi.to_f / 2.0
end

# Włącz tą opcję, jeśli chcesz aby postać mogła być obciążona.
# Na przykład: Kiedy jest 50% obciążenia bohater będzie biegał wolniej,
# dopóki nie sprzeda/wyrzuci kilku itemów.
# Kiedy jest 90% obciążenia wojowniczość nie jest zbyt świetna.
# USE_ENCUMBER = true/false
USE_ENCUMBER = true

# Ta opcja decyduje o szybkości biegu, jeśli USE_ENCUMBER jest 'true'
# Objaśnienie:
# Kiedy bohater ma 50% obciążenia prędkość poruszania się to 3.8.
# Kiedy bohater ma 75% obciążenia prędkość poruszania się to 3.4.
# Kiedy bohater ma 90% obciążenia prędkość poruszania się to 3.2.
# Kiedy bohater ma 95% obciążenia prędkość poruszania się to 3.0
# Poniżej 50% obciążenia- prędkość biegu domyślna
def self.encumber_speed(weight, max, default)
$game_player.move_speed = 3.8 if weight >= max * 0.50
$game_player.move_speed = 3.4 if weight >= max * 0.75
$game_player.move_speed = 3.2 if weight >= max * 0.90
$game_player.move_speed = 3.0 if weight >= max * 0.95
$game_player.move_speed = default if weight <= max * 0.50
end
end
end
# *** Nie edytuj poniżej, chyba, że wiesz co robisz. ***
#==============================================================================#​
# ** RPG::BaseItem
#==============================================================================#​
class RPG::BaseItem

def weight
# // Method to set a item weight.
@note.scan(/<(?:WEIGHT|weight):\s(\d+.\d+)>/i)
return ($1.to_f > 0.0 ? $1.to_f : 0.0)
end

end
#==============================================================================#​
# ** Game_Party
#==============================================================================#​
class Game_Party < Game_Unit

attr_reader :weight
attr_reader :max_weight

alias xail_item_weight_sys_init initialize
def initialize(*args, &block)
# // Method to initialize.
xail_item_weight_sys_init(*args, &block)
@weight = 0.0
@max_weight = 0.0
end

def refresh_weight
# // Method to refresh the max weight.
@max_weight = max_weight? unless leader.nil?
end

def max_weight?
# // Method to check the max weight.
case XAIL::INV_WEIGHT::MAX_WEIGHT_TYPE
when :default ; return @max_weight = XAIL::INV_WEIGHT.weight_level
when :str ; return @max_weight = leader.atk.to_f
when :custom ; return @max_weight = XAIL::INV_WEIGHT.weight_custom
end
end

def weight_item(item, amount = 1, type = :item, weight_type = :gain)
# // Method to gain an item with weight.
case type
when :item ; type = $data_items
when :weapon ; type = $data_weapons
when :armor ; type = $data_armors
end
item = type[item]
case weight_type
when :gain
# // Gain: Increase the current weight.
unless item.nil?
unless XAIL::INV_WEIGHT::STACK_WEIGHT
unless has_item?(type[item.id])
@weight += item.weight
end
else
@weight += item.weight
end
if @weight > max_weight?
return @weight -= item.weight
end
gain_item(item, amount, false)
end
when :lose
# // Lose: Decrease the current weight.
return unless has_item?(type[item.id])
unless item.nil?
unless XAIL::INV_WEIGHT::STACK_WEIGHT
unless has_item?(type[item.id])
@weight -= item.weight unless @weight <= 0.0
end
if item_number(item) < 2
@weight -= item.weight unless @weight <= 0.0
end
else
@weight -= item.weight unless @weight <= 0.0
end
gain_item(item, -amount, false)
end
end
end

end
#==============================================================================#​
# ** Game_Player
#==============================================================================#​
class Game_Player < Game_Character

attr_accessor :move_speed

alias xail_item_weight_game_player_init initialize
def initialize
# // Method to initialize game player.
@weight = $game_party.weight
@max_weight = $game_party.max_weight
xail_item_weight_game_player_init
@default_move_speed = @move_speed.to_f
end

alias xail_item_weight_game_player_dash? dash?
def dash?
# // Method to check if player can dash.
return false if $game_party.weight >= $game_party.max_weight * 0.90 if XAIL::INV_WEIGHT::USE_ENCUMBER
xail_item_weight_game_player_dash?
end

alias xail_item_weight_game_player_update update
def update
# // Method to refresh game player.
if XAIL::INV_WEIGHT::USE_ENCUMBER
if @weight != $game_party.weight
@weight = $game_party.weight
@max_weight = $game_party.max_weight
XAIL::INV_WEIGHT.encumber_speed(@weight, @max_weight, @default_move_speed)
end
end
xail_item_weight_game_player_update
end

end
#==============================================================================#​
# ** Game_Interpreter
#==============================================================================#​
class Game_Interpreter

def w_item(item, amount = 1, type = :item, weight_type = :gain)
# // Quick method to add/remove an item with weight.
$game_party.weight_item(item, amount, type, weight_type)
end

end # END OF FILE

#=*==========================================================================*=#​
# ** END OF FILE
#=*==========================================================================*=#​
(Ten post był ostatnio modyfikowany: 15-05-17 22:14 przez Sharkingv2.)
15-05-17 19:32
Znajdź wszystkie posty użytkownika Odpowiedz cytując ten post
"Pomógł" przyznał(a):
AlmostNoRuby Offline
*


Liczba postów: 126
Dołączył: 22-09-16

Pomógł: 22



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

Dodaj.skrypt w tagi [code], ten post źle wygląda

[Obrazek: 4869108.gif]
[a]nr team working:
big map technology for RPGVX - 2000x2000 maps! :D
Cosmos Setback can be wait :D
16-05-17 07:09
Znajdź wszystkie posty użytkownika Odpowiedz cytując ten post
"Pomógł" przyznał(a):
Yoroiookami Offline
*


Liczba postów: 775
Dołączył: 01-05-13

Pomógł: 91



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

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.

[Obrazek: bhixcw.jpg]
[Obrazek: tumblr_static_eyes.gif]
(Ten post był ostatnio modyfikowany: 16-05-17 12:05 przez Yoroiookami.)
16-05-17 12:04
Znajdź wszystkie posty użytkownika Odpowiedz cytując ten post
"Pomógł" przyznał(a): Sharkingv2
Sharkingv2 Offline
*


Liczba postów: 32
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 Odpowiedz cytując ten post
"Pomógł" przyznał(a):
Mateusz SSJ8 Offline
*


Liczba postów: 508
Dołączył: 10-05-13

Pomógł: 40



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

Rozumiem, że coś ma zostać zwrócone, jeśli "Lune_Weight::Travar" jest true i wartość zwrócona przez funkcję "$game_party.carried_items" jest większa, niż ta zwrócona przez funkcję "Lune_Weight.weight_limit". Przyczyną błędu może być próba sprawdzenia, czy "nil" jest większe, czy mniejsze od liczby. Uruchom test jeszcze raz i przeczytaj cały komunikat błędu.

Nienawidzony i nienawidzący. Przez nienawiść tego drugiego obaj będą martwi.
21-05-17 21:41
Odwiedź stronę użytkownika Znajdź wszystkie posty użytkownika Odpowiedz cytując ten post
"Pomógł" przyznał(a): Sharkingv2
Odpowiedz 


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.