Jump to content
Sign in to follow this  
Chigoo

Improving a script (Tidloc's compass)

Recommended Posts

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: 

 

Share this post


Link to post
Share on other sites

@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

################################################################################
#    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

 

 

Edited by roninator2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted