[SCRIPTING] [RMMV] HOW TO APPLY SCRIPT EFFECTS TO AN ENEMY

Posts

Pages: 1
I feel like there's a simple answer to this one, but I don't know how to get a target's ID and store it as a variable

So I'm not even sure if this is possible with a script call, but I wanted to add a state at X%, where X is a function all its own. What I'm thinking it would look like is something like this:


b.(enemy max hp - enemy current hp)/ enemy max hp = var 001
Random number generate 0-1 = var 002
If var 002 <= var 001,
then $gameTroop.members(){enemyIndex}.addState(n)


I can already script call to add a state to an enemy at 100%, but I'm trying to have a state added at, say, a 30% chance if 30% of their HP is missing. I think this can be done via script call- the reason I put b.() in there was that I know you can create custom damage formulas, so I was hoping to apply a state via the dmg formula box. If there's a script that can do what im asking that's fine too.
You can take a look at this: Lucky 7's
which shows how to use Yanfly's action sequence plugins to compare variables inside a skill.
author=meteomage
You can take a look at this: Lucky 7's
which shows how to use Yanfly's action sequence plugins to compare variables inside a skill.


Ok, I'm using Yanfly Action sequence pack 1 and so far I have the following:

<target action>
$gameVariables(4) = (b.mhp - b.hp)/b.mhp
$gameVariables(5) = Math.rand()
if $gameVariables(4) <= $gameVariables(5)
add state 11: target
</target action>

and get error:
Type error: cannot read property toUpperCase of undefined
Marrend
Guardian of the Description Thread
21781
I'm no expert, but, I wonder if the reference to "b" instead of "target" is throwing the script off? Maybe something like...

<target action>
  $gameVariables.setValue(4,(target.mmp - target.hp) / target.mhp);
  $gameVariables.setValue(5, Math.rand());
  if $gameVariables(4).value <= $gameVariables(5).value
    add state 11: target
  end
</target action>

...this would work? Though, I'm probably off with the exact referencing here, as I don't have MV to make cross-references to.
author=Marrend
I'm no expert, but, I wonder if the reference to "b" instead of "target" is throwing the script off? Maybe something like...

<target action>
  $gameVariables.setValue(4,(target.mmp - target.hp) / target.mhp);
  $gameVariables.setValue(5, Math.rand());
  if $gameVariables(4).value <= $gameVariables(5).value
    add state 11: target
  end
</target action>

...this would work? Though, I'm probably off with the exact referencing here, as I don't have MV to make cross-references to.

I tried your solution (both verbatim and with a few changes so it looks like this:

<target action>
  eval: $gameVariables.setValue(4,((target.mmp - target.mp) / target.mmp);
  eval: $gameVariables.setValue(5, Math.rand());
  eval: 
   if $gameVariables[5].value <= $gameVariables[4].value
    animation 121: target
    add state 11: target
   else 
    common event: 1
  end
</target action>

The main problem I had was I had to put in "eval:" to evaluate script using the plugin. The system is close to working now, except all that happens is I end up with common event 1 (a text box saying skill was unsuccessful). Without the "else" part I was able to get the animation to play and effect to add- so I'm thinking the problem is something with the syntax of the "If, Else" or the comparison between var 004 and var 005.

Almost there, though, your example definitely helped.

Edit: I originally meant to say "MP" instead of HP because I'm basing it off the current target's lost mp %. I have a skill called drain that reduces the enemy's MP by 60%, and I confirmed the enemy's MP is at 40%, so there should be a 60% chance of the status being applied, but I keep getting common event 1 instead.
Pages: 1