forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttack.cs
More file actions
76 lines (64 loc) · 1.97 KB
/
Copy pathAttack.cs
File metadata and controls
76 lines (64 loc) · 1.97 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
using System.Collections.Generic;
using L2dotNET.Models;
namespace L2dotNET.Network.serverpackets
{
class Attack : GameserverPacket
{
public List<Hit> Hits { get; set; }
private readonly int _attackerId;
private readonly int _x;
private readonly int _y;
private readonly int _z;
private readonly bool Soulshot;
private readonly int Grade;
public Attack(L2Character player, params Hit[] hits)
{
_attackerId = player.ObjectId;
_x = player.X;
_y = player.Y;
_z = player.Z;
Hits = new List<Hit>(hits);
}
public Attack(L2Character player, L2Object target, bool ss, int grade)
{
_attackerId = player.ObjectId;
Soulshot = ss;
Grade = grade;
_x = player.X;
_y = player.Y;
_z = player.Z;
Hits = new List<Hit>(0);
}
public void AddHit(int targetId, int damage, bool miss, bool crit, bool shld)
{
int pos = Hits.Count;
Hit[] tmp = new Hit[pos + 1];
for (int i = 0; i < Hits.Count; i++)
tmp[i] = Hits[i];
tmp[pos] = new Hit(targetId, damage, miss, crit, shld, Soulshot, Grade);
// Hits = tmp;
}
public bool HasHits()
{
return Hits.Count > 0;
}
public override void Write()
{
WriteByte(0x05);
WriteInt(_attackerId);
WriteInt(Hits[0].TargetId);
WriteInt(Hits[0].Damage);
WriteByte(Hits[0].Flags);
WriteInt(_x);
WriteInt(_y);
WriteInt(_z);
WriteShort((short)(Hits.Count - 1));
for (int i = 1; i < Hits.Count; i++)
{
WriteInt(Hits[i].TargetId);
WriteInt(Hits[i].Damage);
WriteByte(Hits[i].Flags);
}
}
}
}