Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Hellfire Dragon on January 25, 2009, 12:52:34 pm

Title: Navigation Line
Post by: Hellfire Dragon on January 25, 2009, 12:52:34 pm
I want a Navigation Line script, like th eone in dead space. For those who didn''t play dead space, basically, when a certain button is being held down a glowing blue line would appear and yo could follow it to your next objective. I want it so I can turn it on and off too.

I thought about this and it wold probably be hard, especially when the objective is on another map. Well I don't know, I'm not a scripter but if anyone thinks they could give this a try, could you please :shy:
Title: Re: Navigation Line
Post by: Fantasist on January 26, 2009, 01:25:16 am
I didn't understand the "line" part. If it's an arrow which points to the destination, then it's fine.
Yeah, pointing to something on a different map is a problem. Though, you can point to the teleport event in every map manually. If that's the case, I think I can pull this off.
Title: Re: Navigation Line
Post by: Hellfire Dragon on January 26, 2009, 11:18:30 am
Yeah that'd work fine, the line, well in dead space a blue line appears along the ground and if you follow it you get to the objective, the arrow is fine though and it's probably way easier.
Title: Re: Navigation Line
Post by: G_G on January 26, 2009, 11:43:35 am
This would be an awesome script. Good luck Fantasist hope you can pull it off!

This is also in a game called Legendary. You hold down a button and there's a line to your next objective.
\
Title: Re: Navigation Line
Post by: Fantasist on January 26, 2009, 12:04:50 pm
Okay. I'll give it a shot. It should take 20 mins max, but I need to be able to concentrate. I'll do it within 2 days.

EDIT:

I have the first draft. It's getting late, so I'll update the script header later (the instructions). Here's the demo:

http://www.sendspace.com/file/art9fo

Tell me if you need anything else.
Title: Re: Navigation Line
Post by: G_G on January 27, 2009, 10:32:26 pm
Its great! I think he wanted to only be activated if a certain button is being held down. But great Fantasist this is just pure awesomenes.
Title: Re: Navigation Line
Post by: Hellfire Dragon on January 28, 2009, 01:14:17 pm
That's great! That you Fantasist ;) But like GG said, I wanted it to only appear when a button is being pressed. I'm using Blizz ABS so I wanted it something like, it appears/disappears when the player press 'P' Or something like that. Maybe if you can have it activating with like, whatever = true/false I could just make a common event for it.

Title: Re: Navigation Line
Post by: Fantasist on January 29, 2009, 06:31:54 am
Glad you like it :)
I forgot about the button being pressed. No need to make a common event, it's easy to implement. Also, if you checked out the events in the demo, you can turn it off by using:
$game_temp.point_towards(nil)


nvm, I'll update this tonight.
Title: Re: Navigation Line
Post by: Reno-s--Joker on January 30, 2009, 06:40:10 am
Wow, awesome script! :D
This might really come in handy - better than having to talk to NPCs... XD
Title: Re: Navigation Line
Post by: Fantasist on January 30, 2009, 08:43:24 am
Here you are HFD:
Spoiler: ShowHide

