V's Promotion System Addon

Status
Not open for further replies.

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
I'll have a look. A few questions:
- Will they spend the item to get the promotion?
- Does every actor or promotion need to have an item? And if so, what amount of said item?
- Do you want the item to show in the scene as well?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Yes the item is used when promoted.
Yes every actor needs an item and the item will be different for each actor.
item shown in scene would be nice, but I didn't think to do that. That also makes me think that it should not show the actor in the list of promotable if the item is not present.Just like it does for those that are not at the promotion level.

hold on that. I just found the terms of use for the script.
I need permission to modify it and use it for commercial use.
 
Last edited:

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
822
First Language
Hungarian
Primarily Uses
RMVXA
Making a separate addon for it doesn't really count as "modifying the script", so that's okay to do, unless the terms state something against this too.
Of course, if the commercial part is the issue, that can't be helped.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
No worries, let me know how you get on.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Making a separate addon for it doesn't really count as "modifying the script", so that's okay to do
Well the terms say "You are not allowed to edit any of my scripts without permission or at least attempting to do so."
So like you said if it was a separate script for the add on then I think that would be good. :) @A-Moonless-Night

I found this and thought it fit in well with my plans, instead of just using yanfly class script, which I haven't really incorporated (command disabled). But I have class changes planned and was just trying to work it out by events. I had intended to use items, like the FF1 class change with the 'rat tail' kind of thing.
This script works with my project and could work well. It's a toss up of forcing a class change at a specific level or let the player carry forward.
Could work both ways with my project, because I have benefits and deficits with the class changes.

As for the commercial usage, I've contacted the writer. It's just a matter of paying for the use of it.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
Okay, see how you go with this:
Code:
=begin
#=====================================================================
#   AMN V's Promotions - Add-on
#   Version 1.0
#   Author: AMoonlessNight
#   Date: 23 Mar 2018
#   Latest: 23 Mar 2018
#=====================================================================#
#   UPDATE LOG
#---------------------------------------------------------------------#
# 23 Mar 2018 - created the add-on script for V's Promotions
#=====================================================================#

This script was requested as an add-on to V's Promotions script.
It will not work without it.

V's Promotions script can be found here:
https://forums.rpgmakerweb.com/index.php?threads/vs-promotion-system-v0-2.18875/

Requested by Roninator2

#=====================================================================#
          NOTETAGS
#=====================================================================#

Notetag actors as many times as you require with the following:

    * <Promotion: Level, Graphic_Name, Graphic_Index, Cost, Class, Item>
  #----------------------------------------------------------------#
  # Item is a new addition and should be replaced with the number
  # of the item that the party must have in order for this actor
  # to be promoted (e.g. 5 for Stimulant).
  #----------------------------------------------------------------#
 
=end


#==============================================================================
#
# ** Please do not edit below this point unless you know what you are doing.
#
#==============================================================================



#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :next_promotion_item             # Item needed to promote actor

  #--------------------------------------------------------------------------
  # * Setup                                                  # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias :amn_vpromo_gameactor_setup :setup
  def setup(actor_id)
    @next_promotion_item = 0
    amn_vpromo_gameactor_setup(actor_id)
  end
 
  #--------------------------------------------------------------------------
  # * Sets up the actor's note                           # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def set_up_actor_note(actor_id)
    note= /<Promotion:\s*(\d*)\S*\s*(\w*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)>/i
    @actors_note = $data_actors[actor_id].note.scan(note)
  end

  #--------------------------------------------------------------------------
  # * Check For Promotions                                   # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_checkforpromo  check_for_promotion
  def check_for_promotion
    amn_vpromo_checkforpromo &&
    @actors_note.size.times { |i| @next_promotion_item = @actors_note[i][5].to_i if @level == @actors_note[i][0].to_i }
  end
 
  #--------------------------------------------------------------------------
  # * Check Promotion Items                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def check_promotion_items
    return true if needs_promotion_item? && $game_party.items.include?($data_items[@next_promotion_item])
  end
 
  #--------------------------------------------------------------------------
  # * Needs Promotion Item?                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def needs_promotion_item?
    return false if @next_promotion_item == 0
    return true
  end
 
  #--------------------------------------------------------------------------
  # * Checks if actor is promotable                          # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promotable?  promotable?
  def promotable?
    if needs_promotion_item?
      return true if check_promotion_items && @needs_promotion == true
    else
      amn_vpromo_promotable?
    end
  end
 
  #--------------------------------------------------------------------------
  # * Promote Processing                                     # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promote  promote
  def promote
    if @next_promotion_item > 0
      $game_party.lose_item($data_items[@next_promotion_item], 1)
    end
    amn_vpromo_promote
  end
 
  #--------------------------------------------------------------------------
  # * Promotion Items                                          # NEW METHOD #
  #--------------------------------------------------------------------------
  def promotion_items?
    return @next_promotion_item
  end
 
