[XP/VX] Summoning

This event system will demonstrate how to create a summoning skill that can be used by a party member. There are many things that can be done to make this skill unique. This will provide you with a basic setup which can then be altered to fit your needs.

Features
-Summon and dismiss characters
-Only one character can be summoned at a time
-Complete recovery upon dismissal
-Dismissal after battle (add-on)
-Prevention of summoning when there are already four party members (script)

Characters
Before you go any further, you need to create the characters that you wish to summon. You can, for now, just make the characters, or you could set up their class, stats, etc. now and then continue.

Skills
These are the skills that you will need to create before you start making the common events. I'll only include the information that you need to add for now. I'm going to include two possible characters to summon in this example.

Summon Character 1
Scope: None
Occasion: Always

Summon Character 2
Scope: None
Occasion: Always

Dismiss
Scope: None
Occasion: Always

Common Events
Now, it's time to set up the common events that you'll need.

Summon Character 1
Trigger: None
  1. @>Change Party Member: Add [Character 1]
  2. @>Change Skills: [Summoner], + [Dismiss]
  3. @>Change Skills: [Summoner], - [Summon Character 1]
  4. @>Change Skills: [Summoner], - [Summon Character 2]
Expand to see the code.


Summon Character 2
Trigger: None
  1. @>Change Party Member: Add [Character 2]
  2. @>Change Skills: [Summoner], + [Dismiss]
  3. @>Change Skills: [Summoner], - [Summon Character 1]
  4. @>Change Skills: [Summoner], - [Summon Character 2]
Expand to see the code.


In these events, you add the character to the party (summon them), then add the "Dismiss" skill and remove all "Summon Character" skills.

