I'm been searching, and fumbling around differant weapons, classes states and scripts and am having some trouble figuring out how to make a class use a differant attack formula.
The closest I got was with Yanfly's weapon replace engine but unfortunately it only works if the class is unarmed, and any weapon equipped will overwrite it. What I am TRYING to do, is make it so a mage class learns to add 50% of it's magical attack to it's basic attacks
so: (a.atk * 4) + (a.mat * 0.5) - b.def * 2
Making one for a spear type weapon is easy as it just goes on the weapon itself, but I wanted to make one for a class, and have it over ride any other attack commands. I'm sorry if i'm not being clear, but i'd appreciate any help.
I have experimented and did something a bit similar, giving each weapon TYPE it's own damage formula, I imagine it should not be too hard to do the same for class IDs... Try this
module Damage_Formula Class = [] #Class[Class_Id] = 'Formula' Class[0] = '0' #Default/Monster Class[1] = 'a.mat/2' Class[9] = '7'endclass Game_Battler < Game_BattlerBase def class_bonus(a, unless a.actor? eval(Damage_Formula::Class[0]) else Damage_Formula::Class[@class_id].nil? ? eval(Damage_Formula::Class[0]) : eval(Damage_Formula::Class[@class_id]) end endend In the skill's formula box, add + a.class_bonus( a, b ) to the end, or however you wish to use it.Or, using the formula you've shown, it would turn into (a.atk * 4) + a.class_bonus( a, b ) - b.def * 2, just make sure to have a.mat/2 or a.mat*0.5 for the class ID in the array at the top of the script.
Sorry for the noobishness, but I'm not really sure where to put this code, I hate to ask but could you help me understand where it goes?
Put the code itself into the script editor where most other scripts go, below ▼ Materials and above ▼ Main Process.
a.class_bonus( a, b ) goes into the formula box of any skill that would utilize a class specific bonus, whether it's Attack, or skills that are shared by multiple classes.
You modify the bonus in the script itself at the top, I gave 2 examples for class ID's 1 and 9, you can add more/change them to whatever you want.
Ok, I put it in the scripts, and named it "Class Bonus" is this independant for any class bonuses? Should I specifically name this "Mage class bonus" for simplicity?
and what does class_bonus( a, b ) mean so I know what it is?
Do I put it into the "Skil" what I want to make the mages new "Attack" command?
Edit: Ohhh... I think i'm starting to understand this, I'm just hoping I don't change the wrong thing now, also i'm not sure if you'd know, but if mage is the subclass in Yanfly's class system, will it still come into effect?
As it currently it, it would only have an impact on the main class, I'll do a quick look to see what all is needed to have it work with subclasses in yanfly's class system.
Edit: Should be doable, going to test...
This is what I did:
Attack = (a.atk * 4) + a.class_bonus( a, b ) - (b.def * 2) <------- is that right?
I didn't change anything in the other formula exept the class id which in my case is 3
I'm not sure if it worked though, I battle tested against a monster with 100 def and no Mdef
and got null, if it did would, it should do damage, right?
Uhhh... I still keep getting null, I'm not sure how I'm messing this up, all i've had to do is copy and past o-o
(a.atk * 4) + a.class_bonus( a, b ) - b.def * 2 That is my battle formula
and I copied the script you gave me
I'm fighting a monster with 100 def, and 1 mdef,
I'm really not sure what's wrong >:
I'm using the default classes, so I don't know what your actor's stats are like, I had to raid my guy's level before I got numbers, if the formula results in either 0 or a negative number, then it will give null. Try with less defense or more attack/magic? I'm not sure what else to suggest. And with that I bid you good luck and head off to sleep.
Edit: I originally tested with formulas like 10 + a.class_bonus( a,b ), and no variance, guaranteeing I'd know if the bonus is applied or not unless said bonus results in a negative bonus. It's another way of verifying whether the the script works and you get 0 damage, or the script doesn't work(I'm pretty darn sure it does unless I coped it wrong, which it doesn't look like I did)
I'll check up in the morning or something unless your problem gets solved.
Thank you very much for your help and patience, and have a good night sleep
In case you see this tomorrow, I tried attacking with 0 variance without the class bonus and it did steady 30 damage.
When I added the class bonus it went to null. What about it could actually make the damage go down? Both defenses were set to 5.
The Mob I am testing on is also doing null. what is ( a, b )?
I got to go to bed now too, I don't even know what else to try at this point.
I've checked and double checked, it works fine both with and without Yanfly's Class System, your damage formula is also fine, there shouldn't be anything that decreases your damage.
The only thing I can think of at this point is that you changed something in the Damage Formula module within the script that makes a.class_bonus( a,b ) give an error or nil. The part that reads...
Main_Class = []
#Main_Class[Class_Id] = 'Formula'
Main_Class[0] = '0' #Default/Monster
Main_Class[3] = 'a.mat/2'
Sub_Class = []
Sub_Class[0] = '0' #Default/Monster
Sub_Class[3] = 'a.mat/2'
I had it setup for you already, the 3rd class's class_bonus is half of the user's magic, both as a main class and as a sub class. Don't remove the Main_Class[0] line or the Sub_Class[0] line as that handles the default behavior.
( a,b ) passes attacker/defender so to speak as parameters to the class_bonus method, it is done so that the formulas in the Main_Class/Sub_Class array have access to things like a.atk, b.mat, a.agi, etc... just like the skill's formula box itself.
I'm running out of ideas of what could have gone wrong for you @.@ if this doesn't help.
Alright, so, I woke up and checked back at your response, and I said "whatever" and re-copied and pasted the script you gave me. For whatever reason, it works like a charm now, I'm not really sure what's differant from when I copied and pasted last time but, thank you so much, I really appreciate your help and patience! Thank you so much!
Also I'm not sure if you use the JP manager or would know how to fix it, but in game, if I switch back and forth between a character's main class, it adds like 90 jp repeatedly, giving them unlimited jp o-o;
Ok, so i've since changed the script a bit, to use it basically for a specific classes whole attack formula instead of just the bonus, that way I can make any one class attack how I want it to, but now I'm back to null, I really don't see what I'm doing wrong. Here's what I have
$imported = {} if $imported.nil?module Damage_Formula Main_Class = [] #Main_Class[Class_Id] = 'Formula' Main_Class[0] = '0' #Default/Monster Main_Class[1] = 'a.atk*4' Main_Class[2] = 'a.atk*3' Main_Class[3] = 'a.atk*2 + a.mat/2' Main_Class[4] = 'a.atk*2' Main_Class[5] = 'a.atk*2' Main_Class[6] = 'a.atk*4 + a.mat/2' Main_Class[7] = 'a.atk*3 + a.mat/2' Main_Class[8] = '*a.atk*2 + a.mat' Main_Class[9] = 'a.atk*2 + a.mat/2' Main_Class[10] = 'a.atk*4' Main_Class[11] = 'a.atk*4' Main_Class[12] = 'a.atk*3' Main_Class[13] = 'a.atk*3' Main_Class[14] = 'a,atk*2' Sub_Class = [] Sub_Class[0] = '0' #Default/Monster Sub_Class[1] = 'a.atk*4' Sub_Class[2] = 'a.atk*3' Sub_Class[3] = 'a.atk*2 + a.mat/2' Sub_Class[4] = 'a.atk*2' Sub_Class[5] = 'a.atk*2' Sub_Class[6] = 'a.atk*4 + a.mat/2' Sub_Class[7] = 'a.atk*3 + a.mat/2' Sub_Class[8] = '*a.atk*2 + a.mat' Sub_Class[9] = 'a.atk*2 + a.mat/2' Sub_Class[10] = 'a.atk*4' Sub_Class[11] = 'a.atk*4' Sub_Class[12] = 'a.atk*3' Sub_Class[13] = 'a.atk*3' Sub_Class[14] = 'a,atk*2' endclass Game_Battler < Game_BattlerBase def main_class_bonus(a, unless a.actor? eval(Damage_Formula::Main_Class[0]) else Damage_Formula::Main_Class[@class_id].nil? ? eval(Damage_Formula::Main_Class[0]) : eval(Damage_Formula::Main_Class[@class_id]) end end def sub_class_bonus(a, unless a.actor? eval(Damage_Formula::Sub_Class[0]) else Damage_Formula::Sub_Class[@subclass_id].nil? ? eval(Damage_Formula::Sub_Class[0]) : eval(Damage_Formula::Sub_Class[@subclass_id]) end end def class_bonus(a, if $imported["YEA-ClassSystem"] a.main_class_bonus(a, + a.sub_class_bonus(a, else a.main_class_bonus(a, end endend
That's the script, here's the damage formula
a.class_bonus( a, b ) - b.def * 2
Do you see anything wrong with this?
Ahh sorry about that, at the time my question was solved but then since had another issue, that would be irrelevent posted anywhere else, I don't suppose you see the issue in the script? XD;;;;
It was designed as a bonus, not a replacement for the whole formula, tho it can certainly be used as such. There are however a couple problems that I see right off the bat.
1: Enemies would use Main_Class[0] = '0' and Sub_Class[0] = '0', as a bonus added on to your damage formula as it was originally used, it was fine leaving this as '0', however with the way you are using it now, it means enemies have 0 attack, and are going against the target's defense leaving negative numbers. It would be best to either add a formula there for your enemies, or remove Attack as a skill for them. Obviously easier to just add a quick formula.
2:
Main_Class[8] = '*a.atk*2 + a.mat'
Main_Class[14] = 'a,atk*2'
Sub_Class[8] = '*a.atk*2 + a.mat'
Sub_Class[14] = 'a,atk*2'
Classes 8 and 14 are invalid formulas, 8 because it starts with a *, and 14 because it has a , instead of a .
Other than those I can't see any problems.
Thank you, and yeah I caught on to issue 1 rather quick, and so I made a separate attack skill for enemies to use, and to be honest, I'm a little embarrassed about the other issues. That's kinda sad. Let me go test some things, and I'll come back to edit this post
Ok, everything seems to be working pretty hunky dory now, now I just have to mess with numbers, and worry about late game balance
One thing i've been looking for, but unable to find, is something that might plug in with Yanfly's Class system/JP system, that would allow me to purchase and "equip" up to two passive abilities, if you want some kind of idea what i'm thinking, it's kind of like Final Fantasy 5, or Final fantasy Tactics. Do you know of anything like that, for passive abilities?