注册会员 登录
Project1 返回首页

鼠窝 https://rpg.blue/?335626 [收藏] [复制] [分享] [RSS] ~外站脚本图书馆~

日志

技能商店[已汉化]

热度 6已有 959 次阅读2014-5-20 22:18 |个人分类:外站脚本

=begin
CSCA技能商店
版本: 1.0 (发行时间: 2012年5月24日)
创建者:小精灵游戏( http://www.caspergaming.com/
汉化:by 子弹君

重要提示:所有CSCA脚本应该是相互兼容的,除非另有说明。

该脚本可以让您轻松地创建卖技能的商店。

================================说明===================================

创建一个技能商店的事件:
要创建一个技能店,你需要在事件处做一些脚本调用。

在脚本窗口中,你需要输入3行脚本:
goods= [1,2,3,4 ]
SceneManager.call(CSCA_Scene_Skill_Shop)
SceneManager.scene.prepare(goods)
第一行可以更改ID。该数字对应技能的ID 。
在这个例子中,#1,# 2,#3 ,#4将被出售。
最后两个脚本代码不需要变动
 
如何设置技能价格
技能的价格通过技能备注设置。在技能备注框中,输入此
备注 :
<cscaprice: X>
其中,x是技能的价格。例如,
<cscaprice: 100>
将技能花费100金。
 
如何设定哪些技能有的角色无法学习
默认情况下,角色可以不通过商店学习任何技能。这就需要在
角色的备注栏设置。
这样:
<csca_ss_skills: X>
其中,x将是技能的ID角色可以学习。您可以输入多个技能的ID
通过使用逗号分离。
例如:
<csca_ss_skills: x,y,z>
其中,x将是一个技能的ID ,Y将是另一个技能的ID ,Z将是另一个技能的
ID等。例如,
<csca_ss_skills: 1,2,3>
让角色来学习技能#1,#2,#3 。
============================= 结束=================================
=end

$imported = {} if $imported.nil?
$imported["CSCA-SkillShop"] = true
class CSCA_Scene_Skill_Shop < Scene_MenuBase

  def prepare(goods)
    @goods = goods
  end

  def start
    super
    create_help_window
    create_gold_window
    create_command_window
    create_dummy_window
    create_status_window
    create_buy_window
  end

  def create_gold_window
    @gold_window = Window_Gold.new
    @gold_window.viewport = @viewport
    @gold_window.x = Graphics.width - @gold_window.width
    @gold_window.y = @help_window.height
  end

  def create_command_window
    @command_window = CSCA_Window_SkillShopCommand.new(@gold_window.x)
    @command_window.viewport = @viewport
    @command_window.y = @help_window.height
    @command_window.set_handler(:buy,    method(:command_buy))
    @command_window.set_handler(:cancel, method(:return_scene))
  end

  def create_dummy_window
    wy = @command_window.y + @command_window.height
    wh = Graphics.height - wy
    @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
    @dummy_window.viewport = @viewport
  end

  def create_buy_window
    wy = @dummy_window.y
    wh = @dummy_window.height
    @buy_window = CSCA_Window_SkillShopBuy.new(0, wy, wh, @goods)
    @buy_window.viewport = @viewport
    @buy_window.help_window = @help_window
    @buy_window.status_window = @status_window
    @buy_window.hide
    @buy_window.set_handler(:ok,     method(:on_buy_ok))
    @buy_window.set_handler(:cancel, method(:on_buy_cancel))
  end
 
  def create_status_window
    wx = 304
    wy = @dummy_window.y
    ww = Graphics.width - wx
    wh = @dummy_window.height
    @status_window = CSCA_Window_SkillShopStatus.new(wx, wy, ww, wh)
    @status_window.viewport = @viewport
    @status_window.hide
    @status_window.set_handler(:ok,     method(:on_number_ok))
    @status_window.set_handler(:cancel, method(:on_number_cancel))
  end

  def activate_buy_window
    @buy_window.money = money
    @buy_window.show.activate
    @status_window.show.unselect
  end

  def command_buy
    @dummy_window.hide
    activate_buy_window
  end

  def on_buy_ok
    @item = @buy_window.item
    @buy_window.deactivate
    @status_window.set(@item, buying_price)
    @status_window.show.activate.select(0)
  end

  def on_buy_cancel
    @command_window.activate
    @dummy_window.show
    @buy_window.hide
    @status_window.hide
    @help_window.clear
  end

  def on_number_ok
    Sound.play_shop
    do_buy(@status_window.item,@buy_window.item)
    end_input
    @gold_window.refresh
    @status_window.refresh
  end

  def on_number_cancel
    Sound.play_cancel
    end_input
  end

  def do_buy(actor, skill)
    $game_party.lose_gold(buying_price)
    $game_actors[actor.id].learn_skill(skill.id)
  end

  def end_input
    @status_window.unselect
    activate_buy_window
  end

  def money
    @gold_window.value
  end

  def currency_unit
    @gold_window.currency_unit
  end

  def buying_price
    @buy_window.price(@item)
  end
end
class CSCA_Window_SkillShopCommand < Window_HorzCommand

  def initialize(window_width)
    @window_width = window_width
    super(0, 0)
  end

  def window_width
    @window_width
  end

  def col_max
    return 2
  end

  def make_command_list
    add_command(Vocab::ShopBuy,    :buy)
    add_command(Vocab::ShopCancel, :cancel)
  end
end
class CSCA_Window_SkillShopBuy < Window_Selectable

  attr_reader   :status_window

  def initialize(x, y, height, shop_goods)
    super(x, y, window_width, height)
    @shop_goods = shop_goods
    @money = 0
    refresh
    select(0)
  end

  def window_width
    return 304
  end

  def item_max
    @data ? @data.size : 1
  end

  def item
    @data[index]
  end

  def money=(money)
    @money = money
    refresh
  end

  def current_item_enabled?
    enable?(@data[index])
  end

  def price(item)
    @price[item]
  end

  def enable?(item)
    item && item.skill_price <= @money
  end

  def refresh
    make_item_list
    create_contents
    draw_all_items
  end

  def make_item_list
    @data = []
    @price = {}
    for i in 0...@shop_goods.size
      item = $data_skills[@shop_goods[i]]
      if item
        @data.push(item)
        @price[item] = item.skill_price
      end
    end
  end

  def draw_item(index)
    item = @data[index]
    rect = item_rect(index)
    draw_item_name(item, rect.x, rect.y, enable?(item))
    rect.width -= 4
    draw_text(rect, price(item), 2)
  end

  def status_window=(status_window)
    @status_window = status_window
    call_update_help
  end

  def update_help
    @help_window.set_item(item) if @help_window
    @status_window.item = item if @status_window
  end
end
class CSCA_Window_SkillShopStatus < Window_Selectable
 
  def set(skill, price)
    @skill = skill
    @price = price
    refresh
  end

  def initialize(x, y, width, height)
    super(x, y, width, height)
    @skill = nil
    @page_index = 0
    refresh
    select(0)
  end
 
  def item_max
    @data ? @data.size : 1
  end
 
  def item
    @data[index]
  end
 
  def item=(item)
    @skill = item
    refresh
  end

  def current_item_enabled?
    enable?(@data[index])
  end

  def enable?(actor)
    for i in 0...actor.skills.size
      if actor.skills[i] == @skill
        return false
      end
    end
    for i in 0...actor.csca_learnable_skills.size
      unless @skill.nil?
        if actor.csca_learnable_skills[i] == @skill.id
          return true
        end
      end
    end
    return false
  end

  def refresh
    make_item_list
    create_contents
    draw_all_items
  end

  def make_item_list
    @data = []
    $game_party.members.each do |actor|
      item = actor
      if !item.nil?
        @data.push(item)
      end
    end
  end

  def draw_item(index)
    item = @data[index]
    rect = item_rect(index)
    change_color(normal_color, enable?(item))
    draw_text(rect.x, rect.y, contents.width, line_height, item.name)
    change_color(normal_color)
  end
end
class RPG::Skill < RPG::UsableItem
  def skill_price
    if @note =~ /<cscaprice: (.*)>/i
      return $1.to_i
    else
      return 0
    end
  end
end
class RPG::Actor < RPG::BaseItem
  def learnable_skills
    if @note =~ /<csca_ss_skills: (.*)>/i
      ints = []
      for x in $1.split(",")
        ints.push(x.to_i)
      end
      return ints
    else
      return []
    end
  end
end
class Game_Actor < Game_Battler
  def csca_learnable_skills
    actor.learnable_skills
  end
end


鸡蛋

鲜花

刚表态过的朋友 (0 人)

发表评论 评论 (5 个评论)

回复 zlpwb1666 2014-5-28 14:15
如果能有范例就好了!
回复 子弹君 2014-5-28 18:18
zlpwb1666: 如果能有范例就好了!
周末补上
回复 xingmot 2014-7-13 08:45
如果能有第二货币就好了
回复 972856282 2016-1-9 14:25
你说的挺清楚的
回复 972856282 2016-1-9 14:30
算了,除了等级脚本,VA纯心和我过不去

facelist doodle 涂鸦笔

您需要登录后才可以评论 登录 | 注册会员

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-26 00:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部