How to make this formula?

HopeFragment

H'witch Nerd
Veteran
Joined
Mar 15, 2014
Messages
121
Reaction score
11
First Language
English
Primarily Uses
RMVXA
Hi, I'm making a very weird move that under normal circumstances, gives all enemies Confuse and Silence (so "all enemies" scope, and in the effects box it adds confuse and silence 100%), and gives the user state 54. However, if actor 3 is in the battle, the user instead gets state 55, and actor 3 gets state 13.

I know that this formula would involve like an if statement with a.add_state(54) and a.add_state(55), but I don't know where to go from there.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
During battle your party members become the active party members. That said you can do something like this:
Code:
$game_party.members.include?($game_actors[3]) ? a.add_state(55) : a.add_state(54)
Remember that you can access your formula only if your skill does something like dealing damage/healing. If you want to do something like that with a skill that doesn't act like I said before you have to call a common event and have the common event check if actor 3 is battling then apply the correct state to the user. (This doesn't work if you have more than one character able to use that skill.)

If you use the conditional statement in a common event you cannot use a.add_state and have to use the long way to refer to your actor. The rest of the code is the same.
The result is something like this:
Code:
$game_party.members.include?($game_actors[3]) ? $game_actors[N].add_state(55) : $game_actors[N].add_state(54)

# OR THIS ONE

if $game_party.members.include?($game_actors[3])
  $game_actors[N].add_state(55)
else
  $game_actors[N].add_state(54)
end

# N is the id of the actor using your skill
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
That doesn't apply state 13 to actor 3, or take into account that actor 3 might be using the skill.

Try this, which builds on the above:
Code:
$game_party.members.include?($game_actors[3]) ? (a == $game_actors[3] ? a.add_state(13) : (a.add_state(55); $game_actors[3].add_state(13))) : a.add_state(54)
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@Shaz you're right, I totally missed that part while reading the thread. Thank you for correcting me.

However that formula contains too many characters. VX Ace formula box is not as large as MV. The OP should use a Scriptlet or other methods to overcome this. This is an option even if it is not so easy to the eye.

Code:
c=$game_actors[3]; a.add_state(($game_party.members.include?(c) ? (c.add_state(13); 55) : 54))
In this version of the formula state 55 is applied to the user even if it is actor 3. I don't know if the OP wants the formula to act like that. If not then this one should do:

Code:
c=$game_actors[3]; a.add_state(($game_party.members.include?(c) ? (c.add_state(13) unless a==c; 55) : 54))
I am not sure this last one fits.

EDIT:
@HopeFragment I am sure it doesn't fit. if you don't want your state 55 to be applied to actor 3 when the caster itsef is actor 3 then I am not sure a formula can do it, you probably need a scriptlet.
In that case just use:
Code:
class Game_Battler < Game_BattlerBase

  def your_custom_skill(a, c)
    if $game_party.include?(c)
      a==c ? a.add_state(13) : (a.add_state(55); c.add_state(13))
    else
      a.add_state(54)
    end
  end

end
Call this method in your skill formula using
Code:
a.your_custom_skill(a, $game_actors[3])
It works even if you use
Code:
b.your_custom_skill(a, $game_actors[3])
because the method recives the caster as a parameter which is actually redundant.
 
Last edited:

HopeFragment

H'witch Nerd
Veteran
Joined
Mar 15, 2014
Messages
121
Reaction score
11
First Language
English
Primarily Uses
RMVXA
First off thank you two for helping; I can't try anything right now as I am out, but perhaps I should have given a little more information.

The formula wouldn't have to take into consideration what happens when actor 3 uses the skill, or when two different actors know the skill, because actor 3 can't use it, only one party member can use this skill, and it's actor 4. I'm sorry, I should have said that in the first place. Incidentally, no enemies can use this skill either, only actor 4. Completely unique skill exclusive to actor 4.

So @Heirukichi, you're saying that this actually needs to be a common event and can't be done with the formula box, since this skill doesn't do damage? (It doesn't do damage.)
 
Last edited:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
you're saying that this actually needs to be a common event and can't be done with the formula box, since this skill doesn't do damage? (It doesn't do damage.)
Exactly. If the skill deals no damage you cannot acces its formula box. To access it is must be either a damaging skill or a healing skill. Since using damage formulae is much faster and more versatile than using common events I usually overcome this by setting my skill to heal a flat ammount (let's say 10) that doesn't change my game's mechanics but it is not ugly (seeing a skill that does no damage nor healing is kinda ugly in my opinion).

However the fact that your skill can only be used by actor 4 makes things much easier because you don't have to consider the possibility of having different targets. Using a common event in this particular situation might be the best option.

First of all have your skill call a common event. What your common event should do is basically this: check if actor 3 is a party member, if yes add state 13 to actor 3 and state 55 to actor 4, if not add state 54 to actor 4. This can be achieved without using script calls. If you want to use a script call anyway then just copy/paste the following.

Code:
if $game_party.members.include?($game_actors[3])
  $game_actors[3].add_state(13)
  $game_actors[4].add_state(55)
else
  $game_actors[4].add_state(54)
end
This is not tested but it should work since the "members" method for the Game_Party class returns your battle party members if you are in battle.
 
Last edited:

HopeFragment

H'witch Nerd
Veteran
Joined
Mar 15, 2014
Messages
121
Reaction score
11
First Language
English
Primarily Uses
RMVXA
What if actor 3 isn't an active party member participating in the battle? It should only recognize him as "in the party" if he is participating in the battle, even if he is part of the party. Wouldn't a conditional branch not be able to check that when doing "if Actor is in party"? Or am I wrong about that? On the overworld at least, when there are more than 4 party members and there are non-active ones, conditional branches checking for actors being in the party come up with them being in the party even if they're not active.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
Then I think the check would be
if $game_party.battle_members.include?($game_actor[3])
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
[...] since the "members" method for the Game_Party class returns your battle party members if you are in battle.
@HopeFragment if you check it out of combat it should return true even if they are not active party members. However if you check it in combat, as I said, the members method returns actually the array of battling party members. Using $game_party.battle_members is not wrong anyway. You can decide which one you want to use. Just to clarify how it works check the spoiler below.

Code:
def members
    in_battle ? battle_members : all_members
end

#===========================
# This is the same as saying:
#===========================

def members
    if in_battle
        battle_members
    else
        all_members
    end
end

So using $game_party.members or $game_party.battle_members when in combat is the same. However since Game_Interpreter checks actors in party in the same way when using conditional branches you can also use a conditional branch instead of the script call I wrote.

Code:
def command_111
    result = false
    case @params[0]
# [...]
    when 4  # Actor
      actor = $game_actors[@params[1]]
      if actor
        case @params[2]
        when 0  # in party
          result = ($game_party.members.include?(actor))
# [...]
    end
    @branch[@indent] = result
    command_skip if !@branch[@indent]
end

So if you are in battle and use a conditional branch (or the script call I wrote) to check party members you will only get battle party members.
 
Last edited:

HopeFragment

H'witch Nerd
Veteran
Joined
Mar 15, 2014
Messages
121
Reaction score
11
First Language
English
Primarily Uses
RMVXA
It worked! I tested with actor 3 in the party, without actor 3 in the party, and actor 3 in the party but not in battle, and it worked as intended. Thank you!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top