epson777341

Veteran
Veteran
Joined
Oct 10, 2014
Messages
34
Reaction score
2
First Language
English
Primarily Uses
Hi guys,
 
I know I've been asking a lot of questions, and I am glad for the help, I think this is my last problem, for a while. I'm just having some issues with a custom damage fomula.
 
I took a look at Fomar's tutorial. Made a separate Entry in my scripts, it took me all day, but I came up with my formula.

Its a long one.

def custom_pa_attack(a, b )    c = ((v[2]*((a.atk/1.5)**0.5)) * (1+(v[9]*0.01))) / (1+(v[9]*0.01));        e = ((rand(2)+1)*(a.level/3))    f = ((rand(1)+1)*(a.level/4))     if (rand(2)+1) == 1;      c += e;    elsif (rand(2)+1) == 3;      c -= f;    else;      c = c;    end;    c *= ((a.level**0.5)+(0.01*(rand(75)+25)));    if b.def <= 5;      if rand(100) <= 4;        c = c * 0.85;      elsif rand(100) <= 15;        c = c * 0.9;      end;    elsif b.def <= 10;      if rand(100) <= 2;        c = c * 0.75;      elsif rand(100) <= 13;        c = c * 0.8;      elsif rand(100) <= 46;        c = c * 0.85;      end;    elsif b.def <= 15;       if rand(100) <= 4;        c = c * 0.7;      elsif rand(100) <= 22;        c = c * 0.75;      elsif rand(100) <= 63;        c = c * 0.8;      else;        c = c * 0.9;      end;    elsif b.def <= 20;      if rand(100) <= 4;        c = c * 0.65;      elsif rand(100) <= 16;        c = c * 0.7;      elsif rand(100) <= 31;        c = c * 0.75;      elsif rand(100) <= 80;        c = c * 0.85;      else;        c = c * 0.8;      end; elsif b.def <= 25;if rand(100) <= 5;c = c * 0.6;elsif rand(100) <= 20;c = c * 0.65;elsif rand(100) <= 45;c = c * 0.7;elsif rand(100) <= 85;c = c * 0.75;else;c = c * 0.8; end; elsif b.def <= 30;if rand(100) <= 5;c = c * 0.55;elsif rand(100) <= 25;c = c * 0.6;elsif rand(100) <= 65;c = c * 0.65;elsif rand(100) <= 95;c = c * 0.70;else;c = c * 0.75; end; elsif b.def <= 35;if rand(100) <= 5;c = c * 0.5;elsif rand(100) <= 25;c = c * 0.55;elsif rand(100) <= 65;c = c * 0.6;elsif rand(100) <= 95;c = c * 0.65;else;c = c * 0.7; end; elsif b.def <= 40;if rand(100) <= 10;c = c * 0.5;elsif rand(100) <= 35;c = c * 0.55;elsif rand(100) <= 85;c = c * 0.6;elsif rand(100) <= 95;c = c * 0.65;else;c = c * 0.67; end; elsif b.def <= 45;if rand(100) <= 10;c = c * 0.45;elsif rand(100) <= 35;c = c * 0.5;elsif rand(100) <= 85;c = c * 0.55;elsif rand(100) <= 95;c = c * 0.6;else;c = c * 0.65; end; elsif b.def <= 50;if rand(100) <= 15;c = c * 0.45;elsif rand(100) <= 45;c = c * 0.5;elsif rand(100) <= 90;c = c * 0.55;elsif rand(100) <= 95;c = c * 0.6;else;c = c * 0.65; end; elsif b.def <= 60;if rand(100) <= 15;c = c * 0.45;elsif rand(100) <= 75;c = c * 0.5;elsif rand(100) <= 95;c = c * 0.55;else;c = c * 0.6; end; elsif b.def <= 75;if rand(100) <= 15;c = c * 0.4;elsif rand(100) <= 75;c = c * 0.45;elsif rand(100) <= 95;c = c * 0.5;else;c = c * 0.55; end; elsif b.def <= 90;if rand(100) <= 15;c = c * 0.35;elsif rand(100) <= 75;c = c * 0.4;elsif rand(100) <= 95;c = c * 0.45;else;c = c * 0.5; end; elsif b.def <= 1000;if rand(100) <= 15;c = c * 0.3;elsif rand(100) <= 75;c = c * 0.35;elsif rand(100) <= 95;c = c * 0.4;else;c = c * 0.45; end;  end;c.to_i;end;
I then put the following into my Custom Formula box:

