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
181 파티 [신기술 체험] 2p파티시스템(액알) 8 file 백호 2009.02.22 3193
180 HUD 시트르산의 나침반 스크립트 19 file 시트르산 2011.01.23 3195
179 메시지 말 거는 텍스트 작게 만들끼~!! 4 file 백호 2009.02.22 3214
178 키입력 한글입력기(자음, 모음 분리. 아마 중복일 듯...) 11 캉쿤 2011.09.13 3225
177 메뉴 파이널 판타지 7 스타일 메뉴 7 아방스 2009.01.12 3238
176 메뉴 메뉴화면에 '해야 할 일' 알려주는 창 넣기 11 하진 2012.04.23 3256
175 전투 Trickster씨의 전투 시스템 (SDK 필수?) Alkaid 2012.09.18 3257
174 전투 캐릭터고르기스크립트? ps인간 2009.01.23 3263
173 [스크립트 모음집] 5 file WMN 2008.03.17 3267
172 기타 턴제새로운거. 39 file 이안 2010.01.17 3296
171 스킬 스킬 컷인 - 전투시만.. 4 file 허걱 2009.08.16 3298
170 메시지 XRXS9 - 메세지 표시 업그레이드 X file Alkaid 2010.09.07 3306
169 아이템 [LPG] 아이템 상세정보 - ◇ Last Update : 2009/08/11 ◇ 11 file Claymore 2009.08.16 3308
168 기타 횡스크롤 스크립트 한국말 번역. 15 file 백호 2009.02.21 3311
167 온라인 최신중의 최신 2010년 4월 작 넷플레이 3.0!!! 6 김똘식 2010.09.18 3320
166 타이틀/게임오버 죽엇을경우 마을로이동하기 스크립트 16 file 백호 2009.02.22 3326
165 게임화면의 해상도를 변경하는 스크립트 6 제로스S2 2009.08.06 3334
164 전투 흠.. 아직도 이 스크립트가 없군요 ㅋㅋ(제가올림..) 1 file 백호 2009.02.21 3335
163 전투 간단 액알 사용법(3번째) 12 file 백호 2009.02.21 3337
162 타이틀/게임오버 애니메이션을 타이틀 화면에서 이용 15 file 백호 2009.02.21 3340
Board Pagination Prev 1 ... 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 Next
/ 52