XP 스크립트

문자 그대로 세금, 세금, 세금....... 물건을 살 때에 일정비율로 세금을 붙이는 스크립트입니다.


#============================================================================
# Tax Script-x 1.2
# Requested by Mega Flare
#----------------------------------------------------------------------------
# By The_Darklord
# Thanks to SephirothSpawn for help
#----------------------------------------------------------------------------
# The following methods are rewritten:
# Window_ShopBuy(draw_iten(index), Scene_Shop(update_buy, update_number)
# Window_ShopStatus(refresh)
#============================================================================

class Game_System
attr_accessor :tax
alias declaration initialize
def initialize
declaration
@tax = 0
end
end

class Window_ShopBuy < Window_Selectable
alias make_item draw_item
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
a = item.price
item.price = Integer(a * ( (100 + $game_system.tax) / 100.0))
make_item(index)
item.price = a
end
end

#------------------------------------------------------------------------------

class Scene_Shop
#--------------------------------------------------------------------------
# * Frame Update (when buy window is active)
#--------------------------------------------------------------------------
def update_buy
# Set status window item
@status_window.item = @buy_window.item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Change windows to initial mode
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# Erase help text
@help_window.set_text("")
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get item
@item = @buy_window.item
a = @item.price
@item.price = Integer(a * ( (100 + $game_system.tax) / 100.0))
# If item is invalid, or price is higher than money possessed
if @item == nil or @item.price > $game_party.gold
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Get items in possession count
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 99 items are already in possession
if number == 99
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Calculate maximum amount possible to buy
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
# Change windows to quantity input mode
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
@item.price = a
end
end
#--------------------------------------------------------------------------
# * Frame Update (when quantity input window is active)
#--------------------------------------------------------------------------
def update_number
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Set quantity input window to inactive / invisible
@number_window.active = false
@number_window.visible = false
# Branch by command window cursor position
case @command_window.index
when 0 # buy
# Change windows to buy mode
@buy_window.active = true
@buy_window.visible = true
when 1 # sell
# Change windows to sell mode
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play shop SE
$game_system.se_play($data_system.shop_se)
# Set quantity input window to inactive / invisible
@number_window.active = false
@number_window.visible = false
# Branch by command window cursor position
case @command_window.index
when 0 # buy
# Buy process
a = @item.price
@item.price = Integer(a * ( (100 + $game_system.tax) / 100.0))
$game_party.lose_gold(@number_window.number * @item.price)
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
@item.price = a
# Refresh each window
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# Change windows to buy mode
@buy_window.active = true
@buy_window.visible = true
when 1 # sell
# Sell process
$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
# Refresh each window
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
# Change windows to sell mode
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
end
end

#------------------------------------------------------------------------------

class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item == nil
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
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, "Number in Possession")
self.contents.font.color = normal_color
self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
self.contents.font.color = system_color
if $game_system.tax > 0
self.contents.draw_text(4, 0, 200, 86, "Current Tax Rate")
self.contents.font.color = normal_color
self.contents.draw_text(172, 0, 64, 86, $game_system.tax.to_s + "%", 2)
end
if 0 > $game_system.tax
self.contents.draw_text(4, 0, 200, 86, "Discount Rate")
self.contents.font.color = normal_color
self.contents.draw_text(172, 0, 64, 86, $game_system.tax.to_s + "%", 2)
end
if @item.is_a?(RPG::Item)
return
end
# Equipment adding information
for i in 0...$game_party.actors.size
# Get actor
actor = $game_party.actors[i]
# If equippable, then set to normal text color. If not, set to
# invalid text color.
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
# Draw actor's name
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
# Get current equipment
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
# If equippable
if actor.equippable?(@item)
# If weapon
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
# If armor
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
# Draw parameter change values
self.contents.draw_text(124, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# Draw item
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.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, item1.name)
end
end
end
end

세금붙이는 법은 상점불러오기 직전에 이벤트 명령->스크립트에서:
$game_system.tax = 세금비율

Who's 백호

?

이상혁입니다.

http://elab.kr

Atachment
첨부 '1'
Comment '2'
  • ?
    용호작무 2009.08.23 04:49

    와우 !! 정말 유용한 스크립트!!! ....이긴 한데 그넘의 세금세금세금 OTL

  • ?
    내로미 2010.05.07 16:13

    와! 게임에 현실성을 부여하는 군요! ㄳㄳㄳㄳ


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
381 메시지 TXT 메세지 렌더링 스크립트 16 에돌이 2011.07.14 4069
380 전투 Trickster씨의 전투 시스템 (SDK 필수?) Alkaid 2012.09.18 3256
379 메뉴 Trickster's Plug 'n' Play Gradient Bar 2.0 1 file 백호 2009.02.22 2051
378 이동 및 탈것 Trickster's Caterpillar System 0.99 3 Alkaid 2010.12.23 1590
377 스킬 Trickster's Bag of Skill Effects (SDK 필요) Alkaid 2012.09.17 1289
376 스킬 Trickster's Bag of Skill Effects file 백호 2009.02.22 1077
375 그래픽 Transition Pack 1.11 by Fantasist Alkaid 2011.01.22 2043
374 기타 Trailing Characters ver.1 by SephirothSpawn 6 file 백호 2009.02.22 1551
373 변수/스위치 The Self Data Suite by PK8 (XP/VX/VXA) Alkaid 2012.09.14 1232
372 전투 The Lycan ABS by DerVVulfman Alkaid 2013.07.22 1895
371 기타 The General Monster Generator 1.1 by DerVVulfman 1 file Alkaid 2011.03.02 1496
370 영상 The AVI Player 1.3 by DerVVulfman 3 Alkaid 2010.10.08 1707
369 기타 Text to RGSS by DerVVulfman Alkaid 2011.04.18 1319
368 기타 Text Scroll by Dubealex (Release 3) 2 file 백호 2009.02.22 939
367 기타 Tetris Attack by trickster 1 file 백호 2009.02.22 986
366 기타 Terrain Encounter Areas by SephirothSpawn 백호 2009.02.22 778
365 메시지 Taylor's Simple Message System 2000 Alkaid 2020.07.05 241
» 기타 Tax Script 1.2 by The Darklord@rmxp.org 2 file 백호 2009.02.22 1130
363 메뉴 Tales Of Symphonia Menu 8 file 백호 2009.02.21 1744
362 변수/스위치 Switchless Common Events by PK8(XP/VX/VXA) Alkaid 2012.09.15 1199
Board Pagination Prev 1 ... 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 ... 52 Next
/ 52