Identifying an enemy has been killed

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
I need a script call which can identify if the enemy attacked has died or not.
The same sort of structure as
if b.result.critical;
but in this instance testing if the result is death - either a straightforward identification or perhaps using something like b.hp = 0
I've tried various combinations, but nothing works.

Thanks.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
I need a script call which can identify if the enemy attacked has died or not.
My first question would be where you want this script call is called? Damage formula?

like b.hp = 0
If you write literally by using "=", then it's false. It should be double equals "=="
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@TheoAllen Yes, for use in the damage formula. So it would be something along the lines of

if b.result[whatever it is to indicate the enemy has been killed by this skill]; [some actor buff or other]; end; damage formula
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
@Kes I fail to understand why you want to check if target is dead, when the damage formula is not even executed yet. The logic is, it won't be dead if it didn't get the damage. Ofc it won't work, bcz the damage formula is just to determine the value of damage, and the time the formula is evaluated, it doesn't immediately executed. Here is the illustration:

Screenshot_164.jpg

You can use "b.result.critical" because checking if it's land critical is checked before the formula is evaluated. But checking if it's dead, upon the damage formula evaluation, it isn't yet delivered. It couldn't check if it's dead bcz ofc it isn't dead yet.

Or, is it a skill that targets dead ally/enemy?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@TheoAllen The skill does not target dead enemies.
What I am trying to do is to give the specific actor who kills an enemy with this particular skill a TP boost. Can you suggest an alternative way of going about this?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I did this in my project by making a check after the damage is done (after the execute_damage call), if the target is killed ( hp <= 0), it runs the code specified by a notetag in the skill (and other game objects).. So basically I modified the item_apply method to do it

something like

Code:
execute_damage(user)
#Add the check after the execute_damage
kill_effect(user,item) if self.hp <= 0
with the kill_effect method basically checking the actor, classes, equipment and states for the presence of a notetag that I've set to determine what things to do upon killing a target

But ofc its a bit hazardous since I directly modified the script, but in my case its fine because all battle related stuff in my game was made by me anyway.. You can also opt to just alias item_apply and check if the target dies after calling the aliased method.

Also take note that this of course is for a general purpose "on kill" effect which can generate any effect that you might want

Alternatively, you can always just check the current HP of the target in your formula and if its less than the damage, do the effects that you want. It would ofc happen before the actual damage though

Code:
x=damage_formula;if x >= b.hp; then; a.tp += value;end;return x
But depending on your added systems, it might not be foolproof to check beforehand (like if you have an auto revive system or killing blow blocking abilities etx)
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
@Kes Go try to edit item_user_effect in Game_Battler line 713 (although this one actually deserve their own thread)
Code:
class Game_Battler
  def item_user_effect(user, item)
    user.tp += item.tp_gain * user.tcr
  end
end
The default is like this. Use these to address the user / target
  • user = the user of the skill / item
  • self = the target of the skill / item
Different formula will yield a different result. For example this will boost TP by 10 if target is dead
Code:
class Game_Battler
  def item_user_effect(user, item)
    user.tp += item.tp_gain * user.tcr # <-- default formula
    user.tp += 10 if self.dead?
  end
end
This one will buff TP gain by +50%
Code:
class Game_Battler
  def item_user_effect(user, item)
    user.tp += item.tp_gain * user.tcr * (self.dead? ? 1.5 : 1.0)
  end
end
If you want it only valid for actor, use this
Code:
class Game_Battler
  def item_user_effect(user, item)
    user.tp += item.tp_gain * user.tcr # <-- default formula
    user.tp += 10 if user.actor? && self.dead?
  end
end
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
@TheoAllen You're right, this had got too big for script calls, so I've moved all the posts into their own thread.

I can understand (I think) what the edits you have suggested will cause to happen, and I think that the way they are written will mean that no matter how the enemy is killed, the user will get the TP bonus. However, I want this tied to a particular skill so that it happens then and only then.

Would this mean doing this in a custom damage formula snippet? And if so, where the the actual damage part of the formula go?

Sorry to be so dense on this, I just can't get it straight in my head.

@Engr. Adiktuzmiko Thanks for the suggestion. I'm a bit reluctant to go down that route, as I have all sorts of things which modify battles and it looks to me from your description that I could end up with clashes.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,599
Reaction score
6,552
First Language
Indonesian
Primarily Uses
RMVXA
@Kes yea I forgot that you want it specifically for a certain skill since you originally want it to be in damage formula. In that case, you can check the item by using the keyword "item". For example:
Code:
class Game_Battler
  def item_user_effect(user, item)
   user.tp += item.tp_gain * user.tcr # <-- default formula
   user.tp += 10 if item.is_a?(RPG::Skill) && item.id == <replace with skill ID> && self.dead?
  end
end
Edit:
And if so, where the the actual damage part of the formula go?
Does this tutorial answer your question? https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-vxace-and-mv-damage-flow.4219/
 
  • Like
Reactions: Kes

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Could this not be done using a common event (which gets executed after all the damage), using the user and target that are still stored in the internal variables (which I can never remember)?
 

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,038
Messages
1,018,467
Members
137,821
Latest member
Capterson
Top