How to make a skill that change a PLAYER-selected enemy's HP

kn1000a

Golden Vampire Flandre
Veteran
Joined
Dec 21, 2017
Messages
37
Reaction score
1
First Language
English
Primarily Uses
RMVXA
(to preface, I am still new-ish to RPGM in general)

One of the skill I want to make has the following actions:
- Deals an enemy the player selected with X damage, where X is the current HP amount of the player.
- In return, reduces the player's current HP to 1.

It is supposed to be a self-destruct, glass-cannon skill. However with the default skill options, I was unable to make this skill so I have to rely on common events.

So this is what I have:
1. The skill calling a common event (and does no damage by itself).


2. The common event takes current player's HP as a variable, subtract said amount from a selected enemy's HP (no knockout), then subtracts 9999 HP from the player (no knockout, so it ends up 1 HP).


The bold part is where I have a problem. How do I make it so this skill target the selected enemy in battle?

I do not want the skill to affect all enemies, but if I don't do that, my only option left is choose the position of the enemy to be affected. I want the skill to be used on any enemy determined by the players, not just the 1st or 2nd or 3rd enemy in a group.


I also want to clarify that I am trying to make the game using as little scripts as possible. If there is no other solutions, I will take a look at any script suggestions for this issue. But I would like to know if there's a built-in mechanic that let me deliver the goal of this skill in the way that I wanted.

Thank you!
 

Tiamat-86

old jrpg gamer
Veteran
Joined
Dec 5, 2017
Messages
421
Reaction score
166
First Language
english
Primarily Uses
RMMV
the damage formula would run before the event does. so just use a normal a.hp for a damage formula.

not sure if vx has all the same formula functions as mv does but in mv don't even need an event since formula could also damage the user at the same time. in mv the formula would look like
a.hp; a.setHp(1)

edit: other option for skill events is using blank placeholder states. the event would then do an "if" checking every target/user for the ones that have the state on them. makes the common event look bulky but its mainly just copy/paste
 
Last edited:

kn1000a

Golden Vampire Flandre
Veteran
Joined
Dec 21, 2017
Messages
37
Reaction score
1
First Language
English
Primarily Uses
RMVXA
the damage formula would run before the event does. so just use a normal a.hp for a damage formula.

not sure if vx has all the same formula functions as mv does but in mv don't even need an event since formula could also damage the user at the same time. in mv the formula would look like
a.hp; a.setHp(1)

edit: other option for skill events is using blank placeholder states. the event would then do an "if" checking every target/user for the ones that have the state on them. makes the common event look bulky but its mainly just copy/paste
oh wow, so simple yet I never thought of that. Thank you so much! My implementation would be to do a.hp damage and then call a common event to do tons of damage to the MC without knockout.

Yeah, I tried my best messing around in Ace but I do not see such an option for using own HP as a mean of damage. But it is what it is.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,711
Reaction score
7,365
First Language
German
Primarily Uses
RMMV
damage formula coding has been available for both VXA and MV for years, and that way was always the common way to affect both target and user. The code is just slightly different because VXA uses RGSS3 (a ruby variant) and MV uses javascript. In fact damaging the user was even easier in VXA than it is in MV because you don't need special functions in VXA, you could modify hp directly (a.hp=1).

That said, there is a mistake here:
a.hp; a.setHp(1)
The problem is that the damage is always the last number processed with the damage formula, and in that case it would be 1.

In VXA the solution would be r=a.hp;a.hp=1;r; but I don't know the code in javascript, you need to store the current HP in a temporary variable to access it after the user gets the hp reduction.
 

HumanNinjaToo

The Cheerful Pessimist
Veteran
Joined
Apr 18, 2013
Messages
1,226
Reaction score
601
First Language
English
Primarily Uses
RMMV
So if you type a.hp in the damage formula box, it does not work?

edit: nevermind, andar just answered my question
 

kn1000a

Golden Vampire Flandre
Veteran
Joined
Dec 21, 2017
Messages
37
Reaction score
1
First Language
English
Primarily Uses
RMVXA
damage formula coding has been available for both VXA and MV for years, and that way was always the common way to affect both target and user. The code is just slightly different because VXA uses RGSS3 (a ruby variant) and MV uses javascript. In fact damaging the user was even easier in VXA than it is in MV because you don't need special functions in VXA, you could modify hp directly (a.hp=1).

That said, there is a mistake here:

The problem is that the damage is always the last number processed with the damage formula, and in that case it would be 1.

In VXA the solution would be r=a.hp;a.hp=1;r; but I don't know the code in javascript, you need to store the current HP in a temporary variable to access it after the user gets the hp reduction.
Hmm, I don't think I quite wrap my head around your explanation. Are you referring to directly code the game, or just the damage formula? AFAIK I have not seen anyone uses stuff that can directly set a value of the character's HP/MP/etc to something, at least when I looked into this for VXA.