end


#==============================================================================
# ** Promotion_Info_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Info Window processing.
#==============================================================================

class Promotion_Info_Window < Window_Base
   
  #--------------------------------------------------------------------------
  # * Draws actors info                                  # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def draw_actor_info(index)
    actor = @promotables[@index]
    cost = "Cost: " + actor.promotion_cost?.to_s
    # AMN addition
    if actor.next_promotion_item > 0
      item = $data_items[actor.next_promotion_item]
      icon = '\i[' + item.icon_index.to_s + '] '
      name = item.name.to_s + ' '
      amt = $game_party.item_number(item)
      if amt == 0
        itemtxt = icon + name + '\c[2]' + amt.to_s + '\c[2] / 1'
      else
        itemtxt = icon + name + amt.to_s + ' / 1'
      end
     
    else
      itemtxt = ''
    end
    #
    draw_v_text(120, 55, (Graphics.width / 3) * 2, 75, actor.name, 0, 45)
    draw_actor_face(actor, 10, 10)
    draw_zoomed_actor_graphic(actor, 40, 150, 2)
    draw_v_text(-105, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.class_id].name, 1, 22)
    draw_v_text(-10, 150, (Graphics.width / 3) * 2, 75, ">", 1, 55)
    draw_zoomed_character(actor.next_promotion_name, actor.next_promotion_index, 230, 150, 2)
    draw_v_text(85, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.next_promotion_class].name, 1, 22)
    draw_v_text(-10, 250, (Graphics.width / 3) * 2, 75, cost, 1, 40)
    draw_text_ex(10, 250, itemtxt)
  end
 
end

#==============================================================================
# ** Promotion_Command_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Command Window processing.
#==============================================================================

class Promotion_Command_Window < Window_Command
   
  #--------------------------------------------------------------------------
  # * Checks if party has enough to buy promotion            # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promocmdwdw_afford?      afford?
  def afford?(id)
    if @promotables[id].promotion_items? != 0
      $game_party.gold > @promotables[id].promotion_cost? && $game_party.items.include?($data_items[@promotables[id].promotion_items?])
    else
      amn_vpromo_promocmdwdw_afford?(id)
    end
   
  end
end

EDIT: Forgot to pretty up how the item looks in the promotion window, so take and look and let me know where you want it.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
It works great. Thank you so much. I adjusted the position values for what I wanted.

The script itself still has two flaws, but just have to plan it out for those things to not happen.

1. Cost to level is 1000. Party has exactly 1000 money/gold. Promotion scene will show, but cannot promote as the script wants there to be at least 1 gold left after promoting. I doubt that the party will have exactly that amount an no more, that would be silly.

2. If you were to level a character or the party several levels the game freezes. I confirmed this in V's demo.
Promotion level is set to lets say 5, and your character is at level 4; then you level up by 2. Game Freeze.
Just going to set the promotion level high enough that one battle will never advance 2 levels, and don't use level up by 2 with potions or whatever.

Again thanks, as soon as I get a hold of the author, then I'll have to pay for it.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
Okay, here we are:

Code:
=begin
#=====================================================================
#   AMN V's Promotions - Add-on
#   Version 1.1
#   Author: AMoonlessNight
#   Date: 23 Mar 2018
#   Latest: 24 Mar 2018
#=====================================================================#
#   UPDATE LOG
#---------------------------------------------------------------------#
# 23 Mar 2018 - created the add-on script for V's Promotions
# 24 Mar 2018 - fixed level up and gain exp methods
#             - added greyed out colour for actors that are promotable
#               but don't have the correct items
#=====================================================================#

This script was requested as an add-on to V's Promotions script.
It will not work without it.

V's Promotions script can be found here:
https://forums.rpgmakerweb.com/index.php?threads/vs-promotion-system-v0-2.18875/

Requested by Roninator2

#=====================================================================#
          NOTETAGS
#=====================================================================#

Notetag actors as many times as you require with the following:

    * <Promotion: Level, Graphic_Name, Graphic_Index, Cost, Class, Item>
  #----------------------------------------------------------------#
  # Item is a new addition and should be replaced with the number
  # of the item that the party must have in order for this actor
  # to be promoted (e.g. 5 for Stimulant).
  #----------------------------------------------------------------#
 