#==============================================================================
# ** Map Target Pointer
#------------------------------------------------------------------------------
# by Fantasist
# Version: 1.0
# Date: 30-Jan-2009
#------------------------------------------------------------------------------
# Version History:
#
#   1.0 - First version
#------------------------------------------------------------------------------
# Description:
#
#     This script adds a pointer which points to a desired event on the map.
#------------------------------------------------------------------------------
# Compatibility:
#
#     Should be compatible with almost everything.
#------------------------------------------------------------------------------
# Instructions:
#
#     Place this script in a new slot below Scene_Debug and above main.
#   If you're using any input modules and the key you set is from that script,
#   plave this below that input script.
#
#   Use the following call script to set a target event:
#
#         $game_temp.point_towards(EVENT_ID)
#
#   where EVENT_ID is the ID of the event to which the pointer should point.
#
#   To remove the target, use:
#
#         $game_temp.point_towards
#                   or
#         $game_temp.point_towards(nil)
#------------------------------------------------------------------------------
# Configuration:
#
#     Scroll down a bit for configuration.
#
#  MTP_Pic: Name of the picture file in the "Graphics/Pictures" folder.
#           The pointer should point upwards.
#  MTP_Position: Position of the pointer.
#                 - If it is fixed, use an array of X and Y values
#                   (like this: [X, Y]) if the pointer is static.
#                 - Use nil for placing the pointer above the player.
#  MTP_Key: The key which should be pressed for the pointer to appear.#
#------------------------------------------------------------------------------
# Issues:
#
#     None that I know of.
#------------------------------------------------------------------------------
# Credits and Thanks:
#
#    - Fantasist for making this.
#    - Hellfire Dragon for requesting this.
#------------------------------------------------------------------------------
# Notes:
#
#   If you have any problems, suggestions or comments, you can find me at:
#
# - www.chaos-project.com
# - www.quantumcore.forumotion.com
#
#   Enjoy ^_^
#==============================================================================

#==============================================================================
# ** FTSConfig
#==============================================================================
module FTSConfig
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG BEGIN
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  MTP_Pic = 'Target_Pointer'
  MTP_Position = nil #[320, 240]
  MTP_Key = Input::A
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG END
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
end
#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
 
  attr_reader :point_target
 
  alias mtp_game_temp_init initialize
  def initialize
    mtp_game_temp_init
    @point_target = nil
  end
 
  def point_towards(val=nil)
    @point_target = val
    $scene.set_target(val) if $scene.is_a?(Scene_Map)
  end
 
end
#==============================================================================
# ** Spriteset_Map
#==============================================================================
class Spriteset_Map
 
  attr_reader :character_sprites
  attr_reader :pointer
 
  alias mtp_spriteset_map_init initialize
  def initialize
    mtp_spriteset_map_init
    @pointer = Pointer.new(self)
    @pointer.z = 5100
  end
 
  alias mtp_spriteset_map_upd update
  def update
    mtp_spriteset_map_upd
    @pointer.update if @pointer != nil
  end
 
  alias mtp_spriteset_map_disp dispose
  def dispose
    mtp_spriteset_map_disp
    @pointer.dispose
  end
 
end
#==============================================================================
# ** Pointer
#==============================================================================
class Pointer < Sprite
 
  attr_reader :target
  attr_accessor :spriteset
 
  def initialize(spriteset)
    super()
    self.visible = false
    self.spriteset = spriteset
    self.target = $game_temp.point_target
    self.bitmap = RPG::Cache.picture(FTSConfig::MTP_Pic)
    if FTSConfig::MTP_Position
      self.x, self.y = FTSConfig::MTP_Position[0], FTSConfig::MTP_Position[1]
    end
  end
 
  def update
    super
    self.visible = @target && Input.press?(FTSConfig::MTP_Key)
    return unless Input.press?(FTSConfig::MTP_Key)
    update_pointing if @target
  end
 
  def update_pointing
    y = ($game_player.screen_y - @target.screen_y).to_f
    x = (@target.screen_x - $game_player.screen_x).to_f
    rad = Math.atan2(y, x) - Math::PI/2
    self.angle = rad * 180 / Math::PI
    unless FTSConfig::MTP_Position
      self.x = $game_player.screen_x
      self.y = $game_player.screen_y - 64
    end
  end
 
  def get_sprite_char(event_id)
    return nil unless $scene.is_a?(Scene_Map)
    self.spriteset.character_sprites.each {|spr_char|
    return spr_char if spr_char.character.id == event_id}
    return nil
  end
 
  def target=(event_id)
    @target = nil if event_id == nil || event_id < 0
    @target = get_sprite_char(event_id)
    @target = @target.character unless @target == nil
    update_pointing if @target
    self.visible = false
  end
 
  def bitmap=(val)
    super(val)
    return if val == nil
    self.ox, self.oy = self.bitmap.width/2, self.bitmap.height/2
  end
 
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
 
  attr_reader :spriteset
 
  def set_target(event_id)
    @spriteset.pointer.target = event_id
  end
 
