How to make the most of custom formulae. Part #1

I know this topic is old, but I have been searching everywhere to try to find the syntax retrieving the data of an item a player has equipped for the skill formula.

If I have a ring on that gives 1 atk, what would I put in the formula JUST to do 1 damage.  I don't want the player's overall atk dmg.  

Btw, thanks everyone for the help over the past day.  The quick responses are awesome. 
a.armors[3].atk or might be

a.armors[3].params(2)

Or something like that... Not sure if accesory are index 3 or what.
Yeah I tried those in many variations and none of them work.  Is there a place you can get the information on how to reference this stuff?  
Have a look at this tutorial http://www.rpgmakervxace.net/topic/8986-skill-ideas-you-can-do-with-custom-formula/

If you look through it you will find that it lists all the indices of the things that you might want to refer to.

If that is not the information you are looking for, could you expand on what the "stuff" is that you want to reference.  It's a bit vague,

EDIT

or do you mean, how do you reference the particular piece of armour?  Use the index number of the item from the data base list.
Pretty much I want a player to wear a ring.  The ring gives a skill that does ONLY the damage of the atk stat of the ring.  

So ring's atk is 50.  The skill will do 50 damage.  Not the total atk of the player.

*I've gone through tons of tutorials and stuff.  None of them show how to get this data.  I've gone through tons of the base script.  The closest I thought I got was a.equips[] but none of it worked.
So what is to prevent the player using another skill which isn't limited in that way?

But to the matter at hand.  You want this skill to do 50 damage if the ring is equipped.  Do you want it to do anything else as well?  I don't quite get what the problem is.  If you want this skill to do just 50 damage, then select HP damage from the drop down menu at the top and put 50 in the formula line.  You don't need to check if the ring is equipped because you assign the skill straight to the ring in the armour tab of the data base.  When the ring is equipped the player has the skill.  When it is unequipped, the skill goes away.
Well I guess if you need an explanation I can go into further detail.  

So there is a ton of special rings that you can find throughout the game.  I have altered it so that rings do not give stat bonuses at.  They are used for their abilities.  The rings also can grow or shrink in power.  I do not want to use scripts for this, for the amount of them.  You obviously don't find them all, but there is a large number of random rings that can be found.

So right now if I wear a fire ring.  It is set to 50 atk.  But this atk is not added to the players stat.  Instead I want to use it in the skill formulas of a LOT of skills.  So say I do a skill called Cleave.  It is going to do the damage of the cleave skill plus the atk dmg on the ring.  As the game progresses there is ways to increase or lower the atk of these rings.

Another ring might heal.  This heal is also going to be adjusted by magic attack.

So I didn't think this would be that hard.  I just need to know how to insert the stat parameter of an item I have equipped.  With my foolishness I thought it would be simple like a.equips[1].atk or something easy like that.  But no one seems to be able to answer it.  :-(
So if you want to do the damage of the cleave skill and add the 50 damage if the ring is equipped, it will be something like this.  For the sake of this example, I am going to assume that the ring is item 49 on the armour tab of the data base, and for the cleave skill I am just using the default damage formula.

c=a.atk * 4 - b.def * 2; c*=a.armors.include?(data_armors[49]) ? 50 : 0;c

I hope that's right.  I don't have Ace on this machine to test it.  If it hits a problem remove the * in c*=
Thanks for the help, but there are multiple rings with different amounts. I didnt know if I could just access the atk dmg on a certain slot of equipment. That way I could wear many different types of rings.

So ring x would add 50 dmg. Use a different ring and it adds 25 dmg and 25 magic attack.

So the only thing I really need to accomplish all that is knowing how to get the equipment worn stat.
You are not going to get all that into the damage formula in a straightforward way.  What you might think of doing is doing a snippet for custom_skill_name which sets all that out as conditionals and then in the damage formula just call that snippet up.

i.e.

class Game_Battler < Game_BattlerBase def custom_formula_name(a, b, v) #here you can add as much as you want endend [SIZE=10.5pt]then you only need to write this in your skill formula box:[/SIZE]

[SIZE=10.5pt] [/SIZE]

[SIZE=10.5pt]custom_formula_name(a, b, v)[/SIZE]

[SIZE=10.5pt]a is attacker, b is target, v is variable.[/SIZE]
I hope that this isn't too dumb of a question, but... I want to encourage players to make specialized builds by making higher values on stats more valuable than lower ones. In the damage formula this would be applied by having every point above a certain threshold give double (or maybe triple, I haven't decided) damage bonus. So from strength 1-24 you would get +1 damage every two points while, from 25 upwards, every point would give a +1. Thet thing is that I'm not sure how would I go about implementing that check. Something like a.atk/2 + if a.atk>25; add (a.atk-24) to damage, or something to that effect maybe? (I know that's not an actual formula, it's just an example) But that would require substracting every point above 24 to the original a.atk/2.

Bottom line: I'm not good at maths, please help. 😛

(Sorry about the messy post, I hope it was somewhat clear)
Could the extra strength stat be allocated to a variable?  Then it might be possible to have the same formula all the time which would simply add the damage value of that variable to the base damage.

EDIT

I don't have Ace on this machine to test it, but it might be something like this - for the sake of the example, I'm using variable switch 26 to store the stat increase and using the default damage formula for the base.