a.custom_pa_attack(a,; c;But, I have a feeling that it's wrong. Can somebody help me out, I have no idea what I'm doing and it took me all day just to do the coding part above in a hopefully correct format.

EDIT: Oh yeah, it doesn't give any errors, but when I use the skill, it always shows up as null.

EDIT 2: Aaand I posted in the wrong spot again, what is wrong with me? Could somebody move this to the RPG Maker VX Ace support forum? I don't even know why I posted it here.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
because c is null... it doesn't get the c from inside the a.custom_pa_attack because the c inside that method is LOCAL to that method only... remove the c at the end and just make your custom method return c instead
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,298
Reaction score
14,277
First Language
English
Primarily Uses
RMMV
moving


It won't make a difference, but in all your if statements, you have rand(100). This means if the first case is false, it's going to get a NEW random number for checking the next test, then another one for the third. Much more efficient to set a variable to a random number before ALL of those tests, and then just use the variable instead of rand(100) every single time.


Why aren't you passing in v as an argument?
 
Last edited by a moderator:

epson777341

Veteran
Veteran
Joined
Oct 10, 2014
Messages
34
Reaction score
2
First Language
English
Primarily Uses
So when you say return c, you mean like at the end of the method right? Like after the if statements, but before the def ending and method end?

and then I would just call up the method in the damage formula box, like :"a.custom_pa_attack(a,b );" like that?

----------------------------------------------------

The rands are there to be random? I don't know, I'm not a very efficient guy. I'll do that though, thanks for the tip.

I don't know why i'm not passing v as an argument, probably because I am in fact terribad at this. I saw something with that in it, I'd put a v = $game_variable in the brackets at the beginning, right?
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
yeah, you'd use just this

Code:
a.custom_pa_attack(a,
v is passed in the damage formula, but since your damage formula calls another method, the v doesn't get passed into it... try this

Code:
def custom_pa_attack(a,b,v=$game_variables)
this way, your call will still be
Code:
a.custom_pa_attack(a,
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,298
Reaction score
14,277
First Language
English
Primarily Uses
RMMV
Yes, I know what rands are for. You don't have to have a hundred of them. Put a random number into a variable and use it in all your if tests.


Use this:

a.custom_pa_attach(a, B) without the ; at the end, or it'll still be null.
If you don't pass in v, it won't be available to the method. I'm not sure why it's not actually crashing on you.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,005
First Language
Tagalog
Primarily Uses
RMVXA
@Shaz - it won't crash because the damage formula's eval is kind of enclosed in a begin-rescue clause, so any problem will just result to null damage. It makes things harder to debug if ur using the damage formula.

From the help file

Code:
class RPG::UsableItem::Damage  def eval(a, b, v)    [Kernel.eval(@formula), 0].max * sign rescue 0  end
 
Last edited by a moderator:

epson777341

Veteran
Veteran
Joined
Oct 10, 2014
Messages
34
Reaction score
2
First Language
English
Primarily Uses
That did it! It worked!

I'm still not sure why, but, at this point I don't want to know!

Thank you so much, the both of you. I did change all the rands into a variable before checking them. I apologize, if I sounded curt, I was simply exasperated from trying to figure this out myself.

I'm going to mark this as solved. Thank you again.
 

Latest Threads

Latest Posts

Latest Profile Posts

Anybody know how to make an enemy have a line of sight? I'm trying to make Persona-like enemies.
zomboars.jpg

Concept art

Zomboars- main enemies in my story
mutant pigs addicted to beer
SF_People1_3 added!
index.php

I haven't been on here in forever wow(missed my forum birthday T-T). Anyways, I'm dabbling in BGMs, here's something I'm actually willing to share.

Forum statistics

Threads
109,203
Messages
1,043,022
Members
141,713
Latest member
Quincy_
Top