The Error:
[Only registered and activated users can see links. Click Here To Register...]
Load NPCS
SpawnAllNpcs
I'm working on converting LOTF to ini and i've just converted accounts which works fine although i'm getting the error in the screenshot and the NPC does not load ingame.
I'm just doing this as a side project for when i'm bored, not planning on using it.
Any ideas?
[Only registered and activated users can see links. Click Here To Register...]
Load NPCS
Code:
public static void LoadNPCs()
{
try
{
System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(System.Windows.Forms.Application.StartupPath + @"\NPCS\\");
int count;
count = d.GetFiles().Length;
Console.WriteLine("File Count: " + count);
if (count >= 1)
{
NPCs = new uint[count][];
for (int i = 0; i < count; i++)
{
string filepath = System.Windows.Forms.Application.StartupPath + @"\NPCS\\" + i + ".ini";
if (System.IO.File.Exists(filepath))
{
Ini NPC = new Ini(filepath);
uint npctype = uint.Parse(NPC.ReadValue("Data", "Type"));
uint npcflags = uint.Parse(NPC.ReadValue("Data", "Flags"));
uint npcdirection = uint.Parse(NPC.ReadValue("Data", "Flags"));
uint npcx = uint.Parse(NPC.ReadValue("Data", "X"));
uint npcy = uint.Parse(NPC.ReadValue("Data", "Y"));
uint npcmap = uint.Parse(NPC.ReadValue("Data", "Map"));
uint npcsobtype = uint.Parse(NPC.ReadValue("Data", "SobType"));
Console.WriteLine("NPC ID: " + i + " loaded - " + npctype + "," + npcflags + "," + npcdirection + "," + npcx + "," + npcy + "," + npcmap + "," + npcsobtype + ".");
NPCs[i] = new uint[8] { (uint)i, npctype, npcflags, npcdirection, npcx, npcy, npcmap, npcsobtype };
}
}
}
General.WriteLine("Loaded " + count + " NPCs.");
}
catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
//Console.WriteLine("NOTE TO SELF: CONVERT LOADNPCS() to INI");
}
Code:
public static void SpawnAllNPCs()
{
try
{
foreach (uint[] NPC in DataBase.NPCs)
{
SingleNPC npc = new SingleNPC(Convert.ToUInt32(NPC[0]), Convert.ToUInt32(NPC[1]), Convert.ToByte(NPC[2]), Convert.ToByte(NPC[3]), Convert.ToInt16(NPC[4]), Convert.ToInt16(NPC[5]), Convert.ToInt16(NPC[6]), Convert.ToByte(NPC[7]));
AllNPCs.Add(npc.UID, npc);
}
DataBase.NPCs = null;
SingleNPC npcc = new SingleNPC(614, 1450, 2, 0, (short)DataBase.GC1X, (short)DataBase.GC1Y, (short)DataBase.GC1Map, 0);
AllNPCs.Add(614, npcc);
npcc = new SingleNPC(615, 1460, 2, 0, (short)DataBase.GC2X, (short)DataBase.GC2Y, (short)DataBase.GC2Map, 0);
AllNPCs.Add(615, npcc);
npcc = new SingleNPC(616, 1470, 2, 0, (short)DataBase.GC3X, (short)DataBase.GC3Y, (short)DataBase.GC3Map, 0);
AllNPCs.Add(616, npcc);
npcc = new SingleNPC(617, 1480, 2, 0, (short)DataBase.GC4X, (short)DataBase.GC4Y, (short)DataBase.GC4Map, 0);
AllNPCs.Add(617, npcc);
}
catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
}
}
I'm just doing this as a side project for when i'm bored, not planning on using it.
Any ideas?