Skill Requirement System 1.1 |
|
|
|
|
Mar 20 2008, 11:22 AM
|
Level 6

Group: Member
Posts: 75
Type: None
RM Skill: Beginner

|
Skill Requirements SystemVersion 1.1 This allows you to add all kinds of requirements for skills using the note field for them. This requires TagNote v2.0. To use, all you have to do is add special lines to the notes field for the skill in question. All requirements only check the first requirement of that type per skill, at the moment. This is still currently experimental and largely untested. Please let me know if there are any problems with it or there's any unexpected behaviour. <weapon_type x> Requires a weapon with the same text in its notes field. Note that although a skill can only require on weapon type, weapons can have multiple types assigned to them, one per line formatted as above. 'x' is an arbitrary string. <item_present x> Requires a specific item to be with the party, equipped or not. 'x' is the id number of the item. <item_consumed x> <item_consumed x n> Will consume a number of items and requires the party to have them to do so. 'x' is the id number of the item, 'n' the number to consume. If no 'n' is given, 1 is assumed. <hp_percent_exceed p> Requires the actor's hp total to be equal to or greater than p. 'p' is expressed as a percentage, but can be decimal. <hp_percent_below p> Requires the actor's hp total to be less than p. 'p' is expressed as a percentage, but can be decimal. <mp_percent_exceed p> <mp_percent_exceed p true> Requires the actor's mp total to be equal to or greater than p. 'p' is expressed as a percentage, but can be decimal. If 'true' is included, then that proportion of the actor's mp will be consumed when the skill is used. <mp_percent_below p> Requires the actor's mp total to be less than p. 'p' is expressed as a percentage, but can be decimal. <free_hand> Requires the actor to have a free hand to use the skill. <dual_weapon> Requires the actor to be wielding two weapons. <two_handed_weapon> Requires the actor to be wielding a two-handed weapon. CODE ########################### # Requirements for Skills # ############################################################################## # Version 1.0 # # Author: Queex # # Licence: Creative Commons Non-Commercial Attributive # # Requires: TagNote 2.0+ # ############################################################################## # Allows extra requirement before skills can be used. The requirements are # # tags added to the notes field ofthe skills. Currently, only the first # # requirement of a given type is checked. # # # # Tags that can be used in weapons: # # <weapon_type xxx> # # # # Tags that can be used in items: # # <include_battle_test> - makes this item available when testing battles # # # # Tags that can be used in skills: # # <weapon_type xxx> - only weapons with this same type can use this skill # # <item_present id> - the party must possess at least 1 item of that id # # <item_consume id n> - the party must possess n items of that id, which # # will be consumed. # # <item_consume id> - the party must possess 1 item of that id, which will # # be consumed. # # <hp_percent_exceed per> - the actor's HP must equal or exceed this # # percentage. # # <hp_percent_below per> - the actor's HP must be below this percentage. # # <mp_percent_exceed per> - the actor's MP must equal or exceed this # # percentage. # # <mp_percent_exceed per true> - the actor's MP must equal or exceed this # # percentage, and that percentage will be # # consumed. # # <mp_percent_below per> - the actor's MP must be below this percentage. # # <free_hand> - the actor must have at least one free hand. # # <dual_weapon> - the actor must be using two weapons. # # <two_handed_weapon> - the actor must be using a two-handed weapon. # # # # Note: # # This script also includes the function hands_free which returns the # # number of free hands for a Game_Actor. # # # # Version History: # # 0.4 - test release # # 0.5 - can specify some item to include in battle test # # 1.0 - Bugfix and update to TagNote 2.0 *RELEASE* # ##############################################################################
class Game_Actor < Game_Battler include TAGNOTE
def hands_free if weapons[0]==nil if @armor1_id[0]==0 return 2 elsif weapons.length==2 if weapons[1].two_handed return 0 else return 1 end else return 1 end elsif weapons[0].two_handed or @armor1_id!=0 return 0 else return 1 end end
alias skill_req_skill_can_use? skill_can_use? def skill_can_use?(skill) if skill.id != 0 skill_note=$data_skills[skill.id].note #Check for weapon type skill_needs = get_tag(skill_note,"weapon_type") #weapon type string if skill_needs != nil if two_swords_style if @weapon_id!=0 and @armor1_id!=0 return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs) or has_tag_value?($data_weapons[@armor1_id].note,"weapon_type",skill_needs) elsif @weapon_id!=0 return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs) elsif @armor1_id!=0 return false unless has_tag_value?($data_weapons[@armor1_id].note,"weapon_type",skill_needs) else return false end else return false unless @weapon_id!=0 return false unless has_tag_value?($data_weapons[@weapon_id].note,"weapon_type",skill_needs) end end #Check for item presence skill_needs = get_tag(skill_note,"item_present") #item id if skill_needs != nil return false unless $game_party.has_item?($data_items[skill_needs.to_i],true) end #Check for item consumption skill_needs = get_tag(skill_note,"item_consume") #item id if skill_needs !=nil skill_needs_num = get_additional_tag(skill_note,"item_consume",2) #number if skill_needs_num == nil skill_needs_num = 1 end return false unless $game_party.item_number($data_items[skill_needs.to_i])>=skill_needs_num.to_i end #Check for HP exceeds skill_needs = get_tag(skill_note,"hp_percent_exceed") #percent if skill_needs !=nil return false unless (100.0 * @hp/maxhp)>=skill_needs.to_f end #Check for HP below skill_needs = get_tag(skill_note,"hp_percent_below") #percent if skill_needs != nil return false unless (100.0 * @hp/maxhp)<skill_needs.to_f end #Check for MP exceeds skill_needs = get_tag(skill_note,"mp_percent_exceed") #percent if skill_needs != nil return false unless (100.0 * @mp/maxmp)>=skill_needs.to_f end #Check for MP below skill_needs = get_tag(skill_note,"mp_percent_below") #percent if skill_needs != nil return false unless (100.0* @mp/maxmp)<skill_needs.to_f end #Check for free hand skill_needs = has_tag?(skill_note,"free_hand") #boolean if skill_needs return false unless hands_free>=1 end #Check for dual weapons skill_needs = has_tag?(skill_note,"dual_weapon") #boolean if skill_needs return false unless two_swords_style return false unless weapons[0]!=nil and weapons[1]!=nil end #Check for two-handed weapon skill_needs = has_tag?(skill_note,"two_handed_weapon") #boolean if skill_needs return false unless ( weapons[0]!= nil and weapons[0].two_handed) if two_swords_style return false unless ( weapons[0]!= nil and weapons[0].two_handed) or (weapons[1] != nil and weapons[1].two_handed) end end return skill_req_skill_can_use?(skill) end end def calc_mp_cost(skill) base_cost=skill.mp_cost mp_prop=get_tag(skill.note,"mp_percent_exceed") if mp_prop!=nil mp_lose=get_additional_tag_value(skill.note,"mp_percent_exceed",2) if mp_lose.eql?("true") base_cost=(mp_prop.to_f/100.0 * maxmp).to_i end end if half_mp_cost return base_cost / 2 else return base_cost end end end
class Scene_Battle < Scene_Base include TAGNOTE #-------------------------------------------------------------------------- # * Execute Battle Action: Skill #-------------------------------------------------------------------------- alias skill_req_execute_action_skill execute_action_skill def execute_action_skill skill_req_execute_action_skill skill = @active_battler.action.skill #consume items required skill_needs = get_tag(skill.note,"item_consume") if skill_needs != nil num_items = get_additional_tag(skill.note,"item_consume",2) if num_items==nil num_items=1 end $game_party.lose_item($data_items[skill_needs.to_i],num_items.to_i,true) end end end
class Game_Party < Game_Unit include TAGNOTE alias skill_req_setup_battle_test_members setup_battle_test_members def setup_battle_test_members skill_req_setup_battle_test_members for i in 1...$data_items.size if has_tag?($data_items[i].note,"include_battle_test") @items[i] = 99 end end end end This script is part of the Queex script collection: http://chthonic.150m.com/scratch/Queex_scripts.zip
This post has been edited by puppeto4: May 23 2008, 05:42 AM
|
|
|
|
|
|
|
|
|
Mar 20 2008, 02:05 PM
|
Level 6

