[XP][VXA] Drago Pixel Movement

Started by LiTTleDRAgo, May 07, 2013, 11:53:36 am

Previous topic - Next topic

LiTTleDRAgo

May 07, 2013, 11:53:36 am Last Edit: August 12, 2014, 06:05:22 am by LiTTleDRAgo
Drago Pixel Movement
Authors: LiTTleDRAgo
Version: 1.02
Type: Movement Add-on
Key Term: Movement Add-on



Introduction

Title explain everything


Features


  • Pixel movement on player




Screenshots




Script

XP Version

VXAce Version


Instructions

Only intended for player movement


Compatibility

Will cause problem with other movement script, especially ABS
Not compatible with Blizz ABS


Credits and Thanks


  • LiTTleDRAgo




Author's Notes

Enjoy ~

Zexion

May 07, 2013, 02:10:14 pm #1 Last Edit: May 20, 2013, 03:44:31 am by Zexion
Thanks drago! I was trying to find a good clean base to look at and see if I could make it work with my script. I haven't actually looked at it yet, but your scripts are always top quality :D

Edit: Just looked at it, and it works without any modification! I'm wondering though if it will effect my event battle system..?

LiTTleDRAgo

*slight update, fixes a glitch for passage correction*
*added VXA version*

Soulshaker3

Loved the screenshot best idea ever
Hellow?

Zexion

Oh I don't think I ever noticed the bug, but I still use this so I'll update my script. Tis the best one out imo

LiTTleDRAgo


MetalZelda

It causes some problem with XAS, you can go through some impassable tiles ... But it works !

So if I understant this pixel movement, it reduce the 32x32 tile walk by a 16x16 ?

LiTTleDRAgo

August 13, 2014, 10:44:13 pm #7 Last Edit: May 16, 2017, 06:27:25 am by LiTTleDRAgo
Pixel movement for xas : http://littledrago.blogspot.com/2013/05/rgss-xas-391-ally-system-v112.html

Quote from: MetalZelda on August 13, 2014, 06:07:41 pmSo if I understant this pixel movement, it reduce the 32x32 tile walk by a 16x16 ?


Yes, this script mainly just reduce player step from 1 tile into half (0.5 tile).

Kise

June 23, 2017, 07:29:09 am #8 Last Edit: June 23, 2017, 08:34:44 am by Kise
I really like this script, it makes overall movement so much more enjoyable. I'm using also Event PM addon, and I have one problem with it. I have ingame events approaching player with event touch as trigger, and... they get confused when player stands on the edge of a tile. Is there be any way to fix that issue? I thought that adding 'through' option would work, but it didn't.

LiTTleDRAgo

Try this

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Move toward Player
  #--------------------------------------------------------------------------
  def move_toward_player
    abs_sx = (sx = @x - $game_player.x).abs
    abs_sy = (sy = @y - $game_player.y).abs
    if abs_sx < 1 && abs_sy < 1
      move_away_from_player
      turn_toward_player
    end
    if sx < -0.5 and sy > 0.5
      move_upper_right
    elsif sx > 0.5 and sy > 0.5
      move_upper_left
    elsif sx > 0.5 and sy < -0.5
      move_lower_left
    elsif sx < -0.5 and sy < -0.5
      move_lower_right
    elsif sx < -1.5
      move_right
    elsif sx > 1.5
      move_left
    elsif sy > 1.5
      move_up
    elsif sy < -1.5
      move_down   
    end
  end
end

Kise

June 23, 2017, 12:56:44 pm #10 Last Edit: June 23, 2017, 01:27:21 pm by Kise
Unfortunatly that didn't help. One more thing - I noticed, that when player just stands still in a way of 'through event' with on event touch nothing happens (not always). The event is triggered only (mostly) when player moves.

LiTTleDRAgo


Kise

June 23, 2017, 04:09:13 pm #12 Last Edit: June 24, 2017, 02:28:00 am by Kise
Here's demo, two maps show two mentioned issues - http://www13.zippyshare.com/v/dZOO92DU/file.html

LiTTleDRAgo

Sorry Kise, I'm currently in a remote village without my laptop and rmxp.
I'll be back in a week.

LiTTleDRAgo

Issue map 1 :

I edited all the trigger coordinates so the event will trigger even if player is in edge of tile.
Spoiler: ShowHide
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
#  This class handles the player. Its functions include event starting
#  determinants and map scrolling. Refer to "$game_player" for the one
#  instance of this class.
#==============================================================================

class Game_Player
  #--------------------------------------------------------------------------
  # * Same Position Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_here(triggers)
    result = false
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    # All event loops
    for event in $game_map.events.values
      # If event coordinates and triggers are consistent
      #----------------------------------------------------------
      if (event.x - @x).abs < 1 and (event.y - @y).abs < 1 and
       triggers.include?(event.trigger)
      #----------------------------------------------------------
        # If starting determinant is same position event (other than jumping)
        if not event.jumping? and event.over_trigger?
          event.start
          result = true
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Front Envent Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_there(triggers)
    result = false
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    # Calculate front event coordinates
    new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
    new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
    # All event loops
    for event in $game_map.events.values
      # If event coordinates and triggers are consistent
      #----------------------------------------------------------
      if (event.x - new_x).abs < 1 and (event.y - new_y).abs < 1 and
         triggers.include?(event.trigger)
      #----------------------------------------------------------
        # If starting determinant is front event (other than jumping)
        if not event.jumping? and not event.over_trigger?
          event.start
          result = true
        end
      end
    end
    # If fitting event is not found
    if result == false
      # If front tile is a counter
      if $game_map.counter?(new_x, new_y)
        # Calculate 1 tile inside coordinates
        new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
        new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
        # All event loops
        for event in $game_map.events.values
          # If event coordinates and triggers are consistent
          #----------------------------------------------------------
          if (event.x - new_x).abs < 1 and (event.y - new_y).abs < 1 and
             triggers.include?(event.trigger)
          #----------------------------------------------------------
            # If starting determinant is front event (other than jumping)
            if not event.jumping? and not event.over_trigger?
              event.start
              result = true
            end
          end
        end
      end
    end
    return result
  end
  #--------------------------------------------------------------------------
  # * Touch Event Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    result = false
    # If event is running
    if $game_system.map_interpreter.running?
      return result
    end
    # All event loops
    for event in $game_map.events.values
      # If event coordinates and triggers are consistent
      #----------------------------------------------------------
      if (event.x - x).abs < 1 and (event.y - y).abs < 1 and
          [1,2].include?(event.trigger)
      #----------------------------------------------------------
        # If starting determinant is front event (other than jumping)
        if not event.jumping? and not event.over_trigger?
          event.start
          result = true
        end
      end
    end
    return result
  end
