RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Composite Characters + 8-way directional movement?

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 66
RMRK Junior
So, basically I want to know if there is a way to make Modern Algebra's Composite Characters script  http://rmrk.net/index.php?topic=28124.0 compatible with Kylock's 8-way directional movement script.
Sure, they do already work together as is, but not when you want to display a second spriteset, which represents your hero facing in diagonal directions(upperleft, upperright, lowerleft, lowerright) featured in the 8-directional script.

Here's basically what I want:

Let's say I'd equip an armor to my hero, that armor is shown on him as normally like the script lets me, but then when I move in a diagonal direction, the game will automatically change my heros graphic to a specified spriteset. At the same time the script will read what armor I'm wearing, and based on that armor change the armors graphic to a specified ID or something, or maybe just jump to the next character index(character_index + 1). Now it'll look like the hero is wearing the same armor even when moving in diagonal directions. (Ofcourse, change it back to normal again when conditions are no longer being met.)

If this could be done, or not, let me know. I really wanna know this.   :)

Also, here is Kylocks 8 Way Directional Movement script.(Credit Kylock)
Code: [Select]
==============================================================================
# 8 Way Directional Movement
#------------------------------------------------------------------------------
# Kylock
# 21.3.2008
# Version 1.1
#==============================================================================
# Special thanks to Arrow-1 for the script request and supplying sprites for
#   testing purposes.
#==============================================================================
# Instructions:
#    Add this script towards the top, since methods are rewritten and not
#      aliased.  Once you add it and run your game, the script will
#      automagically enable 8-way directional movement for your hero.
# Features:
#    * Added movement functionality to allow your hero to move in diagonal
#        directions
#    * Corrects directional issues resulting from trying to activate events
#        while facing a diaganol direction. (could be better implemented,
#        but does work as it is)
#==============================================================================
# Changelog
#   1.0 Initial Release
#   1.1 Added support for no custom sprites and added compatibility with
#         Anaryu's Anti-Lag script (must be loaded above the anti-lag script)
#==============================================================================

#==============================================================================
# ** Script Configuration
#==============================================================================
module KMDM
  DIRSPRITE = true     # set to true if you are using a custom
                             # character sprite for diagonal movement
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  rewrote def move_by-input to enable extra directions
#==============================================================================

class Game_Player < Game_Character
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    case Input.dir8
      when 1;  move_lower_left
      when 2;  move_down
      when 3;  move_lower_right
      when 4;  move_left
      when 7;  move_upper_left
      when 6;  move_right
      when 8;  move_up
      when 9;  move_upper_right
    end
  end
end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# Corrects direction so events will respond when hero is facing diagonal.
#  Modifies: def move_lower_left, def move_lower_right, def move_upper_left,
#            and def move_upper_right
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  def move_lower_left(turn_ok = true)
    set_direction(5)
    if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y+1))
      @x -= 1
      @y += 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right(turn_ok = true)
    set_direction(3)
    if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y+1))
      @x += 1
      @y += 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left(turn_ok = true)
    if KMDM::DIRSPRITE == true
      set_direction(7)
    else
      set_direction(8)
    end
    if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y-1))
      @x -= 1
      @y -= 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right(turn_ok = true)
    set_direction(9)
    if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y-1))
      @x += 1
      @y -= 1
      increase_steps
      @move_failed = false
    else
      @move_failed = true
    end
  end
end

#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# Adds functionality for diagonal character sprites.
#  Modifies: def update_src_rect
#==============================================================================

class Sprite_Character < Sprite_Base
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Rectangle
  #--------------------------------------------------------------------------
  def update_src_rect
    if @tile_id == 0
      index = @character.character_index
      #if the character is facing diagonally, use the second spriteset
      if @character.direction % 2 != 0 && KMDM::DIRSPRITE == true
        index = @character.character_index + 1
      end
      pattern = @character.pattern < 3 ? @character.pattern : 1
      sx = (index % 4 * 3 + pattern) * @cw
      sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
  end
end

**
Rep:
Level 66
RMRK Junior
Yeah, right. Seems like nobody gives a d*mn about this thread ;P
But anyways, I've been working a bit on Kylocks script and thought I'd post a little update of it here. It doesn't have anything related to Composite Characters as I pretty much suck at scripting:P But it does however lets you to be able to use eighter a single spritesheet or a 12x4 tile spritesheet to display diagonal movement. It's useful if you're using Tankentai SBS, see in the script for more information. I've also aliased methods with Mm12's footstep script so that footsteps will now play when moving in any direction.
And yeah, these may seem pretty useless, but I thought it'd be cool to post an update of this pretty old but still awsome script:)

PS. Sorry if my english suck, it's not my native language, lol:P

The Script, Updated to Version 1.2
Code: [Select]
#==============================================================================
# 8 Way Directional Movement
#------------------------------------------------------------------------------
# Kylock (Original Author)
# 21.3.2008
# Version 1.1
#------------------------------------------------------------------------------
# Edits by Mangomight
# 18.08.2012
# Version 1.2
#==============================================================================
# Special thanks to Arrow-1 for the script request and supplying sprites for
#   testing purposes.
#==============================================================================
# Instructions:
#      This script MUST be placed BELOW Miget Man12's Footstep Script if it's in
#      use, or you will recieve an error.
#     
#      Place this script near the top since it overwrites methods rather than
#      aliases them.
#      Once you add it and run your game, the script will automagically enable
#      8-way directional movement for your hero.
#     
# Features:
#    * Added movement functionality to allow your hero to move in diagonal
#        directions
#    * Corrects directional issues resulting from trying to activate events
#        while facing a diaganol direction. (could be better implemented,
#        but does work as it is)
#    * Version 1.2- Now compatible with Mm12's Footstep Script aswell as letting
#       you be able to use both single spritesheets and 12x6 tiles spritesheets.
#       Using the single one with the('$')sign put infront could come to handy
#       when using Tankentai SBS, in order to avoid an ugly 'bug'. Remember that
#       you must have a file with the same name as your character +"_dir_eight".
#       
#     # Example: Hero_dir_eight
#
#       Note that this isn't needed when using a 12x6 tiles spriteset, as the
#       script will simply just jump over to the next character_index.
#==============================================================================
# Changelog
#  1.0 Initial Release
#  1.1 Added support for no custom sprites and added compatibility with
#        Anaryu's Anti-Lag script (must be loaded above the anti-lag script)
#  1.2 Added compability with Mm12's Footstep Script when 'DIRSPRITE's enabled,
#       meaning that the footstep_se will be playing as you move in any direction.
#        I also rewrote the old update_src_rect method in order to make it possi-
#        ble to use both singular and non-singular spritesheets, read above for
#        more information.
#==============================================================================