Group: Member
Posts: 75
Type: None
RM Skill: Beginner

|
I'm pretty sure it isn't. Common events don't seem to allow you to, say, see who's currently acting easily, which makes it tricky to check if they have the right weapon. The common event model would seem to fall down if two characters have access to the same skill, because there doesn't seem to be an easy way to differentiate.
Plus, if you plan on having a lot of skills with special prerequisites it's a lot easier to create and maintain a couple of lines in the notes field than a pile of events. Also, it looks like the event is called when the skill is used, so the skill won't be greyed out if its unusable.
I could be wrong, though.
There is another script in this forum for managing weapon requirements- so I thought there was at least a use for it.
|
|
|
|
|
|
|
|
|
Mar 24 2008, 03:22 PM
|
Level 4

Group: Member
Posts: 49
Type: None
RM Skill: Undisclosed

|
Yeah, this is very useful. I was bummed out that the ammo script only worke4d in XP, but this is even better. Thanks, Queex.
EDIT: Hmm...I seem to be pretty confused on what to do. <_> Could you give an example of how to script, for example, an "item present" skill?
This post has been edited by SuperMaxZero: Mar 24 2008, 09:47 PM
|
|
|
|
|
|
|
|
|
Mar 26 2008, 09:12 PM
|

Level 8

