BCj

Veteran
Veteran
Joined
Jun 19, 2014
Messages
1,760
Reaction score
949
First Language
Dutch
Primarily Uses
N/A
Still would like some help with this one:


Basically, I have a skill that randomly attacks foes, but the amount of attacks is determined by the users' mana. Each 20% mana is one hit, so 100% of mana should amount to 5 hits. How would I code that?
 

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
You would be better off using a script that handles random hit count customization rather than trying to do this in the custom formula, not that its impossible to do using the DF but it will just be a bit tiresome (since the DF is ran everytime the skill is invoked you'd need to deal the damage in a custom way, else your DF will be an infinite loop; and you'd also need to calculate each hit chance again and also apply other effects manually if there's any)
 

SnapGuy1337

The Incompetent
Member
Joined
Jul 25, 2014
Messages
13
Reaction score
0
First Language
English
Primarily Uses
If I want a skill that instantly kills all enemis and heals all allies to max HP (limit break attack thing), what should I do?
 

BCj

Veteran
Veteran
Joined
Jun 19, 2014
Messages
1,760
Reaction score
949
First Language
Dutch
Primarily Uses
N/A
You would be better off using a script that handles random hit count customization rather than trying to do this in the custom formula, not that its impossible to do using the DF but it will just be a bit tiresome (since the DF is ran everytime the skill is invoked you'd need to deal the damage in a custom way, else your DF will be an infinite loop; and you'd also need to calculate each hit chance again and also apply other effects manually if there's any)


Would you know of any script that would be able to do it?
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
If I want a skill that instantly kills all enemis and heals all allies to max HP (limit break attack thing), what should I do?

Needs to be two skills, as far as I know. First will be a damage skill, targeting all enemies. The formula will be [b.mhp] without the []s. You'll also use it to call a common event which will force use another skill, which will be the same thing, except a heal and target all allies. You'll need to edit a game variable to be equal to a certain number based on who used the ability, that should be easy to figure out. In your common event you'll used nested conditional branches to ensure that the right person casts the spell based on the variables value.

Still would like some help with this one:


Basically, I have a skill that randomly attacks foes, but the amount of attacks is determined by the users' mana. Each 20% mana is one hit, so 100% of mana should amount to 5 hits. How would I code that?

If 100% is a set number of hits, use a similar method to what I list above with the common event setup. I'm in bed and don't have the exact formula stuck in my head, but maybe you'll be able to piece this together by yourself or someone else here can.


First, convert the current mana into a percentage


a.mp/a.mmp


Then multiply that by 100 and store it in a variable so that you're not dealing with floats. That should be your first "move." Label it as "User is channeling energy!" or something. Common event force the next move, but in the common event, before forcing the move, subtract 20 from your percentage variable  (or whatever integer you decide on, 25 for 4 hits, 15 for 6, whatever). Doing this lets you check where the mana is at after the current cast, but before the next. If it's below 0, then cast a DIFFERENT spell with a guaranteed fail. 


So you have I think 3 moves? 1 to set the variables in place, 1 repeatable move that is your actual hits, and then a third that is your "out of mana" fail.


If you have any questions or need more help just respond here and in the morning I'll get to it.
 

BCj

Veteran
Veteran
Joined
Jun 19, 2014
Messages
1,760
Reaction score
949
First Language
Dutch
Primarily Uses
N/A
Needs to be two skills, as far as I know. First will be a damage skill, targeting all enemies. The formula will be [b.mhp] without the []s. You'll also use it to call a common event which will force use another skill, which will be the same thing, except a heal and target all allies. You'll need to edit a game variable to be equal to a certain number based on who used the ability, that should be easy to figure out. In your common event you'll used nested conditional branches to ensure that the right person casts the spell based on the variables value.


If 100% is a set number of hits, use a similar method to what I list above with the common event setup. I'm in bed and don't have the exact formula stuck in my head, but maybe you'll be able to piece this together by yourself or someone else here can.


First, convert the current mana into a percentage


a.mp/a.mmp


Then multiply that by 100 and store it in a variable so that you're not dealing with floats. That should be your first "move." Label it as "User is channeling energy!" or something. Common event force the next move, but in the common event, before forcing the move, subtract 20 from your percentage variable  (or whatever integer you decide on, 25 for 4 hits, 15 for 6, whatever). Doing this lets you check where the mana is at after the current cast, but before the next. If it's below 0, then cast a DIFFERENT spell with a guaranteed fail. 


So you have I think 3 moves? 1 to set the variables in place, 1 repeatable move that is your actual hits, and then a third that is your "out of mana" fail.


If you have any questions or need more help just respond here and in the morning I'll get to it.

Thank you for your help :)  however, I wouldn't even know how to store something like that into a variable from the damage box so I'm afraid I'm kind of.. stuck :p
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
Thank you for your help :)  however, I wouldn't even know how to store something like that into a variable from the damage box so I'm afraid I'm kind of.. stuck :p

