Save-Point
KMonsterPals VX + ACE - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: KMonsterPals VX + ACE (/thread-9400.html)



KMonsterPals VX + ACE - kyonides - 09-15-2024

KMonsterPals VX + ACE

by Kyonides

Introduction

Well, did you ever wish to let your monsters exact revenge on a hero for killing its pal? Laughing  Now you can do it! Shocked

VX Script

Code:
# * KMonsterPals VX
#   Scripter : Kyonides Arkanthes
#   2019-10-29

# This scriptlet allows monsters to (over)react after their pal's defeat.
# It will allow them to use a hidden skill in an attempt to exact revenge on
# the hero that killed their friend! They will calm down if successful.
# Note: If the revengeful monster has little mana, the script will provide it
#       enough mana to let it use it at least once. (Thank their rage for it!)

module KMonster
 PALS = {} # Do Not Touch This!
 PALS.default = {} # Do Not Touch This!
 # [TroopID] = { MonsterIndex => [MonsterPalIndex, PalSkillID], etc. }
 # NOTE: PalSkillID could also be an Array of Skill IDs, e.g. [1,2,3]
 PALS[1] = { 0 => [1, 1], 1 => [0, 1] }
end

class Game_Battler
 alias :kyon_monsterpals_gm_battler_scu :skill_can_use?
 alias :kyon_monsterpals_gm_battler_se :skill_effect
 def skill_can_use?(skill)
   result = kyon_monsterpals_gm_battler_scu(skill)
   return true if result and @revenge_skill == skill.id
   result
 end

 def skill_effect(user, skill)
   killed = @hp == 0
   result = kyon_monsterpals_gm_battler_se(user, skill)
   return if !result or @skipper or @missed or @evaded
   if self.kind == :enemy and !killed and @hp == 0
     if (ids = KMonster::PALS[@troop_id][@member_index])
       enemy = $game_troop.members[ids[0]]
       enemy.revenge_target = $game_party.members.index(user)
       sid = ids[1].is_a?(Array)? ids[rand(ids.size)] : ids[1]
       enemy.revenge_skill = sid
       cost = $data_skills[sid].sp_cost
       enemy.sp = cost if cost > enemy.sp
     end
   end
 end
end

class Game_Enemy
 attr_writer :revenge_target, :revenge_skill
 alias :kyon_monsterpals_gm_enemy_ma :make_action
 def restriction
   if @revenge_target and @revenge_skill
     @states.delete_if{|s| s.restriction == 1 }
   end
   super
 end

 def make_action
   if @revenge_target and @revenge_skill
     if $game_party.members[@revenge_target].hp == 0 or
        $data_skills[@revenge_skill].sp_cost > @sp
       @revenge_target = @revenge_skill = nil
     else
       a = self.current_action
       a.kind = 1
       a.basic = 0
       a.skill_id = @revenge_skill
       a.target_index = @revenge_target
       return
     end
   end
   kyon_monsterpals_gm_enemy_ma
 end
 def kind() :enemy end
end

class Game_Actor
 def kind() :actor end
end

VX Ace Script

Code:
# * KMonsterPals ACE
#   Scripter : Kyonides Arkanthes
#   2019-10-29

# This scriptlet allows monsters to (over)react after their pal's defeat.
# It will allow them to use a hidden skill in an attempt to exact revenge on
# the hero that killed their friend! They will calm down if successful.
# Note: If the revengeful monster has little mana, the script will provide it
#       enough mana to let it use it at least once. (Thank their rage for it!)

module KMonster
 PALS = {} # Do Not Touch This!
 PALS.default = {} # Do Not Touch This!
 # [TroopID] = { MonsterIndex => [MonsterPalIndex, PalSkillID], etc. }
 # NOTE: PalSkillID could also be an Array of Skill IDs, e.g. [1,2,3]
 PALS[1] = { 0 => [1, 1], 1 => [0, 1] }
end

class Game_BattlerBase
  alias :kyon_monsterpals_gm_battlerbase_scm :skill_conditions_met?
  def skill_conditions_met?(skill)
    result = kyon_monsterpals_gm_battlerbase_scm(skill)
    return true if result and @revenge_skill == skill.id
    result
  end
end

class Game_Battler
  alias :kyon_monsterpals_gm_battler_ed :execute_damage
  def execute_damage(user)
    killed = @hp == 0
    kyon_monsterpals_gm_battler_ed(user)
    return if user.kind == :enemy or kind != :enemy or killed or @hp > 0
    ids = KMonster::PALS[$game_troop.troop_id][@index]
    return unless ids
    enemy = $game_troop.members[ids[0]]
    enemy.revenge_target = $game_party.index_id(user.id)
    sid = ids[1].is_a?(Array)? ids[rand(ids.size)] : ids[1]
    enemy.revenge_skill = sid
    cost = $data_skills[sid].mp_cost
    enemy.mp = cost if cost > enemy.mp
  end
end

class Game_Enemy
 attr_writer :revenge_target, :revenge_skill
 alias :kyon_monsterpals_gm_enemy_ma :make_actions
 def make_actions
   if @revenge_target and @revenge_skill
     @actions.clear
     if $game_party.members[@revenge_target].hp == 0 or
        $data_skills[@revenge_skill].sp_cost > @sp
       @revenge_target = @revenge_skill = nil
     else
       @actions << action = Game_Action.new(self)
       action.set_skill(@revenge_skill)
       action.target_index = @revenge_target
       return
     end
   end
   kyon_monsterpals_gm_enemy_ma
 end
 def kind() :enemy end
end

class Game_Actor
 def kind() :actor end
end

class Game_Party
 def index_id(aid) @actors.index(aid) end
end

class Game_Troop
 attr_reader :troop_id
end

Terms & Conditions

You must include my nickname and the current website's URL in your game credits.
Free for non commercial games.
Give me a free copy of your completed game if you include at least 2 of my scripts! Laughing + Tongue sticking out