Group: Revolutionary
Posts: 124
Type: Event Designer
RM Skill: Skilled

|
This is very useful, especially if you have skills that consume ammunition, or a skill that's only available if a character is near death.
__________________________
We exist within all things and all things exist within us... it's very crowded.
|
|
|
|
|
|
|
|
|
Mar 27 2008, 02:41 AM
|
Level 6

Group: Member
Posts: 75
Type: None
RM Skill: Beginner

|
A quick example.
If you have, in the notes field for the skill:
<item_present 3> <item_consumed 4 2> <weapon_type badger>
Then the skill can only used by an actor wielding a weapon with the line <weapon_type badger> in its notes field. It also requires item number 3 to be in the party inventory, and at least two item number 4s which will be used up by the skill.
|
|
|
|
|
|
|
|
|
Mar 27 2008, 06:56 AM
|

Level 1

Group: Member
Posts: 5
Type: Developer
RM Skill: Beginner

|
I'm getting an error with the item present line as well. I have the associated item in id 22, with <item_present 22> in the notes of the skill, but when I try to use Skills in battle (not the specific skill, but opening the skill menu) i get this: ???? 'Prereqs' ? 50 ?? TypeError ???? cannot convert String into Integer Prereqs is what I named the script to keep things simple, and here is the code section: CODE #Check for item presence skill_needs = getTag(skill_note,"item_present") #item id if skill_needs != nil return false unless $game_party.has_item?($data_items[skill_needs],true) end I'm getting the error at "return false unless" line. Ideas?
__________________________
|
|
|
|
|
|
|
|
|
Mar 27 2008, 07:04 AM
|
Level 6

Group: Member
Posts: 75
Type: None
RM Skill: Beginner

