HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Minimap?  (Read 2815 times)

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Minimap?
« on: Jan 18, 13, 05:39:32 AM »

I have read through the many links on the minimap section. From those I was able to get a minimap up and running. I am now trying to create my own version of it, so that I can put on different features. I have managed to get the base of the minimap, with my own frame (picture), and the image of the area from above (a map), but I am unable to get the scripts to call my override scripts.

In _minimapClassMethods they have the method _onRenderMiniMap(). This is over ridden by method HE_onRenderMiniMap() in _GUIMethodCallbacksClassMethods.

method HE_onRenderMiniMap()
  // completely overrides behavior of a minimap render call
  // you may find it easier to implement this as a method on your minimap itself
.

I have placed a method called HE_onRenderMiniMap() in HaV_minimapClassMethods, but it did not see it there. I have tried placing it in HaV_GUIMethodCallbacksClassMethods, and again it did not see it. This method is similar to the one used in _minimapClassMethods. What am I missing for this override?

Code: [Select]
method HE_onRenderMiniMap()

  println("using my OnRenderMiniMap")
  var map = me._getMinimapTexturePanel()
  if map == None
    return
  .
  var person = GetPlayerCharacterNode()
  if person == None
    return
  .

  position as Vector3 = person["Position"]
  answer as Vector3
  mycenter as Vector3
 
  // WorldSpaceToMiniMapSpace() converts a 3D worldspace position to 2D coordinates within the
  // 512x512 minimap texture.  Here, we're using it to decide how to set the UV coordinates to
  // display the area around the character.  You can also use it to figure out where to place
  // markers for other characters, creatures, etc.

  inRange as Boolean = WorldSpaceToMiniMapSpace(position,answer)
  mycenter = answer
  map.defaultStatePresentation.position.x = answer.x - (map.size.x/2)
  map.defaultStatePresentation.position.y = answer.y - (map.size.y/2)
 
  var cam = GetActiveCamera()
  if (cam["CameraName"]=="GAME")
    position = cam["Rotation"]
    map.rotation = -position.y
  .
  frame as NodeRef of Class GUIPanel = me.HaV_getMinimapCompassFrame()
  frame.rotation = map.rotation

  actorCheck as LookupList indexed by String of Boolean
  actorPanel as NodeRef of Class GUIControl = findGUIControlByName(map.parent, "actors")
  var storage = me._getMinimapActorStorage()
  var actors = GetMinimapCharacters()
  foreach actor in actorPanel.children
    add back actor to storage.children
  .

  var playerColor = me._getMinimapPlayerColor()
  var NPCColor = me._getMinimapNPCColor()
  var HostileColor = me._getMinimapHostileColor()
 
  foreach actor in actors
    dot as NodeRef of Class GUIControl = findGUIControlByName(actorPanel, actor)
    if dot == None
      if storage.children.length > 0
        dot = storage.children[1]
      else
        dot = me._newMinimapActor()
      .
      add back dot to actorPanel.children
      dot.name = actor
      hostile as Boolean = false       
      if hostile == true
        dot.defaultStatePresentation.color = HostileColor
      else if findString(toLower(getcharacterspecification(actor)), "male") > 0
        dot.defaultStatePresentation.color = playerColor
      else
        dot.defaultStatePresentation.color = NPCColor
      .
    .
    position = actor["Position"]
    inRange = WorldSpaceToMiniMapSpace(position,answer)
    if inRange
      answer.x = answer.x - mycenter.x
      answer.y = answer.y - mycenter.y
      answer.z = 0
      var dist = VectorLength(answer)
      if (dist > map.size.x/2)
        dot.visible = false // outside circular distance though within minimap range
      else
        var correctedPos = RotateAndScaleDot(answer,map.rotation,map.scale)
        dot.position.x = correctedPos.x + (map.size.x/2) - (dot.size.x/2)
        dot.position.y = correctedPos.y + (map.size.y/2) - (dot.size.y/2)
        if dot.visible == false
          dot.visible = true
        .
      .
    else
      add back dot to storage.children
    .
  .
  me.lastMinimapUpdate = SYSTEM.TIME.NOW
.

Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Minimap?
« Reply #1 on: Jan 18, 13, 09:24:39 AM »

What exactly do you mean by "does not see it"?  Does the method show up in the HeroSense list of fields and methods when you press '.' at the end of a nodeRef of that class?
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Minimap?
« Reply #2 on: Jan 18, 13, 03:31:17 PM »

Does the method show up in the HeroSense list of fields and methods when you press '.' at the end of a nodeRef of that class?
How does one do this? I have not heard of this before. Is that done in the console window or in actual script or during run time? I have been using the println from here http://hewiki.heroengine.com/wiki/Debug

By not seeing it, I mean the function/method does not get called or used. If it did, the println("using my OnRenderMiniMap") would show up, and I would know the function was called. Currently, it's using the other function with the same name, in the other script.
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Minimap?
« Reply #3 on: Jan 18, 13, 03:53:09 PM »

Quote
Is that done in the console window or in actual script or during run time?
It is in the script editor as you type the code.

