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
|
|
|
|
|
|
|
|
 |
Replies
|
|
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
|
|
|
|
|
|
|
Posts in this topic
Queex Skill Requirement System 1.1 Mar 20 2008, 11:22 AM callydude Sorry but this is really easy to do using events a... Mar 20 2008, 01:00 PM Zelda Freak QUOTE (callydude @ Mar 20 2008, 01:00 PM)... Jan 17 2009, 08:12 PM Queex I'm pretty sure it isn't. Common events do... Mar 20 2008, 02:05 PM Fade Actually, I think this is pretty damned useful. T... Mar 20 2008, 07:20 PM SuperMaxZero Yeah, this is very useful. I was bummed out that t... Mar 24 2008, 03:22 PM SeeYouAlways Hmm, I like this script! I was figuring out ho... Mar 26 2008, 07:00 PM Mr_E_Man This is very useful, especially if you have skills... Mar 26 2008, 09:12 PM Queex A quick example.
If you have, in the notes field ... Mar 27 2008, 02:41 AM ryuujin5 I'm getting an error with the item present lin... Mar 27 2008, 06:56 AM Queex Try this:
CODE###################################... Mar 27 2008, 07:04 AM ryuujin5 Alright, it's working smoothly, but it won... Mar 27 2008, 10:21 AM SuperMaxZero Thanks, I got it to work fine. I was being stupid ... Mar 27 2008, 09:09 PM sunnyghost thanks, but
<item_consumed x>
<item_cons... Mar 28 2008, 07:24 AM Queex The first two should be fixed now.
I'll look ... Mar 28 2008, 08:30 AM lahandi A powerfull script mate. This will make lot things... Mar 28 2008, 10:29 AM aevonhaldy This is a great script--will really help me with t... Mar 29 2008, 09:22 PM Mr_E_Man QUOTE (aevonhaldy @ Mar 29 2008, 08:36 PM... Mar 29 2008, 09:32 PM aevonhaldy @ Mr E
Well, I do actually have the most recent T... Mar 29 2008, 09:39 PM Queex Hmm. I don't know about that. I don't get ... Mar 30 2008, 09:18 AM luciddose I was wondering how you can make this work with Fo... Mar 30 2008, 12:33 PM aevonhaldy QUOTE (Queex @ Mar 30 2008, 11:32 AM) Hmm... Mar 30 2008, 02:59 PM icecold49 I have to say that this is one solid script here. ... Mar 30 2008, 10:37 AM Queex We both change Scene_Battle.execute_action_skill f... Mar 30 2008, 01:47 PM luciddose wow that totally works - thank you, dont know what... Apr 2 2008, 11:25 PM Queex I'm using battlebacks (before this script) wit... Mar 30 2008, 04:07 PM aevonhaldy Well, I tried taking out my scripts ONE BY ONE unt... Mar 30 2008, 06:29 PM Queex Actually- that shouldn't be the last line. I t... Mar 31 2008, 12:51 AM aevonhaldy QUOTE (Queex @ Mar 31 2008, 03:05 AM) Act... Mar 31 2008, 08:28 AM Queex Done- check the original post. That version is the... Mar 31 2008, 02:07 PM aevonhaldy Thanks Queex,
You are awesome. I look forward to ... Mar 31 2008, 03:06 PM Dark Koji Yo there!
I noticed that if I set <weapon_... Apr 1 2008, 07:55 AM Queex I'll fix the script. Tonight, probably. Should... Apr 1 2008, 08:15 AM Dark Koji Tested it, and it works! Both when equipped wi... Apr 1 2008, 03:56 PM Queex Umm, it seems to work for me. As ever, check both ... Apr 1 2008, 04:19 PM Queex Bump for newer version.
Now uses the revised TagN... Apr 4 2008, 05:03 PM yuukimaru hey is there a way to make one of the requirements... Apr 9 2008, 01:15 PM hjorverdr sorry, i'm having problems with the status on ... May 28 2008, 09:16 AM thinkabout This script looks solid.
I'll look forward ... May 28 2008, 12:26 PM Queex I've been side-tracked by other time sinks rec... May 29 2008, 05:57 AM ell I have the same problem as hjorverdr and it seems ... Jul 21 2008, 02:43 AM Mickadell Comment
Rate: Ok
I do like it. Alittle but more i... Jan 17 2009, 08:11 PM The Imp Hey nice script. Is there any way to make this wor... Feb 1 2009, 09:42 PM silvershadic Is there a way to consume armors? Apr 9 2011, 10:29 AM Kread-EX Check this part of the script:
CODE #Check for i... Apr 9 2011, 10:54 AM
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|