forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticObjTable.cs
More file actions
114 lines (101 loc) · 4.27 KB
/
Copy pathStaticObjTable.cs
File metadata and controls
114 lines (101 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections.Generic;
using System.IO;
using L2dotNET.Models.Npcs.Decor;
using L2dotNET.Models.Stats;
using L2dotNET.Utility;
using L2dotNET.World;
using NLog;
namespace L2dotNET.Tables
{
class StaticObjTable
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public static Dictionary<int, L2StaticObject> Objects { get; private set; }
public static void Initialize()
{
Objects = new Dictionary<int, L2StaticObject>();
using (StreamReader reader = new StreamReader(new FileInfo(@"scripts\staticobjects.txt").FullName))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine() ?? string.Empty;
if ((line.Length == 0) || line.StartsWithIgnoreCase("#"))
continue;
string[] pt = line.Split('\t');
L2StaticObject obj = null;
//TODO: Implement this
switch (pt[1])
{
case "map":
// obj = new L2TownMap(IdFactory.Instance.NextId(),null);
break;
case "chair":
// obj = new L2Chair(IdFactory.Instance.NextId(), null);
break;
case "pvp":
//obj = new L2PvPSign(IdFactory.Instance.NextId(), null);
break;
case "door":
//obj = new L2Door(IdFactory.Instance.NextId(), null);
break;
}
if (obj == null)
continue;
obj.StaticId = Convert.ToInt32(pt[0]);
for (byte ord = 2; ord < pt.Length; ord++)
{
string parameter = pt[ord];
string value = parameter.Substring(parameter.IndexOf('{') + 1);
value = value.Remove(value.Length - 1);
switch (parameter.Split('{')[0].ToLower())
{
case "spawn":
obj.SetLoc(value.Split(' '));
break;
case "tex":
obj.SetTex(value.Split(' '));
break;
case "htm":
obj.Htm = value;
break;
case "hp":
obj.CharacterStat = new CharacterStat(obj);
break;
case "defence":
obj.Pdef = Convert.ToInt32(value.Split(' ')[0]);
obj.Mdef = Convert.ToInt32(value.Split(' ')[1]);
break;
case "unlock":
{
foreach (string str in value.Split(' '))
{
switch (str)
{
case "trigger":
obj.UnlockTrigger = true;
break;
case "skill":
obj.UnlockSkill = true;
break;
case "drop":
obj.UnlockNpc = true;
break;
}
}
}
break;
}
}
Objects.Add(obj.StaticId, obj);
}
}
foreach (L2StaticObject o in Objects.Values)
{
L2World.AddObject(o);
o.OnSpawnAsync();
}
Log.Info($"Spawned {Objects.Count} objects.");
}
}
}