The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on May 08, 2010, 02:33:07 PM

Title: Enemy Summon Skill
Post by: modern algebra on May 08, 2010, 02:33:07 PM
Enemy Summon Skill
Version: 1.0
Author: modern algebra
Date: May 8, 2010

Version History



Description


This script allows you to make skills for enemies where they can summon or call additional enemies to the battlefield. This is NOT a summon skill that can be used by actors - it can ONLY be used by enemies.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg293.imageshack.us%2Fimg293%2F8268%2Fessscreen.png&hash=9d0ab923dad4f4c8445f58ce8514ff3311ecb4c8)

Instructions

Please see the header for instructions on how to use.

Script


Code: [Select]
#==============================================================================
#    Enemy Summon Skill
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: May 8, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to make skills for enemies where they can summon or
#   call additional enemies to the battlefield. This is NOT a summon skill that
#   can be used by actors - it can ONLY be used by enemies.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials in its own slot in the
#   Script Editor (F11).
#
#    You can set up some basic configuration options at line 52. Please see the
#   surrounding comments to see what each does.
#
#    To create a summoning skill (again, this skill can ONLY be used by
#   enemies), all you need to do is put the following code (can be changed at
#   line 69 if you desire):
#
#      \SUMMON_ENEMY[enemy_id, x, y, chance]
#        enemy_id : the ID of the enemy it can summon
#        x : the additional pixels along the axis the summoned creature is from
#          its summoner. If omitted, it defaults to the value at line 64.
#        y : the additional pixels along the axis the summoned creature is from
#          its summoner. If omitted, it defaults to the value at line 67.
#        chance: of the potential candidates for summoning, how likely this one
#          will be chosen over the others. If omitted, this defaults to 1.
#
#    As you can probably tell, you can place a number of these codes in the
#   same notebox and thus you can make the same skill potentially summon
#   different enemies, and you can control that through the chance.
#
#  EXAMPLES:
#
#    A skill with its notebox set up like this:
#      \summon_enemy[1, 35, 45, 3]
#      \summon_enemy[2, 25, 35, 1]
#
#  Would, when it succeeds (which is governed directly by the hit ratio of the
# skill) summon the enemy with ID 1 (Default: Slime) 75% of the time and the
# enemy with ID 2 (Default: Bat) 25% of the time, and the position, if it is
# a slime would be 35 pixels to the right of the summoner and 45 pixels down,
# or if it is the bat, then 25 pixels to the right of the summoner and 35
# pixels down. The chances are 75-25 because 3 + 1 = 4, which means that 3/4
# times the slime will be summoned and 1/4 times the bat will be summoned.
#==============================================================================
#  CONFIGURATION
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - MAES_VOCAB_SUMMON_FAILURE; MAES_MAX_TROOP_SIZE;
#      MAES_DEFAULT_X_PLUS; MAES_DEFAULT_Y_PLUS; MAES_NOTECODE
#==============================================================================
# Message shown when a summon skill fails.
MAES_VOCAB_SUMMON_FAILURE = "%s failed to summon ally!"
# The maximum number of enemies in a troop (caps number of summons permitted)
MAES_MAX_TROOP_SIZE = 8
# The default x offset for a summoned enemy from its summoner. If you manually
#  set this in the note box, this value will not be used.
MAES_DEFAULT_X_PLUS = 35
# The default y offset for a summoned enemy from its summoner. If you manually
#  set this in the note box, this value will not be used.
MAES_DEFAULT_Y_PLUS = 25
# This is the label code you need to put into a notebox. It is RegExp
MAES_NOTECODE = "\\SUMMON_ENEMY"

#==============================================================================
#  ** RPG::Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new methods - ma_call_ally?; ma_call_ally
#==============================================================================

