RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Weapon Affinity script

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 67
RMRK Junior
Hi, I feel bad for asking for this been my first post. I was wondering if someone can make a Weapon Affinity script. I've looked for one for days, and I didn't find anything.
The script I need is about something like this: A Knight can use swords, bows and axes; but his affinity are the swords, so, if he wields one, he get a plus in his attack.

I hope someone can help. I'm creative, so if someone need help with his game story, I can give him my help in return.

Thanks in advance.   ;D

P.S. Here is the request:

Weapon Affinity script
August 06, 2011

Summary

When a Class or character equips a piece of equipment that they are most skilled with, they will receive an extra bonus in stats.

Features Desired
  • A Swordman wielding a sword will do extra damage.
  • This feature should work with all the job classes and weapons classes.
  • The bonus could be added as a value, and as a percent.
Games its been in
  • I don't know any.
What other scripts are you using?
  • Yanfly Engine Zealous - Equipment Overhaul (Last Date Updated: 2010.08.16)
  • Yanfly Engine Melody - Item Overhaul (Last Date Updated: 2010.06.20)
  • Yanfly Engine Zealous - Custom Skill Effects (Last Date Updated: 2010.01.08)
  • OverDrive System - KGC_OverDrive (Last Update: 2008/08/28)

Did you search?
Of course
Where did you search?
What did you search for?
  • Weapon efficacy script
  • Weapon mastery script
  • Weapon Affinity script
  • Class Weapon Affinity script
« Last Edit: August 09, 2011, 11:05:07 PM by ovan_ »
None yet...

****
Rep:
Level 71
facepalm, what do you think the elements are for?  ??? You can use Melee or create a new element, then under the class you could set it so sword does more damage by clicking on the element efficiency ,click on it to it reaches A or B.
« Last Edit: August 06, 2011, 03:05:02 PM by DoctorTodd »

**
Rep: +0/-0Level 67
RMRK Junior
That actually works as element resistance, not affinity.
None yet...

****
Rep:
Level 71
I haven't used RPG maker VX for long but through all the experiences I had using it I know for a fact it is affinity. :P

EDIT: Not only that but right click on elements in the database and it tells you.
« Last Edit: August 07, 2011, 04:48:12 AM by DoctorTodd »

**
Rep: +0/-0Level 67
RMRK Junior
I've proved it myself, and its resistance. It refers to "efficacy" at recieving certain element attack. So "A" means that an attatck cause 200% extra damage, and "F" is inmunity.
None yet...

****
Rep:
Level 71
I right clicked on it under classes and this is what it said... "sets the efficiency of actions with various variables for actors in this class, on a 6 point scale."

**
Rep: +0/-0Level 67
RMRK Junior
I know what it says, and thought it was like you say, but it didn't work that way when I tried: A character with a class with efficacy "A" in "Melee" did the same average attack (I tried 10 attacks) as the same character with a class with efficacy "F" in "Melee" against the same enemy. 
Then I tried two characters with the same stats (actually a copy) but different classes: one with "A" in Fire efficacy and another with "F" in Fire efficacy. I make a monster use only Flame (fire on all enemys), and voila: The first character recieved a lot of damage, but the second did'nt! (he was inmune), it was like that during five turns.
That's why I'm asking for script. I thought that the YEZ Elemental Status Affinity would help me, but it doesn't work the way I need to.
None yet...

****
Rep:
Level 71
Well it has always worked for me... I will look for one.

