Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[resolved] Need a little adjustment of a script

Hi people~
I have a question , how can I adjust the following code
so that it will store the damage taken of a specified enemy's during a battle? or..else is there any other way?

Originally, this script is written to store the damage taken for an actor id.


class Game_Battler
DMG_VAR = 668
alias atk_efct_store_dmg_in_var attack_effect
def attack_effect(*args)
result = atk_efct_store_dmg_in_var(*args)
if self.is_a?(Game_Actor) and self.id == 45 #you can remove the "and self.id == 1" if you want it to store for all actors.
$game_variables[DMG_VAR] = self.damage if self.damage.is_a?(Numeric)
end
return result
end


This script is written by Gubid

Thanks for any help!
 
071813g":1ftdvf10 said:
Hi people~
I have a question , how can I adjust the following code
so that it will store the damage taken of a specified enemy's during a battle? or..else is there any other way?

Originally, this script is written to store the damage taken for an actor id.


class Game_Battler
DMG_VAR = 668
alias atk_efct_store_dmg_in_var attack_effect
def attack_effect(*args)
result = atk_efct_store_dmg_in_var(*args)
if self.is_a?(Game_Actor) and self.id == 45 #you can remove the "and self.id == 1" if you want it to store for all actors.
$game_variables[DMG_VAR] = self.damage if self.damage.is_a?(Numeric)
end
return result
end


This script is written by Gubid

Thanks for any help!

Code:
class Game_Battler

  DMG_VAR = 668

  alias atk_efct_store_dmg_in_var attack_effect

  def attack_effect(*args)

    result = atk_efct_store_dmg_in_var(*args)

    if self.is_a?(Game_Enemy) and self.enemy_id == 45  #you can remove the "and self.id == 1" if you want it to store for all actors.

      $game_variables[DMG_VAR] = self.damage if self.damage.is_a?(Numeric)

    end

    return result

  end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top