UltimaForum

Wsparcie [XP] - Poszukiwany skrypt

Lord Voldemort - Czw 19 Maj, 2011 12:46
Temat postu: Poszukiwany skrypt
Czy istnieje skrypt, abym mógł sobie ustawiać ceny u handlarzy?
Chodzi o to, że na przykład miecz u handlarza A kosztuje 500, a ten sam u handlarza B już 600. I jak zrobić, żeby np. handlarz płacił za jakiś itemek 25% jego wartości, a już za inny 75%. I żeby ustalać co można im sprzedać.

Mantiq - Czw 19 Maj, 2011 16:47

Może zrób 2 przedmioty.Jeden cena 500,drugi 600.Ustaw tą samą nazwę.
Melvin - Czw 19 Maj, 2011 16:51

Mantiq, bardzo dobry pomysł, ale lepiej byłoby użyć skryptu..
Lord Voldemort - Czw 19 Maj, 2011 16:53

To nic nie da, sprzedawał bym zawsze za połowę tego tak czy siak (250, 300) zależnie u kogo kupiłem, a to nie to czego chcę. Był taki skrypt do VX.
Ayene - Pią 20 Maj, 2011 13:02

A masz pomysł na konfigurację skryptu? Bo na to wychodzi, że każdy z przedmiotów musiałbyś konfigurować ręcznie. W razie czego możesz skorzystać z tego skryptu.

Spoiler:

Kod:
module Ayene
  VAR_ID = 1 # zmienna sklepu. Przed wywołaniem okna sklepu należy podstawić
  # za zmienną wartość odpowiadającą indeksowi cen w poniższych tabelach, np.
  # Jeśli chcesz wywołać sklep z przedmiotami nr 1, w zdarzeniu przed poleceniem
  # 'Shop processing' użyj polecenia 'Control Variables' i ustaw ('Set') 1.
 
# ===========================
# PRZEDMIOTY
# =========================== 
  # Cena kupna przedmiotów
  ITEM_PRICE = {# id => [domyślny, 1 sprzedawca, 2 sprzedawca, 3 sprzedawca, ...]
  1 => [500, 700, 800],
  2 => [500, 1500, 1800],
  }   
 
  # Cena sprzedaży przedmiotów
  ITEM_SELL = {# id => [domyślny, 1 sprzedawca, 2 sprzedawca, 3 sprzedawca, ...]
  1 => [250, 170, 780],
  2 => [250, 150, 580],
  }
   
# ===========================
# BRONIE
# ===========================
  # Cena kupna broni
  WEAPON_PRICE = {# id => [domyślny, 1 sprzedawca, 2 sprzedawca, 3 sprzedawca, ...]
  1 => [500, 700, 800],
  2 => [500, 1500, 1800],
  }   
 
  # Cena sprzedaży broni
  WEAPON_SELL = {# id => [domyślny, 1 sprzedawca, 2 sprzedawca, 3 sprzedawca, ...]
  1 => [250, 170, 780],
  2 => [250, 150, 580],
  }

# ===========================
# PANCERZE
# =========================== 
  # Cena kupna pancerzy
  ARMOR_PRICE = {# id => [domyślny, 1 sprzedawca, 2 sprzedawca, 3 sprzedawca, ...]
  1 => [500, 700, 800],
  2 => [500, 1500, 1800],
  }   
 
  # Cena sprzedaży pancerzy
  ARMOR_SELL = {# id => [domyślny, 1 sprzedawca, 2 sprzedawca, 3 sprzedawca, ...]
  1 => [250, 170, 780],
  2 => [250, 150, 580],
  } 
end

#============================================================================
class RPG::Item
  def price   
    if Ayene::ITEM_PRICE.include?(@id)
      var = $game_variables[Ayene::VAR_ID]
      if var < Ayene::ITEM_PRICE[@id].size
        @price = Ayene::ITEM_PRICE[@id][var] 
      end     
    end
    return @price
  end 
end

class RPG::Weapon 
  def price   
    if Ayene::WEAPON_PRICE.include?(@id)
      var = $game_variables[Ayene::VAR_ID]
      if var < Ayene::WEAPON_PRICE[@id].size
        @price = Ayene::WEAPON_PRICE[@id][var] 
      end     
    end
    return @price
  end 
end

class RPG::Armor 
  def price   
    if Ayene::ARMOR_PRICE.include?(@id)
      var = $game_variables[Ayene::VAR_ID]
      if var < Ayene::ARMOR_PRICE[@id].size
        @price = Ayene::ARMOR_PRICE[@id][var] 
      end     
    end
    return @price
  end 
end

class Scene_Shop
  def update_sell
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @sell_window.item
      @status_window.item = @item
      if @item == nil or @item.price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.decision_se)
      var = $game_variables[Ayene::VAR_ID]
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
        if Ayene::ITEM_SELL.include?(@item.id)
          @number_window.set(@item, number, @item.price / 2)
        else
          @number_window.set(@item, number, @item.price / 2)
        end
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
        if Ayene::WEAPON_SELL.include?(@item.id) and var < Ayene::WEAPON_PRICE[@item.id].size
          @number_window.set(@item, number, Ayene::WEAPON_SELL[@item.id][var])
        else
          @number_window.set(@item, number, @item.price / 2)
        end
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
        if Ayene::ARMOR_SELL.include?(@item.id)
          @number_window.set(@item, number, @item.price / 2)
        else
          @number_window.set(@item, number, @item.price / 2)
        end
      end
      @sell_window.active = false
      @sell_window.visible = false           
      @number_window.active = true
      @number_window.visible = true
      @status_window.visible = true
    end
  end
 
  alias ayene_cusprice_update_number update_number 
  def update_number
    ayene_cusprice_update_number
    var = $game_variables[Ayene::VAR_ID]
    case @item
    when RPG::Item
      if Ayene::ITEM_SELL.include?(@item.id) and var < Ayene::ITEM_PRICE[@item.id].size and
        Input.trigger?(Input::C)
        case @command_window.index
        when 1 
          $game_party.lose_gold(@number_window.number * (@item.price / 2))
          $game_party.gain_gold(@number_window.number * Ayene::ITEM_SELL[@item.id][var])
          @gold_window.refresh
          @sell_window.refresh
          @status_window.refresh
        end
      end
    when RPG::Weapon
      if Ayene::WEAPON_SELL.include?(@item.id) and var < Ayene::WEAPON_PRICE[@item.id].size and
        Input.trigger?(Input::C)
        case @command_window.index
        when 1 
          $game_party.lose_gold(@number_window.number * (@item.price / 2))
          $game_party.gain_gold(@number_window.number * Ayene::WEAPON_SELL[@item.id][var])
          @gold_window.refresh
          @sell_window.refresh
          @status_window.refresh
        end
      end   
    when RPG::Armor
      if Ayene::ARMOR_SELL.include?(@item.id) and var < Ayene::ARMOR_PRICE[@item.id].size and
        Input.trigger?(Input::C)
        case @command_window.index
        when 1 
          $game_party.lose_gold(@number_window.number * (@item.price / 2))
          $game_party.gain_gold(@number_window.number * Ayene::ARMOR_SELL[@item.id][var])
          @gold_window.refresh
          @sell_window.refresh
          @status_window.refresh
        end
      end
    end   
  end
end


Mam nadzieję, że się połapiesz... w razie czego wytłumaczę. Zalecane dokładne testy.


Powered by phpBB modified by Przemo © 2003 phpBB Group