****
Rep:
Level 71
Try this instead it's an older version of the script you tried. For help with it http://www.rpgrevolution.com/forums/lofiversion/index.php/t44139.html
Code: [Select]
#===============================================================================
#
# Yanfly Engine RD - Custom Element Affinity
# Last Date Updated: 2009.06.26
# Level: Normal, Hard, Lunatic
#
# Element rates were used universally for nearly everything. This goes for
# items, weapons, armours, and skills. However, the lack of control we have
# over them as far as RPG Maker VX is concerned leaves me rather disappointed.
# Keep in mind that this script is heavily geared towards element control and
# has tags split around for weapons, armours, states, and enemies.
#
#===============================================================================
# Updates:
# ----------------------------------------------------------------------------
# o 2009.04.27 - Bugfix for melee actors.
# o 2009.04.23 - Compatibility Update and bugfix.
# o 2009.04.19 - Started script and publicized.
#===============================================================================
# How to Use: Normal Mode
#===============================================================================
#
# Element control is split between multiple instances. First, we'll handle any
# elemental rank changes. These affect the battlers on the receiving end of
# an elemental attack, skill, or item.
#
# <element rank add x:y>, <element rank sub x:y>
# x is the ID of the element you wish to affect. y is the rank change.
# Insert these into weapons, equips, or states to increase or decrease an
# element rate. Note that adding an element rank means they become more
# resistant while lowering an element rate means they become weaker. Element
# rates will fluctuate amongst [Z,A,B,C,D,E,F] ranks.
#
# <element rank set x:y>
# x is the ID of the element you wish to affect. y is either [Z,A,B,C,D,E,F].
# This will set the element of battler to exactly that. There is a rule set of
# priorities. They'll be determined by the highest rank state, then weapons, and
# finally armours from top to bottom. With that said, you can place these into
# weapons, equips, and states.
#
# Elemental control for normal attacks can be applied via states, weapons, and
# equips for actors and states and enemy data for enemies.
#
# <element attack add x>
# x is the ID of the element you wish to infuse normal attacks with. If it's
# placed in a state, weapon, or equip, that battler's normal attacks will have
# that elemental attribute. If it's in an enemy notebox, that enemy will have
# normal attacks with that elemental attribute. This allows for enemies like
# elemental djinns to innately have an elemental attack or swordsmen to have a
# slashing element.
#
# <element attack sub x>
# x is the ID of the element you wish to prevent the battler from using in a
# normal attack. The removal tag will nullify any bonuses that would otherwise
# give an elemental trait to a normal attack. This can be placed inside a state,
# weapon, or equip. If placed in an enemy box, that enemy will never have such
# an elemental trait to its normal attack no matter what kind of status effect
# would provide for it. This is to prevent something like a fire slime suddenly
# using ice attacks.
#
#===============================================================================
# How to Use: Hard Mode
#===============================================================================
#
# Elemental control for skills can be adjusted with the following tags. Note
# that if you wish to use elemental control for skills, you REQUIRE Yanfly's
# Custom Damage Formula script.
#
# <element skill add x>
# x is the ID of the element you wish to infuse skills with. If it's placed in
# a state, weapon, or equip, the battler's skills will possess an additional
# element with them.
#
# <element skill sub x>
# x is the ID of the element you wish to prevent the battler from using in a
# skill. The removal tag will completely nullify any elemental traits that the
# skill would otherwise have. This can be placed inside a state, weapon, or
# equip to take effect.
#
# <element lock>
# Placing this inside of a skill's notebox to prevent that skill from having
# its elements alter through means of the two previously mentioned tags.
#
#===============================================================================
#
# Compatibility
# - Requires: Yanfly Engine, Custom Damage Formula
# - Overwrites: Game_Battler, element_rate, elements_max_rate
# - Overwrites: Game_Actor, element_rate, element_set
# - Overwrites: Game_Enemy, element_rate
#
#===============================================================================

$imported = {} if $imported == nil
$imported["CustomElementAffinity"] = true

module YE
module BATTLE
module ELEMENT

# This is what element an actor's unarmed attack is considered.
# Set to nil if you would like unarmed attacks to have no element.
UNARMED = 7

# This is the modifier for reduction rate if any states or armour possess
# protection against that element. By default, rates are 50%.
REDUCTION = 50

# This sets the default rates for your elements. These rates affect
# how damage inflates or deflates corresponding to a battler's elemental
# affinity. Negative values indicate damage converting to healing.
RATE_Z = 300
RATE_A = 200
RATE_B = 150
RATE_C = 100
RATE_D = 50
RATE_E = 0
RATE_F = -100

# This allows you to set custom elemental rates. This is mostly to prevent
# odd instances like enemies absorbing blunt attacks and whatnot. Any
# element ID that's not listed in here will use the default rates.
CUSTOM_RATES = {
# ID => [ Z, A, B, C, D, E, F]
1 => [300, 200, 150, 100, 50, 25, 0],
2 => [300, 200, 150, 100, 50, 25, 0],
3 => [300, 200, 150, 100, 50, 25, 0],
4 => [300, 200, 150, 100, 50, 25, 0],
5 => [300, 200, 150, 100, 50, 25, 0],
6 => [300, 200, 150, 100, 50, 25, 0],
} # Do not remove this.

