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.

pleaaaase help me with this cross comand script

first,here is the script :
#==============================================================================
#  CrossCommand

#  Blazingamer
#  -----------------------------------------
#  Makes a pretty command window in a shape of a cross like in Wild Arms
#==============================================================================

class CrossCommand < Window_Selectable

  def initialize
super(320 - 128, 160 - 128, 256, 256)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@commands = ["attack", "magic","defend","items","run away"]
@item_max = 5

self.active = false
self.visible = false
self.index = 0
  end
 
  def update_cursor_rect
if index == 0
  self.cursor_rect.set(0, 0, 0, 0)

end
if Input.press?(Input::LEFT)
  @index = 3
elsif Input.press?(Input::RIGHT)
  @index = 2
elsif Input.press?(Input::UP)
  @index = 1
elsif Input.press?(Input::DOWN)
  @index = 4
else
  @index = 0
    @command1 = Sprite.new
    @command1.bitmap = RPG::Cache.icon("cross")
    @command1.y=148
    @command1.x=238
end
  end
  end
class Scene_Battle
 
  def update_phase3_basic_command
if Input.trigger?(Input::B)
  $game_system.se_play($data_system.cancel_se)
  phase3_prior_actor
  return
end
 
  case @actor_command_window.index
  when 0
  @cursor= Sprite.new
@cursor.bitmap = RPG::Cache.icon("bt")
  @cursor.x = 180
  @cursor.y = 171
 
  when 1
  @cursor= Sprite.new 
@cursor.bitmap = RPG::Cache.icon("abl")
@cursor.x = 245
  @cursor.y = 100
  when 2
  @cursor= Sprite.new 
@cursor.bitmap = RPG::Cache.icon("def")
  @cursor.y = 171
  @cursor.x = 290
  when 3
  @cursor= Sprite.new   
@cursor.bitmap = RPG::Cache.icon("ex")
@cursor.y = 171
  @cursor.x = 140
  when 4
  @cursor= Sprite.new   
  @cursor.bitmap = RPG::Cache.icon("item")
@cursor.x = 245
  @cursor.y = 196
end

if Input.trigger?(Input::C)
  @cursor.dispose
  case @actor_command_window.index
  when 0
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 0
start_enemy_select
  when 1
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 1
start_skill_select
  when 2
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 0
@active_battler.current_action.basic = 1
phase3_next_actor
  when 3
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.kind = 2
start_item_select
  when 4
enemies_agi = 0
enemies_number = 0
for enemy in $game_troop.enemies
  if enemy.exist?
enemies_agi += enemy.agi
enemies_number += 1
  end
end
if enemies_number > 0
  enemies_agi /= enemies_number
end
actors_agi = 0
actors_number = 0
for actor in $game_party.actors
  if actor.exist?
actors_agi += actor.agi
actors_number += 1
  end
end
if actors_number > 0
  actors_agi /= actors_number
end
success = rand(100) < 50 * actors_agi / enemies_agi
if success
  $game_system.se_play($data_system.escape_se)
  $game_system.bgm_play($game_temp.map_bgm)
  battle_end(1)
else
  $game_party.clear_actions
  start_phase4
end
  end
  return
end
  end
end

the problem is  probably here
case @actor_command_window.index
  when 0
  @cursor= Sprite.new
@cursor.bitmap = RPG::Cache.icon("bt")
  @cursor.x = 180
  @cursor.y = 171
 
  when 1
  @cursor= Sprite.new 
@cursor.bitmap = RPG::Cache.icon("abl")
@cursor.x = 245
  @cursor.y = 100
  when 2
  @cursor= Sprite.new 
@cursor.bitmap = RPG::Cache.icon("def")
  @cursor.y = 171
  @cursor.x = 290
  when 3
  @cursor= Sprite.new   
@cursor.bitmap = RPG::Cache.icon("ex")
@cursor.y = 171
  @cursor.x = 140
  when 4
  @cursor= Sprite.new   
  @cursor.bitmap = RPG::Cache.icon("item")
