forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL2Territory.cs
More file actions
109 lines (95 loc) · 3.03 KB
/
Copy pathL2Territory.cs
File metadata and controls
109 lines (95 loc) · 3.03 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
using System;
using System.Collections.Generic;
using L2dotNET.Models.Zones.forms;
using L2dotNET.Utility;
using NLog;
namespace L2dotNET.Tables
{
public class L2Territory
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public string Name;
public string Controller;
public bool StartActive;
public List<L2Spawn> Spawns = new List<L2Spawn>();
public List<int[]> TerritoryLoc = new List<int[]>();
public ZoneNPoly Territory;
public void AddNpc(int id, int count, string respawn, string pos)
{
int value = Convert.ToInt32(respawn.Remove(respawn.Length - 1));
if (respawn.Contains("s"))
value *= 1000;
else
{
if (respawn.Contains("m"))
value *= 60000;
else
{
if (respawn.Contains("h"))
value *= 3600000;
else
{
if (respawn.Contains("d"))
value *= 86400000;
}
}
}
// for (int a = 0; a < count; a++)
// Spawns.Add(new L2Spawn(id, value, this, pos));
}
public void AddPoint(string[] loc)
{
int x = Convert.ToInt32(loc[0]);
int y = Convert.ToInt32(loc[1]);
int zmin = Convert.ToInt32(loc[2]);
int zmax;
try
{
zmax = Convert.ToInt32(loc[3]);
}
catch (Exception e)
{
Log.Error($"err in {loc[3]}. Message: {e.Message}");
throw;
}
TerritoryLoc.Add(new[] { x, y, zmin, zmax });
}
public void InitZone()
{
int z1 = 0,
z2 = 0;
int[] x = new int[TerritoryLoc.Count];
int[] y = new int[TerritoryLoc.Count];
byte i = 0;
foreach (int[] l in TerritoryLoc)
{
x[i] = l[0];
y[i] = l[1];
z1 = l[2];
z2 = l[3];
i++;
}
Territory = new ZoneNPoly(x, y, z1, z2);
}
public void Spawn()
{
//Spawns.ForEach(sp => sp.Init());
}
public int[] GetSpawnLocation()
{
for (short a = 0; a < short.MaxValue; a++) //TODO FIX
{
int rndx = RandomThreadSafe.Instance.Next(Territory.minX, Territory.maxX);
int rndy = RandomThreadSafe.Instance.Next(Territory.minY, Territory.maxY);
if (Territory.isInsideZone(rndx, rndy))
return new[] { rndx, rndy, Territory.getHighZ() };
}
Log.Error("getSpawnLocation failed after 400 tries. omg!");
return null;
}
public void SunRise(bool y)
{
// Spawns.ForEach(sp => sp.SunRise(y));
}
}
}