end # ELEMENT
end # BATTLE
module HASH

ELEMENT_TYPE = { # Input the elements into any category you want here.
"Elements" => [ 1, 2, 3, 4, 5, 6, 7 ],
"Magical" => [],
}

end # HASH
end # YE

#===============================================================================
# How to Use: Lunatic Mode
#===============================================================================
#
# <custom element x>
# If placed in a skill, this calls on case ID x. The returned element_set array
# will reveal to the damage multiplier what kind of elements you're applying to
# the skill or skills. Similar to the other Lunatic portions of other Yanfly
# Engine ReDux scripts, there is a "common_element" definition which will run
# for every skill regardless of a custom element tag or not.
#
#===============================================================================

class Game_Battler

def run_custom_element(case_id, element_set, user, target)
case case_id
#---------------------------------------------------------------------------
# //////////////////////////////////////////////////////////////////////////
# This is where you begin adding in your own custom elements
#---------------------------------------------------------------------------
when 1
if target.hp > user.hp
element_set = [10]
else
element_set = [9]
end

when 2

#---------------------------------------------------------------------------
# This is the part you guys shouldn't touch afterwards.
# //////////////////////////////////////////////////////////////////////////
#---------------------------------------------------------------------------
end
return element_set
end

#-----------------------------------------------------------------------------
#-----This is the common element adjustment. Make any element changes here.
def common_element(element_set, user, target)
if user != nil
# This means there is someone performing the elemental adjustments.
end
return element_set
end
#-----------------------------------------------------------------------------

end # Game_Battler

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================

module YE
module REGEXP
module ELEMENT

# these adjust rank modification
RANK_ADD = /<(?:ELEMENT_RANK_ADD|element rank add)[ ]*(\d+)sad.gif\d+)>/i
RANK_SUB = /<(?:ELEMENT_RANK_SUB|element rank sub)[ ]*(\d+)sad.gif\d+)>/i
RANK_SET = /<(?:ELEMENT_RANK_SET|element rank set)[ ]*(\d+):\s*([ZABCDEF])?>/i

# these adjust normal attack elements
ATTACK = /<(?:ELEMENT_ATTACK_ADD|element attack add)[ ]*(\d+)>/i
UNATTACK = /<(?:ELEMENT_ATTACK_SUB|element attack sub)[ ]*(\d+)>/i

# these adjust skill elements
SKILL = /<(?:ELEMENT_SKILL|element skill add)[ ]*(\d+)>/i
UNSKILL = /<(?:ELEMENT_SKILL|element skill sub)[ ]*(\d+)>/i
ELE_LOCK = /<(?:ELEMENT_LOCK|element lock)>/i
CUSTOM_E = /<(?:CUSTOM_ELEMENT|custom element)[ ]*(\d+)>/i

end # ELEMENT
end # REGEXP
end # YE

#===============================================================================
# RPG::BaseItem
#===============================================================================

class RPG::BaseItem

#--------------------------------------------------------------------------
# Yanfly Cache Skill CEA
#--------------------------------------------------------------------------
def yanfly_cache_skill_cea
@element_lock = false
@custom_element = 0

self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::ELE_LOCK
@element_lock = true
when YE::REGEXP::ELEMENT::CUSTOM_E
@custom_element = $1.to_i

end
}
end

#--------------------------------------------------------------------------
# element lock
#--------------------------------------------------------------------------
def element_lock
yanfly_cache_skill_cea if @element_lock == nil
return @element_lock
end

#--------------------------------------------------------------------------
# custom element
#--------------------------------------------------------------------------
def custom_element
yanfly_cache_skill_cea if @custom_element == nil
return @custom_element
end

end # end RPG::BaseItem

#===============================================================================
# RPG::Enemy
#===============================================================================

class RPG::Enemy

#--------------------------------------------------------------------------
# Yanfly Cache Enemy CEA
#--------------------------------------------------------------------------
def yanfly_cache_enemy_cea
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []

self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::ATTACK
@element_attack.push($1.to_i)
when YE::REGEXP::ELEMENT::UNATTACK
@element_unattack.push($1.to_i)
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)

