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.

[Resolved] Help with Trickster's Advanced Battle Commands

Status
Not open for further replies.

Jonny

Member

How do I make it so that when the limit break bar is full the attack command changes to limit break? I'm using DerVVulfman's limit break script v1.1 and the limit break element id is 17. Sorry if this question has already been answered somewhere else.

Edit: Ok, I've tried different things such as
special_learn $game_actor.limitbreak == 1000
but it always comes out with this error message when a battle starts:

NoMethodError occured while running script.

undefined method 'limitbreak' for nil:NilClass
 
Well you would have to use the special_learn parameter
in the Attack command use this condition

special_learn !(limit break is full condition)

now in the Limit Break command use this as the special_learn parameter

special_learn (limit break is full condition)

replace (limit break is full condition) with actual code I'm not familiar with his limit break script
 

Jonny

Member

I tried that and put that in my first post (I just edited it so that it said special_learn) and posted the error message I got ( I don't know how to take screenshots).:-/
 
To post a screenshot look here

Well your code is incorrect there is no such global variable named $game_actor

There is $game_actors and $game_party.actors, but you don't need either.

I already made it so if you wanted the actor using the command all you have to do is use the local variable identifier actor so your code becomes

Code:
actor.limitbreak == 1000
 

Jonny

Member

Ok now I'm getting this error message:

http://img106.imageshack.us/img106/562/errormessageah8.th.png[/IMG][/IMG]


and here is the BattleCommands data:

Code:
#--------------------------------------------------------------------------
# * Command Id 12 : Limit Break
#   Description   : Limit Break skill when bar is full
#--------------------------------------------------------------------------
id		12
name		Limit Break
kind		0
special_learn	actor.limitbreak == 1000
skill_set	skill.element_set.include?(17)
next_method	start_skill_select
 

Jonny

Member

I tried it again and it said a syntax error occured, but when I changed the Attack command in the BattleCommands data the old error came back up.
I had it like this:
Code:
#--------------------------------------------------------------------------
# * Command Id 1  : Attack
#   Description   : Just the normal attack command, nothing else
#--------------------------------------------------------------------------
id		1
name		Attack
special_learn	actor.limitbreak =< 1000
kind		0
next_method	start_enemy_select

But I changed it to this:
Code:
#--------------------------------------------------------------------------
# * Command Id 1  : Attack
#   Description   : Just the normal attack command, nothing else
#--------------------------------------------------------------------------
id		1
name		Attack
special_learn	!actor.limitbreak == 1000
kind		0
next_method	start_enemy_select
 

Jonny

Member

Well, it's your script but here it is. I put line 113 in bold and italics and I put 113 in front of it.

Code:
#--------------------------------------------------------------------------
# Begin SDK Enabled Check
#--------------------------------------------------------------------------
if SDK.state('Advanced Individual Battle Commands') == true
  
class Window_BattleCommand < Window_Selectable    
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(width)
    super(0, 0, width, 160)
    # Setup Commands
    @commands = []
    # Initialize Help Window
    @help_window = nil
    # Setup Contents
    self.contents = Bitmap.new(width - 32, height - 32)
  end
  #--------------------------------------------------------------------------
  # * Set Help Window
  #--------------------------------------------------------------------------
  def help_window=(help_window)
    @help_window = help_window
    update_help if self.active and @help_window != nil
  end
  #--------------------------------------------------------------------------
  # * Set Index
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_help if self.active and @help_window != nil
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Get Command
  #--------------------------------------------------------------------------
  def command
    return @commands[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh Window
  #--------------------------------------------------------------------------
  def refresh(actor = nil)
    # Return if nothing sent
    return if actor == nil
    # Setup Instance Variable
    @actor = actor
    # Get Commands
    @commands = @actor.battle_commands
    # Sort Commands
    @commands.sort_by! {|command| [command.rating, command.id]}
    # If Self Contents is defined
    if self.contents != nil 
      # Dispose Contents
      self.contents.dispose
      # Setup Hieght
      self.height = [160, @commands.size * 32 + 32].min
      # Setup Contents
      self.contents = Bitmap.new(width - 32, @commands.size * 32)
      # Setup Y Coordinate
      self.y = 160 + (4 - [4, @commands.size].min) * 32
    end
    # Get Item Max
    @item_max = @commands.size
    # Draw Item
    @item_max.times {|i| draw_item(i)}
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    # Set Color to Normal Color
    self.contents.font.color = normal_color
    # Set Font Size
    self.contents.font.size = 22
    # Get Command
    command = @commands[index]
    # Set Font Color if disabled
    self.contents.font.color = command.disabled ? disabled_color : normal_color
    # Set Font Color if out of ammo
    self.contents.font.color = command.sp == 0 ? disabled_color : normal_color
    # Setup Rectangle
    rect = Rect.new(4, 32 * index, self.contents.width - 16, 32)
    # Clears Contents at Rectangle
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    # If Commands Icon Name is Defined
    if not command.icon_name.empty?
      # Get Bitmap
      bitmap = RPG::Cache.icon(command.icon_name)
      # Setup Opacity
      opacity = self.contents.font.color == normal_color ? 255 : 128
      # Call Full Block Transfer
      self.contents.full_blt(rect.x, rect.y + 16-bitmap.height/2, bitmap, opacity)
      # Increase X
      rect.x += bitmap.width + 4
    end
    # Setup Name and Define New_Name
    name, new_name = command.name, nil
    # Run Trough Keys Defined in Name_Set in Reverse Order
    # Whatever is Defined First in the Hash has the Highest Priority
    command.name_set.keys.reverse_each do |type|
      # Initialize a hash (Local Block Variable)
      hash = {}
      # Setup Each Type
      hash['actor'] = @actor.id
      hash['class'] = @actor.class_id
      hash['weapon'] = @actor.weapon_id
      hash['shield'] = @actor.armor1_id
      hash['helmet'] = @actor.armor2_id
      hash['body'] = @actor.armor3_id
      hash['accessory'] = @actor.armor4_id
      hash['level'] = @actor.level
  113 [I][B]new_name = battle_command.name_set[type][hash[type]][/B][/I]
    end
    # Overidde if new_name is not nil
    name = new_name if new_name != nil
    # Draw Text
    self.contents.draw_text(rect, name)
    # Return if no ammo type
    return if command.ammo_type == nil
    # Set Color to Normal Color
    self.contents.font.color = normal_color
    # Set Font Size
    self.contents.font.size = 16
    # Setup Ammo Text
    text = "#{command.sp} / #{command.maxsp}" if command.ammo_type == 'sp'
    text = "#{command.sp}" if command.ammo_type == 'item'
    # Draw Ammo Text
    self.contents.draw_text(4, 32 * index, self.contents.width-8, 32, text, 2)
  end
  #--------------------------------------------------------------------------
  # * Update Help Window Text and Visibility
  #--------------------------------------------------------------------------
  def update_help
    # Return if Help Window is nil
    return if @help_window == nil
    @help_window.set_text(self.command.description, 1)
    @help_window.visible = !self.command.description.empty?
  end
end

class Window_Skill < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  alias commands_initialize initialize
  def initialize(actor)
    @command = actor.current_action.command if $scene.is_a?(Scene_Battle)
    commands_initialize(actor)
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias commands_refresh refresh
  def refresh
    commands_refresh
    # Return if additions are not needed
    return if (not $game_temp.in_battle or 
              (@command.skills.empty? and @command.skill_set.empty?))
    # Dispose the contents and reset
    self.contents.dispose
    self.contents = nil
    # Reset Data
    @data = []
    # If Skills Parameter is not used
    if @command.skills.empty?
      # Run Through Each Skill
      @actor.skills.each do |skill_id|
        # Get Corresponding RPG::Skill Object
        skill = $data_skills[skill_id]
        # Add Skill if skill is valid and skill_set evaluates to true
        @data << skill if skill != nil and eval(@command.skill_set)
      end
    # If an Array of Skill Ids were given
    elsif @command.skills.is_a?(Array)
      # Add Each RPG::Skill Object onto data
      @command.skills.each {|skill_id| @data << $data_skills[skill_id]}
    # If an Condition String was given
    elsif @command.skills.is_a?(String)
      $data_skills.each_with_index do |skill, index|
        # Next Index is 0 or Skill is nil
        next if index == 0 or skill == nil
        # Push RPG::Skill object onto data if @command.skills evaluates to true
        @data << skill if eval(@command.skills)
      end
    # If a Hash Given (Advanced)
    elsif @command.skills.is_a?(Hash)
      # Call Each With Index
      $data_skills.each_with_index do |skill, index|
        # Next if Index is 0 or Skill id is not included in hash or skill is nil
        next if index == 0 or not @command.skills.keys.include?(index) or skill == nil
        # If an Array of Level, Actor Id Pairs Was Given
        if @command.skills[index].is_a?(Array)
          # Get Level and Actor Id
          level, actor_id = @command.skills[index]
          # Add to Data If Actor's level is at least the level and right actor id
          @data << skill if @actor.level >= level and @actor.id == actor_id
        # If A Condition String was Given
        elsif @command.skills[index].is_a?(String)
          # Add to Data if Condition evaluates to true
          @data << skill if eval(@command.skills[index])
        # If Level Was Given
        elsif @command.skills[index].is_a?(Numeric)
          # Add to Data if Level is at least the level given
          @data << skill if @actor.level >= @command.skills[index]
        end
      end
    end
    # Sort All Items By Skill Id
    @data.sort_by! {|skill| skill.id}
    # Set Item Max
    @item_max = @data.size
    # If item count is not 0, make a bitmap and draw all items
    if @item_max > 0
      # Create Bitmap
      self.contents = Bitmap.new(width - 32, row_max * 32)
      # Draw Each Item
      @item_max.times {|i| draw_item(i)}
    end
  end
end

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias commands_initialize initialize
  def initialize
    @command = $scene.active_battler.current_action.command if $scene.is_a?(Scene_Battle)
    commands_initialize
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias commands_refresh refresh
  def refresh
    commands_refresh
    # Return if additions are not needed
    return if not $scene.is_a?(Scene_Battle) or @command.skill_set.empty?
    # Dispose the contents and reset
    self.contents.dispose
    self.contents = nil
    # Reset Data
    @data = []
    # Run Through All Items
    $data_items.each_with_index do |item, index|
      # If has item and Item Set (Skill Set) evaluates to true
      cond = $game_party.item_number(index) > 0 and eval(@command.skill_set)
      # Add item is condition is true
      @data << item if cond
    end
    # Get Item Count
    @item_max = @data.size
    # If item count is not 0, make a bit map and draw all items
    if @item_max > 0
      # Setup Bitmap
      self.contents = Bitmap.new(width - 32, row_max * 32)
      # Draw Each Item
      @item_max.times {|i| draw_item(i)}
    end
  end
end
#--------------------------------------------------------------------------
# End SDK Enabled Check
#--------------------------------------------------------------------------
end
 

Jonny

Member

Alright here it is:

Code:
#This text is not parsed by the script
#Remember Here Are the Default Values
#
#id              	Must be declared
#name            	Must be declared
#name_set	 	{}
#kind            	Must be declared
#type            	0
#rating          	10
#icon_name       	''
#skill_id        	0
#common_event_id    	0
#animation_id    	0
#weapon_ids      	[]
#armor_ids       	[]
#ammo			{}
#ammo_refill		{}
#skill_set       	''
#skills          	[]
#class_level     	{}
#actor_level     	{}
#description     	''
#help_text       	''
#special_learn    	'false'
#hidden          	false
#script          	''
#next_method     	phase3_next_actor
#
#
#
#
# 1) Id - Required
# 	The command's id 
#       syntax: Integer id
#
# 2) Name - Required
# 	The command's name 
#       Syntax: String name - name of the command (don't enclose in '' or "")
#
# 3) Name Set
#       The command's other names
#         How you define the names determines the priority of the name chosen
#	  example
#	  {'actor' => {1 => 'Smile', 2 => 'Frown'},'class' => {1 => 'Anger'}}
#	  Now here are the heros
#	  Actor id 1 class 1	resulting name Smile
#	  Actor id 2 class 1	resulting name Frown
#	  Actor id 1 class 2	resulting name Anger
#	  Actor id 3 class 1	resulting name Anger
#	  Actor id 3 class 4	resulting name Default Name
#	  Actor id 2 class 2	Resulting name Frown
#
#	  parameters can include actor, class, weapon, shield, helmet, body, accessory, and level
#       Syntax: A Hash setup like so {parameter => value}
#
# 3) Kind - Required
# 	The command's kind 
#       0: Basic Action (see type) 1: Skill 2: Item
#       Syntax: Integer kind - the commands kind
#
# 4) Type
# 	The command's type 
#       0: Attack, 1: Defend 2: Escape (Enemies) 3: Do Nothing 
#	Syntax: Integer type - the commands type
#
# 5) Rating
# 	The command's rating higher rated commands will appear on the top
#       if the ratings are the same then the id is compared and lower ids have higher priority
#	Syntax: Integer rating - the command's rating
#	
# 6) Icon Name
# 	The command's icon name from Graphics/Icons
#       Syntax: String icon_name - the commands icon name
#
# 7) Skill Id
# 	The command's skill id
#	Syntax: Integer skill_id - the skill id executed when using this command
#
# 8) Common Event Id
# 	The command's common event id
#	Syntax: Integer common_event_id - the common event executed when using this command
#
# 9) Animation Id
# 	The command's animation id
#	For custom commands set this to the animation id to be played when using the command
#	Syntax: Integer animation id
#
# 10) Weapon Ids
# 	Weapon Ids that this command is tagged to must be an array
#	Syntax: Array of Weapon ids
#
# 11) Armor Ids
# 	The armor ids same as weapon ids
#	Syntax: Array of Armor ids
#
# 12) Skill Set
# 	The skill set for use in categorizing the skill list 
#	for example all fire skills will be skill.element_set.include?(1)
#	You may also use this to work for items
#	Syntax: String - condition evaluated 
#
# 13) Skills - Advanced
# 	The usable skill list see Below for more stuff on this
#
# 14) Ammo
#	Flag determining whether the command has ammo or not
#       For Command Sp depending on a value then use {'sp' => maximum sp}
#       For command Sp depending on an item then use {'item' => item_id}
#	Syntax: Hash set up like above
#
# 15) Ammo Refill
#	Flags determining when the commands sp refills (only for sp depending on an value)
#	Current Flags are the following (add as many to the hash as you want):
#	  'defend' => [amount, percentage]    	     - Refills when defending
#	  'wait' => [amount, percentage]      	     - Refills when waiting
#	  'full_heal' => [amount, percentage] 	     - Refills with Recover All Event Command
#	  'battle' => [amount, percentage]    	     - Refills at the end of battle
#         'level_up' => [amount, percentage]  	     - Refills at level up
#	  'turns' => [amount, percentage, a, b, ...] - Refills on turn a, b, and on if defined
#	  'turn' => [amount, percentage, a, b]	     - Refills on turn a + bx
#	  'skill' => {id => [amount, percentage]}    - Refills if skill id id was used (and successful)
#	  'item' => {id => [amount, percentage]}     - Refills if item id id was used (and successful)
#	Syntax: Hash set up like above 
#
#	  
# 16) Class Level
# 	The class level set must be a hash set up like this {class_id => level, class2_id =>level2, ...}
#	Syntax: Hash
#
# 17) Actor Level
# 	The actor level set same as above except {actor_id => level, actor2_id => level2, ...}
#	Syntax: Hash
#
# 18) Description 
# 	The Description of the command 
#	Syntax: String - Description of the command (do not enclose in "" or '')
#
# 19) Help Text
# 	The Help Window Text Displayed when using the command
#	Syntax: String - Help Widnow Text displayed (do not enclose in "" or '')
#
# 20) Special Learn
# 	The special condition must be a boolean expression 
#	for example if you want the Arshes to learn this in battle while he has less than 100 hp
#	then the condition will be (actor.id == 1 and actor.hp <= 100)
#	Syntax: String - script condition to be evaluated
#
# 21) Hidden 
#	if the command is hidden set this to true
#	Syntax: Boolean - true if hidden false if not (Default is false)
#
# 22) Script - Advanced
#	Enter a script here separating lines by using a semicolon ( ; )
#	you may replace @active_battler with just actor 
#	example heal 100 sp when using the command is actor.sp += 100; actor.damage = -100; actor.damage_pop = true; @status_window.refresh
#	Syntax: String - script condition to be evaluated
#
# 23) Next Method
#  	The next method called after selecting the command
#	Syntax: String - next method to be evaluated
#
#
#The Skills Parameter
#You may enter a string, an array, or a hash here
#
#Array
#This array contains all of the skill ids the command can use great for if you want certain skills for a command
#
#String
#Example skill.element_set.include?(1) will make the command contain all fire skills
#the string holds a condition that is passed through each skill if true then the skill will be on the list
#
#Hash
#a bit more complicated but alot more powerful
#  Integer value case 1 { skill.id => value, skill.id => value}
#   in this case value is the minimum level required to use the skill
#
#  Array for value case 2 {skill.id => [v1,v2]}
#   in this case v1 is the minumum level required to use the skill and v2 is the actor id that can use the skill
#
#  String for value case 3 {skill.id => "condition"}
#  in this case the string condition is evaluated and if true then the skill can be used for more advanced effects



#--------------------------------------------------------------------------
# * Command Id 1  : Attack
#   Description   : Just the normal attack command, nothing else
#--------------------------------------------------------------------------
id		1
name		Attack
special_learn	!actor.limitbreak <= 1000
kind		0
next_method	start_enemy_select

#--------------------------------------------------------------------------
# * Command Id 2  : Skill
#   Description   : Just the normal skill command, nothing else
#--------------------------------------------------------------------------
id		2
name		Skill
name_set	{'actor' => {7 => 'Magic', 8 => 'Magic'}}
kind		1
next_method	start_skill_select

#--------------------------------------------------------------------------
# * Command Id 3  : Defend
#   Description   : Just the normal defend command, nothing else
#--------------------------------------------------------------------------
id		3
name		Defend
kind		0
type		1

#--------------------------------------------------------------------------
# * Command Id 4  : Item
#   Description   : Just the normal item command, nothing else
#--------------------------------------------------------------------------
id		4
name		Item
kind		2
next_method	start_item_select

#--------------------------------------------------------------------------
# * Command Id 5  : Regenerate
#   Description   : This command regenerates some hp, It has help text and
#                   Displays an animation the type being set to 3 is there to
#                   do a "Do Nothing" Action
#--------------------------------------------------------------------------
id		5
name		Regenerate
kind		0
type		3
help_text	Regenerate
animation_id	16
script		hp = (actor.maxhp - actor.hp) / 15; actor.hp += hp; actor.damage = -hp; actor.damage_pop = true; @status_window.refresh

#--------------------------------------------------------------------------
# * Command Id 6  : Will
#   Description   : This command regenerates some sp, It has help text and
#                   Displays an animation the type being set to 3 is there to
#                   do a "Do Nothing" Action
#--------------------------------------------------------------------------
id		6
name		Will
kind		0
type		3
help_text	Will
animation_id	18
script		sp = rand(actor.maxsp / 15 + 1) + 5; actor.sp += sp; actor.damage = -sp; actor.damage_pop = true; @status_window.refresh

#--------------------------------------------------------------------------
# * Command Id 7  : Holy
#   Description   : This command comes with the skills Light, Greater Light
#		    and Mass Light. Three uses only.
#--------------------------------------------------------------------------
id		7
name		Holy
kind		1
skills		{25 => 1, 26 => 2, 27 => 3}
ammo		{'sp' => 3}
next_method	start_skill_select

#--------------------------------------------------------------------------
# * Command Id 8  : Elemental
#   Description   : This command comes with all skills that have Fire,
#	            Water, or Thunder element. This also uses a method
#                   From the Method and class Library called includes_any?
#                   Which returns true if any of the values sent is included
#		    Six Uses, and refills one if you defend.
#--------------------------------------------------------------------------
id		8
name		Elemental
kind		1
skills		skill.element_set.includes_any?(1,3,4)
ammo		{'sp' => 6}
ammo_refill	{'defend' => [1,0]}
next_method	start_skill_select

#--------------------------------------------------------------------------
# * Command Id 9  : Paralyze
#   Description   : This Command Comes with the item Ring of Thunder
#                   It calls the skill Mass Paralyze when used
#--------------------------------------------------------------------------
id		9
name		Paralyze
kind		1
skill_id	44
armor_ids	[31]

#--------------------------------------------------------------------------
# * Command Id 10 : Fire Starter
#   Description   : This Command Just Displays the Fire Skills the actor 
#                   knows
#--------------------------------------------------------------------------
id		10
name		Fire Starter
kind		1
skill_set	skill.element_set.include?(1)
next_method	start_skill_select

#--------------------------------------------------------------------------
# * Command Id 11 : Full Healing
#   Description   : This Command Appears Randomly in Gloria's Commands
#                   This command recovers all health and has a 10% chance
#                   of appearing
#--------------------------------------------------------------------------
id		11
name		Full Healing
kind		0
type		3
special_learn	actor.id == 7 && rand(100) < 10
script		actor.recover_all
help_text	Full Healing
animation_id	22

#--------------------------------------------------------------------------
# * Command Id 12 : Limit Break
#   Description   : Limit Break skill when bar is full
#--------------------------------------------------------------------------
id		12
name		Limit Break
kind		0
special_learn	actor.limitbreak == 1000
skill_set	skill.element_set.include?(17)
next_method	start_skill_select

#--------------------------------------------------------------------------
# * Command Id 13 : Summon
#   Description   : Summons powerful creatures or spirits
#--------------------------------------------------------------------------
id		13
name		Summon
kind		0
skill_set	skill.element_set.include?(18)
next_method	start_skill_select
When I take the ! away after special_learn in attack the error doesn't appear but attack doesn't go away when the limit break is full.
 
Yeah precedence got you there the ! is done first and !(Integer) returns false and then that gets compared to the other Integer causing your error

use parenthesis to change it to this

Code:
!(actor.limitbreak <= 1000)

or better yet

Code:
actor.limitbreak > 1000

I flipped the condition so that you don't need the ! anymore
 
Status
Not open for further replies.

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