[HELP!] Can the Damage Formula check to see if the Enemy is using a certain Skill?

Thornyan64

Villager
Member
Joined
Jul 28, 2020
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hi, I was wondering if there is any way for the Damage Formula in the Skills tab to check for whether the enemy has chosen to use a certain skill or not, and if the enemy did choose a certain skill, the player would get to attack.
I'm imagining something like rock, paper, scissors, but with Skills. If the specific Actor used the "Scissors" Skill and the Damage Formula checked and saw that the enemy in question used the "Paper" skill, then only then would the Actor get to attack.
If you know any way to do this, help would be greatly appreciated!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,346
Reaction score
8,389
First Language
German
Primarily Uses
RMMV
not exactly.
you can have any javascript code executed in the damage formula, but the code and data you want to check is a bit complex.

it would be possible to have a plugin change the engine to store that data into an easier array and then use that access in the damage formula, but placing a direct check without plugin assistance is too much I think.
 

Thornyan64

Villager
Member
Joined
Jul 28, 2020
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
Oh okay. Thank you for letting me know. If I find some kind of solution I'll come back to post it.
 

estriole

Veteran
Veteran
Joined
Jun 27, 2012
Messages
1,502
Reaction score
728
First Language
indonesian
Hi, I was wondering if there is any way for the Damage Formula in the Skills tab to check for whether the enemy has chosen to use a certain skill or not, and if the enemy did choose a certain skill, the player would get to attack.
I'm imagining something like rock, paper, scissors, but with Skills. If the specific Actor used the "Scissors" Skill and the Damage Formula checked and saw that the enemy in question used the "Paper" skill, then only then would the Actor get to attack.
If you know any way to do this, help would be greatly appreciated!
I used to make something like that for Suikoden Duel battle for one of my project...
but i'm using event + force action + script call instead of using skill damage formula...
i forgot where i put that project though... but basically the concept:
1. each troop turn -> show choice -> Attack / Defend / Wild Attack...
2. generate random number 1/2/3 (for enemy chosen action) (and show 'dialog' based on it)
3. then do some force action based on the choice chosen by actor and the random number generated.
ex: Attack vs Attack -> force action actor to use "Normal Attack" (i named it 'Attack') skill to enemy that deal normal damage AND force action enemy to also use Attack skill to actor

Attack vs Defend -> force action actor to use "Defended Attack skill (same name with above though with halved damage formula) to enemy

Wild Attack vs Defend -> force actor to use "Missed Attack Skill" (named Wild Attack but always miss) then force enemy to use "Counter Attack Skill"
and so on...

i don't know does your rock paper scissor could also implement that way though...

hope this help...
 

Thornyan64

Villager
Member
Joined
Jul 28, 2020
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMMV
Although I know now I'd need a script or plugin to make a skill find out whether an enemy is using a specific Skill, I found a way around it since the Damage Formula has a way for checking whether an enemy has a certain State on them or not (it's called (a or b).isStateAffected(ID)). I made sure to have the enemy always move first and apply a invisible UsedSkill kind of State on themselves. Then when an actor used a Skill, it would check for the State that the enemy would place on itself using b.isStateAffected(36, 37, or 38 in my case).

Back to the rock paper scissors example, what I put in the Damage Formula was this:

[In Actor's Rock Skill Damage Formula]
if (b.isStateAffected(UsedPaperState)) {a.atk * 0} else if (b.isStateAffected(UsedScissorsState)) {a.atk * 4 - b.def * 2} else if (b.isStateAffected(UsedRockState)) {a.atk * 0};

You may be wondering why both the tie route and the player losing route have the actor do no damage instead of there being some punishment for when the player lost. In truth, I had to manipulate some Common Events and make plenty more invisible States in order to force the actor to use a new self-harming Skill directly after doing no damage with the last one. That self-harming Skill had to be a entirely new Skill and couldn't be implemented in the actor's Rock Skill's Damage Formula because the scope of the Skill was the enemy at all times, and so unless I made a new Skill with the scope set to be the user, either both win and loss would result in the enemy taking damage or both win and loss would result in the actor taking damage.

Thanks for all of the help on this issue! I would've tried out your script call idea, estriole, but I can't script for the life of me, so I guess I'm lucky your way translated okay into the Damage Formula with .isStateAffected() and using force action in Common Events.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,708
Reaction score
2,813
First Language
English
Primarily Uses
RMMZ
You can do this without states. In the damage formula, put

JavaScript:
b._actions.filter(action => action._item._dataId === <ID of skill this one beats>).length > 0 ? a.atk * 4 - b.def * 2 : 0

The proviso is that _actions is empty after the battler acts, so you'll have to make the actor versions of Rock/Paper/Scissors have a speed of 999 to ensure they always go first.
 

Latest Threads

Latest Posts

Latest Profile Posts

Turning a specific vibe into reality is incredibly difficult. For instance, this song is one of the ones I listen to when working on my post apocalyptic project, and getting it's "feeling" into the game has been a real challenge.

I don't just wanna regurgitate the numbers I see, I wanna actually understand the calculations I'm making so I'm probably gonna make a post later with some calculations and what I THINK they mean to get some advice and corrections.

Edit: All (Most) of these will be tested in game prior. I just wanna make sure I understand what's going on under the hood if you will.
my girlfriend calls all my little chibi art cute lol... funny considering that wasn't the original art style of the game.
100 problems in RMMZ 100 more problems take one down pass it around 101 Problems in RMMZ
Made some progress on my game, mostly mapping. Learned quite a bit in the process!.

M6eUoTT.png

Forum statistics

Threads
113,769
Messages
1,077,317
Members
147,804
Latest member
Dracul_JOSHI
Top