|
Try this: CODE ##################################### # Check for requirements for skills # ##################################### class Game_Actor < Game_Battler
def hands_free if weapons[0]==nil if weapons[1]==nil if @armour_id[0]==nil return 2 else return 1 end elsif weapons[1].two_handed return 0 else if @armour_id[0]==nil return 1 else return 0 end end elsif weapons[0].two_handed return 0 elsif weapons[1]!=nil or @armour_id[0]!=nil return 0 else return 1 end end
def skill_can_use?(skill) #Usual checks return false unless skill_learn?(skill) return false unless skill.is_a?(RPG::Skill) return false unless movable? return false if silent? and skill.spi_f > 0 return false if calc_mp_cost(skill) > mp if skill.id != 0 skill_note=$data_skills[skill.id].note #Check for weapon type skill_needs = getTag(skill_note,"weapon_type") #weapon type string if skill_needs != nil return false unless @weapon_id!=0 return false unless hasTagValue($data_weapons[@weapon_id].note,"weapon_type",skill_needs) end #Check for item presence skill_needs = getTag(skill_note,"item_present") #item id if skill_needs != nil return false unless $game_party.has_item?($data_items[skill_needs.to_i],true) end #Check for item consumption skill_needs = getTag(skill_note,"item_consume") #item id if skill_needs !=nil skill_needs_num = getTagAdditionalValue(skill_note,"item_consume",2) #number if skill_needs_num == nil skill_needs_num = 1 end return false unless $game_party.item_number($data_items[skill_needs.to_i])>=skill_needs_num.to_i end #Check for HP exceeds skill_needs = getTag(skill_note,"hp_percent_exceed") #percent if skill_needs !=nil return false unless (100.0 * @hp/maxhp)>=skill_needs.to_f end #Check for HP below skill_needs = getTag(skill_note,"hp_percent_below") #percent if skill_needs != nil return false unless (100.0 * @hp/maxhp)<skill_needs.to_f end #Check for MP exceeds skill_needs = getTag(skill_note,"mp_percent_exceed") #percent if skill_needs != nil return false unless (100.0 * @mp/maxmp)>=skill_needs.to_f end #Check for MP below skill_needs = getTag(skill_note,"mp_percent_below") #percent if skill_needs != nil return false unless (100.0* @mp/maxmp)<skill_needs.to_f end #Check for free hand skill_needs = hasTag(skill_note,"free_hand") #boolean if skill_needs return false unless hands_free>=1 end #Check for dual weapons skill_needs = hasTag(skill_note,"dual_weapon") #boolean if skill_needs return false unless weapons[0]!=nil and weapons[1]!=nil end #Check for two-handed weapon skill_needs = hasTag(skill_note,"two_handed_weapon") #boolean if skill_needs return false unless ( weapons[0]!= nil and weapons[0].two_handed) or (weapons[1] != nil and weapons[1].two_handed) end end if $game_temp.in_battle return skill.battle_ok? else return skill.menu_ok? end end def calc_mp_cost(skill) base_cost=skill.mp_cost mp_prop=getTag(skill.note,"mp_percent_exceed") if mp_prop!=nil mp_lose=getTagAdditionalValue(skill.note,"mp_percent_exceed",2) if mp_lose.eql?("true") base_cost=mp_prop.to_f * maxmp end end if half_mp_cost return skill.mp_cost / 2 else return skill.mp_cost end end end
class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # * Execute Battle Action: Skill #-------------------------------------------------------------------------- def execute_action_skill skill = @active_battler.action.skill text = @active_battler.name + skill.message1 @message_window.add_instant_text(text) unless skill.message2.empty? wait(10) @message_window.add_instant_text(skill.message2) end targets = @active_battler.action.make_targets display_animation(targets, skill.animation_id) @active_battler.mp -= @active_battler.calc_mp_cost(skill) #consume items required skill_needs = getTag(skill.note,"consume_item") if skill_needs != nil num_items = getTagAdditionalValue(skill.note,"consume_item",2) $game_party.lose_item($data_items[skill_needs.to_i],num_items.to_i,true) end $game_temp.common_event_id = skill.common_event_id for target in targets target.skill_effect(@active_battler, skill) display_action_effects(target, skill) end end end
I think I missed a couple of casts out. Let me know if this fixes it.
|
|
|
|
|
|
|
|
|
Mar 27 2008, 01:28 PM
|
Level 6

Group: Member
Posts: 75
Type: None
RM Skill: Beginner