@cursor.x = 245
  @cursor.y = 196
end

that is how the cursor should be working but for some reason if i go to item for example and then skill
the item cursor remains there and i get the skill cursor. how do i fix that.i am using the same method for cms and the cusor works fine there.



here is a demo if you don't get what i say

http://www.megaupload.com/?d=47S0027A

you will notice that the cursor 's older pic will disapear only after a while i want it to happen immediately

Please don't double post. ~ Atemu
 

khmp

Sponsor

Replace the Scene_Battle portion below the Cross_Command class with this:
Code:
class Scene_Battle
  alias_method :joda_crosscommand_scene_battle_main, :main
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Create the cross cursor but make it invisible till it's needed.
    @cross = Sprite.new
    @cross.bitmap = RPG::Cache.icon("cross")
    @cross.y = 148
    @cross.x = 238
    @cross.z = 8
    @cross.visible = false
    
    # Create the sprite responsible for drawing the active selection 
    # of the user.
    @cross_cursor = Sprite.new
    @cross_cursor.z = 9
    
    # Call the old main's code.
    joda_crosscommand_scene_battle_main
    
    # Dispose of our assets.
    @cross.bitmap.dispose unless @cross.bitmap.disposed?
    @cross.dispose unless @cross.disposed?
    
    unless @cross_cursor.bitmap.nil?
      @cross_cursor.bitmap.dispose unless @cross_cursor.bitmap.disposed?
    end
    @cross_cursor.dispose unless @cross_cursor.disposed?
  end
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase : basic command)
  #--------------------------------------------------------------------------
  def update_phase3_basic_command
    @cross.bitmap = RPG::Cache.icon("cross") if @cross.bitmap.nil?
    @cross.visible = true
    
    case @actor_command_window.index
    when 0
      @cross_cursor.bitmap = RPG::Cache.icon("bt")
      @cross_cursor.x = 180
      @cross_cursor.y = 171
    when 1
      @cross_cursor.bitmap = RPG::Cache.icon("abl")
      @cross_cursor.x = 245
      @cross_cursor.y = 100
	  when 2
      @cross_cursor.bitmap = RPG::Cache.icon("def")
      @cross_cursor.y = 171
      @cross_cursor.x = 290
	  when 3
      @cross_cursor.bitmap = RPG::Cache.icon("ex")	
      @cross_cursor.y = 171
      @cross_cursor.x = 140
	  when 4
      @cross_cursor.bitmap = RPG::Cache.icon("item")
      @cross_cursor.x = 245
      @cross_cursor.y = 196
    end
    
    @cross_cursor.update unless @cross_cursor.bitmap.disposed?
	
    if Input.trigger?(Input::C)
      @cross_cursor.bitmap.dispose
      @cross.visible = false
      case @actor_command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        start_enemy_select
      when 1
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        start_skill_select
      when 2
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        phase3_next_actor
      when 3
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 2
        start_item_select
      when 4
        enemies_agi = 0
        enemies_number = 0
        for enemy in $game_troop.enemies
          if enemy.exist?
          enemies_agi += enemy.agi
          enemies_number += 1
          end
        end
        if enemies_number > 0
          enemies_agi /= enemies_number
        end
        actors_agi = 0
        actors_number = 0
        for actor in $game_party.actors
          if actor.exist?
          actors_agi += actor.agi
          actors_number += 1
          end
        end
        if actors_number > 0
          actors_agi /= actors_number
        end
        success = rand(100) < 50 * actors_agi / enemies_agi
        if success
          $game_system.se_play($data_system.escape_se)
          $game_system.bgm_play($game_temp.map_bgm)
          battle_end(1)
        else
          $game_party.clear_actions
          start_phase4
        end
      end
      return
    end
  end
end

Good luck with it joooda! :thumb:
 

khmp

Sponsor

