Jump to content
Rpg²S Forum

*sconti nel gioco


Kingartur2
 Share

Recommended Posts

Con questo script si puo variare il prezzo degli oggetti nel negozio cambando una varibile nel gioco

 

 

#==========================================================================
#creato da Kingartur2
#==========================================================================

module Sconti
#scegli la varibile che imposterà la percentuale di sconto
Variabile_id = 004
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.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
# コマンドウィンドウがアクティブの場合: update_command を呼ぶ
if @command_window.active
update_command
return
end
# 購入ウィンドウがアクティブの場合: update_buy を呼ぶ
if @buy_window.active
update_buy
return
end
# 売却ウィンドウがアクティブの場合: update_sell を呼ぶ
if @sell_window.active
update_sell
return
end
# 個数入力ウィンドウがアクティブの場合: update_number を呼ぶ
if @number_window.active
update_number
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (コマンドウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_command
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# コマンドウィンドウのカーソル位置で分岐
case @command_window.index
when 0 # 購入する
# 決定 SE を演奏
$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 # 売却する
# 決定 SE を演奏
$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 # やめる
# 決定 SE を演奏
$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
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$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
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを取得
@item = @buy_window.item
# アイテムが無効の場合、または価格が所持金より上の場合
if @item == nil or (@item.price - (@item.price * $game_variables[sconti::Variabile_id] / 100)) > $game_party.gold
# ブザー SE を演奏
$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
# すでに 99 個所持している場合
if number == 99
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 最大購入可能個数を計算
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
# ウィンドウの状態を個数入力モードへ
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (売却ウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_sell
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$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
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを取得
@item = @sell_window.item
# ステータスウィンドウのアイテムを設定
@status_window.item = @item
# アイテムが無効の場合、または価格が 0 (売却不可) の場合
if @item == nil or @item.price == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$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 / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (個数入力ウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_number
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$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
# C ボタンが押された場合
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
if $game_variables[sconti::Variabile_id] >= 100
$game_variables[sconti::Variabile_id] = 99
end
$game_party.lose_gold(@number_window.number * @item.price- ((@number_window.number * @item.price) * $game_variables[sconti::Variabile_id] / 100))
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 / 2))
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
#==============================================================================

class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def initialize(shop_goods)
super(0, 128, 368, 352)
@shop_goods = shop_goods
refresh
self.index = 0
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)
self.contents.font.name = "Arial"
self.contents.font.size = 22
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 $game_variables[sconti::Variabile_id ] >= 100
$game_variables[sconti::Variabile_id ] = 99
end
if(item.price - (item.price * $game_variables[sconti::Variabile_id ] / 100)) <= $game_party.gold and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
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)
self.contents.draw_text(x + 240, y, 88, 32, (item.price - (item.price * $game_variables[sconti::Variabile_id ] / 100)).to_s , 2)
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end

 


istruzioni:


Usate una varibile nel gioco che potrete scegliere nello script per impostare la percentuale di sconto.
Se sarà negativa il prezzo aumenterà e se invece supererà o sarà uguale al 100 % sarà settata automaticamente al 99%

Edited by Dilos
Applicato tag code.

Per qualsiasi motivo non aprite questo spoiler.

 

 

Ho detto di non aprirlo !

 

 

Se lo apri ancora esplode il mondo.

 

 

Aaaaaa è un vizio.

 

 

Contento? Il mondo è esploso, sono tutti morti

per colpa della tua curiosità .

 

 

Vuoi che ti venga anche il morbillo, la varicella e l'AIDS???

 

 

O bravo ora sei un malato terminale e nessuno

ti puo curare, sono tutti morti !

 

 

Se clicchi ancora una volta il PC esplode.

 

 

E dai smettila !!

 

Uff!! Hai cliccato tante volte che ho dovuto sostituirlo con un codebox.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

http://s8.postimg.org/yntv9nxld/Banner.png

http://img204.imageshack.us/img204/8039/sccontest3octpl3.gif

Link to comment
Share on other sites

Chi è il jappo che ha prodotto questo script ? O sei tu che scrivi i commenti in jappo ?

http://img256.imageshack.us/img256/7639/ihateyou.gif

Un uomo senza religione è come un pesce senza bicicletta.

http://img18.imageshack.us/img18/3668/decasoft1.png

http://rpg2s.net/gif/SCContest1Oct.gifhttp://rpg2s.net/gif/SCContest2Oct.gifhttp://rpg2s.net/gif/SCContest2Oct.gif

Link to comment
Share on other sites

