KMonsterPals VX + ACE
#1
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
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }




Users browsing this thread: 1 Guest(s)