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

You can set a variable to be a actor's tp if you use a script $game_actors[id].tp where ID is the ID of the actor. If you still wanted to do it via custom formula, I'd probably make a function you can call since you want to use it with a lot of skills.

class Game_Battler < Game_BattlerBase  def set_state_from_tp    case @tp    when 0..24; add_state(id)    when 25..49; add_state(id)    when 50..74; add_state(id)    when 75..100; add_state(id)    end  endendChanging the various id's to the number of the state you would like to add.

Then just call a.set_state_from_tp from the formula box. You can throw a semi-colon after it and put whatever you like for the rest of the damage formula.
I wanted to give the user a state (a buff) while ALSO attacking the enemy.
 

a.add_state(27)2 + a.atk - b.def
But for some reason, the game crashes with an error.

Is it not possible to hit yourself with a state change, while trying to attack an enemy?
You need a semi-colon between lines of script in the formula box.

Code:
a.add_state(27); 2 + a.atk - b.def
You need a semi-colon between lines of script in the formula box.

a.add_state(27); 2 + a.atk - b.defThanks, I totally missed that.

As for the 1st part, I'm still trying to wrap my head around what you said ^^; (I'm a bit new to this, as I decided to look into all this stuff for the 1st time today.)
Quick question about this.


I want to have actors share cooldowns of the same ability--


Basically, the party is given, as one of their MacGuffins, spells, that can only be used every once in a while. What I want to do is make them be sealed for a number of turns across the entire party whenever /anybody/ uses the spell.


So the question is, can I apply a state to all members of the party with the custom formula box?


And if not, is that possible somehow? (I think I can do it via common event, but I don't like to do common events...)


Edit: Another few that I came across:


2) Using the [a.x*c-b.y*d].max formula, how do I change what the maximum values are?


Can I make them scale off of the attacker's level, for example?


(from here I assume that to change the maximum value I do "[a.x*c-b.y*d,cap].max")


3) Using the same formula, if I want the damage to be capped after resistance; I would do

[a.apply_variance(a.atk*2-b.def,1,20)].max and if I want it before resistance and have variance happen last I would do
Code:
a.apply_variance(([a.atk*2].max)-b.def,1,10)
Right?
4) For some reason, I can't get

Code:
(a.apply_variance([a.atk*4+a.agi*0.5+a.level*15-b.def*1.2,110*a.level].max,10)).to_i
to do anything, it nulls every time. What am I doing wrong? D:
I asked about a Gold Toss skill formula a while back, but never ended up going with that because I wanted something more like this...

http://www.rpgmakervxace.net/topic/7214-gold-toss-ability/

As far as I can tell, that should work exactly as I want (specifically I want to be able to choose an amount of Gold to throw, store it in a variable, then use that variable in the damage formula (specifically, that variable / 4)), but... the problem is that in that event from that thread, it specifies which party member must take the action... but in my game, there is more than 1 character who can use the Gold Toss ability.

So is there a way to either:

- Open Number Input and store the variable within the damage formula box of the Coin Toss skill?

- Have the Common Event check which character of the two that can use Gold Toss is using it?

- ...Something else that makes it work?
Using Yanfly engine:

a) Have two skills, one that calls a common event to change a variable that is referenced in the Notes-- <skill cost: v[n] gold> -- of the other, having the former skill with the <instant> tag.

😎 Use a follow up skill, having the first run the common event and the second with the same method

c) Have the skill formula including a variable change that sets who the user is (e.g. v[n] = a.id;end), then have the common event select the actor and use the skill based on both the variable set within the skill formula AND within the common event's header

Basically, the only way to do it is tedious (gotta do it once for each user of the skill) or with scripts.

That said, if there's only two, you might not want to have a whole script just for it...

To expand on what I mean with C--

Skill Formula 1: v[1]=a.id;1;end

Skill On-Use Effects: Run Common Event 1

Common Event 1:

-Input processing for v[2], 5 digits

-Check to make sure that this isn't more than the party's gold; either reduce it to the party's gold or tell the player they don't have that much gold (and naturally include a line that says how much gold they /do/ have).

-Conditional Branches: if a.id = 0, 1, 2, etc

--In each, have "force action" id 0, 1, 2, etc to use a second skill, as well as subtracting the gold.

Skill Formula 2: (v[2]/4).to_i

🙂 Hope that helps

Also really really need help with above issues because I can't figure out what I'm doing wrong..

**Variance must be 0
Using Yanfly engine:

a) Have two skills, one that calls a common event to change a variable that is referenced in the Notes-- <skill cost: v[n] gold> -- of the other, having the former skill with the <instant> tag.

😎 Use a follow up skill, having the first run the common event and the second with the same method

c) Have the skill formula including a variable change that sets who the user is (e.g. v[n] = a.id;end), then have the common event select the actor and use the skill based on both the variable set within the skill formula AND within the common event's header

Basically, the only way to do it is tedious (gotta do it once for each user of the skill) or with scripts.

That said, if there's only two, you might not want to have a whole script just for it...

To expand on what I mean with C--

Skill Formula 1: v[1]=a.id;1;end

Skill On-Use Effects: Run Common Event 1

Common Event 1:

-Input processing for v[2], 5 digits