Chi è il jappo che ha prodotto questo script ? O sei tu che scrivi i commenti in jappo ?

 

 

no semplicemente che uso rpgxp 1.01 e mi servivano alcune funzioni che si trovavano gia scritte negli script quindi ho fatto copia e incolla e ci sono usciti i commenti in jappo.

XDXDXDXD

Per qualsiasi motivo non aprite questo spoiler.

 

 

Ho detto di non aprirlo !

 

 

Se lo apri ancora esplode il mondo.

 

 

Aaaaaa è un vizio.

 

 

Contento? Il mondo è esploso, sono tutti morti

per colpa della tua curiosità .

 

 

Vuoi che ti venga anche il morbillo, la varicella e l'AIDS???

 

 

O bravo ora sei un malato terminale e nessuno

ti puo curare, sono tutti morti !

 

 

Se clicchi ancora una volta il PC esplode.

 

 

E dai smettila !!

 

Uff!! Hai cliccato tante volte che ho dovuto sostituirlo con un codebox.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

http://s8.postimg.org/yntv9nxld/Banner.png

http://img204.imageshack.us/img204/8039/sccontest3octpl3.gif

Link to comment
Share on other sites

wow... triplo messaggio O_o

xD Comunque, bel script! ;-)

Edited by tidus00

http://i46.tinypic.com/260qs1l.jpghttp://i48.tinypic.com/21owyt0.jpghttp://i45.tinypic.com/oj12x5.jpg

http://i45.tinypic.com/oj12x5.jpghttp://i48.tinypic.com/2qanw9v.jpghttp://i45.tinypic.com/oj12x5.jpg

http://i49.tinypic.com/2cpdkb8.jpg

 

http://i47.tinypic.com/vpyfix.jpg http://i45.tinypic.com/jago40.jpg http://img231.imageshack.us/img231/8504/tidus1.png

 

non esco l'ora che veda

Un gioco così ben fatto da farti sballare la testa! XD

 

 

 

 

http://img27.imageshack.us/img27/8540/dsbar.png

http://img294.imageshack.us/img294/6876/nostalebar.png

http://img90.imageshack.us/img90/2158/tbars.png

http://i40.tinypic.com/soqvb8.jpg

http://i45.tinypic.com/29duu1l.jpg

http://img237.imageshack.us/img237/2482/30275.png

http://img182.imageshack.us/img182/8/rpgxpbarrpgmzv1.png

http://img195.imageshack.us/img195/6998/userbarannette.png

http://i48.tinypic.com/awdylh.jpg

Link to comment
Share on other sites

Grazie, è il mio primo script.

Cmq chiedo scusa per il triplo messaggio visto che ho il mouse difettoso e a volte al posto di fare un click ne fa 2 o 3 da solo

Per qualsiasi motivo non aprite questo spoiler.

 

 

Ho detto di non aprirlo !

 

 

Se lo apri ancora esplode il mondo.

 

 

Aaaaaa è un vizio.

 

 

Contento? Il mondo è esploso, sono tutti morti

per colpa della tua curiosità .

 

 

Vuoi che ti venga anche il morbillo, la varicella e l'AIDS???

 

 

O bravo ora sei un malato terminale e nessuno

ti puo curare, sono tutti morti !

 

 

Se clicchi ancora una volta il PC esplode.

 

 

E dai smettila !!

 

Uff!! Hai cliccato tante volte che ho dovuto sostituirlo con un codebox.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

http://s8.postimg.org/yntv9nxld/Banner.png

http://img204.imageshack.us/img204/8039/sccontest3octpl3.gif

Link to comment
Share on other sites

  • 3 weeks later...
Se vuoi te lo adatto non ci vuole niente

Per qualsiasi motivo non aprite questo spoiler.

 

 

Ho detto di non aprirlo !

 

 

Se lo apri ancora esplode il mondo.

 

 

Aaaaaa è un vizio.

 

 

Contento? Il mondo è esploso, sono tutti morti

per colpa della tua curiosità .

 

 

Vuoi che ti venga anche il morbillo, la varicella e l'AIDS???

 

 

O bravo ora sei un malato terminale e nessuno

ti puo curare, sono tutti morti !

 

 

Se clicchi ancora una volta il PC esplode.

 

 

E dai smettila !!

 

Uff!! Hai cliccato tante volte che ho dovuto sostituirlo con un codebox.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

http://s8.postimg.org/yntv9nxld/Banner.png

http://img204.imageshack.us/img204/8039/sccontest3octpl3.gif

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...