I do know you can reference variables inside the formula, but aren't those variables only pointers and won't directly modify the source value? For example, I probably can make a variable that save the amount of steps my character has walked, then call that in the formula to deal that amount of steps as damage. But I cannot set the amount of steps my character has walked to something using that variable; the variable points to the source data but can't modify the data (or at least I haven't seen such a direct method).
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
You don't need to modify the source data though, right? All you want to do is deal the user's HP in damage to the target?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,711
Reaction score
7,365
First Language
German
Primarily Uses
RMMV
just the damage formula? AFAIK I have not seen anyone uses stuff that can directly set a value of the character's HP/MP/etc to something, at least when I looked into this for VXA.
just the damage formula - and there is a very old and very big topic about that pinned here on the forum for VXA:
 

kn1000a

Golden Vampire Flandre
Veteran
Joined
Dec 21, 2017
Messages
37
Reaction score
1
First Language
English
Primarily Uses
RMVXA
You don't need to modify the source data though, right? All you want to do is deal the user's HP in damage to the target?
As state in my post above, I want the skill to deal my character’s current HP as damage while simultaneously reduce my character’s current HP to 1. The second part is where I don’t know how to put in the formula.

@Andar I took a look at that thread. Seems like there are a lot of different variables I can use in the formula (are there a full list of them, or are those it?). I did not see an example that person provided for changing the source data though. The example they gave has to do with complicated variables but ultimately only affect b character/enemy. While I want the skill to both affect b and also damage/taken a’s HP away.
 

kyonides

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
285
Reaction score
70
First Language
English
Primarily Uses
RMXP
Code:
dmg = a.hp; a.hp = 1; b.hp -= dmg; dmg
As far as I have read around here, the formula might look like this. The damage should be the final value listed there. Check out if it works for you...
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
You don't even need the b part, just

Code:
dmg = a.hp; a.hp = 1; dmg
 

kn1000a

Golden Vampire Flandre
Veteran
Joined
Dec 21, 2017
Messages
37
Reaction score
1
First Language
English
Primarily Uses
RMVXA
You don't even need the b part, just

Code:
dmg = a.hp; a.hp = 1; dmg
That actually does work! o.o

Are there documentations for what variables I can use in the formula? I didn't know you can set "dmg" to something (nor what does the "dmg" at the end of the formula means, "execute"?). The thread Andar linked showed some examples, but I would like to learn about the full potential of what I can manipulate inside the formula bar.

Thank you anyway, I learned something new today!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
When it comes to Ruby code, you can use any variable you want in the damage formula box as long as the last statement is the actual damage value you want. You can do anything that fits in the box prior to that, and if you can't fit the whole thing in the box you can add a new method to Game_Battler for your skill formula and call that method from the damage formula box instead.

dmg doesn't mean anything special or specific, it's literally just the name we gave the variable for the damage. You could have called it "banana" and it would have done exactly the same thing.

The reason "dmg" works in the end there is that it's effectively shorthand for "return dmg" but Ruby doesn't require the return keyword; it automatically returns the last value it evaluated in a method.
 

kn1000a

Golden Vampire Flandre
Veteran
Joined
Dec 21, 2017
Messages
37
Reaction score
1
First Language
English
Primarily Uses
RMVXA
When it comes to Ruby code, you can use any variable you want in the damage formula box as long as the last statement is the actual damage value you want. You can do anything that fits in the box prior to that, and if you can't fit the whole thing in the box you can add a new method to Game_Battler for your skill formula and call that method from the damage formula box instead.

dmg doesn't mean anything special or specific, it's literally just the name we gave the variable for the damage. You could have called it "banana" and it would have done exactly the same thing.

The reason "dmg" works in the end there is that it's effectively shorthand for "return dmg" but Ruby doesn't require the return keyword; it automatically returns the last value it evaluated in a method.
Oh ok, I gotcha. Basically just passing variables and returning them. I might not be a great programmer but I know enough to do little coding like that. Thank you, it was a great help and probably saved me countless hours trying to set up multiple common events for each skill :kaosigh:
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Part of me is really missin' the good 'ol days of RM '95... goodness just seems like such simpler times
Just got two Switch E-Shop 20$ gift cards... Is 3D All-Stars worth it? Or should I get something like Celeste? I'd love to know your opinion!
I’m looking at the MZ full body images and I think Priscilla is taller than Reid...
Ami
--- Music Selection ---

M.Archer: It's Music Station,You can Change the Music as you like.
F.Healer: i want to hear the Romantic Music.
M.Fighter: Then,i want the Hard-Rock one!
(the Troll Song has played)
M.Archer: Hey,i hear this Music.
F.Healer: It's popular from Internet Music,i wonder who change it?
Hero: I change it.
Entire Party: YOU????

Forum statistics

Threads
103,044
Messages
996,916
Members
134,517
Latest member
galm
Top