end


Here's the picture:
(http://img50.imageshack.us/img50/2227/targetpointertk5.png) (http://imageshack.us)

EDIT: Oh, and thank you guys :D
Title: Re: Navigation Line
Post by: Shadonking on January 30, 2009, 09:44:27 am
this could be really cool with a few other options. e.g. for the pointer to point at coodinates using variables.

also i seem to be having trouble getting the the pointer to work when pressing a key, if you leave it as A it started up but i use that to walk but if you change it to any other key it comes up with errors.
Title: Re: Navigation Line
Post by: Hellfire Dragon on January 30, 2009, 10:39:47 am
Actually it does work with other keys, but only the ones built into rmxp, so for Q you'd set it to L. Awesome work Fantasist :) So other than than only being able to use the rmxp keys, this script is great ;)
Title: Re: Navigation Line
Post by: shdwlink1993 on January 30, 2009, 11:13:21 am
To use other keys (provided you're using Ton's Input), you use this (I think :)):

Input::Key['A']
Title: Re: Navigation Line
Post by: Shadonking on January 30, 2009, 12:10:18 pm
i see if L uses the Q key what do you put in to use P.

Title: Re: Navigation Line
Post by: Hellfire Dragon on January 30, 2009, 12:40:41 pm
The rmxp keys don't cover the whole keyboard :( They only cover, the arrow keys,Z, X, C, Q, W, A, S, and D.

@shdw I don't know if that would work, I only tried using that with the blizz-abs. I'll check though
Title: Re: Navigation Line
Post by: Shadonking on January 30, 2009, 01:04:29 pm
thats a shame, but at least there is one key there that im not using which is Z but i dont now what to put in for that key to use.
Title: Re: Navigation Line
Post by: Fantasist on January 30, 2009, 01:24:21 pm
Woah, wait a second guys, it'll work with any input module.

Quote# Instructions:
#
#     Place this script in a new slot below Scene_Debug and above main.
#   If you're using any input modules and the key you set is from that script,
#   place this below that input script.


Basically, if you're using Tons or Blizz-ABS, both of them have the same input module, so what shdwlink said would work:

Quote from: shdwlink1993 on January 30, 2009, 11:13:21 am
To use other keys (provided you're using Ton's Input), you use this (I think :)):

Input::Key['A']



So for p, it's:
Input::Key['P']


If you're still getting errors, here is the workaround:

In the config, comment out the MTP_Key option:
Quote
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG BEGIN
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
  MTP_Pic = 'Target_Pointer'
  MTP_Position = nil #[320, 240]
  MTP_Key = Input::A # <<<<< Comment this out!!
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG END
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Then paste the following snipped BELOW any input modules you're using. So this snippet goes below Tons and/or Blizz-ABS:


#==============================================================================
# ** FTSConfig (MTP key workaround)
#==============================================================================
module FTSConfig
 
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG BEGIN
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  MTP_Key = Input::A
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  # CONFIG END
  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
end


Glad you guys like it :)

@Shadonking: That's an interesting feature, pointing to coordinates. I'll remember that ;)
Title: Re: Navigation Line
Post by: Shadonking on January 30, 2009, 01:41:09 pm
ok im not using tons input and im using blizz abs controlles and i have place the script under both of them but certian keys keep coming up with errors, i even just tried that little snippit thing you just posted but the same error came up when tring to use P.

also what would be cool would to have an option to turn it on and off with a swith then people could use this script as an item or skill.
Title: Re: Navigation Line
Post by: Hellfire Dragon on January 30, 2009, 03:25:38 pm
I was just going by the Where to put Blizzards scripts thing, it says to put other people's script above the abs. Anyway I'll try what you said out ;)
Title: Re: Navigation Line
Post by: Aqua on January 30, 2009, 03:29:09 pm
Nice script Fanta! :D

