What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

How to access Terrain Data Entries via DevTab

tozededao

Community Developer
Joined
Jan 15, 2010
Messages
1,225
Reaction score
5
Hello, I'm trying to make a plugin for Voll farm by running straight to him, similar to DockCorruptedFarmer.

I was trying to debug the Terrain Data Entries to see which one matched Voll zone but I wasn't able to do so via DevTab because it was showing me this Exception:

Code:
An exception occurred:
System.Exception: Line number 6, Error Number: CS1002, 'Expected ;;


   in DevTab.Gui.Dev_Execute(String class, String code, IEnumerable`1 assemblies) in **plugins\DevTab\Gui.xaml.cs:line 154

This is basically what I was trying to do :

Code:
 LokiPoe.TerrainDataEntry[,] tgtEntries = LokiPoe.TerrainData.GetTgtEntries();
                for (int i = 0; i < tgtEntries.GetLength(0); i++)
                {
                    for (int j = 0; j < tgtEntries.GetLength(1); j++)
                    {
                        LokiPoe.TerrainDataEntry terrainDataEntry = tgtEntries[i, j];
                        if (terrainDataEntry != null)
                        {
							Log.Alert(terrainDataEntry.TgtName.toString());
                            Log.Alert("distance is" + LokiPoe.Me.Position.Distance(FindWalkablePathToTerrainObject(i, j)));							
                          
                        }
                    }
                }

This way I would get all the entries and respective distance to them, I would just walk to the one that has voll inside and see the closest one.
 
You have a syntax error in your code, so that's what the exception is saying. toString should be ToString, FindWalkablePathToTerrainObject doesn't exist, stuff like that.

If you're using Beta, I added a hotkey to dump the TGT under the player so check out the hotkey list and use that to get the name of the tile.

Once you have the col/row of the tile, and can find it each time, you can get the actual coords like this:

Code:
		static Vector2i GetPositionForTile(int c, int r)
		{
			var pos = new Vector2i(c*23 + 12, r*23 + 12);

			var newpos = ExilePather.FindWalkableLocationsCloseTo(pos, 12).FirstOrDefault();
			if (newpos == default(Vector2i))
			{
				return Vector2i.Zero;
			}

			return newpos;
		}

Here's a snippet to run in the Dev tab in Beta that does that, you'd have to find the right tile though:
Code:
using System;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading.Tasks;
using Buddy.Coroutines;
using Loki;
using Loki.Common;
using Loki.Game;
using Loki.Game.GameData;
using Loki.Bot;
using Loki.Bot.Pathfinding;
using log4net;

public class RuntimeCode
{
	private static readonly ILog Log = Logger.GetLoggerInstanceForType();

	private Coroutine _coroutine;

	static Vector2i GetPositionForTile(int c, int r)
	{
		var pos = new Vector2i(c*23 + 12, r*23 + 12);

		var newpos = ExilePather.FindWalkableLocationsCloseTo(pos, 12).FirstOrDefault();
		if (newpos == default(Vector2i))
		{
			return Vector2i.Zero;
		}

		return newpos;
	}
		
	public void Execute()
	{
		using(LokiPoe.AcquireFrame())
		{
			LokiPoe.TerrainDataEntry[,] tgtEntries = LokiPoe.TerrainData.GetTgtEntries();
			for (int i = 0; i < tgtEntries.GetLength(0); i++)
			{
				for (int j = 0; j < tgtEntries.GetLength(1); j++)
				{
					LokiPoe.TerrainDataEntry terrainDataEntry = tgtEntries[i, j];
					if (terrainDataEntry != null)
					{
						if(terrainDataEntry.TgtName == "Art/Models/Terrain/Beach/LargeCliffs/beach_top_01_c3r2.tgt")
						{
							Log.InfoFormat("{0} found at {1}.", terrainDataEntry.TgtName, GetPositionForTile(i, j));
						}
					}
				}
			}
		}
	}
}
 
Are you sure it was a typo? I tried to run the DevTab with the default code and showed me the same error.

Code:
An exception occurred:System.Exception: Line number 0, Error Number: CS0006, 'Couldn't locate metadata file 'Buddy.Coroutines.dll';


   in DevTab.Gui.Dev_Execute(String class, String code, IEnumerable`1 assemblies) in ***\Plugins\DevTab\Gui.xaml.cs:line 154

Using the code you provided also gives me this error.

I translated the error because it was on my main language.
 
Last edited:
You have a syntax error in your code, so that's what the exception is saying. toString should be ToString, FindWalkablePathToTerrainObject doesn't exist, stuff like that.

If you're using Beta, I added a hotkey to dump the TGT under the player so check out the hotkey list and use that to get the name of the tile.

Once you have the col/row of the tile, and can find it each time, you can get the actual coords like this:

Code:
        static Vector2i GetPositionForTile(int c, int r)
        {
            var pos = new Vector2i(c*23 + 12, r*23 + 12);

            var newpos = ExilePather.FindWalkableLocationsCloseTo(pos, 12).FirstOrDefault();
            if (newpos == default(Vector2i))
            {
                return Vector2i.Zero;
            }

            return newpos;
        }

Here's a snippet to run in the Dev tab in Beta that does that, you'd have to find the right tile though:
Code:
using System;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading.Tasks;
using Buddy.Coroutines;
using Loki;
using Loki.Common;
using Loki.Game;
using Loki.Game.GameData;
using Loki.Bot;
using Loki.Bot.Pathfinding;
using log4net;