end
}
end

#--------------------------------------------------------------------------
# Element Attack/Unattack
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_enemy_cea if @element_attack == nil
return @element_attack
end

def element_unattack
yanfly_cache_enemy_cea if @element_unattack == nil
return @element_unattack
end

#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_enemy_cea if @element_skill == nil
return @element_skill
end

def element_unskill
yanfly_cache_enemy_cea if @element_unskill == nil
return @element_unskill
end

end

#===============================================================================
# RPG::State
#===============================================================================

class RPG::State

#--------------------------------------------------------------------------
# Yanfly Cache State CEA
#--------------------------------------------------------------------------
def yanfly_cache_state_cea
@element_rank_mod = 0; @element_rank_mid = 0
@element_rank_set = 7; @element_rank_sid = 0
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []

self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::RANK_ADD
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i
when YE::REGEXP::ELEMENT::RANK_SUB
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i * -1
when YE::REGEXP::ELEMENT::ATTACK
element = $1.to_i
@element_attack.push(element)
when YE::REGEXP::ELEMENT::UNATTACK
element = $1.to_i
@element_unattack.push(element)
when YE::REGEXP::ELEMENT::RANK_SET
@element_rank_sid = $1.to_i
case $2.upcase
when "F"
@element_rank_set = 6
when "E"
@element_rank_set = 5
when "D"
@element_rank_set = 4
when "C"
@element_rank_set = 3
when "B"
@element_rank_set = 2
when "A"
@element_rank_set = 1
when "Z"
@element_rank_set = 0
end
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)

end
}
end

#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod
yanfly_cache_state_cea if @element_rank_mod == nil
return @element_rank_mod
end
def element_rank_mid
yanfly_cache_state_cea if @element_rank_mid == nil
return @element_rank_mid
end

#--------------------------------------------------------------------------
# Element Rank set
#--------------------------------------------------------------------------
def element_rank_set
yanfly_cache_state_cea if @element_rank_set == nil
return @element_rank_set
end

def element_rank_sid
yanfly_cache_state_cea if @element_rank_sid == nil
return @element_rank_sid
end

#--------------------------------------------------------------------------
# Element Attack/Unattack
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_state_cea if @element_attack == nil
return @element_attack
end

def element_unattack
yanfly_cache_state_cea if @element_unattack == nil
return @element_unattack
end

#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_state_cea if @element_skill == nil
return @element_skill
end

def element_unskill
yanfly_cache_state_cea if @element_unskill == nil
return @element_unskill
end

end # RPG::State

#==============================================================================
# RPG::Weapon
#==============================================================================

class RPG::Weapon < RPG::BaseItem

#--------------------------------------------------------------------------
# Yanfly Cache Weapon CEA
#--------------------------------------------------------------------------
def yanfly_cache_wpn_cea
@element_rank_mod = 0; @element_rank_mid = 0
@element_rank_set = 7; @element_rank_sid = 0
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []

self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::RANK_ADD
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i
when YE::REGEXP::ELEMENT::RANK_SUB
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i * -1
when YE::REGEXP::ELEMENT::ATTACK
element = $1.to_i
@element_attack.push(element)
when YE::REGEXP::ELEMENT::UNATTACK
element = $1.to_i
@element_unattack.push(element)
when YE::REGEXP::ELEMENT::RANK_SET
@element_rank_sid = $1.to_i
case $2.upcase
when "F"
@element_rank_set = 6
when "E"
@element_rank_set = 5
when "D"
@element_rank_set = 4
when "C"
@element_rank_set = 3
when "B"
@element_rank_set = 2
when "A"
@element_rank_set = 1
when "Z"
@element_rank_set = 0
end
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)


end
}
end

#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod
yanfly_cache_wpn_cea if @element_rank_mod == nil
return @element_rank_mod
end
def element_rank_mid
yanfly_cache_wpn_cea if @element_rank_mid == nil
return @element_rank_mid
end

#--------------------------------------------------------------------------
# Element Rank set
#--------------------------------------------------------------------------
def element_rank_set
yanfly_cache_wpn_cea if @element_rank_set == nil
return @element_rank_set
end

