hi there i've found a script which uses items for skills.
it has a check if you got the items and if not the skill is disabled.
but it shows me an error even in a blank project so i want to ask if someone can take a look at it.
maybe its not working because its from cogwheel and if i'm not wrong rtab is from him and maybe this is only for rtab...
i dont know :???:
the error shows up when i use the skill in battle system (i used the standart config 1 potion and 2 high perfumes for heal)
here the script
# Skills That Consume Items Ver 1.00
# Distribution original support URL
# http://members.jcom.home.ne.jp/cogwheel/
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Setting of medium
#--------------------------------------------------------------------------
def medium(skill_id)
case $data_skills[skill_id].name
when "Heal"
return [["Potion"], ["High Perfume", 2]]
end
return false
end
#--------------------------------------------------------------------------
# * Get Item Name
#--------------------------------------------------------------------------
def item_name(name)
for item in $data_items
if item != nil and name == item.name
return item.id
end
end
end
#--------------------------------------------------------------------------
# * Determine if Skill can be Used
# skill_id : skill ID
#--------------------------------------------------------------------------
def skill_can_use?(skill_id)
items = medium(skill_id)
if items
for item in items
id = item_name(item[0])
if $game_party.item_number(id) < (item[1] == nil ? 1 : item[1])
return false
end
end
end
return super
end
end
#==============================================================================
# ** Scene_Battle (part 4)
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
def make_skill_action_result(battler)
# Get skill
@skill = $data_skills[battler.current_action.skill_id]
# Verification whether or not it is cooperation skill
speller = synthe?(battler)
# If not a forcing action
unless battler.current_action.forcing
# When with SP and so on is cut off and it becomes not be able to use
if speller == nil
unless battler.skill_can_use?(@skill.id)
# Shift to step 6
battler.phase = 6
return
end
end
end
# SP consumption
temp = false
if speller != nil
for spell in speller
if spell.current_action.spell_id == 0
spell.sp -= @skill.sp_cost
else
spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
end
# Refreshing the status window
status_refresh(spell)
end
else
battler.sp -= @skill.sp_cost
# Refreshing the status window
status_refresh(battler)
end
# Setting animation ID
battler.anime1 = @skill.animation1_id
battler.anime2 = @skill.animation2_id
# Setting common event ID
battler.event = @skill.common_event_id
# Setting the object side battler
set_target_battlers(@skill.scope, battler)
# Applying the effect of skill
for target in battler.target
if speller != nil
damage = 0
effective = false
state_p = []
state_m = []
for spell in speller
if spell.current_action.spell_id != 0
@skill = $data_skills[spell.current_action.spell_id]
end
effective |= target.skill_effect(spell, @skill)
if target.damage[spell].class != String
damage += target.damage[spell]
elsif effective == true
effect = target.damage[spell]
end
state_p += target.state_p[spell]
state_m += target.state_m[spell]
target.damage.delete(spell)
target.state_p.delete(spell)
target.state_m.delete(spell)
end
if damage != 0
target.damage[battler] = damage
elsif effective = true
target.damage[battler] = effect
end
target.state_p[battler] = state_p
target.state_m[battler] = state_m
else
target.skill_effect(battler, @skill)
end
end
# If item(s) are used
if battler.is_a?(Game_Actor)
items = battler.medium(@skill.id)
if items
for item in items
id = battler.item_name(item[0])
num = item[1] == nil ? 1 : item[1]
# Check if consumable
if $data_items[id].consumable
$game_party.gain_item(id, -num)
end
end
end
end
end
end
#==============================================================================
# ** Scene_Skill
#------------------------------------------------------------------------------
# This class performs skill screen processing.
#==============================================================================
class Scene_Skill
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
def update_target
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Erase target window
@skill_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If unable to use because SP ran out
unless @actor.skill_can_use?(@skill.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @target_window.index == -1
# Apply skill use effects to entire party
used = false
for i in $game_party.actors
used |= i.skill_effect(@actor, @skill)
end
end
# If target is user
if @target_window.index <= -2
# Apply skill use effects to target actor
target = $game_party.actors[@target_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# If single target
if @target_window.index >= 0
# Apply skill use effects to target actor
target = $game_party.actors[@target_window.index]
used = target.skill_effect(@actor, @skill)
end
# If skill was used
if used
# If item(s) are used
if @actor.is_a?(Game_Actor)
items = @actor.medium(@skill.id)
if items
for item in items
id = @actor.item_name(item[0])
num = item[1] == nil ? 1 : item[1]
# Check if consumable
if $data_items[id].consumable
$game_party.gain_item(id, -num)
end
end
end
end
# Play skill use SE
$game_system.se_play(@skill.menu_se)
# Use up SP
@actor.sp -= @skill.sp_cost
# Remake each window content
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# If entire party is dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If command event ID is valid
if @skill.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @skill.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If skill wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
would be nice if its only a bug in the script ^^
btw i cant use tons of addons so thats why i want to use this script ! (tons of addons isnt compatible to gtbs...)
thx in advance
I think there's a script in Tons of Add-ons that does the same (maybe it was even me who made it), but is a lot more compatible with other scripts. You should try it out.
If Tons is not compatible, you can always just remove the specific script from it and use it without all the others.
ok ill try to cut it out from tons of addons ;)