Project1
标题:
蚂蚁人性化商店初级脚本
[打印本页]
作者:
dengwei
时间:
2013-1-19 13:48
标题:
蚂蚁人性化商店初级脚本
#=============================================================================#
# 脚本名称;商店人性化初级脚本 作者;蚂蚁 #
# ●蚂蚁工作室友情制作● #
# #
#使用建议; #
# 建议把之前的Window_ShopBuy和Scene_Shop脚本删除 #
# #
#使用方法; #
# 因为使用的都是全局变量,你可以在地图上操作,具体请看教程。 #
# #
#关于bug; #
# 如果你在使用是发现此脚本的bug,请联系作者,我会尽力修复。 #
# QQ;1660618519 #
# 手机;13977375101 (建议发短信) #
# #
#关于更新; #
# 如果你有什么好的建议,或对此脚本还感到什么不足,可以一起与作者商讨,也可 #
#以与作者一起参与制作新的商店人性化脚本........ #
# #
# ✿以下是各种全局变量,均可自行修改 #
###############################################################################
$打折率 = 1 #打折率,1代表不打折,算法(原价 / 打折率 = 现价)
$折扣率 = 2 #卖出的折扣率,1代表原价卖出。当打折率是2时,折扣率是1时,你再
#原价卖出,则会赚;当打折率是1时(即不打折),折扣率是2时,你再
#卖出,你就亏。算法(原价 / 折扣率 = 售价)
$光标起始位 = 0 #初始化商店时选择行数,如果是2,就选择第三行。不建议输入小数。
$皮肤 = "默认窗口.png" #商店购买区的外观图片。
$帮助后缀 = " (蚂蚁制作)" #在物品描述后面加上帮助后缀。
$商店名称 = " =====>蚂蚁批发市场<=====" #初始化商店时,你会看到
#商店的名称
#=====下面是购买窗口的字体颜色(可购买时的字体颜色,以下为初始值)↓============
$redinok = 255 #红值(red) #
$greeninok = 255 #绿值(green) #
$blueinok = 255 #蓝值(blue) #
#===============================================================================
#=====下面是购买窗口的字体颜色(无效时的字体颜色,以下为初始值)↓==============
#
$redinon = 255 #红值(red) #
$greeninon = 255 #绿值(green) #
$blueinon = 255 #蓝值(blue) #
#
#===============================================================================
#=====以下是关于金钱文本的操作==================================================
$goldname = "美元" #在游戏中金钱的名称(它会在购买区显示) #
#
#======降价时金钱的颜色↓(默认为绿色,要更改请修改下列值↓)========== #
$降价r = 38 #red色值 # #
$降价g = 220 #green色值 # #
$降价b = 38 #blue色值 # #
#====================================================================== #
#
#======涨价时金钱的颜色↓(默认为绿色,要更改请修改下列值↓)========== #
$涨价r = 255 #red色值 # #
$涨价g = 0 #green色值 # #
$涨价b = 0 #blue色值 # #
#====================================================================== #
#
#======原价时金钱的颜色↓(默认为绿色,要更改请修改下列值↓)========== #
$原价r = 255 #red色值 # #
$原价g = 225 #green色值 # #
$原价b = 255 #blue色值 # #
#====================================================================== #
#===============================================================================
#=================================以下是代码,不建议修改========================
class Window_ShopBuy < Window_Selectable
def initialize(shop_goods)
super(0, 128, 368, 352)
self.windowskin = RPG::Cache.windowskin($皮肤)
@shop_goods = shop_goods
refresh
self.index = $光标起始位
end
def item
return @data[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.price / $打折率 <= $game_party.gold and number < 99
self.contents.font.color = Color.new($redinok, $greeninok, $blueinok, 255)
else
self.contents.font.color = Color.new($redinon, $greeninon, $blueinon, 128)
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
if $打折率 > 1
self.contents.font.color = Color.new($降价r, $降价g, $降价b, 255)
self.contents.draw_text(x + 100, y, 200, 32,((item.price / $打折率).to_i).to_s + $goldname + " " + "↓", 2)
elsif $打折率 < 1
self.contents.font.color = Color.new($涨价r, $涨价g, $涨价b, 255)
self.contents.draw_text(x + 100, y, 200, 32,((item.price / $打折率).to_i).to_s + $goldname + " " + "↑", 2)
else
self.contents.font.color = Color.new($原价r, $原价g, $原价b, 255)
self.contents.draw_text(x + 100, y, 200, 32,(item.price / $打折率).to_s + $goldname + " " + "=", 2)
end
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description + $帮助后缀)
end
end
class Scene_Shop
def main
@help_window = Window_Help.new
@command_window = Window_ShopCommand.new
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
@dummy_window = Window_Base.new(0, 128, 640, 352)
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
@number_window = Window_ShopNumber.new
@number_window.active = false
@number_window.visible = false
@status_window = Window_ShopStatus.new
@status_window.visible = false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
end
def update
@help_window.set_text($商店名称)
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
if @command_window.active
update_command
return
end
if @buy_window.active
update_buy
return
end
if @sell_window.active
update_sell
return
end
if @number_window.active
update_number
return
end
end
def update_command
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @command_window.index
when 0
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1
$game_system.se_play($data_system.decision_se)
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
when 2
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
return
end
end
def update_buy
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
if @item == nil or (@item.price / $打折率).to_i > $game_party.gold
$game_system.se_play($data_system.buzzer_se)
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
if number == 99
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
max = @item.price == 0 ? 99 : ($game_party.gold / (@item.price / $打折率)).to_i
max = [max, 99 - number].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, (@item.price / $打折率).to_i)
@number_window.active = true
@number_window.visible = true
end
end
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)
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
max = number
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, (@item.price / $折扣率).to_i)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
def update_number
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0
@buy_window.active = true
@buy_window.visible = true
when 1
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.shop_se)
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0
$game_party.lose_gold((@number_window.number * @item.price / $打折率).to_i)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.gain_armor(@item.id, @number_window.number)
end
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@buy_window.active = true
@buy_window.visible = true
when 1
$game_party.gain_gold(@number_window.number * (@item.price / $折扣率).to_i)
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.lose_armor(@item.id, @number_window.number)
end
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
end
end
复制代码
蚂蚁人性化商店初级脚本 演示.rar
(222.9 KB, 下载次数: 249)
2013-1-19 13:47 上传
点击文件名下载附件
作者:
流星的瞬间
时间:
2013-1-24 23:02
楼主,可以放个截图么?无图无真相啊。
作者:
dengwei
时间:
2013-1-25 20:17
对不起,等几天吧
作者:
clear仔
时间:
2013-2-20 15:11
LZ,如何在事件中改变变量啊
在脚本中输入
“$打折率 = 1.2"
会报错,
不可能在游戏中不可改变吧.....(新手)
作者:
dengwei
时间:
2013-2-22 18:30
我用的是全局变量,我不是做了一个例程吗?你看看吧,你可以加我qq讨论一下的
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1