VX Event Items
By OS
Purpose
This script allows NPCs to hold items. It allows the user to choose which items can be given to NPCs, and allows the player to give items to NPCs, and to take them away. The user can also set a maximum number of items that can be held by the NPC.
Script
Notes and Instructions
This is loosely based on the script I wrote for XP. This script is much shorter and cleaner than the XP script. I copied Scene_Item and altered it very slightly (and deleted every Target reference), and I altered the initialize method of Game_Event, and added three methods.
In order to use this script effectively, use
$scene = Scene_TransferItem(event_id), where event_id is the id of the event that the items will be stored in.
$game_map.events[event_id].max_items = n, where n is the maximum number of items the event will be allowed to hold.
$game_map.events[event_id].give_item(item_id), where item_id is one of the Item IDs from your database. This will only work if the ID is also in the Module OS#GiftItems array at the top of the script.
$game_map.events[event_id].lose_item(item_id), to directly remove an item that an NPC has from their inventory.
It's lightweight and easy to use. Give credit, have fun, and enjoy!
FAQ
None yet.
Screens
http://i64.photobucket.com/albums/h163/ ... temsVX.png[/img]
~OS
By OS
Purpose
This script allows NPCs to hold items. It allows the user to choose which items can be given to NPCs, and allows the player to give items to NPCs, and to take them away. The user can also set a maximum number of items that can be held by the NPC.
Script
Code:
#===============================================================================
# Event Items
# Version: 1.0.0 VX
#
# This is loosely based on the script I wrote for XP. This script is much shorter
# and cleaner than the XP script. I copied Scene_Item and altered it very slightly
#(and deleted every Target reference), and I altered the initialize method of
# Game_Event, and added three methods.
#
# In order to use this script effectively, use
#
# $scene = Scene_TransferItem(event_id), where event_id is the id of the event
# that the items will be stored in.
#
# $game_map.events[event_id].max_items = n, where n is the maximum number of
# items the event will be allowed to hold.
#
# $game_map.events[event_id].give_item(item_id), where item_id is one of the
# Item IDs from your database. This will only work if the ID is also in the
# Module OS#GiftItems array at the top of the script.
#
# $game_map.events[event_id].lose_item(item_id), to directly remove an item that
# an NPC has from their inventory.
#
# It's lightweight and easy to use. Give credit, have fun, and enjoy!
#===============================================================================
module OS
GiftItems = [1, 3, 4, 6]
end
class Game_Event < Game_Character
attr_accessor :items
def initialize(map_id, event)
super()
@map_id = map_id
@event = event
@id = @event.id
@erased = false
@starting = false
@through = true
@items = []
@max_items = 10
moveto(@event.x, @event.y) # Move to initial position
refresh
end
def give_item(item_id)
if @items.size < @max_items
@items.push(item_id)
return true
end
return false
end
def take_item(item_id)
if @item.include?(item_id)
@item.delete(item_id)
return item_id
end
return 0
end
def max_items(count)
@max_items = count
end
end
class Scene_ItemTransfer < Scene_Base
#--------------------------------------------------------------------------
# * Initialize variables
#--------------------------------------------------------------------------
def initialize(event_id)
@event_id = event_id
end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@help_window = Window_Help.new
@help_window.viewport = @viewport
@item_window = Window_Item.new(0, 56, 544, 170)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.active = true
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@viewport.dispose
@help_window.dispose
@item_window.dispose
end
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Update Frame
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@item_window.update
if @item_window.active
update_item_selection
end
end
#--------------------------------------------------------------------------
# * Update Item Selection
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
@item = @item_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if OS::GiftItems.include?(@item.id)
determine_item
else
Sound.play_buzzer
end
end
end
#--------------------------------------------------------------------------
# * Confirm Item
#--------------------------------------------------------------------------
def determine_item
if $game_map.events[@event_id].give_item(@item.id)
$game_party.consume_item(@item)
@item_window.draw_item(@item_window.index)
Sound.play_decision
return
end
Sound.play_buzzer
end
end
Notes and Instructions
This is loosely based on the script I wrote for XP. This script is much shorter and cleaner than the XP script. I copied Scene_Item and altered it very slightly (and deleted every Target reference), and I altered the initialize method of Game_Event, and added three methods.
In order to use this script effectively, use
$scene = Scene_TransferItem(event_id), where event_id is the id of the event that the items will be stored in.
$game_map.events[event_id].max_items = n, where n is the maximum number of items the event will be allowed to hold.
$game_map.events[event_id].give_item(item_id), where item_id is one of the Item IDs from your database. This will only work if the ID is also in the Module OS#GiftItems array at the top of the script.
$game_map.events[event_id].lose_item(item_id), to directly remove an item that an NPC has from their inventory.
It's lightweight and easy to use. Give credit, have fun, and enjoy!
FAQ
None yet.
Screens
http://i64.photobucket.com/albums/h163/ ... temsVX.png[/img]
~OS