Improving a script (Tidloc's compass)

Hey, I'm currently using a script which just points to a x,y location on the map. But I want to be able to use it in a more complex way. The script is only able to point to a location on the current map you're on. I want it to be able to point to a location a different map.

How it should/might work:

  • Events used as doors/transfers can be tagged with a exit door tag to read their location(x , y) this is used for caves and in door maps
  • Events used as doors/transfers can be tagged with a specific door tag to read their location(x , y) this is used for world maps, towns, open areas.
  • if the player is on the same map as location then script works normally
  • if the player is on a map with only 1 exit and its not the same map as location then the location will be set to the exit
  • if the player is on a map like a town where there's no exits then the script will look for a specific door tag to use that as the location


  • script call will be like 3,4,6,"tag" (mapid, x, y, specific tag)
  • calling this again should overwrite the old call (so if i was going to the market then changing it to the blacksmith will then lead me to the black smith)
so scenarios:

  • you are in a house and you get a quest to go to the market
  • the script will set final destination to (*market map*, 33, 20) (map, x, y)
  • user will assign which specific tag is used for the current final destination
  • the script will then scan for a tag on the events if it reads exit tag (which it will since we're in a house) then it will set temporary destination to the location of the exit tag.
  • the player then follows the compass the the exit
  • the next map is the town where there should be no exit tags, the the script will then scan for the specific tag that matches the one the user assigned for final destination and set temporary destination to the location of the exit tag
  • finally the player walking in the door of the market
  • now the script sees its now on the same map the final destination and then works normal.
So basically how the compass works in skyrim where if you're inside but the quest is in a different map it will show that. there can also be indication changes to let the player know if they are on a different map.

I would love to thank you for read though to this far and really apricate the facts you are interested in helping.

The Script In Question: https://www.rpgmakercentral.com/topic/4143-tidlocs-compass/
I think you can easily do this using events with this compass script to do exactly what you want.
I will make an example how I would start it and from there I would work around, tinker and improve this event.

First we need a switch that we turn on when the player is tracker a quest.
Let us call it "Tracking Quest 1"
This will tell us that the player is currently tracking quest 1.
Now make an event in every single map and put in the location of the exit that leads to the quest.This event is our quest tracker. In the second tab you just add Tracking Quest 2 and so on.
Spoiler: Event
Compass.png

Now this script remembers the location so when the player exits a map we put in this code before the player transfers to the next map.
Tidloc::Clear_Coord(2)
This way when the player would ever come back to this map the compass would not track it again unless a Tracking Switch is on.

If you would have the player get multiple quests all at once than either make a way to select an quest to track where it would turn on the select quest's Tracker and turn off the rest.
Make priority quests in the higher tabs in the event Quest Tracker.
For example:
Quest 1 would be in the highest tab.

This is how I would start the tracking system.
Yes, it sounds like a lot of work. But it is just as much work with scripts finding your right location.
But maybe you are lucky finding someone who might be able to script it.

Hope this helps anyway,
Greetings.
Spoiler: QOUTE
I think you can easily do this using events with this compass script to do exactly what you want.
I will make an example how I would start it and from there I would work around, tinker and improve this event.

First we need a switch that we turn on when the player is tracker a quest.
Let us call it "Tracking Quest 1"
This will tell us that the player is currently tracking quest 1.
Now make an event in every single map and put in the location of the exit that leads to the quest.This event is our quest tracker. In the second tab you just add Tracking Quest 2 and so on.
Spoiler: Event

Now this script remembers the location so when the player exits a map we put in this code before the player transfers to the next map.
Tidloc::Clear_Coord(2)
This way when the player would ever come back to this map the compass would not track it again unless a Tracking Switch is on.

If you would have the player get multiple quests all at once than either make a way to select an quest to track where it would turn on the select quest's Tracker and turn off the rest.
Make priority quests in the higher tabs in the event Quest Tracker.
For example:
Quest 1 would be in the highest tab.

This is how I would start the tracking system.
Yes, it sounds like a lot of work. But it is just as much work with scripts finding your right location.
But maybe you are lucky finding someone who might be able to script it.

Hope this helps anyway,
Greetings.

I think you can easily do this using events with this compass script to do exactly what you want.
I will make an example how I would start it and from there I would work around, tinker and improve this event.

First we need a switch that we turn on when the player is tracker a quest.
Let us call it "Tracking Quest 1"
This will tell us that the player is currently tracking quest 1.
Now make an event in every single map and put in the location of the exit that leads to the quest.This event is our quest tracker. In the second tab you just add Tracking Quest 2 and so on.
Spoiler: Event

Now this script remembers the location so when the player exits a map we put in this code before the player transfers to the next map.
Tidloc::Clear_Coord(2)
This way when the player would ever come back to this map the compass would not track it again unless a Tracking Switch is on.

If you would have the player get multiple quests all at once than either make a way to select an quest to track where it would turn on the select quest's Tracker and turn off the rest.
Make priority quests in the higher tabs in the event Quest Tracker.
For example:
Quest 1 would be in the highest tab.

This is how I would start the tracking system.
Yes, it sounds like a lot of work. But it is just as much work with scripts finding your right location.
But maybe you are lucky finding someone who might be able to script it.

Hope this helps anyway,
Greetings.



I started to event this myself, the reason why I wanted to do it with a script is cause i felt it would be easier to manage. I have about 200 maps and counting.


Here's what I did.
When a player gets a quest
I set the final destination to a global variable as an array $fd = [map,x,y]
then I store those values in 3 game variables (when i try to make one variable into an array i get errors)

using 6 variables:
v1-3 is for final destination Map, X, Y -only changed if you get a new quest or change quest
v2-6 is for exit tag destination Map, X, Y - changed if in wrong map to the current exit map (unless in over world where a common event moves the location of exit map depending on what map the quest
is for.

unless player is on the same map as final destination map
the system will use the values from exit tag destination until you get to the right map

then in every map I have an event that checks if current map id == map where quest is
if not then set the location to the events location which i place after the door so it point to door.
if you are in the same map then it will just set the quest marker to the value in final destination.

in the open world I have the same event but this time it can move. So if final destination map == 1 then i will have another common event move it to the location it should be then the event its self will assign the marker to itself as well so it's kind of automated.

so if i have a quest in map one and I'm in an inside map in map 3 it will point to the marker leading to door

once i get to map 2 lets say that's in the open world. then a common event would move the event with marker to location i have to go then the event will set destination to itself.

I got everything working except for one thing which I'll post once i remember what it was.
I did some testing to the way you arrange it and it rolls out nicely but it could get complected when you do not have something to counter multiple quests.
I also receive an error when the player stands exactly on top of the location the compass is pointing at.
Maybe this could help you

This Proximity/Distance Check allows you to trigger something when the player is near an event or simply an area.
I am using this method for many event building.

I will look around and try stuff with this script by using eventing and see what interesting methods I can come up with.
I did some testing to the way you arrange it and it rolls out nicely but it could get complected when you do not have something to counter multiple quests.
I also receive an error when the player stands exactly on top of the location the compass is pointing at.
Maybe this could help you

This Proximity/Distance Check allows you to trigger something when the player is near an event or simply an area.
I am using this method for many event building.

I will look around and try stuff with this script by using eventing and see what interesting methods I can come up with.
Thank you. I don't get that error on my end. The player is able to reach the destination.
I'll check out that script I might need it for something else.

Making a skyrim level sanbox game.
@chigoo
I've made a modification to the script for my game. I realized that the script only holds one set of coordinates. So I converted it to use arrays instead.

Now you can use multiple coordinates. Although not like what you suggested with finding names, but you can stage the coordinates.

The way I have it working now is that you can load a set of coordinates into the array for that map (or multiple maps - as it sounds like that's what you want), then it will point to the last set of coordinates in the array for that map position.

Ex. Map 5 with three coordinates and map 9 with one.

the array will be [nil, nil, nil, nil, nil, [[10,12], [15, 8], [4, 7]], nil, nil, nil, [6, 6]]

While you are on map 5 it will point to 4,7. After reaching those coordinates, you do the command to remove the coordinates and then the compass will point to 15,8.

If you change maps it will point to the coordinates for that map.

Try it and let me know if there are any problems.
Spoiler: Tidloc Compass
Ruby:
################################################################################
#    Compass script v.1.2                                                      #
#         by Tidloc                                                            #
#==============================================================================#
#  simple script, that allows on given maps a compass to appear and point at a #
#  given point on that map. To define that point use th following command:     #
#     Tidloc::Set_Coord(*map*,*x*,*y*)                                         #
#  were x and y are the x and y coordinates on that map.                       #
#  If no coordinates are saved for a specific map, no compass will appear.     #
#==============================================================================#
#  Only adjustable thing in this script is the name of the graphic for the     #
#  compass, and the place where the compass will be shown. Everything else     #
#  will be calculated on its own by using the stated command.                  #
#  You can erase the saved coordinates with the command:                       #
#     Tidloc::Clear_Coord(*map*)                                               #
#  You are free to leave the map out, then all coordinates will be erased.     #
#==============================================================================#
#  Feel free to use this script, but please credit me for my work! ^__^        #
#==============================================================================#
#  Modification: Roninator2                                                    #
#  Now able to hold several locations at once                                  #
#  New method - Remove_Coord                                                   #
#    Specify what coordinates to remove - Tidloc::Remove_Coord(map_id, x, y)   #
#  It will hold any coordinates you provide, but will only point               #
#    to the last one in the array for that map.                                #
################################################################################

$imported = {} if $imported.nil?
$imported["Tidloc-Compass"] = [1,2,0]

module Tidloc
  module Compass
    Graphic = "compass_needle"
    Target  = nil
    X = Graphics.width - 32
    Y = 32
  end
  
################################################################################
 
  class<<self
    def Set_Coord(map,x,y)
      $game_system._tidloc_compass[map] = [] if $game_system._tidloc_compass[map].nil?
      $game_system._tidloc_compass[map] << [x,y]
    end
    
    def Remove_Coord(map,x,y)
      return if $game_system._tidloc_compass == []
      for i in 0..$game_system._tidloc_compass[map].size - 1
        set = $game_system._tidloc_compass[map][i]
        if set[0] == x && set[1] == y
          $game_system._tidloc_compass[map].delete($game_system._tidloc_compass[map][i])
        end
      end
    end
    
    def Clear_Coord(map = nil)
      if map == nil
        $game_system._tidloc_compass = []
      else
        $game_system._tidloc_compass[map] = []
      end
    end
  end
end
 
class Game_System
  attr_accessor :_tidloc_compass
  alias wo_compass_init initialize
  def initialize
    self._tidloc_compass = []
    wo_compass_init
  end
end
 
class Scene_Map < Scene_Base
  if !$imported["Tidloc-Header"]
    alias wo_tidloc_update update
    def update
        compass_update
      wo_tidloc_update
    end
  end

  def compass_update
    if $game_system._tidloc_compass[$game_map.map_id]
      x = Tidloc::Compass::X
      y = Tidloc::Compass::Y
      ydif = 0
      xdif = 0
      $game_map.screen.pictures[401].show(Tidloc::Compass::Graphic,
                                           1, x, y, 50, 50, 255, 0)
      $game_system._tidloc_compass[$game_map.map_id].each do |i|
        next if i.nil?
        xdif = $game_player.x - i[0].to_i
        ydif = $game_player.y - i[1].to_i
      end
      angle = 0
      if ydif == 0 && xdif > 0
        angle = 180
      elsif ydif == 0 && xdif < 0
        angle = -180
      elsif xdif == 0 && ydif > 0
        angle = 0
      elsif xdif == 0 && ydif < 0
        angle = 360
      elsif xdif == 0 && ydif == 0
        $game_map.screen.pictures[401].erase
        unless Tidloc::Compass::Target.nil?
          $game_map.screen.pictures[401].show(Tidloc::Compass::Target,
                                           1, x, y, 50, 50, 255, 0)
        end                                 
      else
        angle = Math::atan2(xdif + 0.0, ydif + 0.0) * 360.0 / Math::PI
      end
      $game_map.screen.pictures[401].rotate(angle)
    else
      $game_map.screen.pictures[401].erase
    end
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/improving-a-script-tidlocs-compass.138897/