Regarding your HaV_minimap class, I presume that is the class you used for your minimap prototype?

By default, the clean engine code creates the minimap control from the _minimap prototype, as seen in the method _newMinimap() of GUIClassMethods:
Code: (hsl) [Select]
minimap as NodeRef of Class _minimap = createNodeFromPrototype("_minimap")That prototype is, obviously, not using the class you created, unless you edited that prototype (but it is not recommended to edit clean engine code).

So, what you need to do is:
  • create a minimap prototype for your HaV_minimap class (if you haven't already)
  • In your GUI class which you should have glommed onto the $GUI system node, define method HE_newMinimap() and put in it the same code that is in _newMiniMap(), except using your prototype instead of _minimap.
« Last Edit: Jan 18, 13, 04:26:58 PM by ScottZarnke »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Minimap?
« Reply #4 on: Jan 18, 13, 04:29:14 PM »

We have had a working minimap in our world for quite some time.  About a month ago, it stopped working.  I also determined the render method was not being called. I just haven't dug into what has happened to make it stop working as I have been focused on other things right now.

In our case, areas were deleted and re-created about the time the minimap stopped working so I assumed it has something to do with that.

Not sure if the problem you are experiencing is the same underlying problem as in our world but I'll make deal with you.  You fix yours, post what the problem was.  If I fix ours first, I'll post my solution.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Minimap?
« Reply #5 on: Jan 18, 13, 08:03:40 PM »

Quote
It is in the script editor as you type the code.
Ah, ok, now I remember. Thanks.

Quote
used for your minimap prototype?
minimap as NodeRef of Class _minimap = createNodeFromPrototype("_minimap")

In HaV_GUIClassMethods it is defined with:
Code: [Select]
public function HaV_newMinimap() as NodeRef of Class _minimap
  println("making our new minmap")
  minimap as NodeRef of Class HaV_miniMap = createNodeFromPrototype("HaV_miniMap")
  minimap.build = true
  minimap.name = "minimap"
  minimap.scale = 0.7
  minimap.owner = 0
  EnableMiniMap(true)
  return minimap
.

This is called in E_playerAccountClassMethods by:
        $GUI._newMinimap()
        HaV_GUIClassMethods:HaV_newMinimap()

When I tried $GUI.HE_newMinimap() I get an error
Code: [Select]
19:50:40: !ERROR!HeroScript::HeroMachine::ScriptError:The method HE_NEWMINIMAP was not found on any of the classes on the node [id=1000000008 class=_GUI,E_GUI].
19:50:40: !ERROR!System:SCRIPT ERROR: The method HE_NEWMINIMAP was not found on any of the classes on the node [id=1000000008 class=_GUI,E_GUI].
01/18/2013 19:50:41
Call trace:
  Script E_playerAccountClassMethods line 8 me[9223372056184021581]
  Script _playerAccountClassMethods line 21 me[9223372056184021581]

Using the F5 tools System Node Configuration, HaV_GUI has been added to _GUI on the client side.

2) not sure if I have glommed yet. I did not quite understand the details in the wiki about it.
Quote
define method HE_newMinimap() and put in it the same code that is in _newMiniMap(), except using your prototype instead of _minimap.
shown above

Quote
experiencing is the same underlying problem
Ok, I will see what we get here. As I have just started working on this, I shall continue.
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Minimap?
« Reply #6 on: Jan 20, 13, 01:44:53 AM »

I was looking at the methods in _GUIMethodCallbackClassMethods and noticed that most of the HE_ scripts that can be overridden have a return None in their methods, while the render method has no return. I was just wondering if that might possibly be the reason it can't be overridden.
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Minimap?
« Reply #7 on: Jan 21, 13, 01:39:03 AM »

I found a partial solution, which does not really solve the problem, because it drops the frame rate way down to 12 fps. What I did was create a new window and add the minimap inside it. Then add a few buttons to determine which map was showing, area or world. And when I select the area button, it constantly updates the minimap, as the button is checked. So, its not using my HaV_onRenderMiniMap() function, but the _onRenderMiniMap() one. But it does keep an acurate location.

Preset pointers are:

  areaMap as NodeRef of Class GUIPanel = FindGUIControlByName(None, "game.HaV_Maps.minimap")
  Map as NodeRef of Class GUIPanel = FindGUIControlByName(None, "game.HaV_Maps.minimap.map")
  main as NodeRef of Class GUIControl = FindGUIControlByName(None, "game.HaV_Maps")

The values of the area button are:

      is "AreaButton"
        main.size.y = 225
        Map.texture = "MINIMAP"
        areaMap.visible = true
      .

The values of the world button are:

      is "WorldButton"
        main.size.y = 225
        Map.texture = "\GUI\e3_map.dds"                  // temp holder until map made
        Map.defaultStatePresentation.position.x = 0
        Map.defaultStatePresentation.position.y = 0
        Map.defaultStatePresentation.size.x = 1024
        Map.defaultStatePresentation.size.y = 1024
        areaMap.visible = true
      .

Logged