% chance to add a debuff

Status
Not open for further replies.

MOSN

Villager
Member
Joined
Sep 9, 2017
Messages
12
Reaction score
1
First Language
Danish
Primarily Uses
RMMV
Simple question that I can't seem to find a solution to through googling:
You know how you can make a skill that has a % chance to add a state? Well what if I want to do that with a debuff instead of a state? I assumed it would be simple enough like it is with states, but apparently not because it only gives you the option to chose how many turns the debuff lasts and not a % for applying it...
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Database >> Common Event
Create a common event named Debuff 1.
Set a variable with a random value.

Conditional Branch: If the variable is less or equal to 30
Do the debuff
End

(This gives a 30% chance of success, you can change it accordingly and even make an else case)


Skill >> Effects: Double Click >> Other >> Common Event
Select the Common event you made.


It would help out to find a command to set the enemy index inside a variable, to target enemies easier I suppose.
In that case you use a Script in the control variables to set it up and I would love to know how to do this if possible:
If not in battle return 0, else return the Enemy id the user has chosen to cast the spell.
Is this possible? :eswt:

If it's not possible, then you might need to use a Plugin.


So continuing you can create a Conditional Branch according to that variable.
Let's say you wanna change Enemy State, you use the event command and you check one after another, using conditional branches, if the variable equals to 1 or 2 or ... or 6.
Thus for each case you target different enemy, then set that variable to 0.

The past missing from the puzzle is the way to set a variable to the value of a selected enemy (0 of no enemy selected).
 
Last edited:

MOSN

Villager
Member
Joined
Sep 9, 2017
Messages
12
Reaction score
1
First Language
Danish
Primarily Uses
RMMV
Ahh nice. Haven't gotten around to using common events yet, but this sounds simple enough at least. Thanks for the help :)
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Ahh nice. Haven't gotten around to using common events yet, but this sounds simple enough at least. Thanks for the help :)
Edited my reply. Read it carefully. It is not THAT simple. :/
We need someone to give us a simple command to solve this puzzle and you are done.


Edit:
So, it seems we need this:
$gameVariables.setValue(var, value);

var will be the #id of the variable (the number of the slot it resides in the database)

value
I want to set enemyIndex there. How can I refer to enemy index on-the-fly people, or return 0 if there is no id?
 
Last edited:

MOSN

Villager
Member
Joined
Sep 9, 2017
Messages
12
Reaction score
1
First Language
Danish
Primarily Uses
RMMV
Yea, I see now getting the enemy ID isn't that simple. On top of that it doesn't seem like there is a default event command for applying buffs or debuffs (Once again there is for state but not for buffs...). I guess you'd probably need scripting to do it.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Let me move this to a more appropriate thread, so people can help you out.

Moved to a more appropriate place.

 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,117
Reaction score
1,525
First Language
EN
Primarily Uses
RMMZ
Oh, you should be able to do this all in the skill formula! ^_^

You can set a variable's value quite easily in a skill formula thanks to a handy alias v[id] for variable #id; you can get the target's id (assuming they are an enemy!) like so:
Code:
v[1] = b.enemyId()
[Edit: @Dreadshadow whoops, it should be b.index(). Either way, though, I've just discovered an awful loophole in this approach: the damage formula only calculates on hit, meaning the variable might not be set correctly! :kaodes: I'll reply with more detail, including a failsafe, on your new thread.]

However, I'd recommend simply doing it all in the damage formula itself. Here's an example formula that has a 52% chance to apply a 2 turn mhp debuff, then it always deals 0 damage:
Code:
if (Math.randomInt(100) < 52) b.addDebuff(0, 2); 0
The last "line" (separated by semicolons) in a formula is always the damage (or healing) amount. addDebuff takes two inputs: parameter ID and duration in turns. The parameter IDs are 0~7: mhp, mmp, atk, def, mat, mdf, agi, and luk respectively.

You may find this thread useful~: https://www.rpgmakercentral.com/topic/36290-damage-formulas-101-mv-edition/ (reposted here on RMW: https://forums.rpgmakerweb.com/index.php?threads/damage-formulas-101.81905/ )
 
Last edited:

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Nice @caethyril !
I will create another thread for the remaining piece of my approach.
 

MOSN

Villager
Member
Joined
Sep 9, 2017
Messages
12
Reaction score
1
First Language
Danish
Primarily Uses
RMMV
Thanks! I wasn't aware you could do fancy stuff like that in the damage formula, very useful. The thread seems like it'll be a lot of help too.
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
This will send you to a thread I asked for that, cause I was curious.
Now all the things on the puzzle are here for you to build what you need.


So this:

Code:
$gameVariables.setValue(40, BattleManager._action ? 1 + BattleManager._action._targetIndex : -999)
Code means:
We will set the value of Variable with id=40
If we are in battle, set the value equal to what this spell targeted,
otherwise set it to -999


inside the formula works like a charm.
I stored the value to the 40th variable.
IS this the only way to run code through battle?
I mean, can you get the current move's targetIndex using the Common Event?
The real question is, what the scope of targetIndex is. Can it be reached from the common event and what the variable would be?


Case is solved, on my behalf, but I am curious to know if you can use a script command from common event and do the same thing.

TO SUM THINGS UP:

Create the skill you need to do the debuff.
Set damage to HP. In the formula, insert this:

Code:
$gameVariables.setValue(40, BattleManager._action ? 1 + BattleManager._action._targetIndex : -999)
Make sure it is certain hit.


Now imagine that the 40th variable is named EnemyIndex.

Database >> Common Event
Create a common event named Debuff 1.

Set a variable named PROB with a random value.

Conditional Branch: If PROB is less or equal to 30
Conditional Branch: If EnemyIndex =1
Change Enemy HP: #1 -10
End


Conditional Branch: If EnemyIndex =2
Change Enemy HP: #2 -10
End


and so on...

End



(This gives a 30% chance of success. Then we check case of Index. Whoever the index belongs, will get a -10HP ddebuff on our example!)

Go back to your Skill.
Skill >> Effects: Double Click >> Other >> Common Event
Select the Common event you made.


And that's how you can set up what you need to do.
 
Last edited:

MOSN

Villager
Member
Joined
Sep 9, 2017
Messages
12
Reaction score
1
First Language
Danish
Primarily Uses
RMMV
Cool, I think I get it. But at least for now I'm probably gonna stick with the other method. Thx anyways :)
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
Is your case solved? :)
 

MOSN

Villager
Member
Joined
Sep 9, 2017
Messages
12
Reaction score
1
First Language
Danish
Primarily Uses
RMMV
I'd say so yes
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top