[RMVX ACE] - USING AN EQUIPPED WEAPON'S ATTACK POWER IN A DAMAGE FORMULA?
Posts
Pages:
1
I'm currently testing out some damage formulae for normal attacks with equipped weapons. I have a few that work fine that I'll use for backup should this not work, but what I would like to know is this: Is there a way to use the weapon's individual attack power in a formula separately from the character's total attack power? Could I find it somewhere in the default scripts, perhaps? I don't need the character's attack power with the weapon equipped, but the actual power of the equipped weapon itself. Like, say if the character has 40 attack power without the weapon equipped. The weapon he equips has 20 attack power, giving him 60 total attack power when equipped. How would I write the 20 in the damage formula?
Because you're using this formula on normal attacks it makes it a bit trickier to do with just a formula that's not a long mess of ternary operators due to enemies not having weapons.
The code below should, however, do the deed.
Just use w_atk instead of atk like so to get the attack power of the weapon alone.
Let me know if this works out for you and if you need anything added to it.
Have a nice day.
The code below should, however, do the deed.
Just use w_atk instead of atk like so to get the attack power of the weapon alone.
a.w_atk * 4 - b.def * 2
#============================================================================== # ** Game_Battler #------------------------------------------------------------------------------ # A battler class with methods for sprites and actions added. This class # is used as a super class of the Game_Actor class and Game_Enemy class. #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Get Weapons Attack Power # slot : weapon slot # combined : if true combine power of dual wielding weapons #-------------------------------------------------------------------------- def w_atk(slot = 0, combined = false) # Return Attack if Enemy return atk if enemy? # Set Initial Value value = 0 # If Combined and Dual wielding if combined and dual_wield? # Increase Value by attack power of weapons weapons.each {|w| value += w.params.at(2)} else # Increase Value by attack power of weapon at slot value += weapons.at(slot).params.at(2) and !weapons.at(slot).nil? end # Return Value return value end end
Let me know if this works out for you and if you need anything added to it.
Have a nice day.
Hmm, either it was how I put the formula in or the way I set it up, but it keeps returning as 0. But I'm not going to bother with it to be honest, because I've come up with another formula some time ago which I've had no problems with in the past (balance-wise), so I think I'm just going to use that instead. Not to mention I've got way too many skills set up as normal attacks as it is, and it'll be a pain to change them all to include individual weapon power. This was just something I happened to think about and I was just curious if it could be done. I'll keep this in mind in case I change my mind, though.
Thanks for the help, anyway.
Thanks for the help, anyway.
Would you show the formula you are using to test the script? I suspect that perhaps it might be the problem or that the character has no weapon equipped unless there are other scripts conflicting with it.
No reason to give up and do it the hard way because the first attempt didn't work right out the bat.
No reason to give up and do it the hard way because the first attempt didn't work right out the bat.
a.atk + ((a.atk + a.level).to_f / 32) * ((a.atk + a.level).to_f / 32) - b.def * 0.7
That's a formula I'm using for normal attacks. The issue I'm having is if I place a.w_atk in the formula, the result returns 0. Then again, since I am using a lot of scripts, there very well may be a conflicting script issue somewhere.
That's a formula I'm using for normal attacks. The issue I'm having is if I place a.w_atk in the formula, the result returns 0. Then again, since I am using a lot of scripts, there very well may be a conflicting script issue somewhere.
I see where the 0 is coming from. Although I'm too sure as to why it even works at all since enemies have no levels and it should crash the formula.
By testing the formula on the default database without variance I learned that by using the default stats on an enemy slime at level 1 against the default player with 19 defense it would come out to -1.134960937499999 damage.
Stats and formula used:
I managed to do at least 1 damage by setting the level of the slime to 37. I don't know the numbers you are using so I can't say what is causing the error for you, but for me the problem with damage seems to stem from the low stats and levels of enemies against the stats of the player.
Not sure if you have an enemy level script, but here is an edit giving the enemies a default level of 37 to test.
By testing the formula on the default database without variance I learned that by using the default stats on an enemy slime at level 1 against the default player with 19 defense it would come out to -1.134960937499999 damage.
Stats and formula used:
a_atk = 12 ; a_level = 1 ; b_def = 19 p a_atk + ((a_atk + a_level).to_f / 32) * ((a_atk + a_level).to_f / 32) - b_def * 0.7 rgss_stop
I managed to do at least 1 damage by setting the level of the slime to 37. I don't know the numbers you are using so I can't say what is causing the error for you, but for me the problem with damage seems to stem from the low stats and levels of enemies against the stats of the player.
Not sure if you have an enemy level script, but here is an edit giving the enemies a default level of 37 to test.
#============================================================================== # ** Game_Battler #------------------------------------------------------------------------------ # A battler class with methods for sprites and actions added. This class # is used as a super class of the Game_Actor class and Game_Enemy class. #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # * Calculate Damage #-------------------------------------------------------------------------- def level return 37 if enemy? return self.level if actor? end #-------------------------------------------------------------------------- # * Get Weapons Attack Power # slot : weapon slot # combined : if true combine power of dual wielding weapons #-------------------------------------------------------------------------- def w_atk(slot = 0, combined = false) # Return Attack if Enemy return atk if enemy? # Set Initial Value value = 0 # If Combined and Dual wielding if combined and dual_wield? # Increase Value by attack power of weapons weapons.each {|w| value += w.params.at(2)} else # Increase Value by attack power of weapon at slot value += weapons.at(slot).params.at(2) and !weapons.at(slot).nil? end # Return Value return value end end
I am indeed using an enemy level script, so I do get different numbers with that formula. But let me give a little insight:
The first character the player gets to control starts at level 1, with 80 HP and 45 attack power, including the weapon he starts equipped with, which has 14 attack power. First enemy in the game (depending on what's encountered) can spawn anywhere from level 1 to level 3 depending on RNG, has anywhere from 50 to about 60 HP and has defense from 14 to 16. The normal attack's variance is 10, so with my formula, a normal attack (if it doesn't critical) does anywhere from 32 to 39 damage. Enemies use another formula for their normal attacks, so this formula only applies to just some of the actors.
While the damage is noticeable as the player changes weapons and/or levels up, even while enemies slowly level along with them, it's a little less noticeable later on in the game. Which is why I was hoping to somehow include some way to incorporate the actor's equipped weapon's attack power somewhere in that formula to make making the damage from each weapon equipped more noticeable during mid to late game. Sorta how like FFXII's weapons are, I suppose. Or maybe I need to adjust the defense gains enemies get in the enemy level script. Hmm.
I'll fiddle around with it more tomorrow and see what happens.
The first character the player gets to control starts at level 1, with 80 HP and 45 attack power, including the weapon he starts equipped with, which has 14 attack power. First enemy in the game (depending on what's encountered) can spawn anywhere from level 1 to level 3 depending on RNG, has anywhere from 50 to about 60 HP and has defense from 14 to 16. The normal attack's variance is 10, so with my formula, a normal attack (if it doesn't critical) does anywhere from 32 to 39 damage. Enemies use another formula for their normal attacks, so this formula only applies to just some of the actors.
While the damage is noticeable as the player changes weapons and/or levels up, even while enemies slowly level along with them, it's a little less noticeable later on in the game. Which is why I was hoping to somehow include some way to incorporate the actor's equipped weapon's attack power somewhere in that formula to make making the damage from each weapon equipped more noticeable during mid to late game. Sorta how like FFXII's weapons are, I suppose. Or maybe I need to adjust the defense gains enemies get in the enemy level script. Hmm.
I'll fiddle around with it more tomorrow and see what happens.
Pages:
1














