Prellmarc

Squire
Member
Joined
Sep 23, 2014
Messages
13
Reaction score
1
First Language
German
Primarily Uses
RMVXA
Hi, everyone.

I started a prequel to GBA Golden Sun, maybe someone remembers how great that series was.
Unfortunately, I absolutely cannot write a good script for the series Field magic.

There is the ability Move, which moves an object like a boulder one square in any direction, when the player is facing it and stands one square away from the tile he wants to move.

I googled and googled and googled ... but Field skills which would manipulate events like in GS just seem not to be questioned anywhere. So I thought, maybe is there somebody who could solve the mystery about skill-event-movement. I would be very grateful for I can go on :)

Cheers

Thats what I exactly want to do

:)
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,460
Reaction score
11,936
First Language
English
Primarily Uses
RMVXA
'Scripts' is where people who have written completed scripts that they want to share with others can post them.

It might be possible to do this with events, but it would be complicated, so we'll assume that a script will be the most efficient way.
[move]RGSS3 Script Requests[/move]
 

Prellmarc

Squire
Member
Joined
Sep 23, 2014
Messages
13
Reaction score
1
First Language
German
Primarily Uses
RMVXA
Oh sorry for that, didn't see the Request category and thought, I was right ^^ I'm completly new to this board hehe

Hmm, I didn't find a way to let a skill affect more than one specific object via event so far.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,319
Reaction score
8,380
First Language
German
Primarily Uses
RMMV
it can be done by eventing alone - you need to have the skill call a common event, and then that common event has to check player position, what events are near and how to affect those events.
Unfortunately that means a very complex common event to work, so it usually is easier to use a script - but that depends on what you want to do with the event.

Basically you need to be more specific before we can help, asking for a specific thing to do rather than general event manipulation.
Because the different effects will require different handling.
 

Prellmarc

Squire
Member
Joined
Sep 23, 2014
Messages
13
Reaction score
1
First Language
German
Primarily Uses
RMVXA
Well, the common event would have to determine wether a event in a max distance of two squares from the player is movable or not. If it was, the spell cast in field should allow the player to move it one step in a chosen direction. Like as you would push it yourself, but via skill and from a distance, if it happens that you can't reach the object to move by yourself. It's probably harder to describe as it is actually ;D
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
692
Reaction score
448
First Language
English
Primarily Uses
RMVXA
All right, I whipped something up for you to make it more convenient. I made it pretty quickly, so let me know if there are any issues.

Code:
=begin
#=====================================================================
#   AMN Field Objects
#   Version 1.0
#   Author: AMoonlessNight
#   Date: 18 Feb 2018
#   Latest: 18 Feb 2018
#=====================================================================#
#   UPDATE LOG
#---------------------------------------------------------------------#
# 18 Feb 2018 - created the original script
#=====================================================================#

This script has a number of convenience script calls to check if the
tile in front of the player has a field object.

Use the notetag <field_object> in an event's comments to denote it as
a Field Object.

This script also contains some convenience script calls for moving Field
Object events.

Requested by Prellmarc

#=====================================================================#
          SCRIPT CALLS
#=====================================================================#

You can use the following script calls in conditional branches:

    * player_fieldobj?(distance) or player_fieldobj?
  #----------------------------------------------------------------#
  # Checks if the event in front of the player is a Field Object.
  # For example:  player_fieldobj?(2)   will check 2 tiles away.
  # For example:  player_fieldobj?   will check the tile next to
  #               the player.
  #----------------------------------------------------------------#
 
 
  The following script calls can be used to move events:
 
 
    * movefieldobj_toplayer or movefieldobj_toplayer(distance)
  #----------------------------------------------------------------#
  # Moves the Field Object event randomly the specified amount of
  # steps.
  # For example: movefieldobj_toplayer   will move the event one
  #              step toward the player.
  # For example: movefieldobj_toplayer(2)  will move the event 2
  #              steps toward the player.
  #----------------------------------------------------------------#
 
    * movefieldobj_rand or movefieldobj_rand(distance)
  #----------------------------------------------------------------#
  # Moves the Field Object event randomly the specified amount of
  # steps.
  # For example: moveev_rand   will move the event one random step.
  # For example: moveev_rand(2)  will move the event 2 random steps.
  #----------------------------------------------------------------#
 
    * movefieldobj_left or movefieldobj_left(distance)
  #----------------------------------------------------------------#
  # Moves the event left the specified amount of times.
  # For example: movefieldobj_left   will move event left one step.
  # For example: movefieldobj_left(2)  will move the event left 2
  #               steps.
  #----------------------------------------------------------------#
 
    * movefieldobj_right or movefieldobj_right(distance)
  #----------------------------------------------------------------#
  # Moves the event right the specified amount of times.
  # For example: movefieldobj_right   will move the event right
  #              one step.
  # For example: movefieldobj_right(2)  will move the event
  #              right 2 steps.
  #----------------------------------------------------------------#
 
    * movefieldobj_down or movefieldobj_down(distance)
  #----------------------------------------------------------------#
  # Moves the event down the specified amount of times.
  # For example: movefieldobj_down   will move event down one step.
  # For example: movefieldobj_down(2)  will move the event down 2
  #               steps.
  #----------------------------------------------------------------#
 
    * movefieldobj_up or movefieldobj_up(distance)
  #----------------------------------------------------------------#
  # Moves the event up the specified amount of times.
  # For example: movefieldobj_up   will move event up one step.
  # For example: movefieldobj_up(2)  will move the event up 2 steps.
  #----------------------------------------------------------------# 

