Jump to content
Fomar0153

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

Recommended Posts

Thanks Xypher, it works perfectly!

Just another noob question for anyone who can answer, what does the "@" before temphp stand for and what does it do? We need this in order to create a temp variable?

if @temphp==nil
  @temphp=a.hp
end
if @temphp!=a.hp && a.id==b.id
  @temphp=a.hp
end
@temphp

Share this post


Link to post
Share on other sites

temphp is a local variable while @temphp is an instance variable

local variables have to be defined while an instance variable will have a value of nil without being defined.

Share this post


Link to post
Share on other sites

This stuff is awesome.  My brain however doesn't want to fully grasp it.  I know it's just math, but man, when I look at one of those expressions my mind just freezes up.

 

Still, the power involved in these expressions for modifying combat can't be ignored.

 

Thanks for keeping this thread alive.

Share this post


Link to post
Share on other sites

I posted this in another topic, but after relentlessly searching google and coming up with next to nothing, I figured it wouldn't hurt to post it here as well since this is another formula topic.

 

Hello there. I'm a complete newb to all of this so any help would be greatly appreciated.

 

I have a few formulas I'd like to have, but I'm not sure how to go about making them. I apologize if I'm asking too much in one post.

 

If anyone's familiar with Guild Wars, you'll recognize some of these. :P

 

First skill is a spell that drains the target's MP and restores the caster's HP.

Example: Target loses 20 MP, caster gains 150% of it (30) as HP.  What I've tried is:

 

r = a.mat * 2; a.hp + r

 

But it only deals MP damage if I have it set to MP damage and drains MP and gives it to the caster if I set it to MP drain.

 

Second skill is one that deals damage if no states like poison are on the target, and additional (additive) damage for EACH negative state on the target. I know you use b.state?(n) for one state, but can you make it check for more than one state? Like, b.state?(2, 3, 4, 5) which signifies poison, bleed, burn, and vulnerability? Would that work?

 

Third and fourth skills are basically like the one above, only one of them heals a base amount and an additive amount for every negative state, and one only heals IF it removes states.

 

Fifth is a skill that causes the target to lose MP and take the amount lost *n as HP damage.

What I have so far for this one is

 

r = a.mat * 2; b.hp -= r * 3; 

 

Except if it's dealing HP damage, it's not saying, and on second cast the target instantly dies. 

 

 

Last, how do you make a skill that boosts one of the user's stats based on a percent of another stat? Say I want my character to have increased attack based on magic attack. 100 Attack, 100 Magic Attack, the skill increases Attack based on 20% of Magic Attack so the end result would be 120 Attack. Would I even use a formula for this? Or is it possible with just states, or would I have to use both?

 

 

Thanks in advance for any help! And again, I apologize if I'm being too presumptuous asking all of this at once.

Edited by Zebraoracle

Share this post


Link to post
Share on other sites

Oh wow I feel dumb. I was literally laying in bed trying to sleep and a potential formula for the first skill (the drain MP and give it to the caster as HP skill) popped into my head.

r = b.mp; b.mp -= r * 0.8; a.hp += r * 0.4

 

It was confusing me at first because I was using stuff like 0.2 and 0.3 instead of 0.8 as I wanted something low like 20-30%, but for some reason 0.8 is acting like 20%. I'm not entirely happy with the a.hp += r * 0.4 part because I think it's based on the enemy's MP instead of the amount

drained, but I'm not sure how to go about doing that.

 

Now, if I could get my other formulas working properly I'd be set!

 

For the one that deals extra damage based on a state, I tried

 

b.state?(state id, state id, state id, etc) but it didn't want to work, which left me having it check for each state individually and resulted in me reaching the formula character limit which severely crippled the skill (I have about 13 states I wanted it to check for). I looked for ways to bypass the formula limit, the result involved scripted.  I followed the instructions here: http://cobbtocs.co.uk/wp/?p=286

but the skill resulted in doing null damage.

Share this post


Link to post
Share on other sites

fomar already had an example of the multi state thing.in the comments of his first formula tutorial.

 