I'll definitely use it in my game (unless like... I don't find a need for it... but who wouldn't need this!?! :P)
Title: Re: Navigation Line
Post by: Hellfire Dragon on January 30, 2009, 03:38:18 pm
Thanks Fantasist (again, maybe I should stop saying that, getting kinda weird or something right? :haha: ) Anyway I put the script below the Blizz ABS and used Input::Key['P'] and it's working perfectly now!

Tha-...nks :^_^':
Title: Re: Navigation Line
Post by: Shadonking on January 30, 2009, 03:46:24 pm
also i got it working, silly me forgot to put Input::Key['P'], i put Input::key['P'] any way great script. powersup
Title: Re: Navigation Line
Post by: Calintz on January 30, 2009, 05:04:00 pm
What kind of game are you making??
This is an impressive script, but why exactly do you want it??

By telling the person the proper direction and pointing out exactly where he needs to go...doesn't that make the game less exciting??
Title: Re: Navigation Line
Post by: Shadonking on January 30, 2009, 05:41:54 pm
lets say that you have a freerome type game and lots of quests and its differcult to descripe certian areas so to add that little bit more help this script would be perfect (i find that trying to find places isnt the part of games i like its the puzzles and monster that truely make games)
Title: Re: Navigation Line
Post by: Calintz on January 30, 2009, 09:10:44 pm
...Great response.
I can understand why this would help =)

Powers Up...
Title: Re: Navigation Line
Post by: Fantasist on January 30, 2009, 09:49:18 pm
OK, enable/disable and point to coordinates. I'll add those and post this script in a new topic in a day or two. Glad you like it folks :)
Title: Re: Navigation Line
Post by: Ryex on January 30, 2009, 09:54:37 pm
Wow Fantasist this looks great (powers up)
Title: Re: Navigation Line
Post by: Reno-s--Joker on January 30, 2009, 11:12:34 pm
Agreed, I checked it out this morning and it's awesome! :haha:
Great job! :P
Title: Re: Navigation Line
Post by: Fantasist on January 31, 2009, 01:14:51 am
Okay, seriously, this is not that difficult ^_^'. You just need to know how to access the sprites displayed on the map and know some math. I'm sure at least some of you guys can easily figure out what's going on in the method Pointer#update_position. The rest is just your regular sprite management.

PS: I've been thinking and it's very much possible to make a navigation line, not just a pointer. You'd need path finding and you need to figure out how to handle the sprites with lines drawn on them. I don't know much about how path finding is used though, it'll be a little tougher for me than a pointer.
Title: Re: Navigation Line
Post by: Blizzard on February 01, 2009, 01:40:07 pm
Should I wait until you add this before I add it to Tons then?
Title: Re: Navigation Line
Post by: Fantasist on February 02, 2009, 08:21:54 am
Yeah, I might as well complete it properly. It'll be done by this weekend (after the exams).
Title: Re: Navigation Line
Post by: Reno-s--Joker on February 03, 2009, 01:55:59 am
:D This'd be great for Tons! <3
Title: Re: Navigation Line
Post by: Calintz on February 03, 2009, 02:05:02 am
Good add for tons'.
Seriously though. This is right up tons' lane...
Title: Re: Navigation Line
Post by: Starrodkirby86 on February 03, 2009, 02:33:53 am
Wow, so that would mean another add-on with Fantasist. At this rate, maybe Tons of Add-Ons would truly be Tons of Add-Ons, and not just by Blizzard. It'll be by many a mil of authors...:D Of course, none of that SDK-forced messy code pallooza, no, no, none of that.
Title: Re: Navigation Line
Post by: Blizzard on February 03, 2009, 07:12:25 am
I'm doing my best not to let Tons turn into SDK. Actually it's kinda already is an "SDK" (more like MACL, but w/e), but it will never turn into THE SDK. xD