The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: scarletrose on January 12, 2013, 06:52:17 PM

Title: In Battle Enemy Change Parameter
Post by: scarletrose on January 12, 2013, 06:52:17 PM
In Battle Enemy Change Parameter
12/01/2013




Summary
I need a way to change Enemies parameters during battle applying a positive or negative variable.
I searched for all similar scripts but I failed to find a script that could manage to do the Kind of operations that I need to do in my game.
In My game this kind of modification can apply to the actors too, and the function change parameter already cover everything I need to do with the Variable Operand but a similar function for enemies is missing.

Features Desired
I need a script who either

Mockups
I can't think of a visual that would provide any help. Feel free to ask If you need something here

Games its been in

What other scripts are you using?
I also have
In my attept to resolve My problem. I have no real need for these and I will remove them if provided with a script that makes no use of them and delivers the effect I want.




Did you search?
yes

Where did you search?

What did you search for?




I would really Appreciate any help or advice on the matter.
Feel free to ask any question if you need more information on how will this script be implemented in game
Thanks
Title: Re: In Battle Enemy Change Parameter
Post by: modern algebra on January 12, 2013, 07:05:21 PM
Under what circumstances would you want the parameters to change? Just upon an event? In that case, the following code in a script call should work:


b = $game_troop.members[troop_id]
b.add_param(param_id, value)


Where:

troop ID is the enemy's index in the troop. (IE. 0 is the first enemy, 1 is the second enemy, etc..)

param_id is between 0 and 7. 0=> Max HP; 1 => Max MP; 2 => ATK; 3 => DEF; 4 => MAT; 5 => MDF; 6 => AGI; 7 => LUK.

value is the integer amount you want to add.

Examples:


b = $game_troop.members[2]
b.add_param(6, 100)


That would add 100 to the AGI of the third enemy in the troop.


b = $game_troop.members[0]
v = $game_variables[4]
b.add_param(2, v)


That would add the value of variable 4 to the ATK of the first enemy in the troop.


If you wanted to apply it to actors, you would change the b=  line to:


b = $game_party.members[x]
Title: Re: In Battle Enemy Change Parameter
Post by: scarletrose on January 12, 2013, 07:26:21 PM
Thank you very much I will Try it as soon as possible.

I have a rather complex Battle system that is based on a lot of common events triggering during battles and extra statistics stored in variables.
This situation in particular will be triggered by one of these common events.

So I guess I just have to put that script into the common event.

Just 3 of questions. I'm pretty sure about the answers myself but I'll ask just to be sure...

1) Is the modifier stackable?
If it Is I will use it like it is. If is not I will simply have to store the variable and add/subtract from it instead of creating a new variable every time the event triggers. in either case there is no need for a new script, I can do the adjustements myself.

2)To subtract from a stat Should I change the word "add" to "sub" (is it sub?) or should I enter a negative variable? probably both but ... just to be sure.

3)The script does anything that will modify the stats of the basic monster? I'll try to explain better....
If I drain 10 AGI from the enemy during a battle and then I will face the same kind of enemy again would he be as good as new or would be the drain permanently imprinted in that type of enemy? (Probably not since it affects troop_id and not Enemy_id)

Thanks a lot for the help.

P.s.

Actually... another question arises that is way more important.
Using this script is it possible to lower a stat to 0 or below? If that is possible I need to anticipate or I would divide by 0 ... and you know what happens when you divide by 0....
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fwww.mathsisfun.com%2Fnumbers%2Fimages%2Fdivide-by-zero.jpg&hash=694fb1c1dec98b9d1194d0ba4ac3cf6ef5caa491)
Title: Re: In Battle Enemy Change Parameter
Post by: modern algebra on January 12, 2013, 10:17:36 PM
1. Yes.

2. You would use a negative value. Do not change the name of the method.

3. The script only affects the monster in the troop, not its basic stats. So the enemy will be as good as new next time you battle one.

4. No, the minimum value is 1 for all parameters except Max MP, in which case it is 0. But you wouldn't ordinarily divide by the max MP. (That said, the actual value you are modifying can drop below 0, it's just that the actual parameter cannot. For example, if the enemy's ATK is 20 and you drain it by 30, then the enemy's ATK would only be 1 when you retrieve it directly. However, if you wanted to then bring the enemy's ATK to 5, you would need to add 15, not 4.)