Jump to content
Fomar0153

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

Recommended Posts

if $game_party.members.include?(2);500;else;250;end

 

That won't work, because $game_party.members returns an array of the actors as objects, not just their ID numbers. So it'll never include 2, and thus always return 250.

Assuming that it's not too long for the box, this will work:

$game_party.members.include?($game_actors[2]) ? 500 : 250

 

Thanks, not too Sure How That Works But Thanks

It works because the damage formula basically runs as a script. If it doesn't contain a "return" command, the returned value is whatever the LAST line of it equates to. So if you put 300;200;100 it would give 100 damage, if you put 100;200;300, it would give 300 damage. In the case of a function call that doesn't return any value, such as add_state, being the last thing, it'll equate to 0. This is why it will only work if you put the formula *after* the add_state.

Edited by Ninjamida

Share this post


Link to post
Share on other sites

m=1+a.mat*1.2-b.mdf*2;if m< 1;m=1;end;m

 

Slightly shorter, and more common ruby idiom:

 

[1+a.mat*1.2-b.mdf*2,1].max

Share this post


Link to post
Share on other sites

Vega needs help! T^T

I'm trying to make a skill that deals massive damage to a single targeted enemy using the b.hp - b.def formula. Great it works, everything is fantastic.

But I need to add in the function that for certain enemies (namely bosses) it will deal significantly less.

Currently I'm working with this:

b.id==4 ? b.hp - b.def * 5 : b.hp - b.def

 