a.atk * 4 - b.def * 2 + $game_variables[26] * 2 

It might be that the $game_variables bit needs to go first.
you might try to use the fact that integers automatically cut off decimals


a.atk/25 is zero for ATK<25, 1 for ATK between 25 and 49, two for ATK between 50 anf 74 and so on.


(a.atk/25) * a.atk gives zero if ATK is lower than 25, a.atk for values between 25 and 49, 2*a.atk for values between 50 and 74 and so on.


However, the order is important and the formula must not be switched to float falues to work that way.
Could the extra strength stat be allocated to a variable?  Then it might be possible to have the same formula all the time which would simply add the damage value of that variable to the base damage.

EDIT

I don't have Ace on this machine to test it, but it might be something like this - for the sake of the example, I'm using variable switch 26 to store the stat increase and using the default damage formula for the base.

a.atk * 4 - b.def * 2 + $game_variables[26] * 2 

It might be that the $game_variables bit needs to go first.
I guess I could check it by setting a variable at the start of each player's turn (this would be necesary to take into account the player buffing themselves or changing equipment mid battle) equals to a character's strength, and if it is above 24 add the necesary points to a second personal variable (this would require the formula to check for a different variable depending on the user, right?). Though if the player changed equipment, it would only take effect on the next round, also since I'm using Yami's atb I'm not sure how accurate the span option in the battle event would be. Still, sounds like a good choice, should no other answer work.

you might try to use the fact that integers automatically cut off decimals

a.atk/25 is zero for ATK<25, 1 for ATK between 25 and 49, two for ATK between 50 anf 74 and so on.

(a.atk/25) * a.atk gives zero if ATK is lower than 25, a.atk for values between 25 and 49, 2*a.atk for values between 50 and 74 and so on.

However, the order is important and the formula must not be switched to float falues to work that way.
I think there's something in there but my not-math-oriented brain is sweating trying to puzzle out what to do with that 1. All I can think of is something like this:

Once again, keep in mind I'm no expert on formulas, so I'm just trying to explain the idea...

if (a.atk/25)>=1; (a.atk-24)+((a.atk-(a.atk-24))/2) else a.atk/2

The first part [if (a.atk/25)=1; (a.atk-24)] would get us the double points above 24, the second part [((a.atk-(a.atk-24))/2)] would add the regular half value points to it while the else part would be the default formula for strengths below 25. I'm not sure if this makes sense or how I would go about making sure not to switch to float values, though.

Thanks to both of you. 🙂
If nothing else, that formula you posted

if (a.atk/25)>=1; (a.atk-24)+((a.atk-(a.atk-24))/2) else a.atk/2

is going to need a semi-colan or two.  Like this

if (a.atk/25)>=1; (a.atk-24)+((a.atk-(a.atk-24))/2); else; a.atk/2
Thanks! I knew there would be some colons there, I just wasn't sure where.

Anyway the final formula..

if (a.atk/25)>=1; (a.atk-24)+((a.atk-(a.atk-24))/2); else; a.atk/2 end - b.def

...works great (it threw me an error before I added the "end"). Thanks a lot again. 👍
Awesome topic. Made me subscribe here right away to see what else I could learn ^^

I have a pen&paper rpg I wanted to translate into a rpg maker project. I have used older rpg maker versions  in the past and am just learning VX ace (although I might wait just a short while for MV), so the scripting, mostly, and some other features like these fomulae are quite new to me.

I've concocted this today thanks to this topic:

 

if v[4900] == 20; a.mat * 2; else; if v[4900] * 10 + a.atk >= b.def; a.mat; else; 0 ; end; end;
I've set this to be the first attack (the one taken as normal attacks) and added a common event that is called straight after the attack is done to reroll the variable.

As you can see it has a crit function that causes to deal double damage, but I'm having trouble with a fumble function I would want to put in. When a 1 is rolled (before calculations) something 'bad' must happen. Like attacking yourself or an ally or something. Preferably something random. Anyone any ideas how to do that?

Another problem I found is the determination of attack order/speed. I think it's set off on AGI as I see differences when I play with that. Is there a way to change that too without having to go into heavy scripting?

Furthermore I'd like to hear feedback wether this is the best way to work to what I want or maybe there are even easier ways to do this. 

Note: the '* 10' in the formula is with a reason, so not a mistake 😉

 
I am trying to have a skill where a state is added to it if the player is on a particular region, and I'm stuck on what the syntax to identify that region might be.  The formula would be something like

(region id) ? b.add_state(49); damage_formula_here : damage_formula_here

Can anyone supply the code for (region id)?  (err... that's an ordinary question mark, not the ? in the formula)

Also, do I need an 'end' in there?  As in:

(region id) ? b.add_state(49); end; damage_formula_here : damage_formula_here

Thanks.
You'd need to save the x,y coordinates before battle starts... Or better yet save the region itself... Into a variable of course.

As far as I know, ypu can still access map properties even in battle since $game_map doesnt get cleared anyway, but I'm not sure if $game_player gets cleared or not... If it doesnt, then you'd need to do the above... Else you can try to do

$game_map.region_id($game player.x,$game_player.y)
$game_player.region_id works

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-most-of-custom-formulae-part-1.1143/