|
This should be fixed. I won't embarrass myself by saying what I'd got wrong... I'd recommend getting v1.2 of TagNote as well, just in case... CODE ##################################### # Check for requirements for skills # ##################################### class Game_Actor < Game_Battler
def hands_free if weapons[0]==nil if weapons[1]==nil if @armour_id[0]==nil return 2 else return 1 end elsif weapons[1].two_handed return 0 else if @armour_id[0]==nil return 1 else return 0 end end elsif weapons[0].two_handed return 0 elsif weapons[1]!=nil or @armour_id[0]!=nil return 0 else return 1 end end
def skill_can_use?(skill) #Usual checks return false unless skill_learn?(skill) return false unless skill.is_a?(RPG::Skill) return false unless movable? return false if silent? and skill.spi_f > 0 return false if calc_mp_cost(skill) > mp if skill.id != 0 skill_note=$data_skills[skill.id].note #Check for weapon type skill_needs = getTag(skill_note,"weapon_type") #weapon type string if skill_needs != nil return false unless @weapon_id!=0 return false unless hasTagValue($data_weapons[@weapon_id].note,"weapon_type",skill_needs) end #Check for item presence skill_needs = getTag(skill_note,"item_present") #item id if skill_needs != nil return false unless $game_party.has_item?($data_items[skill_needs.to_i],true) end #Check for item consumption skill_needs = getTag(skill_note,"item_consume") #item id if skill_needs !=nil skill_needs_num = getTagAdditionalValue(skill_note,"item_consume",2) #number if skill_needs_num == nil skill_needs_num = 1 end return false unless $game_party.item_number($data_items[skill_needs.to_i])>=skill_needs_num.to_i end #Check for HP exceeds skill_needs = getTag(skill_note,"hp_percent_exceed") #percent if skill_needs !=nil return false unless (100.0 * @hp/maxhp)>=skill_needs.to_f end #Check for HP below skill_needs = getTag(skill_note,"hp_percent_below") #percent if skill_needs != nil return false unless (100.0 * @hp/maxhp)<skill_needs.to_f end #Check for MP exceeds skill_needs = getTag(skill_note,"mp_percent_exceed") #percent if skill_needs != nil return false unless (100.0 * @mp/maxmp)>=skill_needs.to_f end #Check for MP below skill_needs = getTag(skill_note,"mp_percent_below") #percent if skill_needs != nil return false unless (100.0* @mp/maxmp)<skill_needs.to_f end #Check for free hand skill_needs = hasTag(skill_note,"free_hand") #boolean if skill_needs return false unless hands_free>=1 end #Check for dual weapons skill_needs = hasTag(skill_note,"dual_weapon") #boolean if skill_needs return false unless weapons[0]!=nil and weapons[1]!=nil end #Check for two-handed weapon skill_needs = hasTag(skill_note,"two_handed_weapon") #boolean if skill_needs return false unless ( weapons[0]!= nil and weapons[0].two_handed) or (weapons[1] != nil and weapons[1].two_handed) end end if $game_temp.in_battle return skill.battle_ok? else return skill.menu_ok? end end def calc_mp_cost(skill) base_cost=skill.mp_cost mp_prop=getTag(skill.note,"mp_percent_exceed") if mp_prop!=nil mp_lose=getTagAdditionalValue(skill.note,"mp_percent_exceed",2) if mp_lose.eql?("true") base_cost=mp_prop.to_f * maxmp end end if half_mp_cost return skill.mp_cost / 2 else return skill.mp_cost end end end
class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # * Execute Battle Action: Skill #-------------------------------------------------------------------------- def execute_action_skill skill = @active_battler.action.skill text = @active_battler.name + skill.message1 @message_window.add_instant_text(text) unless skill.message2.empty? wait(10) @message_window.add_instant_text(skill.message2) end targets = @active_battler.action.make_targets display_animation(targets, skill.animation_id) @active_battler.mp -= @active_battler.calc_mp_cost(skill)
#consume items required skill_needs = getTag(skill.note,"item_consume") if skill_needs != nil num_items = getTagAdditionalValue(skill.note,"item_consume",2) if num_items==nil num_items=1 end $game_party.lose_item($data_items[skill_needs.to_i],num_items.to_i,true) end $game_temp.common_event_id = skill.common_event_id for target in targets target.skill_effect(@active_battler, skill) display_action_effects(target, skill) end end end
This post has been edited by Queex: Mar 27 2008, 01:40 PM
|
|
|
|
|
|
|
|
|
Mar 27 2008, 09:09 PM
|
Level 4

Group: Member
Posts: 49
Type: None
RM Skill: Undisclosed

|
Thanks, I got it to work fine. I was being stupid and over thinking when I was using the notes before.
|
|
|
|
|
|
|
|
|
Mar 28 2008, 07:24 AM
|

Group: Member
Posts: 1
Type: None
RM Skill: Undisclosed

|
thanks, but
<item_consumed x> <item_consumed x n>
<mp_percent_exceed p true>
these don't work, nothing will be consumed
and when use <free_hand> with out any weapon, it will make error
|
|
|
|
|
|
|
|
|
Mar 28 2008, 08:30 AM
|
Level 6

Group: Member
Posts: 75
Type: None
RM Skill: Beginner

|
The first two should be fixed now.
I'll look at the other two shortly.
EDIT: Should both be working properly, now.
This post has been edited by Queex: Mar 28 2008, 09:18 AM
|
|
|
|
|
|
|
|
|
Mar 29 2008, 09:32 PM
|

Level 8

Group: Revolutionary
Posts: 124
Type: Event Designer
RM Skill: Skilled

|
QUOTE (aevonhaldy @ Mar 29 2008, 08:36 PM)  This is a great script--will really help me with two skill ideas I have! --But any idea why I am getting a syntax error at the last line??
display_animation(targets, skill.animation_id) I got that at first too. You need to have the TagNote script as well for it to work.
__________________________
We exist within all things and all things exist within us... it's very crowded.
|
|
|
|
|
|
|
|
|
Mar 30 2008, 09:18 AM
|
Level 6

Group: Member
Posts: 75
Type: None
RM Skill: Beginner

|
Hmm. I don't know about that. I don't get an error my end. Are you using any other scripts that affect Scene_Battle at all? That line is taken unaltered from the default code so I have no idea why it may cause a syntax error.
|
|
|
|
|
|
|
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|