If/else command request for damage formula.

Miyoko

Villager
Member
Joined
May 9, 2014
Messages
20
Reaction score
0
First Language
English
Primarily Uses
One of the character classes in my game is a goo girl. One of her abilities involves engulfing an enemy and digesting them while the battle rages on.Digesting an enemy slowly damages them while slowly healing the goo girl. I have two states setup for this, digested and digesting. However, I'm having trouble getting the skill to function as I want. Essentially, what I want to have happen, is something along these lines (in grossly simplified terms):


if = enemy is successfully afflicted with state(id1), then user is afflicted with state(id2)


else;


nothing.


In otherwords, if the player uses "Engulf Target" and the state is successfully applied, then the character who used it gets a state applied to them too. If the attack fails and then nothing happens. No states are applied to anyone.


I am wondering if there is a way I can do this using the damage formula box, since that thing is crazy powerful and its usefulness is woefully understated. I want to have this work using skills and avoiding common events, since common events just seems like it's going to be problematic as it's hard to check which character used what. Considering I have 27 character slots and 22 character classes, that would be an insanely huge common event to check and see which character is using what skill on what enemy and if it worked...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Not really, because the states are applied after the damage is calculated.  If it's possible for the state to be resisted, you won't know, when the damage formula gets calculated, whether the state is going to be applied or not.


I suggest you attach a common event to the skill - as this will be the very last thing that gets run, the damage will have been dealt and the state would have been applied to the target by the time it runs.


In your damage formula, you can put something like this:

Code:
v[1] = a; v[2] = b; real_damage_formula_here
which will put the actor into variable 1 and the target into variable 2 (replace 1 and 2 with variables you have available for this purpose).  Then in your common event you can do this:

Code:
Conditional Branch: Script: $game_variables[2].state?(15)
  Script: $game_variables[1].add_state(16)
Branch End
again replacing the 1 and 2 with the appropriate variable ids, and the 15 and 16 with the appropriate state ids.
 

Miyoko

Villager
Member
Joined
May 9, 2014
Messages
20
Reaction score
0
First Language
English
Primarily Uses
There were a couple errors but I managed to fix it. I was using a script call instead of putting that first part into a conditional branch to start. Thank you a bunch! It's awesome to see this actually working now!


My only concern is that the status icon doesn't update on the end of the turn. Is there a script call I can do to force update status icons? It's not really a big deal, just a small quality of life thing.


Lastly, I use yanfly's skill restriction script. Do you know how I'd be able to add onto the same conditional branch that if the skill lands, a cooldown is placed on the skill?


Thank you again!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Instead of add_state, try calling add_new_state which does a few other things, including refreshing the battler.


With the Yanfly question, sorry, I have no idea.  I'm not familiar with the script.  There might be someone else who can fill in the blanks there.  As a guess though, the skill landing and the state being applied are two different things - I would imagine it would already cater for a cooldown if the skill lands - you just need to set it up in the notes of the skill, not as part of the conditional branch.
 

Miyoko

Villager
Member
Joined
May 9, 2014
Messages
20
Reaction score
0
First Language
English
Primarily Uses
add_new_state didn't work and actually caused a crash with the following error!


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



Script 'Game_Battler' line 246: NoMethodError occurred.


undefined method `>' for nil:NilClass
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
oh no, add_state was correct - it calls add_new_state.


I imagine there would need to be a refresh somewhere to update the status icons.  I can't see where, after a quick look through, and don't have time to go into it more thoroughly.  Sorry.
 

Miyoko

Villager
Member
Joined
May 9, 2014
Messages
20
Reaction score
0
First Language
English
Primarily Uses
That's fine. It's only a small quality of life change, definitely not necessary. Thank you Shaz!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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'??
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

Forum statistics

Threads
105,857
Messages
1,017,019
Members
137,564
Latest member
McFinnaPants
Top