The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Azark on March 11, 2006, 07:47:28 AM

Title: Diagonal movement script!!!
Post by: Azark on March 11, 2006, 07:47:28 AM
Here is the Script!!!

#==============================================================================
#??????????????????ver. 1.01???
#??Script by ???
#??http://para.j-mx.com/
#------------------------------------------------------------------------------
# ???????????????????????????????
# ?Graphics/Characters??????
# ?????????????_quarter????????????????
# ????????????????????????001-Fighter01_quarter?
#------------------------------------------------------------------------------
#????????
# ??????????????????????????????
# ??????????????????????
# ??????????????????????????????_dash_quarter??
# ?????
#==============================================================================

#==============================================================================
# ? Game_Player
#==============================================================================

class Game_Player < Game_Character
 #--------------------------------------------------------------------------
 # ? ??????
 #--------------------------------------------------------------------------
 alias update_para_quarter update
 def update
   update_para_quarter
   unless moving? or $game_system.map_interpreter.running? or
          @move_route_forcing or $game_temp.message_window_showing
     # ???????????????????????????
     case Input.dir8
     when 1  # ?????
       move_lower_left
     when 3  # ?????
       move_lower_right
     when 7  # ?????
       move_upper_left
     when 9  # ?????
       move_upper_right
     end
   end
 end
end

#==============================================================================
# ? Sprite_Character
#==============================================================================

class Sprite_Character < RPG::Sprite
 #--------------------------------------------------------------------------
 # ? ??????
 #--------------------------------------------------------------------------
 alias update_para_quarter update
 def update
   update_para_quarter
   if @tile_id == 0
     if (@character.direction - 2) % 2 == 1
       # ????????????
       if quarter_graphic_exist?(@character)
         # ????????
         if character.dash_on and dash_quarter_graphic_exist?(@character)
           @character_name = @character.character_name + "_dash_quarter"
         else
           @character_name = @character.character_name + "_quarter"
         end
         self.bitmap = RPG::Cache.character(@character_name,
           @character.character_hue)
         # ?????
         case @character.direction
           when 1
             n = 0
           when 3
             n = 2
           when 7
             n = 1
           when 9
             n = 3
         end
       else
         @character.direction = @character.sub_direction
         # ???????????????
         n = (@character.direction - 2) / 2
       end
       # ?????????
       sx = @character.pattern * @cw
       sy = n * @ch
       self.src_rect.set(sx, sy, @cw, @ch)
     else
       self.bitmap = RPG::Cache.character(@character.character_name,
         @character.character_hue)
       # ?????????
       sx = @character.pattern * @cw
       sy = (@character.direction - 2) / 2 * @ch
       self.src_rect.set(sx, sy, @cw, @ch)
     end
   end
 end
 #--------------------------------------------------------------------------
 # ? ????????????
 #--------------------------------------------------------------------------
 def quarter_graphic_exist?(character)
   # ???????
   begin
     RPG::Cache.character(character.character_name.to_s + "_quarter", character.character_hue)
   rescue
     return false
   end
   return true
 end
 #--------------------------------------------------------------------------
 # ? ????????????????
 #--------------------------------------------------------------------------
 def dash_quarter_graphic_exist?(character)
   # ???????
   begin
     RPG::Cache.character(character.character_name.to_s + "_dash_quarter", character.character_hue)
   rescue
     return false
   end
   return true
 end
end

#==============================================================================
# ? Game_Character
#==============================================================================

class Game_Character
 #--------------------------------------------------------------------------
 # ? ??????????
 #--------------------------------------------------------------------------
 attr_accessor   :direction        # ??
 attr_accessor   :sub_direction    # ???????????????
 #--------------------------------------------------------------------------
 # ? ?????
 #--------------------------------------------------------------------------
 def move_lower_left
   # ?????????
   unless @direction_fix
     @sub_direction = @direction
     @direction = 1
     # ?????????????????????????
     @sub_direction = (@sub_direction == 6 ? 4 : @sub_direction == 8 ? 2 : @sub_direction)
   end
   # ??????? ?????????????????
   if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 4)) or
      (passable?(@x, @y, 4) and passable?(@x - 1, @y, 2))
     # ?????
     @x -= 1
     @y += 1
     # ????
     increase_steps
   end
 end
 #--------------------------------------------------------------------------
 # ? ?????
 #--------------------------------------------------------------------------
 def move_lower_right
   # ?????????
   unless @direction_fix
     @sub_direction = @direction
     @direction = 3
     # ?????????????????????????
     @sub_direction = (@sub_direction == 4 ? 6 : @sub_direction == 8 ? 2 : @sub_direction)
   end
   # ??????? ?????????????????
   if (passable?(@x, @y, 2) and passable?(@x, @y + 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 2))
     # ?????
     @x += 1
     @y += 1
     # ????
     increase_steps
   end
 end
 #--------------------------------------------------------------------------
 # ? ?????
 #--------------------------------------------------------------------------
 def move_upper_left
   # ?????????
   unless @direction_fix
     @sub_direction = @direction
     @direction = 7
     # ?????????????????????????
     @sub_direction = (@sub_direction == 6 ? 4 : @sub_direction == 2 ? 8 : @sub_direction)
   end
   # ??????? ?????????????????
   if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 4)) or
      (passable?(@x, @y, 4) and passable?(@x - 1, @y, 8))
     # ?????
     @x -= 1
     @y -= 1
     # ????
     increase_steps
   end
 end
 #--------------------------------------------------------------------------
 # ? ?????
 #--------------------------------------------------------------------------
 def move_upper_right
   # ?????????
   unless @direction_fix
     @sub_direction = @direction
     @direction = 9
     # ?????????????????????????
     @sub_direction = (@sub_direction == 4 ? 6 : @sub_direction == 2 ? 8 : @sub_direction)
   end
   # ??????? ?????????????????
   if (passable?(@x, @y, 8) and passable?(@x, @y - 1, 6)) or
      (passable?(@x, @y, 6) and passable?(@x + 1, @y, 8))
     # ?????
     @x += 1
     @y -= 1
     # ????
     increase_steps
   end
 end
 #--------------------------------------------------------------------------
 # ? ?????????????
 #--------------------------------------------------------------------------
 def dash_on
   if @dash_on != nil
     return @dash_on
   else
     return false
   end
 end
end


And you will be needing this too.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi15.photobucket.com%2Falbums%2Fa368%2FZack999%2F001-Fighter01_quarter.png&hash=005a2c75c520c8a080f990e5df121897bddab5e7)

Just uimport the opic to charaters!!!!
Credits dont go to me but some japanese guy.
Have fun!!!
Title: Re: Diagonal movement script!!!
Post by: Arrow on October 11, 2006, 12:54:05 PM
Needs to be bumped, I think.
Title: Re: Diagonal movement script!!!
Post by: Fantom on October 13, 2006, 02:10:29 PM
this is cool. good work [insert japnese guys name here]!