Chain Skill System questions

Started by element, March 28, 2012, 10:02:22 am

Previous topic - Next topic

element

Hello guys.
I'm making my first rgss script but I still have some questions.
It is supposed to be a chain skill system, you press four or less buttons in an order and then it unleashes the skill.
I dont know yet how to unleash the skill so I put print commands instead to test it.

Warning:
this is my first ever script so I know that there's probably a lot wrong and it could be done much simpler, but show some support.
Any ideas on how to improve it are deeply appreciated.


Code:
Spoiler: ShowHide
##################################
#     - Chain Skill System -     #
#       By  Element Island       #
##################################

# Scene_Map #
class Scene_Map
  # Declaring variables #
  $SkillID = 0
  $CycleCounter = 0   # set initial cycle to one
  $CurrentChain = 0
  @ChainOne = 0
  @ChainTwo = 0
  @ChainThree = 0
  @ChainFour = 0
  # update alias #
  alias :update_CSS :update
  def update
    # Button press check #
    # A button #
    if Input.trigger?(Input::Key['A'])
      $CurrentChain += 1
      $CycleCounter = 0 if $CurrentChain == 1
      if $CurrentChain == 1
        @ChainOne = 1
        @Button_Icon_One = Sprite.new
        @Button_Icon_One.bitmap = Bitmap.new("Graphics/Pictures/Abutton.png")
        @Button_Icon_One.x = 252
        @Button_Icon_One.y = 280
      elsif $CurrentChain == 2
        @ChainTwo = 1
        @Button_Icon_Two = Sprite.new
        @Button_Icon_Two.bitmap = Bitmap.new("Graphics/Pictures/Abutton.png")
        @Button_Icon_Two.x = 300
        @Button_Icon_Two.y = 280
      elsif $CurrentChain == 3
        @ChainThree = 1
        @Button_Icon_Three = Sprite.new
        @Button_Icon_Three.bitmap = Bitmap.new("Graphics/Pictures/Abutton.png")
        @Button_Icon_Three.x = 348
        @Button_Icon_Three.y = 280
      elsif $CurrentChain == 4
        @ChainFour = 1
        @Button_Icon_Four = Sprite.new
        @Button_Icon_Four.bitmap = Bitmap.new("Graphics/Pictures/Abutton.png")
        @Button_Icon_Four.x = 396
        @Button_Icon_Four.y = 280
      end
    # Z button #
    elsif Input.trigger?(Input::Key['Z'])
      $CurrentChain += 1
      $CycleCounter = 0 if $CurrentChain == 1
      if $CurrentChain == 1
        @ChainOne = 2
        @Button_Icon_One = Sprite.new
        @Button_Icon_One.bitmap = Bitmap.new("Graphics/Pictures/Zbutton.png")
        @Button_Icon_One.x = 252
        @Button_Icon_One.y = 280
      elsif $CurrentChain == 2
        @ChainTwo = 2
        @Button_Icon_Two = Sprite.new
        @Button_Icon_Two.bitmap = Bitmap.new("Graphics/Pictures/Zbutton.png")
        @Button_Icon_Two.x = 300
        @Button_Icon_Two.y = 280
      elsif $CurrentChain == 3
        @ChainThree = 2
        @Button_Icon_Three = Sprite.new
        @Button_Icon_Three.bitmap = Bitmap.new("Graphics/Pictures/Zbutton.png")
        @Button_Icon_Three.x = 348
        @Button_Icon_Three.y = 280
      elsif $CurrentChain == 4
        @ChainFour = 2
        @Button_Icon_Four = Sprite.new
        @Button_Icon_Four.bitmap = Bitmap.new("Graphics/Pictures/Zbutton.png")
        @Button_Icon_Four.x = 396
        @Button_Icon_Four.y = 280
      end
    # E button #
    elsif Input.trigger?(Input::Key['E'])
      $CurrentChain += 1
      $CycleCounter = 0 if $CurrentChain == 1
      if $CurrentChain == 1
        @ChainOne = 3
        @Button_Icon_One = Sprite.new
        @Button_Icon_One.bitmap = Bitmap.new("Graphics/Pictures/Ebutton.png")
        @Button_Icon_One.x = 252
        @Button_Icon_One.y = 280
      elsif $CurrentChain == 2
        @ChainTwo = 3
        @Button_Icon_Two = Sprite.new
        @Button_Icon_Two.bitmap = Bitmap.new("Graphics/Pictures/Ebutton.png")
        @Button_Icon_Two.x = 300
        @Button_Icon_Two.y = 280
      elsif $CurrentChain == 3
        @ChainThree = 3
        @Button_Icon_Three = Sprite.new
        @Button_Icon_Three.bitmap = Bitmap.new("Graphics/Pictures/Ebutton.png")
        @Button_Icon_Three.x = 348
        @Button_Icon_Three.y = 280
      elsif $CurrentChain == 4
        @ChainFour = 3
        @Button_Icon_Four = Sprite.new
        @Button_Icon_Four.bitmap = Bitmap.new("Graphics/Pictures/Ebutton.png")
        @Button_Icon_Four.x = 396
        @Button_Icon_Four.y = 280
      end
    # R button #
    elsif Input.trigger?(Input::Key['R'])
      $CurrentChain += 1
      $CycleCounter = 0 if $CurrentChain == 1
      if $CurrentChain == 1
        @ChainOne = 4
        @Button_Icon_One = Sprite.new
        @Button_Icon_One.bitmap = Bitmap.new("Graphics/Pictures/Rbutton.png")
        @Button_Icon_One.x = 252
        @Button_Icon_One.y = 280
      elsif $CurrentChain == 2
        @ChainTwo = 4
        @Button_Icon_Two = Sprite.new
        @Button_Icon_Two.bitmap = Bitmap.new("Graphics/Pictures/Rbutton.png")
        @Button_Icon_Two.x = 300
        @Button_Icon_Two.y = 280
      elsif $CurrentChain == 3
        @ChainThree = 4
        @Button_Icon_Three = Sprite.new
        @Button_Icon_Three.bitmap = Bitmap.new("Graphics/Pictures/Rbutton.png")
        @Button_Icon_Three.x = 348
        @Button_Icon_Three.y = 280
      elsif $CurrentChain == 4
        @ChainFour = 4
        @Button_Icon_Four = Sprite.new
        @Button_Icon_Four.bitmap = Bitmap.new("Graphics/Pictures/Rbutton.png")
        @Button_Icon_Four.x = 396
        @Button_Icon_Four.y = 280
      end
    end

    # Skill execution #
    if $CycleCounter == 50 or $CurrentChain >= 4
     
      print "Wind Fire Earth" if @ChainOne == 1 and @ChainTwo == 4 and @ChainThree == 3
      print "Wind Wind" if @ChainOne == 1 && @ChainTwo == 1
      @ChainOne = 0
      @ChainTwo = 0
      @ChainThree = 0
      @ChainFour = 0
      $CycleCounter = 0
      $CurrentChain = 0
      @Button_Icon_One.clear
      @Button_Icon_Two.clear
      @Button_Icon_Three.clear
      @Button_Icon_Four.clear
    end
    # frame counter #
    $CycleCounter += 1
    update_CSS
  end
end


First question:
I tried to find out how to unleash a skill but I cant seem to figure out how to.

Second question:
In the code you see that I have 4 images that need to pop up, though, when the skill is used, I want those images te be cleared.
Now, this wont work, it gives me an error and says that it cant find the .clear module for @Button_Icon_One.
So, I guess that it doesnt know what the variable is but I still dont understand.

KK20

March 28, 2012, 11:22:43 am #1 Last Edit: March 28, 2012, 06:42:15 pm by KK20
Force game player to use a skill:
s = $data_skills[id]
$game_player.use_skill(s, true)
Remove 'true' if you don't want the skill to be forced.
Try 'dispose' instead of 'clear'.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!