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 기타 전투 승리 BGM+페이드아웃 스크립트 1 file 백호 2009.02.21 1159
180 기타 Encounter Control by SephirothSpawn (SDK호환) 4 file 백호 2009.02.22 1157
179 이동 및 탈것 World Map & Teleporter by SephirothSpawn 2 file 백호 2009.02.22 1156
178 이동 및 탈것 마나 소비 텔레포트 2 백호 2009.02.22 1155
177 전투 A-battle 수정 file 백호 2009.02.21 1155
176 이동 및 탈것 KGC_Teleport file 백호 2009.02.22 1153
175 기타 레벨9999스크립트 4 백호 2009.02.21 1151
174 맵/타일 Mode07 0.5 by mewsterus 3 백호 2009.02.22 1149
173 아이템 아이템 사용 클래스 한정 스크립트! 2 백호 2009.02.22 1147
172 기타 맵처리를 가볍게 1 백호 2009.02.21 1147
171 키입력 Key Simulator by Fantasist 4 습작 2013.05.01 1143
170 이동 및 탈것 [통합] 텔레포트 통합 수정편 1 백호 2009.02.22 1143
169 기타 스테이터스 표시 플러스 1.00ver 백호 2009.02.22 1141
168 전투 FF10 전투 대미지 공식 by hydro@rmxp.org 백호 2009.02.22 1140
167 오디오 음악 재생 스크립트 3 file 백호 2009.02.21 1140
166 스킬 스킬 도감 1 백호 2009.02.21 1138
165 기타 메세지창의 위치 변동 자동화 file 백호 2009.02.21 1138
164 맵/타일 Map Event Large Make 2 백호 2009.02.22 1132
163 전투 물리친 적의수 표시 file 백호 2009.02.21 1131
» 기타 Tax Script 1.2 by The Darklord@rmxp.org 2 file 백호 2009.02.22 1130
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