How to make the most of custom formulae. Part #1

EDIT

Never mind, I've solved my question.
-sigh- I tried to get this to work but something small again is preventing it from working:

if a.id == 8 ; a.add_state(80) + a.atk * 3 - b.mdf * 1.0 else; a.atk * 3 - b.mdf * 1.0; end;
A.id == 8 is supposed to be powered by his blood-sucking attack more so than others who use this skill. But number 8 doesn't do damage when he strikes. What did I mess up?
you're probably missing a ; and a few other parts...

a.add_state(80) doesn't return a number (as far as I know) and therefore the + behind it doesn't make sense.

Close it with a ;

Then check your remaining damage calculation - I don't see a difference before and after the else (other than adding the state), so you might use that damage formula behind the end; or add the missing number to the part before the else.
I can get one of two characters to do damage but never the id 8, the one with the state applied. Even after moving some things around.
if a.id == 8; a.add_state(80); end; a.atk * 3 - b.mdf * 1.0
Yes. That did it, thanks.
Is there a way to make a formula where the actor gains an attack power will increase as long as an ally(s) are dead. Like the damage is multiplied by two for each dead ally (so 6 would be the max if all 3 allies are dead at the same time) but returns to normal when the allies are revived.
Try:


[(4 - $game_party.alive_members.size) * 2,1].max * formula
I am trying to make a spell that sacrifices the user, killing them and heals/revives the target for the caster's current health. Kinda like an explosion spell that heals rather than used for damage.
How would I do this?
I tried using a formula I seen for explosion spell and changed to healing but didn't work.

c = a.hp; a.add_state(1); c^^ above formula works great to damage, but doesn't to squat to heal.

Edit: I had the Scope set to One Ally (Dead), works fine on One Ally. 😛
However, the spell doesn't work on dead allies.
How do I get it to remove death from a dead ally, and not let it affect the user if he is targeted with his own spell?
I want to be able to use an item to give protection in battle against an element e.g. to reduce damage from fire by 20%

Is it possible to do this in the damage formula for that item?
I want to make a spell that targets all enemies, but divides the total damage by the number of enemies targeted.

For example, it would deal 1000 damage to 1 enemy, or 250 damage each to 4 enemies.

and ksjp17, probably the easiest way to have a consumable item grant element protection would be to make a state for each element and have the item's effect apply that state.  Basically you make a state called Fire Protection with the feature Element Rate [Fire] * 80%.  Then your item will have the effect Add State [Fire Protection] 100%.
@Ministry

Yes, I'm using the State approach at the moment as a placeholder, but I'm using States for quite a wide range of things, and I'm fairly sure I've read somewhere that there is a fairly low maximum number of states that you can stack onto an actor at any one time.  I therefore want to avoid using States unless there is no other choice.
Try:

[(4 - $game_party.alive_members.size) * 2,1].max * formula
I was able to reverse engineer it from this solution.  This is what worked for me:

1000 / $game_troop.alive_members.size

Interesting side effect, it calculates damage each time it hits an enemy.  So if I cast it during a boss fight where there's a boss and 3 minions (with less than 250HP each), the amount of damage dealt increases after each minion is killed.  If the boss is hit last, he gets the full 1000 damage.  I'm probably going to have to store a variable at the beginning of the spell and then reference it while dealing damage, but I'm fumbling around in the dark here.  Anyone with more experience have any advice on this matter?
ok...

so I'd like to determine what state an enemy has, then apply that state to all enemies. Here is what I got so far:


 

 

    for c in 2..41;

      if b.state?( c ) ; $game_troop.add_state( c ) ; else ; 

      end
i keep getting a Null on enemies. Im not very experienced in programming, just dabbling. Any help would be appreciated! Im thinking I need the code syntax to target a group.
Allright, I got it sorted out exactly how I want it!

So first thing I have to do is set a variable at the start of each encounter.  So every Troop gets a Battle Event with the condition of Turn No. 0 that does Control Variables: [0004:# of enemies] = $game_troop.alive_members.size

I also need to decrease this variable by 1 every time an enemy dies.  I created a Common Event called "Dec # of enemies" with the Content of Control Variables: [0004:# of enemies] -= 1.  Then for every enemy within a Troop I made a New Event Page with Condition: enemy [1. Slime]'s HP 0% or below to Call Common Event: [Dec # of enemies].  The enemy ID gets changed to match each enemy, of course.  For some reason this event is not called until the spell finishes doing it's business (which is a good thing as it will not deal more damage as it goes if it's killing weaker enemies).

Lastly the Skill's Formula just checks the variable and uses: 100 / v[0004]

This way the number of enemies is updated at the beginning of each battle and gets decreased if an enemy is killed BEFORE the spell is actually cast (however it does not change if an enemy is killed by the spell until the spell completes dealing damage to all targets).

I know this is not exactly a custom formulae solution, and therefore is a little off-topic, but in case anyone else was following my issue to use in their own RPG I want them to see how it was solved.
ok...

so I'd like to determine what state an enemy has, then apply that state to all enemies. Here is what I got so far:

i keep getting a Null on enemies. Im not very experienced in programming, just dabbling. Any help would be appreciated! Im thinking I need the code syntax to target a group.
In the skill box put:

eval($data_skills[x].note)

where x is the skill id

then in the notebox:

Code:
for c in 2..41  if b.state?(c)    for m in $game_troop.members      next unless m.alive?      m.add_state(c)    end  end end
This will also re-apply the states to the target just so that you're aware.
In the skill box put:

eval($data_skills[x].note)

where x is the skill id

then in the notebox:

for c in 2..41 if b.state?(c) for m in $game_troop.members next unless m.alive? m.add_state(c) end end endThis will also re-apply the states to the target just so that you're aware.
Thank you very much for the response. Just a few questions...

1) I assume the text in the damage formula area is to re-direct to the notes for the function of the skill, but why does it work there but not if I add a custom script like:

class Game_Battler < Game_BattlerBase 

  

  def State_Spread

    (2..41).each do c;

      if b.state?© ; 

        for m in $game_troop.members

          next unless m.alive?

          m.add_state© ;

        end

      end

      end    

    end   

  end
2) Is the second loop a standard way of targeting multiple enemies from a skill with a scope of one enemy?

3) Seems like the code recognizes the enemies in $game_troop.members as an integer. can you target enemies with 1, 2, 3 etc?

Thank you for this thread. It has helped me a lot with learning what the system is capable of.
1) Try:

b.state_spread

class Game_Battler < Game_BattlerBase def State_Spread for c in 2..41 if self.state?(c) for m in $game_troop.members next unless m.alive? m.add_state(c) end end end end end2) It's one way of doing it.3) No $game_troop.members is an array of objects type Game_Enemy.
Awesome!

If you wanted to use that loop for damaging enemies, would you put the damage formula after m? do you need anything else?
for that point you would probably use the all enemies scope for the skill

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-most-of-custom-formulae-part-1.1143/