Yanfly's Lunatic Damage: Apply State to Self

Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Hey guys.


Quick question here.... I want to apply a state to user when using an attacking skill.


On the script, I used something like this:


when /customdamage/i
          value+=a.add_state(7);(120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1);


But everytime the skill hits, it says "Nil cannot be coerced into Fixnum"


Is it possible to do this? Thanks.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
That "value+=" at the beginning is the problem, because it makes absolutely no sense. The damage formula should begin with a.add_state, then it should work(haven't checkedit for other problems however)


The reason is 1) a.add_state() doesn't return a value to be added to a number and


2) += adds numbers to the variable in front of it, but if that variable doesn't exist yet it cannot work.
 
Last edited by a moderator:

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
Hey guys.


Quick question here.... I want to apply a state to user when using an attacking skill.


On the script, I used something like this:


when /customdamage/i
          value+=a.add_state(7);(120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1);


But everytime the skill hits, it says "Nil cannot be coerced into Fixnum"


Is it possible to do this? Thanks.


Try this:

Code:
when /customdamage/i
          a.add_state(7)
          value+= (120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
That "value+=" at the beginning is the problem, because it makes absolutely no sense. The damage formula should begin with a.add_state, then it should work(haven't checkedit for other problems however)


The reason is 1) a.add_state() doesn't return a value to be added to a number and


2) += adds numbers to the variable in front of it, but if that variable doesn't exist yet it cannot work.
So I should eliminate the " value+= "  ?
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Try this:



when /customdamage/i
a.add_state(7)
value+= (120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)
Totally worked!! Thanks for helping me again, xdan! You earned another like from me!


Can you teach me how to write "if" command/ conditional branch for damage formula, please?


Its like..


when /customdamage/i


set variable x= rand (1 until 4)


if(x==1)


{


a.add_state(7)
value+= (120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)



}


else


{


value+= (120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)


}


I have zero experience in Ruby...
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
Totally worked!! Thanks for helping me again, xdan! You earned another like from me!


Can you teach me how to write "if" command/ conditional branch for damage formula, please?


Its like..


when /customdamage/i


set variable x= rand (1 until 4)


if(x==1)


{


a.add_state(7)
value+= (120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)



}


else


{



value+= (120 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)


}


I have zero experience in Ruby...


I tested your script and the game crashed, so I started changing little things until it stopped crashing. But I can't assure you it does what it should, since I don't know what it should do:

Code:
when /customdamage/i
        x = rand (4)
        if(x==1)
          a.add_state(7)
          value+= (10 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)
        else
          value+= (10 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)
        end
 
Last edited by a moderator:
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
I tested your script and the game crashed, so I started changing little things until it stopped crashing. But I can't assure you it does what it should, since I don't know what it should do:



when /customdamage/i
x = rand (4)
if(x==1)
a.add_state(7)
value+= (10 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)
else
value+= (10 + a.atk * 4 - b.def * 2)*(b.state?(9) ? 0 : 1)*(b.state?(32) ? 0 : 1)
end
That wasn't really a script XD That's just an example of how I want it to work lol


And yes!! Your script seems to work! Thank you! I wanted the state to apply 25% of the time
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
That wasn't really a script XD That's just an example of how I want it to work lol


And yes!! Your script seems to work! Thank you! I wanted the state to apply 25% of the time


Then there's something about it you should know: rand (4) doesn't give 1, 2, 3 or 4, instead it gives 0, 1, 2 or 3. The script still works cause it gives 1 in 25% of the cases in both.
 
Last edited by a moderator:
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Then there's something about it you should know: rand (4) doens't give 1, 2, 3 or 4, instead it gives 0, 1, 2 or 3. The script still works cause it gives 1 in 25% of the cases in both.
Alright, cool! It's like array kind of thing, right?


if we declare int a[4] means a[0] until a[3] available
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top