=end


#==============================================================================
#
# ** Please do not edit below this point unless you know what you are doing.
#
#==============================================================================



#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :next_promotion_item             # Item needed to promote actor
  attr_accessor :next_promo_level                # The next promotion level

  #--------------------------------------------------------------------------
  # * Setup                                                  # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias :amn_vpromo_gameactor_setup :setup
  def setup(actor_id)
    @next_promotion_item = 0
    amn_vpromo_gameactor_setup(actor_id)
  end
 
  #--------------------------------------------------------------------------
  # * Sets up the actor's note                           # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def set_up_actor_note(actor_id)
    note= /<Promotion:\s*(\d*)\S*\s*(\w*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)>/i
    @actors_note = $data_actors[actor_id].note.scan(note)
  end

  #--------------------------------------------------------------------------
  # * Check For Promotions                                   # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_checkforpromo  check_for_promotion
  def check_for_promotion
    amn_vpromo_checkforpromo &&
    @actors_note.size.times { |i| @next_promotion_item = @actors_note[i][5].to_i if @level == @actors_note[i][0].to_i }
  end
 
  #--------------------------------------------------------------------------
  # * Check Promotion Items                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def check_promotion_items
    return true if needs_promotion_item? && $game_party.items.include?($data_items[@next_promotion_item])
  end
 
  #--------------------------------------------------------------------------
  # * Needs Promotion Item?                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def needs_promotion_item?
    return false if @next_promotion_item == 0
    return true
  end
 
  #--------------------------------------------------------------------------
  # * Checks if actor is promotable                          # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promotable?  promotable?
  def promotable?
    if needs_promotion_item?
      return true if check_promotion_items && @needs_promotion == true
    else
      amn_vpromo_promotable?
    end
  end
 
  #--------------------------------------------------------------------------
  # * Next Promotion Level                                     # NEW METHOD #
  #--------------------------------------------------------------------------
  def next_promo_level?
    array = []
    @actors_note.size.times { |i| array.push(@actors_note[i][0].to_i) }
    array.keep_if { |a| a > @level }
    array.sort
    if array.empty?
      @next_promo_level = max_level
    else
      @next_promo_level = array[0]
    end
  end
 
  #--------------------------------------------------------------------------
  # * At Promotion Level?                                      # NEW METHOD #
  #--------------------------------------------------------------------------
  # Had to do this in order for level up commands to work properly
  #--------------------------------------------------------------------------
  def at_promotion_level?
    amn_vpromo_promotable?
  end
 
  #--------------------------------------------------------------------------
  # * Promote Processing                                     # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promote  promote
  def promote
    if @next_promotion_item > 0
      $game_party.lose_item($data_items[@next_promotion_item], 1)
    end
    amn_vpromo_promote
  end
 
  #--------------------------------------------------------------------------
  # * Promotion Items                                          # NEW METHOD #
  #--------------------------------------------------------------------------
  def promotion_items?
    return @next_promotion_item
  end
 
end

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  alias amn_vpromo_gameint_cmd315   command_315
  def command_315
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      req_exp = actor.exp_for_level(actor.next_promo_level?)
      if !actor.at_promotion_level?
        if value < req_exp
          actor.change_exp(actor.exp + value, @params[5])
        else
          actor.change_exp(req_exp, @params[5])
        end
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Change Level
  #--------------------------------------------------------------------------
  alias amn_vpromo_gameint_cmd316   command_316
  def command_316
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      if !actor.at_promotion_level?
        if value < actor.next_promo_level?
          actor.change_level(actor.level + value, @params[5])
        else
          actor.change_level(actor.next_promo_level, @params[5])
        end
      end
    end
  end
 
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a super class of all windows within the game.
#==============================================================================

class Window_Base < Window
 
  def greyout_colour;    text_color(7);  end;    # Greyed out

  #--------------------------------------------------------------------------
  # * Draw Level
  #--------------------------------------------------------------------------
  alias :amn_vpromo_windbase_drawactorlevel   :draw_actor_level
  def draw_actor_level(actor, x, y)
    amn_vpromo_windbase_drawactorlevel(actor, x, y)
    if actor.promotable?
      draw_v_text(x, y + 25, 150, line_height, "Promotable", 0, 24, crisis_color)
    elsif actor.at_promotion_level? && !actor.promotable?
      draw_v_text(x, y + 25, 150, line_height, "Promotable", 0, 24, greyout_colour)
    end
  end
 