-Check to make sure that this isn't more than the party's gold; either reduce it to the party's gold or tell the player they don't have that much gold (and naturally include a line that says how much gold they /do/ have).

-Conditional Branches: if a.id = 0, 1, 2, etc

--In each, have "force action" id 0, 1, 2, etc to use a second skill, as well as subtracting the gold.

Skill Formula 2: (v[2]/4).to_i

🙂 Hope that helps

Also really really need help with above issues because I can't figure out what I'm doing wrong..

**Variance must be 0
Um... but both actors use the same class. In my game, the main character can change classes, and other party members are locked into their class. In this case, the main character can use the Gambler class (the one with Gold Toss) and you can also have the other character who is natively the Gambler class. But they both share the exact same class and the exact same skill set. Isn't this an issue with what you said?

Edit:

Okay I managed to make this work using the previously mentioned method by duplicating the Gambler class and having the main character and native Gambler have different Gambler classes.

Though I'm having some crashing issues... But it's related to the battle system I use so I don't think you guys can really help, but...

Spoiler
[IMG]http://i.imgur.com/1Guk1Y9.png[/IMG]
But anyway, I have a new question.

Is it possible to limit the amount of damage that an attack can do? Either by specifying it per skill or universally. I don't want attacks to exceed 9,999 damage, but if someone throws over 40,000 Gold using my formula, they break 9,999.

Edit 2: Also, maybe you guys know how to do something like this...

http://forums.rpgmakerweb.com/index.php?/topic/11779-is-there-any-way-to-make-a-state-that-buffs-damage-rate-only-if-enemy-is-weak-to-the-attack-element/
You can solve the first issue by...

Actually, bleh. I don't feel like typing it.

For the second question, I believe you can use "[formula, maximum].max". However, I've never gotten that to work as intended.
However, for Gold Toss in particular, there's two ways-- one, limit the amount of gold you can throw to be 5 digits if you want the cap to be 9999 and make it a 1:1 ratio, two, if they throw more than the desired cap of gold/damage, have the common event say back "That is an illegal amount of gold to throw", and take them back to the part where they pick how much gold to throw via label and jump to label.

Spoiler
Capture.PNG
Also, I started getting that crashing issue too after I made the gold toss skill... which is really really weird. o_0

Though for me, it does it as soon as anybody attacks normally... even if I don't use Gold Toss. :V
Today i found a nice little trick with formulaes. U can use the Graphics Module to play a movie before the actual dmg will be calculated. So u can give ur Ultimate attacks an intro Movie.

Graphics.play_movie('Movies/' + "<Moviename") ;<UrFormula>

<Moviename> =Name of ur movie

<UrFormula> = Ur normal Formula

Hope that it will help someone

regards Bot
Is it possible to make a skill which only hits if the opponent is already afflicted with a specific state?

Like for my idea, you would have a skill called Knockdown, which would... knock the enemy down.

Then you would have an attack called Execute which would instantly kill the foe, but would only work if they were afflicted with Knockdown state.
The Problem is

... only hits ...
Formulae are only calculated if the skill hits. It would be easier to deal no dmg if the state isn't applied.

b.state?(<id>)? 9999 : 0;

<id> must be switched with the id of the state and remove the zeros at the beginning (009 => 9)

It is possible 2 make something with aren't hitting at all with a workaround but i think this isn't necessary in that case.

regards Bot
The Problem is

Formulae are only calculated if the skill hits. It would be easier to deal no dmg if the state isn't applied.

b.state?(<id>)? 9999 : 0;

<id> must be switched with the id of the state and remove the zeros at the beginning (009 => 9)

It is possible 2 make something with aren't hitting at all with a workaround but i think this isn't necessary in that case.

regards Bot
I suppose that would work, but what if they have more than 9999 HP? Is there a way to make a skill do 100% HP damage?
Was thinking about my project max lifepoints 9999

if b.state?(<id>); b.hp=1; 1; else; 0; end;
So I'm very new to all the scripting stuff. I just wanted to ask about how to set it up so that when an enemy heals they only heal one specific person in the group. i have a final boss who is fighting with two fanatics. They are its servants and serve mainly as status ailment dealing pests. I want them to heal ONLY the boss and never accidentally each other, for 5000 HP after a set number of turns. The only trouble I am having is setting up a formula or a skill in which they will ONLY target the boss with this specific skill.

This tutorial has been helpful in getting me to understand .id recipients. It makes targeting things much easier now. Especially for event creation
Wouldn't use Formula at all this would be far to complicate

Just make Common Event call from the skill which contains a "Change Enemy HP"

regards Bot
Wouldn't use Formula at all this would be far to complicate

Just make Common Event call from the skill which contains a "Change Enemy HP"

regards Bot
Thank you so much. My final fight is coming out so well.
Quick question...

Is there a way to set HP/MP at a specific percentage with an Item?

I want to make an item which sets both HP and MP at exactly 50% of the target's HP and MP. No matter what their current HP and MP is, I want it to immediately snap both their HP and MP to 50% of max.

Can I do this?
Try;

b.mp=b.mmp/2;b.mhp/2-b.hp
Try;

b.mp=b.mmp/2;b.mhp/2-b.hp
Almost. It works for MP, but not for HP.

Any way to achieve that effect?

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