=end

#==============================================================================
#
# ** Please do not edit below this point unless you know what you are doing.
#
#==============================================================================

module AMN_fieldobject_setup
 
Field_Object_Regex = /<field_object>/i

end

#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
#  This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :fieldobj                    # ID of field object

  #--------------------------------------------------------------------------
  # * Object Initialization                                  # ALIAS METHOD #
  #--------------------------------------------------------------------------
  alias amn_fieldobj_gamemap_init   initialize
  def initialize
    @fieldobj = 0
    amn_fieldobj_gamemap_init
  end
 
  #--------------------------------------------------------------------------
  # * Field Object Event Comments                              # NEW METHOD #
  #--------------------------------------------------------------------------
  # Parses the event's comments and checks for Field Object regex.
  #--------------------------------------------------------------------------
  def fieldobj_event_comments(event_id)
    event = @events[event_id]
    if event.list
      event.list.each do |cmd|
        if cmd.code == 108
          if cmd.parameters[0] =~ AMN_fieldobject_setup::Field_Object_Regex
            return true
          else
            return false
          end
        else
          return false
        end
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Check if Field Object?                                   # NEW METHOD #
  #--------------------------------------------------------------------------
  # Checks the X and Y coordinates and sees if they contain a field object.
  #--------------------------------------------------------------------------
  def check_if_field_object?(x, y)
    if event_id_xy(x, y) > 0
      ev = event_id_xy(x, y)
      if fieldobj_event_comments(ev)
        @fieldobj = ev
        return true
      else
        @fieldobj = 0
        return false
      end
    end
    return false
  end
 