end

#==============================================================================
# ** Promotion_Info_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Info Window processing.
#==============================================================================

class Promotion_Info_Window < Window_Base
   
  #--------------------------------------------------------------------------
  # * Draws actors info                                  # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def draw_actor_info(index)
    actor = @promotables[@index]
    cost = "Cost: " + actor.promotion_cost?.to_s
    # AMN addition
    if actor.next_promotion_item > 0
      item = $data_items[actor.next_promotion_item]
      icon = '\i[' + item.icon_index.to_s + '] '
      name = item.name.to_s + ' '
      amt = $game_party.item_number(item)
      if amt == 0
        itemtxt = icon + name + '\c[2]' + amt.to_s + '\c[2] / 1'
      else
        itemtxt = icon + name + amt.to_s + ' / 1'
      end
     
    else
      itemtxt = ''
    end
    #
    draw_v_text(120, 55, (Graphics.width / 3) * 2, 75, actor.name, 0, 45) 
    draw_actor_face(actor, 10, 10)
    draw_zoomed_actor_graphic(actor, 40, 150, 2)
    draw_v_text(-105, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.class_id].name, 1, 22) 
    draw_v_text(-10, 150, (Graphics.width / 3) * 2, 75, ">", 1, 55) 
    draw_zoomed_character(actor.next_promotion_name, actor.next_promotion_index, 230, 150, 2)
    draw_v_text(85, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.next_promotion_class].name, 1, 22) 
    draw_v_text(-10, 250, (Graphics.width / 3) * 2, 75, cost, 1, 40)
    draw_text_ex(10, 250, itemtxt)
  end
 
end

#==============================================================================
# ** Promotion_Command_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Command Window processing.
#==============================================================================

class Promotion_Command_Window < Window_Command
   
  #--------------------------------------------------------------------------
  # * Checks if party has enough to buy promotion            # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promocmdwdw_afford?      afford?
  def afford?(id)
    if @promotables[id].promotion_items? != 0
      $game_party.gold >= @promotables[id].promotion_cost? && $game_party.items.include?($data_items[@promotables[id].promotion_items?])
    else
      $game_party.gold >= @promotables[id].promotion_cost?
    end
   
  end
end

I also fixed the method for gaining EXP, too, because that also made the game freeze.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Thank you for that.
The exp does still freeze, at least for my game, but only when going up two levels. just like the gain level does when going past the promotion level. Otherwise it work fine. :LZYsmile:. If I never have the player get into a battle where they would gain 50000+ exp then I will be safe for the first promotion level. It took 25000 exp to go from 49 to 50.
I commented out one line from the original script as I forgot that I changed the position value for the promotion text. It was under my JP text.
With the original script unmodified (position or commented out) I was getting "Promotable" showing up twice.
Keep up the awesome work.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
Hmm, that's strange. It's working fine for me, no errors. Can you show me a screenshot of how you have the event set up? And can you show me which line you commented out?

EDIT: Wait, I see now. I was thinking of if things were manually changed by event, rather than in battle. Hang on.

EDIT: Give this one a try:
Code:
=begin
#=====================================================================
#   AMN V's Promotions - Add-on
#   Version 1.2
#   Author: AMoonlessNight
#   Date: 23 Mar 2018
#   Latest: 24 Mar 2018
#=====================================================================#
#   UPDATE LOG
#---------------------------------------------------------------------#
# 23 Mar 2018 - created the add-on script for V's Promotions
# 24 Mar 2018 - fixed level up and gain exp methods
#             - added greyed out colour for actors that are promotable
#               but don't have the correct items
#             - fixed gain exp method
#=====================================================================#

This script was requested as an add-on to V's Promotions script.
It will not work without it.

V's Promotions script can be found here:
https://forums.rpgmakerweb.com/index.php?threads/vs-promotion-system-v0-2.18875/

Requested by Roninator2

#=====================================================================#
          NOTETAGS
#=====================================================================#

Notetag actors as many times as you require with the following:

    * <Promotion: Level, Graphic_Name, Graphic_Index, Cost, Class, Item>
  #----------------------------------------------------------------#
  # Item is a new addition and should be replaced with the number
  # of the item that the party must have in order for this actor
  # to be promoted (e.g. 5 for Stimulant).
  #----------------------------------------------------------------#
 
=end


#==============================================================================
#
# ** Please do not edit below this point unless you know what you are doing.
#
#==============================================================================



#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :next_promotion_item             # Item needed to promote actor
  attr_accessor :next_promo_level                # The next promotion level

  #--------------------------------------------------------------------------
  # * Setup                                                  # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias :amn_vpromo_gameactor_setup :setup
  def setup(actor_id)
    @next_promotion_item = 0
    amn_vpromo_gameactor_setup(actor_id)
  end
 
  #--------------------------------------------------------------------------
  # * Gain EXP (Account for Experience Rate)
  #--------------------------------------------------------------------------
  alias :amn_vpromo_gameactor_gainexp :gain_exp
  def gain_exp(exp)
    req_exp = exp_for_level(next_promo_level?)
    value = self.exp + (exp * final_exp_rate).to_i
    if !at_promotion_level?
      if value < req_exp
        amn_vpromo_gameactor_gainexp(exp)
      else
        change_exp(req_exp, true)
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Change Experience
  #     show : Level up display flag
  #--------------------------------------------------------------------------
  def change_exp(exp, show)
    @exp[@class_id] = [exp, 0].max unless at_promotion_level?
    last_level = @level
    last_skills = skills
    level_up while !max_level? && self.exp >= next_level_exp
    level_down while self.exp < current_level_exp
    display_level_up(skills - last_skills) if show && @level > last_level
    refresh
  end
 
  #--------------------------------------------------------------------------
  # * Sets up the actor's note                           # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def set_up_actor_note(actor_id)
    note= /<Promotion:\s*(\d*)\S*\s*(\w*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)>/i
    @actors_note = $data_actors[actor_id].note.scan(note)
  end
 
  #--------------------------------------------------------------------------
  # * Check For Promotions                                   # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_checkforpromo  check_for_promotion
  def check_for_promotion
    amn_vpromo_checkforpromo &&
    @actors_note.size.times { |i| @next_promotion_item = @actors_note[i][5].to_i if @level == @actors_note[i][0].to_i }
  end
 
  #--------------------------------------------------------------------------
  # * Check Promotion Items                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def check_promotion_items
    return true if needs_promotion_item? && $game_party.items.include?($data_items[@next_promotion_item])
  end
 
  #--------------------------------------------------------------------------
  # * Needs Promotion Item?                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def needs_promotion_item?
    return false if @next_promotion_item == 0
    return true
  end
 
  #--------------------------------------------------------------------------
  # * Checks if actor is promotable                          # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promotable?  promotable?
  def promotable?
    if needs_promotion_item?
      return true if check_promotion_items && @needs_promotion == true
    else
      amn_vpromo_promotable?
    end
  end
 
  #--------------------------------------------------------------------------
  # * Next Promotion Level                                     # NEW METHOD #
  #--------------------------------------------------------------------------
  def next_promo_level?
    array = []
    @actors_note.size.times { |i| array.push(@actors_note[i][0].to_i) }
    array.keep_if { |a| a > @level }
    array.sort
    if array.empty?
      @next_promo_level = max_level
    else
      @next_promo_level = array[0]
    end
  end
 
  #--------------------------------------------------------------------------
  # * At Promotion Level?                                      # NEW METHOD #
  #--------------------------------------------------------------------------
  # Had to do this in order for level up commands to work properly
  #--------------------------------------------------------------------------
  def at_promotion_level?
    amn_vpromo_promotable?
  end
 
  #--------------------------------------------------------------------------
  # * Promote Processing                                     # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promote  promote
  def promote
    if @next_promotion_item > 0
      $game_party.lose_item($data_items[@next_promotion_item], 1)
    end
    amn_vpromo_promote
  end
 
  #--------------------------------------------------------------------------
  # * Promotion Items                                          # NEW METHOD #
  #--------------------------------------------------------------------------
  def promotion_items?
    return @next_promotion_item
  end
 
end

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  alias amn_vpromo_gameint_cmd315   command_315
  def command_315
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      req_exp = actor.exp_for_level(actor.next_promo_level?)
      if !actor.at_promotion_level?
        if value < req_exp
          actor.change_exp(actor.exp + value, @params[5])
        else
          actor.change_exp(req_exp, @params[5])
        end
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Change Level
  #--------------------------------------------------------------------------
  alias amn_vpromo_gameint_cmd316   command_316
  def command_316
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      if !actor.at_promotion_level?
        if value < actor.next_promo_level?
          actor.change_level(actor.level + value, @params[5])
        else
          actor.change_level(actor.next_promo_level, @params[5])
        end
      end
    end
  end
 
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a super class of all windows within the game.
#==============================================================================

class Window_Base < Window
 
  def greyout_colour;    text_color(7);  end;    # Greyed out

  #--------------------------------------------------------------------------
  # * Draw Level
  #--------------------------------------------------------------------------
  alias :amn_vpromo_windbase_drawactorlevel   :draw_actor_level
  def draw_actor_level(actor, x, y)
    amn_vpromo_windbase_drawactorlevel(actor, x, y)
    if actor.promotable?
      draw_v_text(x, y + 25, 150, line_height, "Promotable", 0, 24, crisis_color)
    elsif actor.at_promotion_level? && !actor.promotable?
      draw_v_text(x, y + 25, 150, line_height, "Promotable", 0, 24, greyout_colour)
    end
  end
 
end

#==============================================================================
# ** Promotion_Info_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Info Window processing.
#==============================================================================

class Promotion_Info_Window < Window_Base
    
  #--------------------------------------------------------------------------
  # * Draws actors info                                  # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def draw_actor_info(index)
    actor = @promotables[@index]
    cost = "Cost: " + actor.promotion_cost?.to_s
    # AMN addition
    if actor.next_promotion_item > 0
      item = $data_items[actor.next_promotion_item]
      icon = '\i[' + item.icon_index.to_s + '] '
      name = item.name.to_s + ' '
      amt = $game_party.item_number(item)
      if amt == 0
        itemtxt = icon + name + '\c[2]' + amt.to_s + '\c[2] / 1'
      else
        itemtxt = icon + name + amt.to_s + ' / 1'
      end
      
    else
      itemtxt = ''
    end
    #
    draw_v_text(120, 55, (Graphics.width / 3) * 2, 75, actor.name, 0, 45)
    draw_actor_face(actor, 10, 10)
    draw_zoomed_actor_graphic(actor, 40, 150, 2)
    draw_v_text(-105, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.class_id].name, 1, 22)
    draw_v_text(-10, 150, (Graphics.width / 3) * 2, 75, ">", 1, 55)
    draw_zoomed_character(actor.next_promotion_name, actor.next_promotion_index, 230, 150, 2)
    draw_v_text(85, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.next_promotion_class].name, 1, 22)
    draw_v_text(-10, 250, (Graphics.width / 3) * 2, 75, cost, 1, 40)
    draw_text_ex(10, 250, itemtxt)
  end
 
end

#==============================================================================
# ** Promotion_Command_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Command Window processing.
#==============================================================================

class Promotion_Command_Window < Window_Command
    
  #--------------------------------------------------------------------------
  # * Checks if party has enough to buy promotion            # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promocmdwdw_afford?      afford?
  def afford?(id)
    if @promotables[id].promotion_items? != 0
      $game_party.gold >= @promotables[id].promotion_cost? && $game_party.items.include?($data_items[@promotables[id].promotion_items?])
    else
      $game_party.gold >= @promotables[id].promotion_cost?
    end
    
  end
end
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Well I actually haven't tested in battle. I was using events and setting the gain exp to be higher than what was needed to go up two levels.
I should test the battle I suppose. Have to set one up to be super exp. (not sure that would ever happen though)

Commented out line 268

Actor
actor.PNG
Event1
event1-1.PNG event1-2.PNG

event2
event2-1.PNG event2-2.PNG event2-3.PNG

promote
event3.PNG

So I would go event 1-1 -> event 1-2 (*5) -> event 2-1 -> event 1-2 (*7~8) -> event 2-2 (whatever was needed to reach max level)
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
Have you tried it with the version I just posted?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
I thought you got it perfect. Yes I just tested the last one you just posted.
The battle experience works perfectly, only going up to promotion level and nothing more.
The event leveling still freezes. From my pictures I did event 1-1 then 2-1 so +48 levels , then +48 levels. With promotion level at 50

*Edit, I just tested the gold part as well. You fixed that too. So it's just the event leveling that is a problem.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
Had a look and I think it's freezing from having one promotion level set at level 100, where the max level is 99. I did notice another bug with it skipping one promotion, though, so let me work on that.

EDIT: Give this one a shot:
Code:
=begin
#=====================================================================
#   AMN V's Promotions - Add-on
#   Version 1.3
#   Author: AMoonlessNight
#   Date: 23 Mar 2018
#   Latest: 25 Mar 2018
#=====================================================================#
#   UPDATE LOG
#---------------------------------------------------------------------#
# 23 Mar 2018 - created the add-on script for V's Promotions
# 24 Mar 2018 - fixed level up and gain exp methods
#             - added greyed out colour for actors that are promotable
#               but don't have the correct items
#             - fixed gain exp method
# 25 Mar 2018 - tinkered with gain exp method some more
#=====================================================================#

This script was requested as an add-on to V's Promotions script.
It will not work without it.

V's Promotions script can be found here:
https://forums.rpgmakerweb.com/index.php?threads/vs-promotion-system-v0-2.18875/

Requested by Roninator2

#=====================================================================#
          NOTETAGS
#=====================================================================#

Notetag actors as many times as you require with the following:

    * <Promotion: Level, Graphic_Name, Graphic_Index, Cost, Class, Item>
  #----------------------------------------------------------------#
  # Item is a new addition and should be replaced with the number
  # of the item that the party must have in order for this actor
  # to be promoted (e.g. 5 for Stimulant).
  #----------------------------------------------------------------#
 
=end


#==============================================================================
#
# ** Please do not edit below this point unless you know what you are doing.
#
#==============================================================================



#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :next_promotion_item             # Item needed to promote actor
  attr_accessor :next_promo_level                # The next promotion level

  #--------------------------------------------------------------------------
  # * Setup                                                  # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias :amn_vpromo_gameactor_setup :setup
  def setup(actor_id)
    @next_promotion_item = 0
    amn_vpromo_gameactor_setup(actor_id)
  end
 
  #--------------------------------------------------------------------------
  # * Gain EXP (Account for Experience Rate)
  #--------------------------------------------------------------------------
  alias :amn_vpromo_gameactor_gainexp :gain_exp
  def gain_exp(exp)
    req_exp = exp_for_level(next_promo_level?)
    value = self.exp + (exp * final_exp_rate).to_i
    if !at_promotion_level?
      if value < req_exp
        amn_vpromo_gameactor_gainexp(exp)
      else
        change_exp(req_exp, true)
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Change Experience
  #     show : Level up display flag
  #--------------------------------------------------------------------------
  def change_exp(exp, show)
    @exp[@class_id] = [exp, 0].max unless at_promotion_level?
    last_level = @level
    last_skills = skills
    level_up while !max_level? && !at_promotion_level? && self.exp >= next_level_exp
    level_down while self.exp < current_level_exp
    display_level_up(skills - last_skills) if show && @level > last_level
    refresh
  end
 
  #--------------------------------------------------------------------------
  # * Sets up the actor's note                           # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def set_up_actor_note(actor_id)
    note= /<Promotion:\s*(\d*)\S*\s*(\w*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)\S*\s*(\d*)>/i
    @actors_note = $data_actors[actor_id].note.scan(note)
  end
 
  #--------------------------------------------------------------------------
  # * Check For Promotions                                   # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_checkforpromo  check_for_promotion
  def check_for_promotion
    amn_vpromo_checkforpromo &&
    @actors_note.size.times { |i| @next_promotion_item = @actors_note[i][5].to_i if @level == @actors_note[i][0].to_i }
  end
 
  #--------------------------------------------------------------------------
  # * Check Promotion Items                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def check_promotion_items
    return true if needs_promotion_item? && $game_party.items.include?($data_items[@next_promotion_item])
  end
 
  #--------------------------------------------------------------------------
  # * Needs Promotion Item?                                    # NEW METHOD #
  #--------------------------------------------------------------------------
  def needs_promotion_item?
    return false if @next_promotion_item == 0
    return true
  end
 
  #--------------------------------------------------------------------------
  # * Checks if actor is promotable                          # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promotable?  promotable?
  def promotable?
    if needs_promotion_item?
      return true if check_promotion_items && @needs_promotion == true
    else
      amn_vpromo_promotable?
    end
  end
 
  #--------------------------------------------------------------------------
  # * Next Promotion Level                                     # NEW METHOD #
  #--------------------------------------------------------------------------
  def next_promo_level?
    array = []
    @actors_note.size.times { |i| array.push(@actors_note[i][0].to_i) }
    array.keep_if { |a| a > @level }
    array.sort
    if array.empty?
      @next_promo_level = max_level
    else
      @next_promo_level = array[0]
    end
  end
 
  #--------------------------------------------------------------------------
  # * At Promotion Level?                                      # NEW METHOD #
  #--------------------------------------------------------------------------
  # Had to do this in order for level up commands to work properly
  #--------------------------------------------------------------------------
  def at_promotion_level?
    amn_vpromo_promotable?
  end
 
  #--------------------------------------------------------------------------
  # * Promote Processing                                     # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promote  promote
  def promote
    if @next_promotion_item > 0
      $game_party.lose_item($data_items[@next_promotion_item], 1)
    end
    amn_vpromo_promote
  end
 
  #--------------------------------------------------------------------------
  # * Promotion Items                                          # NEW METHOD #
  #--------------------------------------------------------------------------
  def promotion_items?
    return @next_promotion_item
  end
 
end

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  alias amn_vpromo_gameint_cmd315   command_315
  def command_315
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      req_exp = actor.exp_for_level(actor.next_promo_level?)
      p(req_exp)
      if !actor.at_promotion_level?
        if value < req_exp
          actor.change_exp(actor.exp + value, @params[5])
        else
          actor.change_exp(req_exp, @params[5])
        end
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Change Level
  #--------------------------------------------------------------------------
  alias amn_vpromo_gameint_cmd316   command_316
  def command_316
    value = operate_value(@params[2], @params[3], @params[4])
    iterate_actor_var(@params[0], @params[1]) do |actor|
      if !actor.at_promotion_level?
        if value < actor.next_promo_level?
          actor.change_level(actor.level + value, @params[5])
        else
          actor.change_level(actor.next_promo_level, @params[5])
        end
      end
    end
  end
 
end

#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This is a super class of all windows within the game.
#==============================================================================

class Window_Base < Window
 
  def greyout_colour;    text_color(7);  end;    # Greyed out

  #--------------------------------------------------------------------------
  # * Draw Level
  #--------------------------------------------------------------------------
  alias :amn_vpromo_windbase_drawactorlevel   :draw_actor_level
  def draw_actor_level(actor, x, y)
    amn_vpromo_windbase_drawactorlevel(actor, x, y)
    if actor.promotable?
      draw_v_text(x, y + 25, 150, line_height, "Promotable", 0, 24, crisis_color)
    elsif actor.at_promotion_level? && !actor.promotable?
      draw_v_text(x, y + 25, 150, line_height, "Promotable", 0, 24, greyout_colour)
    end
  end
 
end

#==============================================================================
# ** Promotion_Info_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Info Window processing.
#==============================================================================

class Promotion_Info_Window < Window_Base
    
  #--------------------------------------------------------------------------
  # * Draws actors info                                  # OVERWRITE METHOD #
  #--------------------------------------------------------------------------
  def draw_actor_info(index)
    actor = @promotables[@index]
    cost = "Cost: " + actor.promotion_cost?.to_s
    # AMN addition
    if actor.next_promotion_item > 0
      item = $data_items[actor.next_promotion_item]
      icon = '\i[' + item.icon_index.to_s + '] '
      name = item.name.to_s + ' '
      amt = $game_party.item_number(item)
      if amt == 0
        itemtxt = icon + name + '\c[2]' + amt.to_s + '\c[2] / 1'
      else
        itemtxt = icon + name + amt.to_s + ' / 1'
      end
      
    else
      itemtxt = ''
    end
    #
    draw_v_text(120, 55, (Graphics.width / 3) * 2, 75, actor.name, 0, 45)
    draw_actor_face(actor, 10, 10)
    draw_zoomed_actor_graphic(actor, 40, 150, 2)
    draw_v_text(-105, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.class_id].name, 1, 22)
    draw_v_text(-10, 150, (Graphics.width / 3) * 2, 75, ">", 1, 55)
    draw_zoomed_character(actor.next_promotion_name, actor.next_promotion_index, 230, 150, 2)
    draw_v_text(85, 200, (Graphics.width / 3) * 2, 75, $data_classes[actor.next_promotion_class].name, 1, 22)
    draw_v_text(-10, 250, (Graphics.width / 3) * 2, 75, cost, 1, 40)
    draw_text_ex(10, 250, itemtxt)
  end
 
end

#==============================================================================
# ** Promotion_Command_Window
#------------------------------------------------------------------------------
#  This class handles all of the Promotion Command Window processing.
#==============================================================================

class Promotion_Command_Window < Window_Command
    
  #--------------------------------------------------------------------------
  # * Checks if party has enough to buy promotion            # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_vpromo_promocmdwdw_afford?      afford?
  def afford?(id)
    if @promotables[id].promotion_items? != 0
      $game_party.gold >= @promotables[id].promotion_cost? && $game_party.items.include?($data_items[@promotables[id].promotion_items?])
    else
      $game_party.gold >= @promotables[id].promotion_cost?
    end
    
  end
end
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Everything is working. You're pretty good at this.
Thanks.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
681
Reaction score
446
First Language
English
Primarily Uses
RMVXA
No worries, give us a yell if any other bugs pop up.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
Edited* new thread made
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,225
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top