Dismiss
Trigger: None
  1. @>Conditional Branch: [Character 1] is in the party
  2.    @>Recover All: [Character 1]
  3.    @>Change Party Member: Remove [Character 1]
  4.  :  Branch End
  5. @>Conditional Branch: [Character 2] is in the party
  6.    @>Recover All: [Character 2]
  7.    @>Change Party Member: Remove [Character 2]
  8.  :  Branch End
  9. @>Control Variables: [0001: Summoner's Level] = [Summoner]'s Level
  10. @>Change Skills: [Summoner], + [Summon Character 1]
  11. @>Conditional Branch: Variable [0001: Summoner's Level] >= 3
  12.    @>Change Skills: [Summoner], + [Summon Character 2]
  13.  :  Branch End
  14. @>Change Skills: [Summoner], - [Dismiss]
Expand to see the code.


That's a lot to take in all at once, so I'll explain it in pieces. The first two conditional branches check which character is in the party (which one was summoned), and, based on those results, it heals the appropriate character and removes them from the party. Next, I created a variable to keep track of the summoner's level. This isn't used for "Summon Character 1" because the summoner knew that skill at level 1, but "Summon Character 2" is learned at level 3. So, I created a conditional branch that checks the summoner's level. If the summoner's level is greater than or equal to level 3, "Summon Character 2" is added to the summoner's skills. Finally, I removed the "Dismiss" skill.

Dismiss Check
Trigger: Parallel
Switch: 0001: Start
  1. @>Conditional Branch: [Summoner] is [Dismiss] learned
  2.    @>Conditional Branch: [Summoner] is [Summon Character 2] learned
  3.        @>Change Skills: [Summoner], - [Summon Character 2]
  4.     :  Branch End
  5.  :  Branch End
Expand to see the code.


This common event is needed because when a character achieves the required level, the skill is added to their list. So, this parallel common event that starts as soon as possible (with a switch that's turned on at the start of the game) resolves a small problem. If a character is summoned and the summoner learns a new summoning skill, they'll have both the "Dismiss" skill and the new summoning skill. That means they'll be able to have more than one summoned character in the party. This common event checks if the summoner has "Dismiss" and then, if that's true, it checks for extra summoning skills and removes them.

Skills
Summon Character 1
Common Event: 001: Summon Character 1

Summon Character 2
Common Event: 002: Summon Character 2

Dismiss
Common Event: 003: Dismiss

You just need to attach the common events to the corresponding skills. Now, fill out the rest of the information in the skills if you wish and attach the skills to the summoner's class. That's it!


Dismissal After Battle
If you want the summoned characters to be dismissed after battle, you just need to make a few adjustments, which will be explained below.

Skills
Summon Character 1
Occasion: Only in Battle

Summon Character 2
Occasion: Only in Battle

Dismiss
Occasion: Only in Battle

You'll need to change all of the summoning skills so the player can only use them in battle. If the player can summon outside of battle, there's no point in dismissing the summoned character after battle in the first place, so make sure you include these changes.

Common Events
Dismiss Check
  1. @>Conditional Branch: [Summoner] is [Dismiss] learned
  2.    @>Conditional Branch: [Character 1] is in the party
  3.       @>Recover All: [Character 1]
  4.       @>Change Party Member: Remove [Character 1]
  5.     :  Branch End
  6.    @>Conditional Branch: [Character 2] is in the party
  7.       @>Recover All: [Character 2]
  8.       @>Change Party Member: Remove [Character 2]
  9.     :  Branch End
  10.    @>Control Variables: [0001: Summoner's Level] = [Summoner]'s Level
  11.    @>Change Skills: [Summoner], + [Summon Character 1]
  12.    @>Conditional Branch: Variable [0001: Summoner's Level] >= 3
  13.       @>Change Skills: [Summoner], + [Summon Character 2]
  14.     :  Branch End
  15.    @>Change Skills: [Summoner], - [Dismiss]
  16.  :  Branch End
Expand to see the code.


It looks like a lot, but it's really just the Dismiss common event pasted below the conditional branch that checks whether or not the character knows "Dismiss". The conditional branch that checked for the "Summon Character 2" skill after checking for "Dismiss" is no longer necessary, so it can be deleted and replaced by the entire "Dismiss" common event.


Scripts
RPG Maker XP
Battler Error
If you're using RPG Maker XP, you'll need to use the following script. This script fixes an error where a character's battler won't appear if the character is removed and then added to the party again.
  1. #----------------------------------------------------------------------------
  2. # [XP] Battler Fix
  3. #----------------------------------------------------------------------------
  4. # Made by khmp
  5. #----------------------------------------------------------------------------
  6. # This script fixes an error where a character's battler won't appear if
  7. # the character is removed and then added to the party again.
  8. #----------------------------------------------------------------------------
  9. # Instructions: Paste in a new slot above "Main" and below "Scene_Debug".
  10. #----------------------------------------------------------------------------
  11.  
  12. class Sprite_Battler < RPG::Sprite
  13.   #--------------------------------------------------------------------------
  14.   # * Frame Update
  15.   #--------------------------------------------------------------------------
  16.   def update
  17.     super
  18.     # If battler is nil
  19.     if @battler == nil
  20.       #
  21.       # I only added this one line
  22.       #
  23.       @battler_name = nil
  24.       #
  25.       #
  26.       #
  27.       self.bitmap = nil
  28.       loop_animation(nil)
  29.       return
  30.     end
  31.    
  32.     # If file name or hue are different than current ones
  33.     if @battler.battler_name != @battler_name or
  34.        @battler.battler_hue != @battler_hue
  35.       # Get and set bitmap
  36.       @battler_name = @battler.battler_name
  37.       @battler_hue = @battler.battler_hue
  38.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  39.       @width = bitmap.width
  40.       @height = bitmap.height
  41.       self.ox = @width / 2
  42.       self.oy = @height
  43.       # Change opacity level to 0 when dead or hidden
  44.       if @battler.dead? or @battler.hidden
  45.         self.opacity = 0
  46.       end
  47.     end
  48.     # If animation ID is different than current one
  49.     if @battler.damage == nil and
  50.        @battler.state_animation_id != @state_animation_id
  51.       @state_animation_id = @battler.state_animation_id
  52.       loop_animation($data_animations[@state_animation_id])
  53.     end
  54.     # If actor which should be displayed
  55.     if @battler.is_a?(Game_Actor) and @battler_visible
  56.       # Bring opacity level down a bit when not in main phase
  57.       if $game_temp.battle_main_phase
  58.         self.opacity += 3 if self.opacity < 255
  59.       else
  60.         self.opacity -= 3 if self.opacity > 207
  61.       end
  62.     end
  63.     # Blink
  64.     if @battler.blink
  65.       blink_on
  66.     else
  67.       blink_off
  68.     end
  69.     # If invisible
  70.     unless @battler_visible
  71.       # Appear
  72.       if not @battler.hidden and not @battler.dead? and
  73.          (@battler.damage == nil or @battler.damage_pop)
  74.         appear
  75.         @battler_visible = true
  76.       end
  77.     end
  78.     # If visible
  79.     if @battler_visible
  80.       # Escape
  81.       if @battler.hidden
  82.         $game_system.se_play($data_system.escape_se)
  83.         escape
  84.         @battler_visible = false
  85.       end
  86.       # White flash
  87.       if @battler.white_flash
  88.         whiten
  89.         @battler.white_flash = false
  90.       end
  91.       # Animation
  92.       if @battler.animation_id != 0
  93.         animation = $data_animations[@battler.animation_id]
  94.         animation(animation, @battler.animation_hit)
  95.         @battler.animation_id = 0
  96.       end
  97.       # Damage
  98.       if @battler.damage_pop
  99.         damage(@battler.damage, @battler.critical)
  100.         @battler.damage = nil
  101.         @battler.critical = false
  102.         @battler.damage_pop = false
  103.       end
  104.       # Collapse
  105.       if @battler.damage == nil and @battler.dead?
  106.         if @battler.is_a?(Game_Enemy)
  107.           $game_system.se_play($data_system.enemy_collapse_se)
  108.         else
  109.           $game_system.se_play($data_system.actor_collapse_se)
  110.         end
  111.         collapse
  112.         @battler_visible = false
  113.       end
  114.     end
  115.     # Set sprite coordinates
  116.     self.x = @battler.screen_x
  117.     self.y = @battler.screen_y
  118.     self.z = @battler.screen_z
  119.   end
  120. end
Expand to see the code.


Inhibit Party Overload
This script will allow you to set which skills are summoning skills so they can't be used when there are already four party members. Instructions for setting it up are inside the script.
  1. #----------------------------------------------------------------------------
  2. # [XP] Inhibit Party Overload
  3. #----------------------------------------------------------------------------
  4. # Made by Guardian(1239)
  5. #----------------------------------------------------------------------------
  6. # This script prevents a skill or skills from being used when there
  7. # are already four party members.  This was made to be used with my
  8. # summoning event system, but it can be used elsewhere.
  9. #----------------------------------------------------------------------------
  10. # Instructions: Paste in a new slot above "Main" and below all other
  11. # custom scripts.  Edit the values for "Skills" to match the ID(s)
  12. # of the skill(s) you wish to follow the restriction of the script
  13. # (can't be used when there are four party members).
  14. #----------------------------------------------------------------------------
  15. # Copyright: You may use this script freely.  You may distribute
  16. # this script as long as credit is given to Guardian(1239).  You
  17. # may edit this script as you wish.  You may distribute an edit of
  18. # this script as long as credit for the original is given to
  19. # Guardian(1239).
  20. #----------------------------------------------------------------------------
  21.  
  22. module PARTY_OVERLOAD
  23.   # Edit these values to match the ID(s) of the skill(s) you wish
  24.   # to follow the restriction of the script (can't be used when
  25.   # there are four party members).
  26.   Skills = [1,2]
  27. end
  28.  
  29. class Game_Battler
  30.   include PARTY_OVERLOAD
  31.   #--------------------------------------------------------------------------
  32.   # * Determine Usable Skills
  33.   #     skill_id : skill ID
  34.   #--------------------------------------------------------------------------
  35.   alias overload_skill_can_use? skill_can_use?
  36.   def skill_can_use?(skill_id)
  37.     # If there are 4 party members, the summoning skills can't be used.
  38.     if ($game_party.actors.size == 4 and Skills.include?(skill_id))
  39.       return false
  40.     end
  41.    
  42.     overload_skill_can_use?(skill_id)
  43.  
  44.   end
  45. end
Expand to see the code.


RPG Maker VX
Variable Error
If you're using RPG Maker VX, you'll need to use the following script. This script fixes the problems with the default variable operation scripts.
  1. #----------------------------------------------------------------------------
  2. # [VX] Variable Fix
  3. #----------------------------------------------------------------------------
  4. # Made by Yeyinde
  5. #----------------------------------------------------------------------------
  6. # This script fixes the problems with the default variable operation
  7. # scripts.
  8. #----------------------------------------------------------------------------
  9. # Paste in a new slot under "Materials".
  10. #----------------------------------------------------------------------------
  11.  
  12. class Game_Interpreter
  13.   def command_122
  14.     value = 0
  15.     case @params[3]  # Operand
  16.     when 0  # Constant
  17.       value = @params[4]
  18.     when 1  # Variable
  19.       value = $game_variables[@params[4]]
  20.     when 2  # Random
  21.       value = @params[4] + rand(@params[5] - @params[4] + 1)
  22.     when 3  # Item
  23.       value = $game_party.item_number($data_items[@params[4]])
  24.     when 4  # Actor
  25.       actor = $game_actors[@params[4]]
  26.       if actor != nil
  27.         case @params[5]
  28.         when 0  # Level
  29.           value = actor.level
  30.         when 1  # Experience
  31.           value = actor.exp
  32.         when 2  # HP
  33.           value = actor.hp
  34.         when 3  # MP
  35.           value = actor.mp
  36.         when 4  # Maximum HP
  37.           value = actor.maxhp
  38.         when 5  # Maximum MP
  39.           value = actor.maxmp
  40.         when 6  # Attack
  41.           value = actor.atk
  42.         when 7  # Defense
  43.           value = actor.def
  44.         when 8  # Spirit
  45.           value = actor.spi
  46.         when 9  # Agility
  47.           value = actor.agi
  48.         end
  49.       end
  50.     when 5  # Enemy
  51.       enemy = $game_troop.members[@params[4]]
  52.       if enemy != nil
  53.         case @params[5]
  54.         when 0  # HP
  55.           value = enemy.hp
  56.         when 1  # MP
  57.           value = enemy.mp
  58.         when 2  # Maximum HP
  59.           value = enemy.maxhp
  60.         when 3  # Maximum MP
  61.           value = enemy.maxmp
  62.         when 4  # Attack
  63.           value = enemy.atk
  64.         when 5  # Defense
  65.           value = enemy.def
  66.         when 6  # Spirit
  67.           value = enemy.spi
  68.         when 7  # Agility
  69.           value = enemy.agi
  70.         end
  71.       end
  72.     when 6  # Character
  73.       character = get_character(@params[4])
  74.       if character != nil
  75.         case @params[5]
  76.         when 0  # x-coordinate
  77.           value = character.x
  78.         when 1  # y-coordinate
  79.           value = character.y
  80.         when 2  # direction
  81.           value = character.direction
  82.         when 3  # screen x-coordinate
  83.           value = character.screen_x
  84.         when 4  # screen y-coordinate
  85.           value = character.screen_y
  86.         end
  87.       end
  88.     when 7  # Other
  89.       case @params[4]
  90.       when 0  # map ID
  91.         value = $game_map.map_id
  92.       when 1  # number of party members
  93.         value = $game_party.members.size
  94.       when 2  # gold
  95.         value = $game_party.gold
  96.       when 3  # steps
  97.         value = $game_party.steps
  98.       when 4  # play time
  99.         value = Graphics.frame_count / Graphics.frame_rate
  100.       when 5  # timer
  101.         value = $game_system.timer / Graphics.frame_rate
  102.       when 6  # save count
  103.         value = $game_system.save_count
  104.       end
  105.     end
  106.     for i in @params[0] .. @params[1]   # Batch control
  107.       case @params[2]  # Operation
  108.       when 0  # Set
  109.         $game_variables = value
  110.       when 1  # Add
  111.         $game_variables[i] += value
  112.       when 2  # Sub
  113.         $game_variables[i] -= value
  114.       when 3  # Mul
  115.         $game_variables[i] *= value
  116.       when 4  # Div
  117.         $game_variables[i] /= value if value != 0
  118.       when 5  # Mod
  119.         $game_variables[i] %= value if value != 0
  120.       end
  121.       if $game_variables[i] > 99999999    # Maximum limit check
  122.         $game_variables[i] = 99999999
  123.       end
  124.       if $game_variables[i] < -99999999   # Minimum limit check
  125.         $game_variables[i] = -99999999
  126.       end
  127.     end
  128.     $game_map.need_refresh = true
  129.     return true
  130.   end
  131. end
  132.  
Expand to see the code.


[i]Inhibit Party Overload

This script will allow you to set which skills are summoning skills so they can't be used when there are already four party members. Instructions for setting it up are inside the script.
  1. #------------------------------------------------------------------
  2. # [VX] Inhibit Party Overload
  3. #------------------------------------------------------------------
  4. # Made by Guardian(1239)
  5. #------------------------------------------------------------------
  6. # This script prevents a skill or skills from being used when there
  7. # are already four party members.  This was made to be used with my
  8. # summoning event system, but it can be used elsewhere.
  9. #------------------------------------------------------------------
  10. # Instructions: Paste in a new slot under "Materials" and below all
  11. # other custom scripts.  Edit the values for "Skills" to match the
  12. # ID(s) of the skill(s) you wish to follow the restriction of the
  13. # script (can't be used when there are four party members).
  14. #------------------------------------------------------------------
  15. # Copyright: You may use this script freely.  You may distribute
  16. # this script as long as credit is given to Guardian(1239).  You
  17. # may edit this script as you wish.  You may distribute an edit of
  18. # this script as long as credit for the original is given to
  19. # Guardian(1239).
  20. #------------------------------------------------------------------
  21.  
  22. module PARTY_OVERLOAD
  23.   # Edit these values to match the ID(s) of the skill(s) you wish
  24.   # to follow the restriction of the script (can't be used when
  25.   # there are four party members).
  26.   Skills = [1,2]
  27. end
  28.  
  29. class Game_Battler
  30.   include PARTY_OVERLOAD
  31.   #--------------------------------------------------------------------------
  32.   # * Determine Usable Skills
  33.   #     skill : skill
  34.   #--------------------------------------------------------------------------
  35.   alias overload_skill_can_use? skill_can_use?
  36.   def skill_can_use?(skill)
  37.     # If there are 4 party members, the summoning skills can't be used.
  38.     if ($game_party.members.size == 4 and Skills.include?(skill.id))
  39.       return false
  40.     end
  41.  
  42.     overload_skill_can_use?(skill)
  43.  
  44.   end
  45. end
Expand to see the code.



Demos
The first two demos contain the base structure for summoning, and the second two demos contain the Dismissal After Battle add-on. All of them are hosted by Mediafire.

Summoning Base (XP)
Summoning Base (VX)
Summoning Dismissal (XP)
Summoning Dismissal (VX)


Problems?
Post any problems you're having with the event system or scripts here and I'll help you fix them.
"**Please be aware that if you summon in RMXP, dismiss, then summon again, the battler will not appear.  It has nothing to do with the event.  It's an error that occurs within the system."

I got to there and stopped.  That's kind of a big glitch thats in your event.  There must be a way to fix it, you probably should.
Actingman00 wrote:
"**Please be aware that if you summon in RMXP, dismiss, then summon again, the battler will not appear.  It has nothing to do with the event.  It's an error that occurs within the system."

I got to there and stopped.  That's kind of a big glitch thats in your event.  There must be a way to fix it, you probably should.

I've tried, but no one's been able to figure it out.  I was waiting for a solution, but I wanted to release it as it is for now.  Rest assured, I'm working on it.
Wow nice! imma try this right away!
That 2nd time summoning graphics glitch is the weirdest I've ever seen.
that glitch is probably because you do not reset the event, as it never happened. If you use it once, you'll switch on one of the conditional branches making it impossible for the summon to occur again.

although i may be wrong.
If that were the problem, I'd think the actual summoning wouldn't work.  The character is summoned, but the graphic isn't.  I tried adding "Exit Event Processing" after each branch end, but it made no difference.  Thank you for your suggestions, though.
how about this, after you dismiss it, you add a "charge" function in which you can only use it again after X turns. after X turns, you can repeat the Summon command.
Nope, that didn't work, either.  I created a state that adds the restriction Can't Move, but after that I still encountered the problem.  The charge function is a good idea, though.
khmp generously made a script that fixes the graphic error in XP.  Please be sure to credit him if you use it.

~Guardian1239
I've now added a demo for XP as well as VX, which will make it much easier for anyone that's using XP.
Nice, I like it...however, they seem to stay in your party the next time you battle instead of being dismissed automatically at the end of the battle.  Is there a way to fix this maybe?
Hmm..  I've no idea on how to fix this with events. I have a solution though, but it requires a little bit of scripting..
Anyways, here it is if anyone wants it:

Remove Summon Show
#==============================================================================
# ** Remove Summon [XP] & [VX]
#------------------------------------------------------------------------------
#  By: Gando
#  15/4 2008
#------------------------------------------------------------------------------
#  This little script will help you remove the summons after the battle.
#  All you have to do is to create a Common event. Set it to parallel process
#  and choose your condition switch. Then inside the common event, create an
#  event command saying: Change party member:Remove [Summoned person]
#
#  Change "Summoned Person" to the the Actor that you can summon.
#
#  For every summon that is available in the game, you need to add an extra
#  remove event inside the Common event.
#  Or else they won't be removed after battle.
#
#
#  REMOVE_SWITCH: change this number to the condition switch in the Common event
#  SUMMON_SWITCH: This should be the same number as the summoning switch,
#                 (switch number 1 in the tutorial)
#
#
#  I noticed that if you have a summoned unit, and the battle ends, then in the
#  the next battle if you try to summon again it will say:
#  "you can only have one summon.." even if you don't have any units summoned.
#  And that is what the summon switch is for. It will fix this.
#
#==============================================================================
class Scene_Battle
  REMOVE_SWITCH = 2
  SUMMON_SWITCH = 1
  #--------------------------------------------------------------------------
  # * Alias definitions
  #--------------------------------------------------------------------------
  alias summon_removal_switch_battle_end battle_end
  #--------------------------------------------------------------------------
  # * Battle Ends
  #     result : results (0:win 1:lose 2:escape)
  #--------------------------------------------------------------------------
    def battle_end(result)
    summon_removal_switch_battle_end(result)
    if (result == 0 or
        result == 1 or
        result == 2)
      $game_switches[REMOVE_SWITCH] = true
      $game_switches[SUMMON_SWITCH] = false
    end
  end
end
Expand to see the code.


The comments inside the script will help you set it up.
This script works for both XP and VX. :thumb:

Over and out - Gando
Wow, Gando.  That's excellent!  Thank you for helping!  I'll add it to the first post!  I also made it easier to navigate by using more spoilers.
very good job Guardian!
but, can you made compatible your summon system with the RTAB system??
i tested it on a RTAB system and it don't work, so can you do enithing?
I've never actually worked with anything that isn't turn-based.  I very much prefer the turn-based combat system.  I'm not sure why it wouldn't work on a RTAB system since events are events and they should work unless there's a conflict with the battle system.  I recommend checking with the maker of the system you're using and asking them what you can do to resolve the problem.
Updated! :thumb:

Let me know if you have any questions or problems.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=44508