end

#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Touch Event Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    # If event is running
    if $game_system.map_interpreter.running?
      return
    end
    # If trigger is [touch from event] and consistent with player coordinates
    #----------------------------------------------------------
    if @trigger == 2 and
      (x - $game_player.x).abs < 1 and (y - $game_player.y).abs < 1
    #----------------------------------------------------------
      # If starting determinant other than jumping is front event
      if not jumping? and not over_trigger?
        start
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Automatic Event Starting Determinant
  #--------------------------------------------------------------------------
  def check_event_trigger_auto
    # If trigger is [touch from event] and consistent with player coordinates
    #----------------------------------------------------------
    if @trigger == 2 and
      (x - $game_player.x).abs < 1 and (y - $game_player.y).abs < 1
    #----------------------------------------------------------
      # If starting determinant other than jumping is same position event
      if not jumping? and over_trigger?
        start
      end
    end
    # If trigger is [auto run]
    if @trigger == 3
      start
    end
  end
end

#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # * Move toward Player
  #--------------------------------------------------------------------------
  def move_toward_player
    abs_sx = (sx = @x - $game_player.x).abs
    abs_sy = (sy = @y - $game_player.y).abs
    if abs_sx < 1 && abs_sy < 1
      move_away_from_player
      turn_toward_player
    end
    if sx < -0.5 and sy > 0.5
      move_upper_right
    elsif sx > 0.5 and sy > 0.5
      move_upper_left
    elsif sx > 0.5 and sy < -0.5
      move_lower_left
    elsif sx < -0.5 and sy < -0.5
      move_lower_right
    elsif sx < -1.5
      move_right
    elsif sx > 1.5
      move_left
    elsif sy > 1.5
      move_up
    elsif sy < -1.5
      move_down   
    end
  end
end



Issue map 2 :

Don't use Approach, use Custom > Move Toward Player instead.

Spoiler: ShowHide

Kise

June 28, 2017, 10:58:09 am #15 Last Edit: June 28, 2017, 01:57:28 pm by Kise
Thank you, but there's still problem with second solution - events now don't get confused but event touch isn't as responsive. Now sometimes player can just go around it before it triggers.

One more little thing, I'm also using your smooth scroller script and for some reason camera always starts from lower right corner and then centers. It happens at the start of the game, or teleporting player. Oh, and it breaks Scroll Map command.

LiTTleDRAgo

June 28, 2017, 09:43:30 pm #16 Last Edit: June 28, 2017, 09:45:27 pm by LiTTleDRAgo
Hmm... for this problem I think you should thinker a bit with eventing.
As in checking the distance between event and player then make a custom scene / trigger instead relying on rtp's event touch.

Try insert this script.

class Game_Character
  #--------------------------------------------------------------------------
  # * adjust_follow_selfswitch
  #--------------------------------------------------------------------------
  def adjust_follow_selfswitch(selfswitch = 'A')
    # Of course other self switch is also okay.
    key = [$game_map.map_id, @id, selfswitch]   
    temp = $game_self_switches[key]
    # Go ahead change this number with whatever distance you need.
    if distance_from($game_player) < 1.75
      # If distance from player is less than 1.75 tile
      $game_self_switches[key] = true
    else
      # If distance from player is more or same than 1.75 tile
      $game_self_switches[key] = false
    end
    if temp != $game_self_switches[key]
      $game_map.need_refresh = true
    end
  end
end


And then you do this :
Spoiler: ShowHide


Now your event self switch will turn on whenever their distance with player is near.
Then, create a new page and do whatever you want in that page.


About smooth scroller script, not sure what your problem are.
Is the camera starts from the very corner right of the map every start / teleported?
I tested it in empty project and there are no such things.
I reuploaded the script and include a switch to activate / deactivate it now.

Kise

June 29, 2017, 03:34:56 am #17 Last Edit: July 04, 2017, 04:35:20 pm by Kise
That solution didn't work. I just tried cogwheels pixel movement, and there're no such issues, event touch triggers without any problem and it events don't get confused - but... I still think yours feels better, isn't 'shaky' and is compatible with footsteps sounds script.

There's script - https://pastebin.com/eZztLTiC
Maybe you'll learn something from it, and improve your own? Of course if you have time. No need to rush.

KK20

BTW Drago, regarding the camera moving at the start of the game, I can reproduce it on clean XP too. If the map is, for example, 40x40 in size and the player start position is (12,12), the screen will move up and left upon the map loading. In the following

if ... (tile_y = ($BlizzABS ? CY : CENTER_Y)+ 64)

if ... (tile_x = ($BlizzABS ? CX : CENTER_X)+ 64)

if I remove the + 64, it no longer does this behavior.

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!

LiTTleDRAgo

Thanks KK20, I forgot that I modified my RTP.
I'll edit the script now.