Apologies, you can't store that from the damage box without whatever that variable ends up being ending up being the amount of damage you do.


According to this thread, I'm fairly certain the proper way of doing this would be in a script call in a common event (I'll use these things for days, man).This is in no way formatted, nor should it work as-is but it's the base idea:


$game_variables[1] = $game_actors[1].mp
$game_variables[2] = $game_actors[1].mmp

$game_variables[3] = $game_variables[1] / $game_variables[2]


Variable 1 will be actor1's current MP, variable 2 actor1's max MP, variable 3 the result of the division. You might also just be able to do blah.mp/blah.mmp but it's stuck in my head for some reason that Ruby doesn't like that, so I can't guarantee that I'm right.


There's a downside to doing it this way, however. I'm not positive if you can change the index number so that it just references the last user, rather than a particular member. If you can make it reference the last user, then you'd essentially do $game_actors[WHATEVERTHINGMEANSLASTUSER], otherwise you'll need some way of determining who used the spell. You could do that any number of ways, but the cleanest would probably be adding an invisible state that serves as a "marker," since the first move could be set to "The User," since it doesn't actually *do* anything to health/mp/whatever. Then, when you call your common event, you'd nest conditional branches. If Actor1 has InvisiState, force cast [index1], else Actor2 InvisiState, force cast [Index2]. Does that make sense?


Also I vastly apologize to whichever mod I'm giving brain aneurysms to, since this has nothing to do with custom formulae lol.
 

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
You'd mostly be doing it in a method in the script editor then simply call that method from the formula box (so that you can easily take the user and target, if you want to do it via common event you need to still use the DF to set the user and target to the variables)... Though it's still far easier to just make a script to handle randomization, there are probably some out there... I have one but it's not for the default battle system
 
Last edited by a moderator:

SergeX

Veteran
Veteran
Joined
Nov 25, 2012
Messages
64
Reaction score
15
First Language
Portuguese
Primarily Uses
I'm trying to do a formula which a variable controls final damage output this way: 


v = 10 = +50% damage


v = 9 = +40% damage


v = 8 = +30% damage


v = 7 = +20% damage 


v = 6 = +10% damage


v = 5 = -50% damage


v = 4 = -40% damage


v = 3 = - 30% damage


v = 2 = - 20% damage 


v = 1 = -10% damage


The first try was


if v[x] = 10; 1.5*(100 + a.mat *4 - b.mdf * 3); elsif v[x] == 9; 1.4 *(100 + a.mat *4 - b.mdf * 3); else; 100 + a.mat *4 - b.mdf * 3; end;


This formula works but theres no space for the other if situations of the variable. How can I rewrite this formula in a more effective way? Only the +50%, +40% and normal damage already take lots of space. 
 

Eliwan

Villager
Member
Joined
Apr 11, 2013
Messages
29
Reaction score
5
First Language
English
Primarily Uses
v = 10 = +50% damage


v = 9 = +40% damage


v = 8 = +30% damage


v = 7 = +20% damage 


v = 6 = +10% damage


v = 5 = -50% damage


v = 4 = -40% damage


v = 3 = - 30% damage


v = 2 = - 20% damage 