class RPG::Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Ally Skill?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_call_ally?
    return self.note[/#{MAES_NOTECODE}\[\d+.*?\]/i] != nil
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Ally Stats
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_call_ally
    miss = rand (100)
    return nil if self.hit < miss
    possibilities = []
    note = self.note.dup
    note.gsub! (/#{MAES_NOTECODE}\[(\d+)[,;]?\s*(-?\d*)[,;]?\s*(-?\d*)[,;]?\s*(\d*)\]/i) { |match|
      id = $1.to_i
      x = $2.empty? ? MAES_DEFAULT_X_PLUS : $2.to_i
      y = $3.empty? ? MAES_DEFAULT_Y_PLUS : $3.to_i
      percent = $4.empty? ? 1 : $4.to_i
      (percent).times do possibilities.push ([id, x, y]) end
      ""
    }
    return *possibilities[rand(possibilities.size)]
  end
end

#==============================================================================
# ** Game Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    attr_accessor - summon_count
#    aliased method - initialize, skill_can_use?
#==============================================================================

class Game_Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :ma_summon_count
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias moda_clally_intz_7uj2 initialize
  def initialize (*args)
    @ma_summon_count = 0
    moda_clally_intz_7uj2 (*args) # Run Original Method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Can Use?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias moral_caly_skllcnuse_6yh1 skill_can_use?
  def skill_can_use? (skill, *args)
    return false if skill.ma_call_ally? && $game_troop.members.size >= MAES_MAX_TROOP_SIZE
    return moral_caly_skllcnuse_6yh1 (skill, *args)
  end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - skill_can_use?
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Can Use?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modbr_ess_skcnuse_7uj2 skill_can_use?
  def skill_can_use? (skill, *args)
    return false if skill.ma_call_ally?
    return modbr_ess_skcnuse_7uj2 (skill, *args)
  end
end

#==============================================================================
# ** Game Troop
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - ma_call_ally
#==============================================================================

class Game_Troop
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Ally
  #    user     : the enemy using the skill
  #    enemy_id : the ID of the enemy being summoned
  #    x, y     : screen coordinates to display enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_call_ally (user, enemy_id, x, y)
    user.ma_summon_count += 1
    enemy = Game_Enemy.new (@enemies.size, enemy_id)
    good_position = false
    while !good_position
      enemy.screen_x = user.screen_x + (x*user.ma_summon_count)
      enemy.screen_y = user.screen_y + (y*user.ma_summon_count)
      good_position = true
      @enemies.each { |baddie|
        if baddie.screen_x == enemy.screen_x && baddie.screen_y == enemy.screen_y
          user.ma_summon_count += 1
          good_position = false
        end
      }
    end
    @enemies.push(enemy)
    make_unique_names
    return enemy
  end
end

#==============================================================================
# ** Spriteset_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - ma_call_enemy
#==============================================================================

class Spriteset_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Call Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_call_enemy (battler)
    @enemy_sprites.push(Sprite_Battler.new(@viewport1, battler))
  end
end

#==============================================================================
# ** Scene_Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - execute_action_skill
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Execute Action Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malb_callally_exactsk_5hy1 execute_action_skill
  def execute_action_skill (*args)
    skill = @active_battler.action.skill
    if skill.ma_call_ally?
      enemy_id, x, y = skill.ma_call_ally
      if enemy_id.nil?
        text = sprintf (MAES_VOCAB_SUMMON_FAILURE, @active_battler.name)
        @message_window.add_instant_text(text)
        wait (30)
        return
      else
        target = $game_troop.ma_call_ally (@active_battler, enemy_id, x, y)
        @spriteset.ma_call_enemy (target)
        display_animation([target], skill.animation_id)
      end
    end
    malb_callally_exactsk_5hy1 (*args) # Run Original Method
  end
end

Credit



Thanks


Support


Please post in this topic at RMRK for support.

Known Compatibility Issues

No currently known incompatibility issues, but I suspect it will be incompatible with most custom battle scenes that deviate significantly from the default.

Demo


Please see attached demo (http://rmrk.net/index.php?action=dlattach;topic=38504.0;attach=20296).

Author's Notes


Just playing Skies of Arcadia, and liked this ability that some enemies would have. Also, I realize that this effect can be done with events, but I figure it is a lot easier to do with a script and can be a little more random as well, which is a good thing.
Title: Re: Enemy Summon Skill
Post by: Zylos on May 08, 2010, 03:41:05 PM
Uh oh, monster breeding. o_o *flees*
Title: Re: Enemy Summon Skill
Post by: Cascading Dragon on May 08, 2010, 04:06:29 PM
Just wondering, but if I edited this script to make it compatible with Yanfly's Melody Battle System, should I send you the edit for you to post on here?
Title: Re: Enemy Summon Skill
Post by: Zero2008 on May 08, 2010, 04:56:54 PM
OMG Modern this looks PERFECT!
This will go perfectly with my EarthBound game! Thanks!
Title: Re: Enemy Summon Skill
Post by: modern algebra on May 09, 2010, 09:51:52 PM
Just wondering, but if I edited this script to make it compatible with Yanfly's Melody Battle System, should I send you the edit for you to post on here?

No, you don't need to. I would appreciate if you posted it in this thread so that other people could find it, but no, you can do with it as you like.
Title: Re: Enemy Summon Skill
Post by: LuKo on May 09, 2010, 10:11:57 PM
great Algebra, another cool and uncommon script^^

This give an really coll addiction to the battle.

Nice job^^
Title: Re: Enemy Summon Skill
Post by: cozziekuns on May 09, 2010, 10:49:27 PM
This script looks awesome, though I thought the script could allow you to change the hue of the monster summoned -.-

It's still cool.
Title: Re: Enemy Summon Skill
Post by: Grafikal on May 09, 2010, 11:15:43 PM
You could always summon the same monsters with a different hue. The only difference is that you'd have to make it a separate enemy in the database instead of coping an existing one and changing the color via the script.
Title: Re: Enemy Summon Skill
Post by: cozziekuns on May 09, 2010, 11:30:16 PM
That would work, but it'd clog up some monster space. Oh well, the give us 1000 spaces, so I guess making hue recolours wouldn't hurt.


Title: Re: Enemy Summon Skill
Post by: Grafikal on May 09, 2010, 11:34:47 PM
That would work, but it'd clog up some monster space. Oh well, the give us 1000 spaces, so I guess making hue recolours wouldn't hurt.

lol. I generally make hue adjustments to enemies for new monsters. So instead of having 100 different monsters, it's much easier to have only 50, then having 50 recolors of them all representing a 'more powerful' version of the one before it - or something similar.
Title: Re: Enemy Summon Skill
Post by: thanatos2k1 on June 24, 2011, 11:28:16 PM
Ok, so this looks like its nearly what I need, especially what I saw with the slimes..  Now, what I want to do is if an actor uses slash or pierce weapons to a slime it splits and the hp of the original is halfed with the new one.

So, if Slime A has 62 HP and an actor hits it:

"The slime has split in half, spawning a new slime!"
 
Now there is 2 slimes, A + B and they both have 31HP.

Can this be done with this script?
Title: Re: Enemy Summon Skill
Post by: Mr G W on July 09, 2011, 07:29:06 PM
theres a small issue, if the summoner keeps summoning new monsters they eventually start appearing offscreen, even if you kill the older ones.
Title: Re: Enemy Summon Skill
Post by: bdcam on January 29, 2012, 09:45:24 PM
Can this be used with ABS 9?
Title: Re: Enemy Summon Skill
Post by: DoctorTodd on January 29, 2012, 09:52:45 PM
I know your new so you should probably read the rules first because that was a pretty big necropost. Any way I positive it won't unless you basically rewrote it.
Known Compatibility Issues
No currently known incompatibility issues, but I suspect it will be incompatible with most custom battle scenes that deviate significantly from the default.


Title: Re: Enemy Summon Skill
Post by: modern algebra on January 30, 2012, 02:26:40 AM
It's actually OK to necro resource topics when it's on topic, but DoctorTodd is right that it won't work with any ABS. Depending on the nature of the ABS though, I would suspect that it would be possible to do something similar through eventing.
Title: Re: Enemy Summon Skill
Post by: pacdiggity on January 30, 2012, 02:56:24 AM
Hey MA, would it be cool with you if I ported this to VXA? It seems like a pretty easy port, I'm bored, and it's a cool script.
I know that you're gradually converting some of your scripts, but I thought you could use a hand in the process :D
Title: Re: Enemy Summon Skill
Post by: modern algebra on January 30, 2012, 03:21:47 AM
Sure, go right ahead!
Title: Re: Enemy Summon Skill
Post by: Darkrai1276 on March 31, 2012, 10:51:16 AM
very nice, coud defently get some use out of this, very good for enemy's that can multiply and is excellent move for my fina boss
i give it a 9/10= perfect
(https://s3.amazonaws.com/TrollEmoticons/chuckthumbsup.jpeg)