Which *should* check to see if the enemy getting hit has an id of 4 (which is the test monster I'm using it on) and then deal it a lot less damage than it would a non boss monster equivalent.

If I only have b.hp - b.def it hits him for 199 points of damage since he has 200 hp and 1 defense.

But if I plug in all of that up there then it just comes up as "Null" and does nothing. Doesn't matter if I'm targeting the Test monster or another monster.

 

If there's a better way (and one that actually works XD) of checking if a certain monster has a certain trait to change which damage hits them that works fine for me too, I'm not set in the way I have it right now, especially considering it doesn't even work. >.>

Please help? :<

Omg I can't believe the solution was so simple.

The formula needs to be this:

if b.enemy_id == 4; b.hp-b.def*5; else; b.hp-b.def; end;

b.enemy_id *not* b.id

b.id must check actors only.

Anyway I think I'll tinker around and search around a bit more but I need another Veir skill (basically "trinity" attacks that my party has to use in succession in order to activate.) which detects actor 1's attack, 2's agility, 3's mag, and 4's defense then adds those together and hits the enemy for that much.

It's probably a simple solution, I just need to find it.

Edited by VegaKotes

Share this post


Link to post
Share on other sites

The formula needs to be this:

if b.enemy_id == 4; b.hp-b.def*5; else; b.hp-b.def; end;

It's probably a simple solution, I just need to find it.

 

Slightly shorter (since custom formula length is pretty limited anyway):

 

b.enemy_id == 4 ? b.hp - b.def * 5 : b.hp - b.def

 

or, alternatively:

b.hp - b.def * (b.enemy_id == 4 ? 5 : 1)

 

(I left spaces in for clarify when you read what I wrote, remove them if needed to compact it.)

  • Like 1

Share this post


Link to post
Share on other sites

Now would I be able to make it

b.hp - b.def * (b.enemy_id == 4:2:6:7 ? 5 : 1) in order to have it check if the enemy's are 4, 2, 6, and 7? So multiple bosses all take reduced damage from the skill? Or would it have to be something different?

Share this post


Link to post
Share on other sites

just make a new script under materials with

class Game_Battler < Game_BattlerBase
 def boss?
   return @enemy_id == 4 || @enemy_id == 2 || @enemy_id == 6 || @enemy_id == 7
 end
end

and then use

b.hp - b.def * (b.boss? 5 : 1)

  • Like 1

Share this post


Link to post
Share on other sites

Plugged in the script and ran with the formula, but it gives me this error when using it.

 

 

tikhO.png

 

 

If you don't know what's causing it I'll start sifting through the scripts to see if any of them are jarring with it.

Share this post


Link to post
Share on other sites

oops missed a ?

try

b.hp - b.def * (b.boss? ? 5 : 1)

Share this post


Link to post
Share on other sites

Works perfectly, thanks. :D

I don't suppose you could help me get another one working could you? :3

 

In my game I've got special abilities called "Vier"

Vier need tp in order to be activated, but they also need all four of the party members to use the "Vier" set up skills. (using the skill fusion by Kread-Ex) So Actor 1 uses his Vier, then Actor 2 uses his, then actor 3 uses her's, then actor 4 selects the target of the attack which launches the actual Vier attack itself.

The one you so awesomely helped me get working is called "Vier Sol" and it hits a single target for its hp - its defense (or it's defense times 5 for a boss)

The next Vier skill I'm trying to get working is the "Vier Salvaje" skill which adds up the four actor's special skill and hits the entire enemy team with that damage.

 

(act 1) Dominic's attack stat, (act 2) Razor's agility stat, (act 3) Nivisia's magic stat, (act 4) and Shenra's defense stat.

I have Dominic use his vier skill which runs a common event that sets 4 variables to the four stats and then use this formula.

v[7]+v[8]+v[9]+v[10]

but it doesn't actually appear to damage any of the enemies. >.>

Share this post


Link to post
Share on other sites

class Game_Battler < Game_BattlerBase
def salvaje
d = $game_actors[dominic's actor.id here].atk + $game_actors[razor's actor.id here].agi + $game_actors[nivisia's actor.id here].mat + $game_actors[shenra's actor.id here].def
d
end
end

try that.

and use a.salvaje in the formula box

  • Like 1

Share this post


Link to post
Share on other sites

I was about to say it doesn't work, but then I realized I forgot to put the "a." into the formula. XD

Thanks a million Xypher. I think I'll be able to make a lot of skills like that now that I have a basis for them. :D

Share this post


Link to post
Share on other sites

Hi, I've been trying to solve this myself, I think without success, so I really hope someone here will give me a hand...

 

Basic formula for attack is: a.atk-b.def. Nothing complicated. But! I want to put Luck to some use here. I'd like to have two random values, both from -0.3 to 0.3 (whole numbers only), one for attacker and one for defender, let's say the attacker's variable is called x, defender's y.

Each 10 points of battler's Luck increase his appropriate value by 0.1.

I'd like to have damage done by the attacker to have the final form of a.atk*(1+x), ignored by the defender b.def*(1+y). This means that every time damage is done, both attack and defense of respective battlers fluctuate by -0.3...0.3. And since high Luck assures that these values will be higher, it directly influences how much damage a battler does or receives.

 

However, function rand(X) only returns natural numbers, not negative ones or fractions. So, here's my question - is it possible to create a formula I described above? If yes, than does anyone have any ideas?

  • Like 1

Share this post


Link to post
Share on other sites

Is there a way to make a skill deal a certain amount of damage if the enemy has 25% hp or less left? I've been trying the following:

if b.hp =< b.mhp / 4; 200; else; 50; end;

so does anyone know how to write the formulae with a "equals-to-or-less" if-statement?

Share this post


Link to post
Share on other sites

Your formula is sound, just switch =< with <= and it should work.

Thanks for the help it works

Share this post


Link to post
Share on other sites

Ok, i got one.

Say I have a character enter the Hide state. While in this state, he uses the Backstab ability.

I want to have Backstab deal bonus damage or effects while the character is in the Hide state.

 

Also, is there a way to bypass the damage reduction for the Guard state?

Share this post


Link to post
Share on other sites

This is one of the coolest threads on the tutorials section.

 

I would have never even considered using the formulea window like this before and now my mind is racing with ideas.

 

Thanks so much for posting this.

 

I do have one scenario I could use help with.

 

Is there a way to check if a character has a certain item and if so then an attack is 1, 2, or 3 times as likely to crit?  I have an idea for a class that collects trophies from monsters and then is able to find weaknesses in that type of monster and exploit the weakness for more damage.  Problems is checking if he has the trophy and if it is the same type of enemy as the trophy.

Share this post


Link to post
Share on other sites

Is there anyway to use a formula to make a DoT?

 

If there is than just something general would be great, I can modify it myself.

 

If not then if someone could point me in the right direction, different thread or whatever, that would be awesome.

 

Thanks.

Share this post


Link to post
Share on other sites

I simply want to make a skill that does not use an action turn. I have it set to where I can swap between certain skills, but I don't want it to take up an action to swap.

Share this post


Link to post
Share on other sites
Is there a way to check if a character has a certain item and if so then an attack is 1, 2, or 3 times as likely to crit?  I have an idea for a class that collects trophies from monsters and then is able to find weaknesses in that type of monster and exploit the weakness for more damage.  Problems is checking if he has the trophy and if it is the same type of enemy as the trophy.

$game_party.item_number($data_items[n])

 

This will get the number of items in your inventory of item number n.

 

 

Is there anyway to use a formula to make a DoT? If there is than just something general would be great, I can modify it myself. If not then if someone could point me in the right direction, different thread or whatever, that would be awesome. Thanks.

Afraid not. You'll need a script or to use statuses.

 

 

I simply want to make a skill that does not use an action turn. I have it set to where I can swap between certain skills, but I don't want it to take up an action to swap.

 

Sorry but skills only occur when the turns commences. You'll probably need a script.

 

 

Ok, i got one.

Say I have a character enter the Hide state. While in this state, he uses the Backstab ability.

I want to have Backstab deal bonus damage or effects while the character is in the Hide state.

 

http://www.rpgmakervxace.net/topic/8986-skill-ideas-you-can-do-with-custom-formula/

This should help you with that/

Edited by Titanhex

Share this post


Link to post
Share on other sites

Scenario: I think it has been done already, but the White Wind spell (heals HP equal to the caster's HP) from the FF games would be an HP recovery skill with the formula "a.hp"

 

Scenario: The Shining Wind from the Suikoden games damages all foes and heals all allies by the same base power.

 

I thought of making it an HP Absorb attack with the formula "a.mat - b.mdf", but it only heals the caster. I want to make it heal all the caster's allies as well.

Edited by judasmartel

Share this post


Link to post
Share on other sites

Not sure if anyone knows this one, but I'm trying to write a script that adds different states depending on the value of an enemy stat.  (called enemy_pcf)  But I'm not entirely sure how to do it.  This is what I have:

 

class Game_Battler < Game_BattlerBase
 def custom_formula_peace(a, B)
1; 1; b.enemy_pcf += (5+rand(3)); if b.enemy_pcf <= 20; 1; b.add_state(28); elsif b.enemy_pcf >20 and b.enemy_pcf <=39; 1; b.add_state(29); elsif b.enemy_pcf > 40 and b.enemy_pcf <= 59; 1; b.add_state(29); else; 1; b.add_state(31); end
end
   end

 

But I keep getting errors on the third line. Any ideas as to what I'm doing wrong?

 

This would be super easy if it were just two possibilities, but it's trickier with like 5.

 

(And yes, enemy_pcf is already created in the RPG and GameBattler, so that's not an issue)



@Judas  Lunatic Targeting script allows you to create things like "target all actors"  in your skills.  Give it a whirl.  http://dl.dropbox.com/u/49701990/YEA/Target_Manager.rb

Yanfly FTW

Edited by KDLMaj

Share this post


Link to post
Share on other sites

@ KDLMaj, as other scripts may be involved with the issue you are having, I believe it would be better if you post that query in the script support section. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted