Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help with Extra Parameter Change script.

Hello here. I'm trying to use this script that allows the creation of items that modify extra in-game parameters such as ATK and PDEF. I did what the directions indicate but there's a syntax error at line 142 and I don't know how to work that around.

There's the script:

Code:
#------------------------------------------------------------------------------

#  Extra Parameter Change (ver 1.0) [XP]

#  

#==============================================================================

#   About

#------------------------------------------------------------------------------

#   Title: Extra Parameter Change XP

#

#   A script that allows the player to increase or decrease additional

#    in game parameters. In version 1.0, these stats include:

#      attack (atk)    physical defence (pdef)    magical defence (mdef)

#      evasion (eva)

#

#

#   Version: 1.0

#       # 1.0 - Initial Release

#      

#   Date Published: 01 February 2013

#   Last Updated  : 01 February 2012

#   Author: Logan Forrests

#   Hosted on: RMRK.net only.

#

#   Permissions for use of this script can be found here:

#       - [url=http://rmrk.net/index.php/topic,45481.0.html]http://rmrk.net/index.php/topic,45481.0.html[/url]

#

#   Redistribution of this script is stricly prohibited with prior permission.

#==============================================================================

#   Directions

#------------------------------------------------------------------------------

#    Items which are designed to increase or decrease any of these additional

#     parameters must be defined under BATTLE_STAT_ITEMS. The ID of the item

#     is required and is used to check if the item being used is one that will

#     modify the base parameter.

#    Follow the example provided in the relevant section to set up items that

#     will have the desired effect of modifying these extra parameters.

#

#   A maximum bonus can also be set for each extra parameter. By default,

#    these values have been set to 999.

#==============================================================================

module LFXP

  module STAT_PLUS

    #------------------------------------------------------------------------

    # * Set which items change these parameters

    #------------------------------------------------------------------------

    BATTLE_STAT_ITEMS = {  #Do Not Remove

    # Item ID  =>  {:atk => #, :pdef => #, :mdef => #, :eva => #},

    #

    # Ex. To make Item ID 35 increase ATK by 5:

    #    35    =>  {:atk => 5, :pdef => 0, :mdef => 0, :eva => 0},

    # Insert your items in the space below:

       24    =>  {:atk => 10, :pdef => 0, :mdef => 0, :eva => 0},

       25    =>  {:atk => 0, :pdef => 10, :mdef => 0, :eva => 0},

       26    =>  {:atk => 0, :pdef => 0, :mdef => 10, :eva => 0},

       27    =>  {:atk => 0, :pdef => 0, :mdef => 0, :eva => 10},

    } #Do Not Remove

    #------------------------------------------------------------------------

    # * Maximum bonus attainable for each parameter type

    #------------------------------------------------------------------------

    MAX_BONUS = {  # Do Not Remove

      :atk    =>  999,

      :pdef   =>  999,

      :mdef   =>  999,

      :eva    =>  999,

    } #Do Not Remove

  end

 

end

#==============================================================================

#  DO NOT EDIT BELOW THIS LINE  ::::::::::::::: DO NOT EDIT BELOW THIS LINE   #

#==============================================================================

$imported ||= {}

$imported[:lfxp_statplus] = true

#==============================================================================

# ** Game_Battler

#==============================================================================

class Game_Battler

  #--------------------------------------------------------------------------

  # * Base Class attr_readers for extra stat bonuses

  #     Prevents errors from no method defined in base class use

  #--------------------------------------------------------------------------

  def lfxp_sp_atk;  0; end

  def lfxp_sp_dpef; 0; end

  def lfxp_sp_mdef; 0; end

  def lfxp_sp_eva;  0; end

  def lfxp_sp_statplus(*args); 0; end

  #--------------------------------------------------------------------------

  # * Application of Item Effects

  #     item : item

  #--------------------------------------------------------------------------

  alias lfxp_statplus_itmeff_gb_lk93 item_effect

  def item_effect(item, *args, &block)

    #Set effective flag to false (ie. has a change occured in stat)

    effective = false

    #If item is a stat boost item as defined in LFXP::STAT_PLUS config

    boost = LFXP::STAT_PLUS::BATTLE_STAT_ITEMS[item.id]

    if boost

      boost.each_pair do |s, v|

        #Take result of changing the stat

        result = lfxp_sp_statplus(s, v)

        # if result is true, then stat_changed is true

        #  once stat_changed is true, it will remain true despite result

        if result then effective = true end

      end

    end

    return (lfxp_statplus_itmeff_gb_lk93(item, *args, &block) or effective)

  end

 