I do appreciate the offer but I'm good thanks though. You might instead want to release it to the public inside Submitted Scripts section of this forum when it is finished, if you weren't intending on doing that already. I'm just glad I was able to help you out. If you do wanna know the basics of where it was going wrong. It was that the bitmaps held within the cursor sprite were never being disposed of. So they would wait around until the program performs garbage cleanup and gets rid of them.

Tangent: As an owner of Wild Arms 3 it was very cool to see that so thank you.

Good luck with your scripting joooda! :thumb:
 
here is the somewhat final form of the script i added the charge comand and the  examine comand.
and you can't escape if you can't escape.
but i still need help with one last thing and that is when you pick attack and then you cancel it , well you're stuck.
Code:
class CrossCommand < Window_Selectable

  def initialize
	super(320 - 128, 160 - 128, 256, 256)
	self.contents = Bitmap.new(width - 32, height - 32)
	self.opacity = 0
	@commands = ["attack", "magic","defend","items","run away","examine"]
	@item_max = 7
	
	self.active = false
	self.visible = false
	self.index = 0
  end
  
  def update_cursor_rect
	if index == 0
	  self.cursor_rect.set(0, 0, 0, 0)
  
	end
	if Input.press?(Input::LEFT)
 
	  @index = 3
	elsif Input.press?(Input::RIGHT)
     
	  @index = 2
	elsif Input.press?(Input::UP)
     
	  @index = 1
	elsif Input.press?(Input::DOWN)
    
	  @index = 4
	elsif Input.press?(Input::B)
    
    @index = 5
   elsif Input.press?(Input::A)
    @index = 6
  else
    
	  @index = 0
  
	end
  end
  end
class Scene_Battle
  
  def update_phase3_basic_command
	
  
  
	
	if Input.trigger?(Input::C)
@cursor.bitmap = RPG::Cache.icon("")
  @command1.bitmap = RPG::Cache.icon("")
	  case @actor_command_window.index
	  when 0
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 0
		@active_battler.current_action.basic = 0
		start_enemy_select
	  when 1
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 1
		start_skill_select
	  when 2
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 0
		@active_battler.current_action.basic = 1
		phase3_next_actor
	  when 3
		$game_system.se_play($data_system.decision_se)
		@active_battler.current_action.kind = 2
		start_item_select
     
	  when 4
		enemies_agi = 0
		enemies_number = 0
		for enemy in $game_troop.enemies
		  if enemy.exist?
			enemies_agi += enemy.agi
			enemies_number += 1
		  end
		end
		if enemies_number > 0
		  enemies_agi /= enemies_number
		end
		actors_agi = 0
		actors_number = 0
		for actor in $game_party.actors
		  if actor.exist?
			actors_agi += actor.agi
			actors_number += 1
		  end
		end
		if actors_number > 0
		  actors_agi /= actors_number
		end
		success = rand(100) < 50 * actors_agi / enemies_agi
		if success
		  $game_system.se_play($data_system.escape_se)
		  $game_system.bgm_play($game_temp.map_bgm)
		  battle_end(1)
		else
		  $game_party.clear_actions
		  start_phase4
    end
    when 5 
     if  rand(99) <30
       @active_battler.state?(3) 
      end
       phase3_next_actor
		end
	  end
	  return
	end
  end