d=4*a.atk-2*b.def;for s in [2,3,4,5];if b.state?(s);d+=100;end;end;d

  • Like 1

Share this post


Link to post
Share on other sites

Thank you so much! And sorry, I'd looked through his original post and didn't see what looked like a formula that checks for more than one state, but like I said, I'm really new to this so I probably just didn't recognize it.

 

Also, I figured out why my custom formulas from scripts weren't working: I wasn't putting b.custom_formula_name(a,B) in the custom formula box. Haha.

Edited by Zebraoracle

Share this post


Link to post
Share on other sites

 

Thanks Xypher, it works perfectly!

Just another noob question for anyone who can answer, what does the "@" before temphp stand for and what does it do? We need this in order to create a temp variable?

if @temphp==nil
  @temphp=a.hp
end
if @temphp!=a.hp && a.id==b.id
  @temphp=a.hp
end
@temphp

I found a problem with the first whitewind formula i made where the heal value wouldnt update until it reached it's caster.

 

add this below materials somewhere and use a.whitewind(a,B) in the formula bar

 

 

class Game_Battler < Game_BattlerBase

 

  def whitewind(a,

    @lc = 1 if @lc.nil?

    @thp = a.hp if @thp.nil?

    if @lc == a.alive

      @lc = 1

      @thp2 = @thp

      @thp = nil

    else

      @lc += 1

    end

    @thp.nil? ? @thp2 : @thp

  end

 

 

  def alive

    actor? ? $game_party.alive_members.size : $game_troop.alive_members.size

  end

 

end
Edited by Xypher
  • Like 1

Share this post


Link to post
Share on other sites

Is there a way to use the custom formulae box to have an attack that only harms the enemy if the enemy's HP is 30% or below?

Share this post


Link to post
Share on other sites

b.hprate <= 0.3 ? damage : 0

Edited by Xypher

Share this post


Link to post
Share on other sites

b.hprate <= 0.3 ? damage : 0

? damage is where I'd put the a.atk bla bla formula and then : 0 is the part where it doesn't do jack if above, right?

Share this post


Link to post
Share on other sites

example:

b.hprate <= 0.3 ? a.atk * 4 - b.def * 2 : 0

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Xypher, this is a game saver, I was about to rage quit on this project.

 

Dang, this happened:

 

error_zps698c08b7.png

Edited by Wren

Share this post


Link to post
Share on other sites

you missed the ? after b.hprate <= 0.3

also you dont really need the * 1 after b.def

Share this post


Link to post
Share on other sites

Thanks!  Working now!

 

**Edit**

Spoke too soon.

 

 

enemy takes no damage even though it is definitely below 30% hp.

Edited by Wren

Share this post


Link to post
Share on other sites

Scenario:
A Toxic skill, it deals large damage (with 75 % chance of poisoning) to all enemies, but it only works if the user has the the poison state. Also, once the skill is used, the user is no longer poisoned.

How would one do that?

Share this post


Link to post
Share on other sites

Formula box:

(22 is the poison state id; also this will poison enemies regardless of if the actor is poisoned)

 

c=1+rand(100);a.state?(22) ? a.remove_state(22);d=500:d=0;end;c <= 75 ? b.add_state(22);d

 

If I did that right. brb testing

Edited by Eliwan

Share this post


Link to post
Share on other sites

Is there a way to check if an actor, and that actor only, has killed an enemy in a given round?

 

I wanted to make a character gain some tp every time they successfully kill an enemy as a passive trait, but only if they were the one who dealt the final blow.

Share this post


Link to post
Share on other sites

Hello, I was wondering if it was possible to make a skill that would get stronger as the caster has the less HPs left ? ( sorry if this isn't said correctly, english isn't my main language, but I hope you understood the effect I was talking about)

Additionaly with, if possible, the skill basically targeting a single enemy, but targeting all of them when the caster's HPs are really low.

Edited by Eliphas

Share this post


Link to post
Share on other sites

Hello, I was wondering if it was possible to make a skill that would get stronger as the caster has the less HPs left?

Here is a formula using the basic attack as an example:

a.atk*4+((a.mhp-a.hp)*2)-b.def*2

 

This will add 2 times the HP lost to the damage calculations. To show an example we will say all stats are 10 and the caster has 2 health of 10:

10*4+((10-2)*2)-10*2=36

Additionaly with, if possible, the skill basically targeting a single enemy, but targeting all of them when the caster's HPs are really low.

In order to do this you will need 3 skills and a common event. 1 skill will be what your character uses. Set this one to target one enemy and remove the damage formula. Then add in the effects box the command to call the common event. In the common event you will have a conditional branch. The condition is when actor's HP is less than the amount you want(I'll say 15%). If true then it will call skill number 2. This skill will be set to target all enemies and will use the above formula( or your variation) for damage. Now back to the conditional branch. In the false(else) section have it use skill number 3. This skill will be exactly the same as number 2 save for that instead of all enemies it will be set to one enemy. Note: when using the skill from a branch you can set the target. It is very important to make sure that you select the target as the last target for skill 3 as otherwise it will hit a random target.

 