def element_rank_sid
yanfly_cache_wpn_cea if @element_rank_sid == nil
return @element_rank_sid
end

#--------------------------------------------------------------------------
# Element Bestow/Unattack/Resist/Unresist
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_wpn_cea if @element_attack == nil
return @element_attack
end

def element_unattack
yanfly_cache_wpn_cea if @element_unattack == nil
return @element_unattack
end

#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_wpn_cea if @element_skill == nil
return @element_skill
end

def element_unskill
yanfly_cache_wpn_cea if @element_unskill == nil
return @element_unskill
end

end # RPG::Weapon

#==============================================================================
# RPG::Armor
#==============================================================================

class RPG::Armor < RPG::BaseItem

#--------------------------------------------------------------------------
# Yanfly Cache Armour CEA
#--------------------------------------------------------------------------
def yanfly_cache_arm_cea
@element_rank_mod = 0; @element_rank_mid = 0
@element_rank_set = 7; @element_rank_sid = 0
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []

self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::RANK_ADD
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i
when YE::REGEXP::ELEMENT::RANK_SUB
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i * -1
when YE::REGEXP::ELEMENT::ATTACK
element = $1.to_i
@element_attack.push(element)
when YE::REGEXP::ELEMENT::UNATTACK
element = $1.to_i
@element_unattack.push(element)
when YE::REGEXP::ELEMENT::RANK_SET
@element_rank_sid = $1.to_i
case $2.upcase
when "F"
@element_rank_set = 6
when "E"
@element_rank_set = 5
when "D"
@element_rank_set = 4
when "C"
@element_rank_set = 3
when "B"
@element_rank_set = 2
when "A"
@element_rank_set = 1
when "Z"
@element_rank_set = 0
end
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)

end
}
end

#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod
yanfly_cache_arm_cea if @element_rank_mod == nil
return @element_rank_mod
end
def element_rank_mid
yanfly_cache_arm_cea if @element_rank_mid == nil
return @element_rank_mid
end

#--------------------------------------------------------------------------
# Element Rank set
#--------------------------------------------------------------------------
def element_rank_set
yanfly_cache_arm_cea if @element_rank_set == nil
return @element_rank_set
end

def element_rank_sid
yanfly_cache_arm_cea if @element_rank_sid == nil
return @element_rank_sid
end

#--------------------------------------------------------------------------
# Element Bestow/Unattack/Resist/Unresist
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_arm_cea if @element_attack == nil
return @element_attack
end

def element_unattack
yanfly_cache_arm_cea if @element_unattack == nil
return @element_unattack
end

#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_arm_cea if @element_skill == nil
return @element_skill
end

def element_unskill
yanfly_cache_arm_cea if @element_unskill == nil
return @element_unskill
end

end # RPG::Armor

#==============================================================================
# Game_Battler
#==============================================================================

class Game_Battler

#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod(rank, element_id)
#---------------------------
for state in states
if state.element_rank_sid == element_id
return state.element_rank_set unless state.element_rank_set > 6
end
end
#---------------------------
if self.actor?
for weapon in weapons.compact
next if weapon == nil
if weapon.element_rank_mid == element_id
return weapon.element_rank_set unless weapon.element_rank_set > 6
end
end
for armor in armors.compact
next if armor == nil
if armor.element_rank_mid == element_id
return armor.element_rank_set unless armor.element_rank_set > 6
end
end
#---------------------------
for weapon in weapons.compact
next if weapon == nil
if weapon.element_rank_mid == element_id
rank += weapon.element_rank_mod
end
end
for armor in armors.compact
next if armor == nil
if armor.element_rank_mid == element_id
rank += armor.element_rank_mod
end
end
end
#---------------------------
for state in states
if state.element_rank_mid == element_id
rank += state.element_rank_mod
end
end
#---------------------------
rank = [[rank, 0].max, 6].min
return rank
end

