I think it was a typo there and should be:
b.mp=b.mmp/2;b.hp=b.mhp/2Edit: ninja'ed! 🙂
Oh, i have another question... Is it possible to make a skill that cannot actually kill the enemy? Like, it will do whatever damage it is supposed to based on the formula, but it cannot reduce the enemy below 1 HP.
Something like False Swipe from Pokemon, basically.
Try:
d=a.atk*4-b.def*2;c=(d*20)/100;d+=rand(c+1)+rand(c+1)-c;[d,b.hp-1].min
And set variance to 0.
Hmm you could try adding in something like:
if (b.weapons.select { |item| item.wtype_id == 1 }).size > 0
or
if (b.armors.select { |item| item.atype_id == 1 }).size > 0
Also I'd just stick it in the notebox e.g.
eval($data_skills[x].note)
^ Wait, that's for his formula, right?
What about what I posted? Is there a way to calculate damage based on the DEF stat of your equipped shield?
Edit: Also, how can I call a character's level into the equation?
Try:
a.equips[1] == nil ? 0 : a.equips[1].def
a.level
b is for the "person" who is the target of the skill
a is for the user who uses the skill
(i switched b to a because u need the caster)
if (a.armors.select { |item| item.atype_id == 1 }).size > 0
a.armors gets all the armors of the caster (headgear,body, shield acces).
.select {...} gets all armors of the caster which fulfill the condition between "{" and "}".
|item| item.atype_id == 1 says that u wanna have all the armors which have the atype 1 (this would be all general armour items in the default project).
with .size u get the quantity of armors which fulfill the condition.
>0 controls whether the caster has a an armor with atype 1 equpped.
Hope this helped u to understand it.
regards Bot
Since the test of this is hard to determine I wanted to check with people in the know if this custom formula would work:
a.atk * 3 - b.def * 1; if b.agi > a.agi ? a.hit*0.8 : a.hit*1.2
This would increase the attacker's hit % if they had higher agility or lower it if theirs was lower, right?
Formulas can't control hit-percentage at all.
A Formuale is executed after the decision whether the skill hits or not.
If the skill doesn't hit the formulae will not be executed at all.
regards Bot
This one keeps failing me and I don't know why...it says I have a missing ')', but I can't figure it out.
(a.atk*3 *(a.hp / a.mhp) - b.def) * (1+ ((a.agi - b.agi) / 100)).
Can anyone see what I am missing in the syntax? Seems like this should work...
Edit: Figured it out. Understand now that the system rounds every decimal DOWN, no matter what the value is. So any partial values like 0.76, becomes 0, meaning an entire formula could result in a zero value.
My new formula ends up being very different:
(a.atk*3 - b.def)*(a.hp*100/a.mhp)*(100 + (a.agi - b.agi))/100/100
It means the actor's have to maintain a high health to be effective and agility plays a much more significant role in my game.
to get decimal values u have to use decimal numbers
for example
(a.agi - b.agi) / 100)
would transform to
(a.agi - b.agi) / 100.0)
as soon as one number is decimal the result is an decimal otherwise Ruby thinks that u wanna have an integer (I hope that is the way they are called outside computer since) and not an decimal.
Regarding the new formulae, I would encourage you to use some decimals as well:
(a.atk*3 - b.def)*(a.hp*100.0/a.mhp)*(100 + (a.agi - b.agi))/100/100
regards Bot