v = 1 = -10% damage

The "easy" way would be rescaling the variable to be 5 = +50%, -5 = -50%, and have a 0. Since, however, that would require more attention with how you manipulate the variable that may or may not be possible or easily difficult...


dmg = (100+a.mat*4-b.mdf*3); if v[x] >= 6 and v[x] <= 10; (1+((v-5)/10))*dmg; elsif v[x] >= 1 and v[x] <= 5; (1-(v/10))*dmg; end


[128 characters first draft]


So this


1. stores the base output for easy calling and space-saving (it saves like 10 characters of space)


2. checks if the variable is 6~10, since i'm not sure what you want if the variable is greater than 10


3. returns appropriate value-- 1~5 for 6~10 is simply -5 then divide by 10.


4. checks if the variable is 1~5, since again i'm not sure what you want if the variable is less than 1 or greater than 5.


5. returns appropriate value-- 1 - (v/10) is pretty easy.


that's too long though so...


reduce variable lengths as much as possible, remove some spaces.


M=(100+a.mat*4-b.mdf*3);if v[x]>=6 and v[x]<=10;(1+((v-5)/10))*M;elsif v[x]>=1 and v[x]<=5;(1-(v/10))*M;end


still 107 characters.


Removing most of the unlisted cases (variable is greater than 10 or between 5 and 6),


M=(100+a.mat*4-b.mdf*3);if v[x]>=6;(1+((v-5)/10))*M;elsif v[x]>=1;(1-(v/10))*M;end


(82 characters)


In this case you can actually sub out the "elsif v[x] >=1" for just "else" if you want to further reduce this (73 characters if you do); but that means if the variable is less than 0 the damage will start increasing.
 

SergeX

Veteran
Veteran
Joined
Nov 25, 2012
Messages
64
Reaction score
15
First Language
Portuguese
Primarily Uses
The "easy" way would be rescaling the variable to be 5 = +50%, -5 = -50%, and have a 0. Since, however, that would require more attention with how you manipulate the variable that may or may not be possible or easily difficult...


dmg = (100+a.mat*4-b.mdf*3); if v[x] >= 6 and v[x] <= 10; (1+((v-5)/10))*dmg; elsif v[x] >= 1 and v[x] <= 5; (1-(v/10))*dmg; end


[128 characters first draft]


So this


1. stores the base output for easy calling and space-saving (it saves like 10 characters of space)


2. checks if the variable is 6~10, since i'm not sure what you want if the variable is greater than 10


3. returns appropriate value-- 1~5 for 6~10 is simply -5 then divide by 10.


4. checks if the variable is 1~5, since again i'm not sure what you want if the variable is less than 1 or greater than 5.


5. returns appropriate value-- 1 - (v/10) is pretty easy.


that's too long though so...


reduce variable lengths as much as possible, remove some spaces.


M=(100+a.mat*4-b.mdf*3);if v[x]>=6 and v[x]<=10;(1+((v-5)/10))*M;elsif v[x]>=1 and v[x]<=5;(1-(v/10))*M;end


still 107 characters.


Removing most of the unlisted cases (variable is greater than 10 or between 5 and 6),


M=(100+a.mat*4-b.mdf*3);if v[x]>=6;(1+((v-5)/10))*M;elsif v[x]>=1;(1-(v/10))*M;end


(82 characters)


In this case you can actually sub out the "elsif v[x] >=1" for just "else" if you want to further reduce this (73 characters if you do); but that means if the variable is less than 0 the damage will start increasing.



Edit: I've tried your formula but it doesn't make any damage. I guess I wasn't very clear, but I did explain now.


Thanks for helping! I'll try your formula as soon I get home. 


For me dealing with a 5 and -5 scale makes no difference. I can easily rescale to 5 = +50%; and -5 = -50%. How this could change the formula? Would make it less intricate? The way I'm going to deal with the variable is by substitution , so I guess that there's no problem with your sugestion to rescale.