#--------------------------------------------------------------------------
# Set Element Rates
#--------------------------------------------------------------------------
def set_element_rate(element_id)
if YE::BATTLE::ELEMENT::CUSTOM_RATES.include?(element_id)
ray = YE::BATTLE::ELEMENT::CUSTOM_RATES[element_id]
rz = ray[0]
ra = ray[1]
rb = ray[2]
rc = ray[3]
rd = ray[4]
re = ray[5]
rf = ray[6]
else
rz = YE::BATTLE::ELEMENT::RATE_Z
ra = YE::BATTLE::ELEMENT::RATE_A
rb = YE::BATTLE::ELEMENT::RATE_B
rc = YE::BATTLE::ELEMENT::RATE_C
rd = YE::BATTLE::ELEMENT::RATE_D
re = YE::BATTLE::ELEMENT::RATE_E
rf = YE::BATTLE::ELEMENT::RATE_F
end
rate_hash = [rz,ra,rb,rc,rd,re,rf]
return rate_hash
end

#--------------------------------------------------------------------------
# Element Reduction
#--------------------------------------------------------------------------
def element_reduction(result)
result *= YE::BATTLE::ELEMENT::REDUCTION
result /= 100
return result
end

#--------------------------------------------------------------------------
# Overwrite Element_Set (for enemies)
#--------------------------------------------------------------------------
def element_set
result = []
for state in states
result = state.element_attack
end
result += enemy.element_attack
result -= enemy.element_unattack
result.uniq
return result
end

#--------------------------------------------------------------------------
# Overwrite Elements Max Rate
#--------------------------------------------------------------------------
def elements_max_rate(element_set, attacker = nil)
#--------------------------------------
if attacker != nil and attacker.action.skill?
obj = attacker.action.skill
if obj.custom_element > 0
rce_id = obj.custom_element
element_set = run_custom_element(rce_id, element_set, attacker, self)
end
unless obj.element_lock
if attacker.actor?
for weapon in attacker.weapons.compact
next if weapon == nil
element_set += weapon.element_skill
end
for armor in attacker.armors.compact
next if armor == nil
element_set += armor.element_skill
end
end
#--------------------------------------
for state in attacker.states do
element_set += state.element_skill
end
for state in attacker.states do
element_set -= state.element_unskill
end
#--------------------------------------
if attacker.actor?
for weapon in attacker.weapons.compact
next if weapon == nil
element_set -= weapon.element_unskill
end
for armor in attacker.armors.compact
next if armor == nil
element_set -= armor.element_unskill
end
end
end
end
#----------------------------------------------------
element_set = common_element(element_set, attacker, self)
return 100 if element_set.empty?
rate_list = []
for i in element_set
rate_list.push(element_rate(i))
end
return rate_list.max
end

end # end Game_Battler

#==============================================================================
# Game_Actor
#==============================================================================

class Game_Actor < Game_Battler

#--------------------------------------------------------------------------
# Overwrite Element_Rate
#--------------------------------------------------------------------------
def element_rate(element_id)
rank = element_rank_mod(self.class.element_ranks[element_id], element_id)
rate_hash = self.set_element_rate(element_id)
result = rate_hash[rank]
for armor in armors.compact
if armor.element_set.include?(element_id)
result = self.element_reduction(result)
end
end
for state in states
if state.element_set.include?(element_id)
result = self.element_reduction(result)
end
end
return result
end

#--------------------------------------------------------------------------
# Overwrite Element_Set
#--------------------------------------------------------------------------
def element_set
result = []
if weapons.compact == []
# Unarmed: melee attribute
unele = YE::BATTLE::ELEMENT::UNARMED
result.push(unele) unless unele == nil
return result
end
for weapon in weapons.compact
next if weapon == nil
result |= weapon == nil ? [] : weapon.element_set
end
for state in states
result += state.element_attack
end
for weapon in weapons.compact
next if weapon == nil
result += weapon.element_attack
end
for armor in armors.compact
next if armor == nil
result += armor.element_attack
end
result.uniq
for state in states
result -= state.element_unattack
end
for weapon in weapons.compact
next if weapon == nil
result -= weapon.element_unattack
end
for armor in armors.compact
next if armor == nil
result -= armor.element_unattack
end
result.uniq
return result
end

end #end Game_Actor

#==============================================================================
# Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler

#--------------------------------------------------------------------------
# Overwrite Element_Rate
#--------------------------------------------------------------------------
def element_rate(element_id)
rank = element_rank_mod(enemy.element_ranks[element_id], element_id)
rate_hash = self.set_element_rate(element_id)
result = rate_hash[rank]
for state in states
if state.element_set.include?(element_id)
result = self.element_reduction(result)
end
end
return result
end

