how to add a.tp+=20 into this custom formula?

Murd

Apprentice
Member
Joined
Jan 28, 2015
Messages
112
Reaction score
7
First Language
Thai
Primarily Uses
I have been toying around with my custom formula. The situation is if $game_variables[1] is set to 1, it can deal 50% extra damage and it works wonderfully without any problem. However; if I would like to add a.tp+=20 after the extra damage, where should I put it in to make the formula works correctly?

Correctly you say? Yes, I mean that.

I try add "&& a.tp+=20" after "e*1.5", I do gain 20 TP every time the spell is cast but the damage keeps increasing cumulatively every time (which I don't want it).

Kindly help me to fix this and what could be the cause of the increase of the spell damage.

Thanks!

Code:
class Game_Battler < Game_BattlerBase  def fireball_dmg(a,    c=((a.mat/2*1.05)-b.mdf/4).to_i    d=c/11+1    e=(c-d..c+d).to_a.sample    if c>=1;e;elsif c<=0;if rand(10)+1>=4;1;else;0;end;end    if $game_variables[1]==1    return e*1.5  else     return e    end  endend
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
I never use the a and b constructs outside of the formula box so I'm not 100% sure this will work, but try adding the a.tp += 20 on the line ABOVE the return (and space it out as shown if it doesn't work at first).

The && operator is a logical operator so it will look to see whether "e * 1.5" and "a.tp += 20" are both true, rather than executing both of the actions.
 

Murd

Apprentice
Member
Joined
Jan 28, 2015
Messages
112
Reaction score
7
First Language
Thai
Primarily Uses
I never use the a and b constructs outside of the formula box so I'm not 100% sure this will work, but try adding the a.tp += 20 on the line ABOVE the return (and space it out as shown if it doesn't work at first).

The && operator is a logical operator so it will look to see whether "e * 1.5" and "a.tp += 20" are both true, rather than executing both of the actions.
It works perfectly now! Even it is a basic of Ruby, I think I have learned a lot from this.

Thank you for your quick answer and also pointing out the reason of the increase of the damage. 
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,858
Messages
1,017,023
Members
137,565
Latest member
Callmelogann
Top