public class RuntimeCode
{
    private static readonly ILog Log = Logger.GetLoggerInstanceForType();

    private Coroutine _coroutine;

    static Vector2i GetPositionForTile(int c, int r)
    {
        var pos = new Vector2i(c*23 + 12, r*23 + 12);

        var newpos = ExilePather.FindWalkableLocationsCloseTo(pos, 12).FirstOrDefault();
        if (newpos == default(Vector2i))
        {
            return Vector2i.Zero;
        }

        return newpos;
    }
        
    public void Execute()
    {
        using(LokiPoe.AcquireFrame())
        {
            LokiPoe.TerrainDataEntry[,] tgtEntries = LokiPoe.TerrainData.GetTgtEntries();
            for (int i = 0; i < tgtEntries.GetLength(0); i++)
            {
                for (int j = 0; j < tgtEntries.GetLength(1); j++)
                {
                    LokiPoe.TerrainDataEntry terrainDataEntry = tgtEntries[i, j];
                    if (terrainDataEntry != null)
                    {
                        if(terrainDataEntry.TgtName == "Art/Models/Terrain/Beach/LargeCliffs/beach_top_01_c3r2.tgt")
                        {
                            Log.InfoFormat("{0} found at {1}.", terrainDataEntry.TgtName, GetPositionForTile(i, j));
                        }
                    }
                }
            }
        }
    }
}


I swear I knew that there was something that did that I just couldn't find it.

I tried to use it while I was standing on top of Voll zone and it printed:

Code:
LokiPoe.ProcessHookManager.DumpTGT pressed.
[24, 28] Art/Models/Terrain/Blank.tgt

Tried running a lot on different positions

Code:
LokiPoe.ProcessHookManager.DumpTGT pressed.
[15, 55] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[17, 53] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[16, 52] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[16, 52] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[16, 51] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[16, 50] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[16, 49] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[16, 49] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[16, 48] Art/Models/Terrain/Blank.tgt
LokiPoe.ProcessHookManager.DumpTGT pressed.
[15, 47] Art/Models/Terrain/Blank.tgt
 
Last edited:
I swear I knew that there was something that did that I just couldn't find it.

I tried to use it while I was standing on top of Voll zone and it printed:

Code:
LokiPoe.ProcessHookManager.DumpTGT pressed.
[24, 28] Art/Models/Terrain/Blank.tgt
That's cause the TGT is blank lol. It's correct for the Dev tab that Pushedx gave you.. You are lucky that Pushedx put in a hoykey, I had to manually do this back then and it was a pita.
 
I tried this code

Code:
using System;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading.Tasks;
using Buddy.Coroutines;
using Loki;
using Loki.Common;
using Loki.Game;
using Loki.Game.GameData;
using Loki.Bot;
using Loki.Bot.Pathfinding;
using log4net;


public class RuntimeCode
{
    private static readonly ILog Log = Logger.GetLoggerInstanceForType();


    private Coroutine _coroutine;


    static Vector2i GetPositionForTile(int c, int r)
    {
        var pos = new Vector2i(c * 23 + 12, r * 23 + 12);


        var newpos = ExilePather.FindWalkableLocationsCloseTo(pos, 12).FirstOrDefault();
        if (newpos == default(Vector2i))
        {
            return Vector2i.Zero;
        }


        return newpos;
    }


    public void Execute()
    {
        using (LokiPoe.AcquireFrame())
        {
            LokiPoe.TerrainDataEntry[,] tgtEntries = LokiPoe.TerrainData.GetTgtEntries();
            for (int i = 0; i < tgtEntries.GetLength(0); i++)
            {
                for (int j = 0; j < tgtEntries.GetLength(1); j++)
                {
                    LokiPoe.TerrainDataEntry terrainDataEntry = tgtEntries[i, j];
                    if (terrainDataEntry != null)
                    {
                        int rangeCalc = LokiPoe.Me.Position.Distance(GetPositionForTile(i, j));
                        if (rangeCalc < 50)
                        {
                            Log.InfoFormat(rangeCalc + " - " + terrainDataEntry.TgtName);


                        }
                        
                       
                    }
                }
            }
        }
    }
}

While standing on top of Voll Zone, this was the output

Code:
36 - Art/Models/Terrain/Act4/DriedLake/rockwall_v01_02_c3r2.tgt
46 - Art/Models/Terrain/Act4/DriedLake/rockwall_v01_02_c3r3.tgt
41 - Art/Models/Terrain/Act4/DriedLake/rockwall_v03_01_c3r3.tgt
20 - Art/Models/Terrain/Blank.tgt
14 - Art/Models/Terrain/Blank.tgt
32 - Art/Models/Terrain/Blank.tgt
24 - Art/Models/Terrain/Act4/DriedLake/rockwall_v03_01_c3r2.tgt
18 - Art/Models/Terrain/Blank.tgt
17 - Art/Models/Terrain/Blank.tgt
36 - Art/Models/Terrain/Blank.tgt
38 - Art/Models/Terrain/Blank.tgt
 
That's cause the TGT is blank lol. It's correct for the Dev tab that Pushedx gave you.. You are lucky that Pushedx put in a hoykey, I had to manually do this back then and it was a pita.

So basically the tileset that has Voll inside is just called blank? GGG haven't named it yet? Bleh, I've had this output before and I thought I was doing something wrong, oh well :D

Thanks for the help \o/
 
Back
Top