This should be all you need. If you do require more help please PM me instead of posting so we do not clutter this thread anymore than needed.

Edited by kurashi

Share this post


Link to post
Share on other sites

Hello there, I'm trying to make a healer spec with a restore mana skill that stores "energy". Then, you have another skill that does damage depending on the value of energy stored. I typed something like this on the formula:

 

- RESTORE SKILL

 

x = 0.1 * a.mmp; a.mp -= x; d = (0.1 * x).to_i; v[97] += d;

 

- ENERGY SKILL

 

v[97] * 10

 

The problem I've found testing the skills is that it restores perfectly the amount of MP I want but, when I test the energy skill alone, it still does damage without using the restore skill before. Also, the energy skill does strange numbers of dmg that doesnt correspond to the number it should do, so I really don't have a clue about what I'm missing, even more when I am not good at all at formulas nor ruby (haven't learned enough yet...).

Any idea? Thanks in advance and sorry for my bad english.

 

- EDITED:

 

I've found the way, so I'll post it if someone find it useful. I've changed the energy skill to

 

x = v[97] * 10; v[97] == 0; x; (the == 0 is for reseting the variable once u use it).

Now it works properly. Hope I've helped some noob like me ^^

Edited by Siul

Share this post


Link to post
Share on other sites

I am a little bit confused why you divide the value by 10.

d = (0.1 * x).to_i

just to multiply it later:

v[97] * 10

 

Also v[97] == 0 should not reset this variable, but v[97] = 0.

 

I'd make it more like this:

x = (0.1 * a.mmp).to_i; a.mp -= x; v[97] += x; damage_the_energy_skill_should_do

and

x = v[97]; v[97] = 0; x

 

Edit: maybe you don't want to store 10% energy if the user of the skill has not that much mp left. In this case, the energy formula would look like this:

x = [(0.1 * a.mmp).to_i, a.mp].min; a.mp -= x; v[97] += x; damage_the_energy_skill_should_do

Edited by pencilcase27

Share this post


Link to post
Share on other sites

The numbers are not reliable, I mean ofc there's no point on multiply when u already divided by the same number. I Was just wondering numbers to check it ingame with known values (so I would know I was doing it right). I'm not pro at formuling so I just try my best ^^'.

The point is that with v[97] == 0 it does reset the variable. If you say to me that it shouldn't reset the variable it makes me freak out since I promise u that it resets itself by this formula :S. At least I've learnt v[97] = 0 should do the same, thanks for it :)

Share this post


Link to post
Share on other sites

One reason why your numbers could be strange is, that you multiply your actors mana by 0.01 and then turn it into an integer. If your actor has 199 mana, then he will loose 19.9 mana, but the value you add to v[97] is ( 19.9 * 0.1 ).to_i, and that equals 1.

So your actor will loose almost 20 mana and still only deal 10 damage. I don't kow how much mana your actors have, but this formula will only produce accurate numbers for a mana pool > 1000.

 

And I tested == ingame, this does not work. Use a common event to show this variable after a skill was used.

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