end
 

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
 
  #--------------------------------------------------------------------------
  # * Player Field Object?                                     # NEW METHOD #
  #--------------------------------------------------------------------------
  # Check if the tile in front of the player has a Field Object.
  #--------------------------------------------------------------------------
  def player_fieldobj?(dist = 1)
    event = $game_player
    case event.direction
    when 2;  evy = (event.y + dist); evx = event.x
    when 4;  evx = (event.x - dist); evy = event.y
    when 6; evx = (event.x + dist); evy = event.y
    when 8; evy = (event.y - dist); evx = event.x
    end
    $game_map.check_if_field_object?(evx, evy)
  end
 
  #--------------------------------------------------------------------------
  # * Field Object                                             # NEW METHOD #
  #--------------------------------------------------------------------------
  # Returns the value of the instance variable fieldobj, or the event called
  # Field Object.
  #--------------------------------------------------------------------------
  def fieldobj
    return $game_map.fieldobj
  end
 
  #--------------------------------------------------------------------------
  # * Move Field Object Randomly                               # NEW METHOD #
  #--------------------------------------------------------------------------
  # Just a convenient way of making the event move in a random
  # direction.
  #--------------------------------------------------------------------------
  def movefieldobj_rand(dist = 1)
    mr = RPG::MoveRoute.new
    mr.repeat = false
    mr.skippable = true
    mr.wait = true
    mr.list = []
    dist.times do
      mr.list.push( RPG::MoveCommand.new(9, []) )
    end
    mr.list.push( RPG::MoveCommand.new )
    $game_map.events[fieldobj].force_move_route(mr) unless fieldobj == 0
  end
 
  #--------------------------------------------------------------------------
  # * Move Field Object Left                                   # NEW METHOD #
  #--------------------------------------------------------------------------
  # Just a convenient way of making the event move left.
  #--------------------------------------------------------------------------
  def movefieldobj_left(dist = 1)
    mr = RPG::MoveRoute.new
    mr.repeat = false
    mr.skippable = true
    mr.wait = true
    mr.list = []
    dist.times do
      mr.list.push( RPG::MoveCommand.new(2, []) )
    end
    mr.list.push( RPG::MoveCommand.new )
    $game_map.events[fieldobj].force_move_route(mr) unless fieldobj == 0
  end
 
  #--------------------------------------------------------------------------
  # * Move Field Object Right                                  # NEW METHOD #
  #--------------------------------------------------------------------------
  # Just a convenient way of making the event move left.
  #--------------------------------------------------------------------------
  def movefieldobj_right(dist = 1)
    mr = RPG::MoveRoute.new
    mr.repeat = false
    mr.skippable = true
    mr.wait = true
    mr.list = []
    dist.times do
      mr.list.push( RPG::MoveCommand.new(3, []) )
    end
    mr.list.push( RPG::MoveCommand.new )
    $game_map.events[fieldobj].force_move_route(mr) unless fieldobj == 0
  end
 
  #--------------------------------------------------------------------------
  # * Move Field Object Down                                   # NEW METHOD #
  #--------------------------------------------------------------------------
  # Just a convenient way of making the event move left.
  #--------------------------------------------------------------------------
  def movefieldobj_down(dist = 1)
    mr = RPG::MoveRoute.new
    mr.repeat = false
    mr.skippable = true
    mr.wait = true
    mr.list = []
    dist.times do
      mr.list.push( RPG::MoveCommand.new(1, []) )
    end
    mr.list.push( RPG::MoveCommand.new )
    $game_map.events[fieldobj].force_move_route(mr) unless fieldobj == 0
  end
 
  #--------------------------------------------------------------------------
  # * Move Field Object Up                                     # NEW METHOD #
  #--------------------------------------------------------------------------
  # Just a convenient way of making the event move left.
  #--------------------------------------------------------------------------
  def movefieldobj_up(dist = 1)
    mr = RPG::MoveRoute.new
    mr.repeat = false
    mr.skippable = true
    mr.wait = true
    mr.list = []
    dist.times do
      mr.list.push( RPG::MoveCommand.new(4, []) )
    end
    mr.list.push( RPG::MoveCommand.new )
    $game_map.events[fieldobj].force_move_route(mr) unless fieldobj == 0
  end
 
  #--------------------------------------------------------------------------
  # * Move Field Object Toward Player                          # NEW METHOD #
  #--------------------------------------------------------------------------
  # Just a convenient way of making the event move toward the player.
  #--------------------------------------------------------------------------
  def movefieldobj_toplayer(dist = 1)
    mr = RPG::MoveRoute.new
    mr.repeat = false
    mr.skippable = true
    mr.wait = true
    mr.list = []
    dist.times do
      mr.list.push( RPG::MoveCommand.new(10, []) )
    end
    mr.list.push( RPG::MoveCommand.new )
    $game_map.events[fieldobj].force_move_route(mr) unless fieldobj == 0
  end
 
end

1. Add the script
2. Create a skill
3. Make the skill call a common event
4. In the common event, use a conditional branch with the script call 'player_fieldobj?(2)'. This will check if the tile two steps in front of the player has a Field Object.
5. Inside that conditional branch, put whatever you want to do when the event is a Field Object (e.g. you could use the script call 'movefieldobj_toplayer(1)' to move the Field Object one step toward the player, you could play an animation, etc.)
6. In the else branch, you could add a sound effect to show that the skill didn't work or something.

Hope this helps. There's a bit more info in the script itself. Let me know if you need anything.
 

Prellmarc

Squire
Member
Joined
Sep 23, 2014
Messages
13
Reaction score
1
First Language
German
Primarily Uses
RMVXA
Wow, that fits perfect for me. You are my heroine :D Thank you so much!
 
Last edited:

Latest Threads

Latest Profile Posts

Chili: Evolved to taste spicy so no animal would eat them.

Humans: "Jokes on you ..."
I guess it becomes purely academic in less than four days but before then can anyone explain to me why the %^&*( animations in the MZ database don't have a 'Hue' slider??
Who here knows of the hidden laws of this multiverse? Such as the law of attraction
Exploding Fruits and Rasaks Pixelfarm Assets | RPG Maker News #108

So ghosts can go through walls and stuff, and depending their type (according to fantasy media) they can or can't interact with objects to a certain degree...

So why they don't always fall through floors? Do they always float and sometimes simulate walking? If things go through them how can they hear/see? And why sometimes they have clothing? Do clothes die as well?

Forum statistics

Threads
113,704
Messages
1,076,790
Members
147,728
Latest member
Alteria
Top