#==============================================================================
# ** Script Configuration
#==============================================================================
$imported = {} if $imported == nil
$imported["KMDM"] = true
module KMDM
  DIRSPRITE = true     # set to true if you are using a custom   
                           # character sprite for diagonal movement
CHAR_NAME = '_dir_eight' # If the spriteset is a single('$')spriteset and DIRSPRITE
                         #is enabled, you need to create a file with the same name
                          # as your character and add "_dir_eight" to its name.
                          # The script will check after that file in the Graphics\
                          # Characters folder and automatically enable it for
                          # your hero when facing a diagonal direction. If it's
                          # not a single spriteset, then the script will instead
                          # jump to the next character_index.

 FOOTSTEPS = false    # set to true if Miget Man12's Footsteps Script is in use.
end

#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  rewrote def move_by-input to enable extra directions
#==============================================================================

class Game_Player < Game_Character
  def move_by_input
    return unless movable?
    return if $game_map.interpreter.running?
    case Input.dir8
      when 1;  move_lower_left
      when 2;  move_down
      when 3;  move_lower_right
      when 4;  move_left
      when 7;  move_upper_left
      when 6;  move_right
      when 8;  move_up
      when 9;  move_upper_right
    end
  end
end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# Corrects direction so events will respond when hero is facing diagonal.
#  Modifies: def move_lower_left, def move_lower_right, def move_upper_left,
#            and def move_upper_right
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Move Lower Left
  #--------------------------------------------------------------------------
  if KMDM::FOOTSTEPS
  alias mm12_ftstp_ge footstep_se
  end
  def move_lower_left(turn_ok = true)
    set_direction(5)
    if (passable?(@x, @y+1) and passable?(@x-1, @y+1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y+1))
      @x -= 1
      @y += 1
      increase_steps
      @move_failed = false
      footstep_se if KMDM::FOOTSTEPS
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Lower Right
  #--------------------------------------------------------------------------
  def move_lower_right(turn_ok = true)
    set_direction(3)
    if (passable?(@x, @y+1) and passable?(@x+1, @y+1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y+1))
      @x += 1
      @y += 1
      increase_steps
      @move_failed = false
      footstep_se if KMDM::FOOTSTEPS
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Left
  #--------------------------------------------------------------------------
  def move_upper_left(turn_ok = true)
    if KMDM::DIRSPRITE == true
      set_direction(7)
    else
      set_direction(8)
    end
    if (passable?(@x, @y-1) and passable?(@x-1, @y-1)) or
       (passable?(@x-1, @y) and passable?(@x-1, @y-1))
      @x -= 1
      @y -= 1
      increase_steps
      @move_failed = false
      footstep_se if KMDM::FOOTSTEPS
    else
      @move_failed = true
    end
  end
  #--------------------------------------------------------------------------
  # * Move Upper Right
  #--------------------------------------------------------------------------
  def move_upper_right(turn_ok = true)
    set_direction(9)
    if (passable?(@x, @y-1) and passable?(@x+1, @y-1)) or
       (passable?(@x+1, @y) and passable?(@x+1, @y-1))
      @x += 1
      @y -= 1
      increase_steps
      @move_failed = false
      footstep_se if KMDM::FOOTSTEPS
    else
      @move_failed = true
    end
  end
end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# Adds functionality for diagonal character sprites.
#  Modifies: def update_src_rect
#==============================================================================

class Sprite_Character < Sprite_Base
  include KMDM
  #--------------------------------------------------------------------------
  # * Update Transfer Origin Rectangle (Rewritten by Mangomight)
  #--------------------------------------------------------------------------
  # DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!
  #==========================================================================
  def update_src_rect
    if @tile_id == 0 
      index = @character.character_index
      @chara_name_old = ""
      sign = @character_name[/^[\!\$]./]
      #if the character is facing diagonally, use the second spriteset
      if @character.direction % 2 != 0 && KMDM::DIRSPRITE == true
        if @chara_name_old != $game_party.members[0].character_name
          @chara_name_old = $game_party.members[0].character_name
       end
        if sign != nil and sign.include?('$')
        self.bitmap = Cache.character(@chara_name_old+CHAR_NAME, 0)
        @previous_character = true
    else
    #If not using a single spriteset, jumps to the next character_index
      index = @character.character_index + 1
    end
    elsif @previous_character
    #Change it back to normal when conditions are no longer being met
    return if @character.direction % 2 != 0
    @chara_name_old = $game_party.members[0].character_name
    self.bitmap = Cache.character(@chara_name_old)
    @previous_character = false
    end
      pattern = @character.pattern < 3 ? @character.pattern : 1
      sx = (index % 4 * 3 + pattern) * @cw
      sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
  end
end

PPS. Tell me if you find any bugs, althogh I'm pretty sure there isn't.