To make myself more clear, the idea of this formula is add bonus damage for elemental spells according to the area. Example: depending on the battleback or map, the final damage of a water spell could range from +10% (surrounds of a tiny river or lake) to +50% (near beach, ocean) or from -10% (earth area, a bit dry area) to -50% (strong dry area, desert). Each element is supossed to have a variable tracking the increase or decrease of damage. 


The maximum bonus is 50%, because I guess that a bigger bonus would break the game balance, since there are elemental affinities of resistance or weakness. So variable value above 10 is a situation that doesn't matter to me. The same applies for if the variable is less than 0.
 
Last edited by a moderator:

Eliwan

Villager
Member
Joined
Apr 11, 2013
Messages
29
Reaction score
5
First Language
English
Primarily Uses
Edit: I've tried your formula but it doesn't make any damage. I guess I wasn't very clear, but I did explain now.

No, I actually screwed up, you were perfectly clear.

Formula does no damage

0. I made a syntax error. I forgot the ";" at the end of the statement.


-> Yeah, this problem is existent, having tested.


1. I made a syntax error. There were "v-5" and just "v" when it should have been "v[x]-5" and "v[x]" respectively


-> This also causes the code to return a null value.


2. Subbing the x in "v[x]" with the appropriate integer {i've done this more than once}


-> I wouldn't know if you've done it right or not and I assume that you did because you aren't stupid like I am


A fixed formula would be:

Code:
M=(100+a.mat*4-b.mdf*3);if v[1749]&gt;=6;(1+((v[1749]-5)/10))*M;elsif v[1749]&gt;=1;(1-(v[1749]/10))*M;end;



Where 1749 is used to make sure that I'd not screwed up.

For me dealing with a 5 and -5 scale makes no difference. I can easily rescale to 5 = +50%; and -5 = -50%. How this could change the formula? Would make it less intricate? The way I'm going to deal with the variable is by substitution , so I guess that there's no problem with your sugestion to rescale.

The reason behind this is because you could just do

Code:
(100+a.mat*4-b.mdf*3)*(1+(v[1749]/10))





without needing to ever check what value variable x actually has (thus avoiding the syntax I always mess up). Negative number means reduced and positive number means increased. Though this also means that values below -10 return as negative damage (thus may end up healing the target).


So it's significantly less complicated.

The maximum bonus is 50%, because I guess that a bigger bonus would break the game balance, since there are elemental affinities of resistance or weakness. So variable value above 10 is a situation that doesn't matter to me. The same applies for if the variable is less than 0.

:3


If you want to have the simpler formula capped to make certain that the variable, even if it manages to exceed the intended range (which I'm taking as 5~-5 because I'm pretty sure there isn't enough space otherwise)...

Code:
M=100+a.mat*4-b.mdf*3;P=1+(v[1749]/10);if P&gt;1.5;1.5*M;elsif P&lt;0.5;0.5*M;else;P*M;end;
 
Last edited by a moderator:

SergeX

Veteran
Veteran
Joined
Nov 25, 2012
Messages
64
Reaction score
15
First Language
Portuguese
Primarily Uses
Code:
M=(100+a.mat*4-b.mdf*3);if v[1749]&gt;=6;(1+((v[1749]-5)/10))*M;elsif v[1749]&gt;=1;(1-(v[1749]/10))*M;end;



I get a syntax error with this one: "unexpected '='"

Code:
(100+a.mat*4-b.mdf*3)*(1+(v[1749]/10))



I must be screwing something up. With this formula, I keep getting the damage of ~153 HP if the variable is less than 10. From v = 10 on, I get a damage of 322 HP.

Code:
M=100+a.mat*4-b.mdf*3;P=1+(v[1749]/10);if P&gt;1.5;1.5*M;elsif P&lt;0.5;0.5*M;else;P*M;end;



No damage too. My idea is: if the variable equals 0, the damage is normal (100 + a.mat*4-b.mdf*3), and then it can be decreased or increased according to a variable. The first formula I've shown here works, but since is too long, I can't put all the boost  or deboost situations. These P&gt are part ofthe code?


Maybe I am doing something wrong? I set the values of a variable I determined but I dunno what happens.
 
Last edited by a moderator:

Eliwan

Villager
Member
Joined
Apr 11, 2013
Messages
29
Reaction score
5
First Language
English
Primarily Uses
Maybe I am doing something wrong? I set the values of a variable I determined but I dunno what happens.

Nope!


I'm just that bad at coding and remembering rules.


In order:


The syntax error is caused because there are random "&gt;" signs, which were caused because I suck at copy-pasting because different text formats (thus making an error that I didn't notice: I assembled my entire post in notepad and copy-pasted it without checking to see if it actually pasted properly).


They were supposed to be greater-than symbols (>).


M=(100+a.mat*4-b.mdf*3);if v[NN]>=6;(1+((v[NN]-5)/10.0))*M;elsif v[NN]>=1;(1-(v[NN]/10.0))*M;end;


The reason why the value doesn't properly increment is because I forgot unless you specify it as a float it converts to an int (though that's not exactly what happens, I don't actually know exactly what happens). The division needed to be by 10.0 to make it properly get a float for the multiplication...


(100.0+a.mat*4-b.mdf*3)*(1.0+(v[1749]/10.0))


-


M=100+a.mat*4-b.mdf*3;P=1+(v[NN]/10.0);if P>1.5;1.5*M;elsif P>0.5;0.5*M;else;P*M;end;






This alternate one created a constant but again I messed it up with copy-paste. But it wouldn't have worked properly anyway because I didn't put in the float divide.


Since copy-paste is evidently being an issue; have a pastebin link.


...If I type "&gt;" into the reason-for-edit box it actually prints out a >....
 
Last edited by a moderator:

SergeX

Veteran
Veteran
Joined
Nov 25, 2012
Messages
64
Reaction score
15
First Language
Portuguese
Primarily Uses
Nope!


I'm just that bad at coding and remembering rules.


In order:


The syntax error is caused because there are random "&gt;" signs, which were caused because I suck at copy-pasting because different text formats (thus making an error that I didn't notice: I assembled my entire post in notepad and copy-pasted it without checking to see if it actually pasted properly).


They were supposed to be greater-than symbols (>).



M=(100+a.mat*4-b.mdf*3);if v[NN]>=6;(1+((v[NN]-5)/10.0))*M;elsif v[NN]>=1;(1-(v[NN]/10.0))*M;end;


The reason why the value doesn't properly increment is because I forgot unless you specify it as a float it converts to an int (though that's not exactly what happens, I don't actually know exactly what happens). The division needed to be by 10.0 to make it properly get a float for the multiplication...



(100.0+a.mat*4-b.mdf*3)*(1.0+(v[1749]/10.0))


-



M=100+a.mat*4-b.mdf*3;P=1+(v[NN]/10.0);if P>1.5;1.5*M;elsif P>0.5;0.5*M;else;P*M;end;






This alternate one created a constant but again I messed it up with copy-paste. But it wouldn't have worked properly anyway because I didn't put in the float divide.


Since copy-paste is evidently being an issue; have a pastebin link.


...If I type "&gt;" into the reason-for-edit box it actually prints out a >....



Formula 2 works perfectly! I can't thank you enough for this. Really nice that I'll be able to design the project the way I intended to.


Thanks again!
 

sentinelshade

Villager
Member
Joined
Mar 17, 2016
Messages
9
Reaction score
2
First Language
English
Primarily Uses
Hopefully this qualifies as a correct place to post this question, as it relates to custom formulae.


I'm currently trying to meld N.A.S.T.Y Extra stats, (allows you to create additional "xstat" categories using an actor's or enemy's notetag section) with Kread's custom weapon formulas. (allows you to plug custom weapon formulas into each individual weapon notetag) 


I'm relatively new to all this and have no idea how to write a custom weapon formula that would check the x-stats in the notetag of the actor that has the weapon equipped. To explain more specifically:


Let's say a character has an x-stat of strength: 30, listed in their notetag.


If I wanted to make a weapon that has 20 ATK but also adds 10% of the character's strength (which would be 3 for this example) to the attack. In this case the weapon ATK would be 23 if a character had 30 strength. How would I properly code it to execute that?


So far I've tested this but what happens is the slime, whose defense is currently set to 1, still receives no damage:


a.atk=  + (self.xstat.str * 0.10)* 4 - b.def * 2


I need it to say something to this effect:


<formula>


(weapon's attack power + 10% of strength xstat from whoever has it equipped) * 4 - b.def * 2


</formula>


Can anyone shed some light on this? 
 
Last edited by a moderator:

Eliwan

Villager
Member
Joined
Apr 11, 2013
Messages
29
Reaction score
5
First Language
English
Primarily Uses
So far I've tested this but what happens is the slime, whose defense is currently set to 1, still receives no damage:


a.atk=  + (self.xstat.str * 0.10)* 4 - b.def * 2


<formula>


(weapon's attack power + 10% of strength xstat from whoever has it equipped) * 4 - b.def * 2


</formula>


Can anyone shed some light on this? 



Well, first


Your formula is saying "set actor attack" and trying to set it to "plus [var] divided by 10 times 4 minus twice defender's defense".


What you want is for the box to just have an integer.


Additionally, reading the script of Extra Stats, it says that the variable is stored under


"$game_actors[1].xstat.str".


In damage formulas, "a." is what is used to call the attacker's stats-- or any method of an actor that returns a variable. "self" in the damage formula box refers to neither the attacker nor defender (it actually would refer to the engine that handles combat in default VXA).


So if the weapon's attack power is stored as the actor's attack stat (which your <formula> makes me believe), then what you want is:


«


(a.atk + a.xstat.str*0.1)*4 - b.def*2


»
 

sentinelshade

Villager
Member
Joined
Mar 17, 2016
Messages
9
Reaction score
2
First Language
English
Primarily Uses
So if the weapon's attack power is stored as the actor's attack stat (which your <formula> makes me believe), then what you want is:


«


(a.atk + a.xstat.str*0.1)*4 - b.def*2


»



Worked like a charm! Thanks, Eliwan!


Now all I have to do is go figure out to make the weapon's attack power in the equip screen include stat bonuses (like 23 ATK instead of 20 ATK from my example) of the character who is considering equipping it. I get the impression that's going to be script editor instead of notetags, and not a far cry from the formula you fixed for me :)
 

BCj

Veteran
Veteran
Joined
Jun 19, 2014
Messages
1,760
Reaction score
949
First Language
Dutch
Primarily Uses
N/A
I need some help with this one..
I basically made a leeching shot, it deals damage to enmies and converts a part of that damage into healing to the whole party.
But here's the problem:

a) it heals only the user
B)  I set it to "all enemies" and instead of attacking once and attacking them all, my character attacks them one by one. Not exactly what I want..Not sur eif it's the fault of my Symhony tags though.

This is the formula:
c=a.atk * 2.6 - b.def;d=$game_party.alive_members;d.size.times{|i|d.hp+=(c*0.25).to_i};c
 

Eliwan

Villager
Member
Joined
Apr 11, 2013
Messages
29
Reaction score
5
First Language
English
Primarily Uses
I need some help with this one..
I basically made a leeching shot, it deals damage to enmies and converts a part of that damage into healing to the whole party.





iirc the "hits all enemies" tag isn't particularly well done, and hits every enemy in succession instead of simultaneously by default.


You want it to deal damage to some number of enemies and then heal all allies evenly equal to the sum of the damage dealt?


I think you can do that with


«


c=a.atk*2.6 - b.def;d=$game_party.alive_members;d.each{|f| f.hp+=(c/d.size)};c


»


but I am not absolutely sure that's correct.
 

Latest Threads

Latest Posts

Latest Profile Posts

Sorry, lot of unexpected hospital things. I'm trying. Life is hectic atm. I know it must seem like I say this every week. XD Anybody wanna trade me for awhile so I can game test and game make?
I love running events, I hate setting up all the awards at the end. >_> But you know, gotta do it :B :B :B

Forum statistics

Threads
111,242
Messages
1,059,522
Members
144,506
Latest member
ItsFNREtro
Top