Code:
   class Scene_Battle
  alias_method :joda_crosscommand_scene_battle_main, :main
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def sg_phase2_allbasic(sg_temp)
    $game_system.se_play($data_system.decision_se)
    for i in $game_party.actors
      i.current_action.kind = 0
      i.current_action.basic = 0
    end
    start_phase4
  end
  
  def sg_phase2_lastaction
    $game_system.se_play($data_system.decision_se)
    for i in $game_party.actors
        i.current_action.kind = 0
        i.current_action.basic = 0
      end
    end
  
  
  def main
    
    # Create the cross cursor but make it invisible till it's needed.
    @cross = Sprite.new
    @cross.bitmap = RPG::Cache.icon("cross")
    @cross.y = 148
    @cross.x = 238
    @cross.z = 8
    @cross.visible = false
    
    # Create the sprite responsible for drawing the active selection 
    # of the user.
    @cross_cursor = Sprite.new
    @cross_cursor.z = 9
    
    # Call the old main's code.
    joda_crosscommand_scene_battle_main
    
    # Dispose of our assets.
    @cross.bitmap.dispose unless @cross.bitmap.disposed?
    @cross.dispose unless @cross.disposed?
    
    unless @cross_cursor.bitmap.nil?
      @cross_cursor.bitmap.dispose unless @cross_cursor.bitmap.disposed?
    end
    @cross_cursor.dispose unless @cross_cursor.disposed?
  end
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase : basic command)
  #--------------------------------------------------------------------------
  def update_phase3_basic_command
    @cross.bitmap = RPG::Cache.icon("cross") if @cross.bitmap.nil?
    @cross.visible = true
    
    case @actor_command_window.index
    when 0
      @cross_cursor.bitmap = RPG::Cache.icon("bt")
      @cross_cursor.x = 180
      @cross_cursor.y = 171
    when 1
      @cross_cursor.bitmap = RPG::Cache.icon("abl")
      @cross_cursor.x = 245
      @cross_cursor.y = 100
	  when 2
      @cross_cursor.bitmap = RPG::Cache.icon("def")
      @cross_cursor.y = 171
      @cross_cursor.x = 290
	  when 3
      @cross_cursor.bitmap = RPG::Cache.icon("ex")	
      @cross_cursor.y = 171
      @cross_cursor.x = 140
	  when 4
      @cross_cursor.bitmap = RPG::Cache.icon("item")
      @cross_cursor.x = 245
      @cross_cursor.y = 196
    when 5  
    @cross_cursor.bitmap = RPG::Cache.icon("esc")
      @cross_cursor.x = 293
      @cross_cursor.y = 115  
    when 6
      @cross_cursor.bitmap = RPG::Cache.icon("chg")
      @cross_cursor.x = 140
      @cross_cursor.y = 115  
    end
    
    @cross_cursor.update unless @cross_cursor.bitmap.disposed?
	
    if Input.trigger?(Input::C)
      @cross_cursor.bitmap.dispose
      @cross.visible = false
      case @actor_command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 0
        start_enemy_select
      when 1
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 1
        start_skill_select
      when 2
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
       	phase3_next_actor
      when 3  
         $game_system.se_play($data_system.decision_se)
         if rand(99) < 30
           @active_battler.add_state(3)
         end  
       phase3_next_actor
      when 4
        $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 2
        start_item_select
      when 5
         # If it's not possible to escape
        if $game_temp.battle_can_escape == false
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        enemies_agi = 0
        enemies_number = 0
        for enemy in $game_troop.enemies
          if enemy.exist?
          enemies_agi += enemy.agi
          enemies_number += 1
          end
        end
        if enemies_number > 0
          enemies_agi /= enemies_number
        end
        actors_agi = 0
        actors_number = 0
        for actor in $game_party.actors
          if actor.exist?
          actors_agi += actor.agi
          actors_number += 1
          end
        end
        if actors_number > 0
          actors_agi /= actors_number
        end
        success = rand(100) < 50 * actors_agi / enemies_agi
        if success
          $game_system.se_play($data_system.escape_se)
          $game_system.bgm_play($game_temp.map_bgm)
          battle_end(1)
        else
          $game_party.clear_actions
          start_phase4
        end
        when 6
         sg_phase2_allbasic(1)
      end
      return
    end
  end
end

here are the pics you don't have :
http://www.megaupload.com/?d=DVTLPOR8

khmp: Please use code tags around code.

EDIT : code tags ? what is that ?
 

khmp

Sponsor

{code}{/code} But in place of the curly brackets you would use square brackets, []. We try to encapsulate code in them to make it cleaner, maintain tabbing, and prevent emoticon bugs. I don't think emoticons are a problem now though.  :lol:

Anyway as for your problem. Its most likely due to some kind of Scene_Battle behavior we overwrote. And I'm assuming you mean like you can't backtrack to the previous character after selecting an action? I'll look into it.
 

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