end

#==============================================================================

# ** Game_Actor

#==============================================================================

class Game_Actor < Game_Battler

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  alias lfxp_statplus_init_ga_aqwq initialize

  def initialize(*args, &block)

    #Create new varaibles for holding base stat bonus for atk, pdef, mdef, eva

    @lfxp_sp_base = [0, 0, 0, 0]

    #run original method

    lfxp_statplus_init_ga_aqwq(*args, &block)

  end

  #--------------------------------------------------------------------------

  # * Base Class attr_readers for extra stat bonuses

  #     Prevents errors from no method defined in base class use

  #--------------------------------------------------------------------------

  def lfxp_sp_atk;  @lfxp_sp_base[0];  end    #ATK

  def lfxp_sp_pdef; @lfxp_sp_base[1];  end    #PDEF

  def lfxp_sp_mdef; @lfxp_sp_base[2];  end    #MDEF

  def lfxp_sp_eva;  @lfxp_sp_base[3];  end    #EVA  

  #--------------------------------------------------------------------------

  # * Stat Plus method

  #    Increases or decreases appropriate stats

  #    Returns true if a parameter change occurs, false if not

  #--------------------------------------------------------------------------

  def lfxp_sp_statplus(stat, value)

    #Change  the relative value

    case stat

    when :atk

      orig_value = lfxp_sp_atk #original attack

      @lfxp_sp_base[0] = [[lfxp_sp_atk + value, 0].max, LFXP::STAT_PLUS::MAX_BONUS[:atk].min

      return true if orig_value != lfxp_sp_atk

    when :pdef

      orig_value = lfxp_sp_pdef #original pdef

      @lfxp_sp_base[1] = [[lfxp_sp_pdef + value, 0].max, LFXP::STAT_PLUS::MAX_BONUS[:pdef].min

      return true if orig_value != lfxp_sp_pdef

    when :mdef

      orig_value = lfxp_sp_mdef #original mdef

      @lfxp_sp_base[2] = [[lfxp_sp_mdef + value, 0].max, LFXP::STAT_PLUS::MAX_BONUS[:mdef].min

      return true if orig_value != lfxp_sp_mdef

    when :eva

      orig_value = lfxp_sp_eva #original eva

      @lfxp_sp_base[3] = [[lfxp_sp_eva + value, 0].max, LFXP::STAT_PLUS::MAX_BONUSeva].min

      return true if orig_value != lfxp_sp_eva

    end

    #In all cases, or when no case

    return false #not effective

  end

  #--------------------------------------------------------------------------

  # * Sub class method definitions.

  #    Also retrieves value from Superclass in case changes are added

  #    By default, all super values are 0

  #--------------------------------------------------------------------------

  def base_atk

    super + lfxp_sp_atk

  end

 

  def base_pdef

    super + lfxp_sp_pdef

  end

 

  def base_mdef

    super + lfxp_sp_mdef

  end

 

  def base_eva

    super + lfxp_sp_eva

  end

 

end
 
Unfortunately, there's no line 142, or anything close to it, in the script you provided here.
The error message should also specify a script name with the line number. Provide the correct script, and the exact text of the error message, and I (or someone else) should be able to get it resolved for you.
 
My bad, Let me try this again. This is the error that pops ups:

LBQXOWe.png
 
Considering there's still no line 142 in that script, we're still missing a piece.
I guess it's worth asking: is this in RPG Maker XP? That is the script's target platform, indicated by the [XP].

Aside from that, there's just not enough information here. You'll either have to figure out what part to share, or upload a demo (you can send me one privately, if that's better for you).
 
A demo wouldn't work as the error pops out as soon as I playtest the project.

From my understanding, the error is at this part of the script:

Code:
#==============================================================================

    # ** Game_Actor

    #==============================================================================

    class Game_Actor < Game_Battler

      #--------------------------------------------------------------------------

      # * Object Initialization

      #--------------------------------------------------------------------------

      alias lfxp_statplus_init_ga_aqwq initialize

      def initialize(*args, &block)

        #Create new varaibles for holding base stat bonus for atk, pdef, mdef, eva

        @lfxp_sp_base = [0, 0, 0, 0]

        #run original method

        lfxp_statplus_init_ga_aqwq(*args, &block)

      end

      #--------------------------------------------------------------------------

      # * Base Class attr_readers for extra stat bonuses

      #     Prevents errors from no method defined in base class use

      #--------------------------------------------------------------------------

      def lfxp_sp_atk;  @lfxp_sp_base[0];  end    #ATK

      def lfxp_sp_pdef; @lfxp_sp_base[1];  end    #PDEF

      def lfxp_sp_mdef; @lfxp_sp_base[2];  end    #MDEF

      def lfxp_sp_eva;  @lfxp_sp_base[3];  end    #EVA  

      #--------------------------------------------------------------------------

      # * Stat Plus method

      #    Increases or decreases appropriate stats

      #    Returns true if a parameter change occurs, false if not

      #--------------------------------------------------------------------------

      def lfxp_sp_statplus(stat, value)

        #Change  the relative value

        case stat

        when :atk

          orig_value = lfxp_sp_atk #original attack

          @lfxp_sp_base[0] = [[lfxp_sp_atk + value, 0].max, LFXP::STAT_PLUS::MAX_BONUS[:atk].min

          return true if orig_value != lfxp_sp_atk

        when :pdef

          orig_value = lfxp_sp_pdef #original pdef

          @lfxp_sp_base[1] = [[lfxp_sp_pdef + value, 0].max, LFXP::STAT_PLUS::MAX_BONUS[:pdef].min

          return true if orig_value != lfxp_sp_pdef

        when :mdef

          orig_value = lfxp_sp_mdef #original mdef

          @lfxp_sp_base[2] = [[lfxp_sp_mdef + value, 0].max, LFXP::STAT_PLUS::MAX_BONUS[:mdef].min

          return true if orig_value != lfxp_sp_mdef

        when :eva

          orig_value = lfxp_sp_eva #original eva

          @lfxp_sp_base[3] = [[lfxp_sp_eva + value, 0].max, LFXP::STAT_PLUS::MAX_BONUSeva].min

          return true if orig_value != lfxp_sp_eva

        end

        #In all cases, or when no case

        return false #not effective

      end

Namely this bit:

Code:
return true if orig_value != lfxp_sp_atk

It's the part where the script is supposed to calculate how much is to be add to the extra parameter.
 
Found it:
@lfxp_sp_base[3] = [[lfxp_sp_eva + value, 0].max, LFXP::STAT_PLUS::MAX_BONUSeva].min
return true if orig_value != lfxp_sp_eva

The line before your posted line is missing a "[:" for some reason.
should be MAX_BONUS[:eva].min

Edit: I owe you an apology, for accusing you of not posting the whole script. I am sorry. My browser seems to have taken issue with codeboxes, the problem is on my end, not yours.
 
avarisc":r4iaz8t3 said:
Found it:
@lfxp_sp_base[3] = [[lfxp_sp_eva + value, 0].max, LFXP::STAT_PLUS::MAX_BONUSeva].min
return true if orig_value != lfxp_sp_eva

The line before your posted line is missing a "[:" for some reason.
should be MAX_BONUS[:eva].min
Alright I fixed it. Sadly, the same error persists. Perhaps there's more to be configured than the instruction blurb indicates?

avarisc":r4iaz8t3 said:
Edit: I owe you an apology, for accusing you of not posting the whole script. I am sorry. My browser seems to have taken issue with codeboxes, the problem is on my end, not yours.
That's ok. No biggie here. Were you using Chrome, by the way? I've had my share of problem when using Chrome to browse message boards lately
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top