end # end Game_Enemy

#===============================================================================
#
# END OF FILE
#
#===============================================================================



**
Rep: +0/-0Level 67
RMRK Junior
Thank you for your help, but it didn't work the way I wanted.
None yet...

****
Rep:
Level 71
How exactly do you want it to function?

**
Rep: +0/-0Level 67
RMRK Junior
Quote
The script I need is about something like this: A Knight can use swords, bows and axes; but his affinity are the swords, so, if he wields one, he get a plus in his attack.
The script show works as element resistance (which results to be contrary to the script I want).
Maybe a script that needs to add a instruction in every equipment's comment to work will do the job.
None yet...

****
Rep:
Level 71
I will look again, sadly I only know very little about scripting some one may be to make  it for you if I can't find one.  :D

EDIT: Sorry I looked there's nothing more I can do. May some can make it for you
« Last Edit: August 08, 2011, 08:54:43 PM by DoctorTodd »

**
Rep: +0/-0Level 67
RMRK Junior
Thank you very much for trying helping me DoctorTodd. I hope a scripter could help me with this problem.
None yet...

****
Rep:
Level 71
No problem, I may have not solved your problem but +1 rep is always nice.

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Basically what you want is that if a Class or character equips a piece of equipment that they are most skilled with, they would receive an extra bonus in stats?

If that is the case, then I finished the script.

Just fix up your post with the script request template and I will post it.

Template:
http://rmrk.net/index.php/topic,24347.0.html
« Last Edit: August 09, 2011, 09:19:13 AM by TDS »

**
Rep: +0/-0Level 67
RMRK Junior
Ok TDS, here it is:
Weapon Affinity script
August 06, 2011

Summary

When a Class or character equips a piece of equipment that they are most skilled with, they will receive an extra bonus in stats.

Features Desired
  • A Swordman wielding a sword will do extra damage.
  • This feature should work with all the job classes and weapons classes.
Games its been in
  • I don't know any.
What other scripts are you using?
  • Yanfly Engine Zealous - Equipment Overhaul (Last Date Updated: 2010.08.16)
  • Yanfly Engine Melody - Item Overhaul (Last Date Updated: 2010.06.20)
  • Yanfly Engine Zealous - Custom Skill Effects (Last Date Updated: 2010.01.08)
  • OverDrive System - KGC_OverDrive (Last Update: 2008/08/28)

Did you search?
Of course
Where did you search?
What did you search for?
  • Weapon efficacy script
  • Weapon mastery script
  • Weapon Affinity script
  • Class Weapon Affinity script
None yet...

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Alright, I meant fix your original post, but you I'll take it.

Here you go.

Code: [Select]
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias listing and method definition
  #-------------------------------------------------------------------------- 
  # Basic Stats Array as symbols
  stats = [:base_atk, :base_def, :base_spi, :base_agi]
  # Attributes as Strings
  attributes = ["ATK", "DEF", "SPI", "AGI"]
  # Go Through Stats
  stats.each_with_index {|stat, i|
    # Alias Method
    alias_method ("tds_equipment_class_bonus_game_actor_#{stat}".to_sym, stat)
    # Define Stat Method
    define_method (stat) {
      # Return Base Stat with Equipment Class Bonus
      return self.send ("tds_equipment_class_bonus_game_actor_#{stat}") + equipment_class_bonus(attributes[i])
     }
  }   
  #--------------------------------------------------------------------------
  # * Get Equipment Class Bonus
  #     attribute : attribute name
  #--------------------------------------------------------------------------
  def equipment_class_bonus(attribute)   
    # Set Initial Bonus
    bonus = 0
    # Go Through Equipment and add up attribute bonus
    equips.compact.each {|equip| bonus += equip.class_attribute_bonus(@class_id, attribute)}
    # Return Attribute Bonus
    return bonus
  end 
end


#==============================================================================
# ** RPG::BaseItem
#------------------------------------------------------------------------------
# This module handles Item, Weapons and Armor information.
#==============================================================================

module RPG
    class BaseItem
    #--------------------------------------------------------------------------
    # * Equipment Class Attribute Bonus
    #     class_id  : class id
    #     attribute : attribute for bonus
    #--------------------------------------------------------------------------   
    def class_attribute_bonus(class_id, attribute)
      # Check For Class Bonus
      self.note[/CLASS_#{class_id}_#{attribute}_BONUS: ([-0-9]+)/]     
      # Return Class Bonus
      return $1.nil? ? 0 : $1.to_i
    end 
  end 
end

To use it just add this to the note box of any piece of equipment you want to have bonuses for classes.

Code: [Select]
CLASS_ID_STAT_BONUS: BONUS

It's a little tricky, but you need to replace ID and STAT to the ID of the class that would receive the bonus and which stat.

Example:

Code: [Select]
CLASS_1_ATK_BONUS: 10
CLASS_1_DEF_BONUS: 10
CLASS_1_AGI_BONUS: 10
CLASS_1_SPI_BONUS: 10

It will also accept negative values in case you want certain classes to have penalties instead of bonuses.

Let me know if this works out for you and if you need anything added or removed.

Have a nice day.

***
Rep:
Level 75
I was looking through this topic and I was wondering if the bonus could a be percents instead of a fixed value.

Spoiler for:



Spoiler for:
John 3:16: For God loved the world so much that he gave his one and only Son, so that everyone who believes in him will not perish but have eternal life

**
Rep: +0/-0Level 67
RMRK Junior
I was about to ask the same thing CodeMaster. I worked perfectly, but, would you please fix it that way (in %) TDS?
None yet...

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Here you go.

Code: [Select]
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias listing and method definition
  #-------------------------------------------------------------------------- 
  # Basic Stats Array as symbols
  stats = [:base_atk, :base_def, :base_spi, :base_agi]
  # Attributes as Strings
  attributes = ["ATK", "DEF", "SPI", "AGI"] 
  # Go Through Stats
  stats.each_with_index {|stat, i|
    # Alias Method
    alias_method ("tds_equipment_class_bonus_game_actor_#{stat}".to_sym, stat)
    # Define Stat Method
    define_method (stat) {
      # Return Base Stat with Equipment Class Bonus
      return self.send ("tds_equipment_class_bonus_game_actor_#{stat}") + equipment_class_bonus(attributes[i], 2 + i)
     }
  }   
  #--------------------------------------------------------------------------
  # * Get Equipment Class Bonus
  #     attribute : attribute name
  #     index     : attribute index
  #--------------------------------------------------------------------------
  def equipment_class_bonus(attribute, index)   
    # Set Initial Bonus
    bonus = 0
    # Get Base Value for Parameter
    base = actor.parameters[index, @level]
    # Go Through Equipment and add up attribute bonus
    equips.compact.each {|equip| bonus += equip.class_attribute_bonus(@class_id, attribute, base)}
    # Return Attribute Bonus
    return bonus
  end 
end


#==============================================================================
# ** RPG::BaseItem
#------------------------------------------------------------------------------
# This module handles Item, Weapons and Armor information.
#==============================================================================

module RPG
    class BaseItem
    #--------------------------------------------------------------------------
    # * Equipment Class Attribute Bonus
    #     class_id  : class id
    #     attribute : attribute for bonus
    #     base      : base value for percentage
    #--------------------------------------------------------------------------   
    def class_attribute_bonus(class_id, attribute, base)
      # Check For Class Bonus
      self.note[/CLASS_#{class_id}_#{attribute}_BONUS: ([-%0-9]+)/]     
      # If Match is not nil and includes % Percent Sign
      if !$1.nil? and $1.include?("%")
        # Determine Percent Increase for Base
        base *= ($1.to_i / 100.0)
        # Return Base % Increase
        return base.to_i
      end
      # Return Class Bonus
      return $1.nil? ? 0 : $1.to_i
    end 
  end 
end

Just add the bonus as the number plus percent

Code: [Select]
CLASS_1_ATK_BONUS: 10%

It will still work like before and accept normal values too.

Let me know if this version works out for you.

Also fix your main post with the request template one.

**
Rep: +0/-0Level 67
RMRK Junior
Thanks TDS, it worked ;D . I'll give you reps when I can XD (I don't have any to give yet). The request template is fixed and in my main post.
None yet...

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
I see you've used MA's block tip for aliasing already! It's a neat trick.
Fine script you have thar.
it's like a metaphor or something i don't know