forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathL2Warrior.cs
More file actions
134 lines (109 loc) · 4.24 KB
/
Copy pathL2Warrior.cs
File metadata and controls
134 lines (109 loc) · 4.24 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.Linq;
using System.Threading.Tasks;
using L2dotNET.Models.Player;
using L2dotNET.Network.serverpackets;
using L2dotNET.Tables;
using L2dotNET.Templates;
using L2dotNET.Utility;
namespace L2dotNET.Models.Npcs
{
public class L2Warrior : L2Npc
{
public bool SpoilActive = false;
public DateTime Dtstart;
public L2Spawn TerritorySpawn;
public System.Timers.Timer socialTask;
public L2Warrior(SpawnTable spawnTable, int objectId, NpcTemplate template, L2Spawn spawn) : base(spawnTable, objectId, template, spawn)
{
}
public override string AsString()
{
return base.AsString().Replace("L2Npc", "L2Warrior");
}
public override async Task OnActionAsync(L2Player player)
{
await player.SendMessageAsync(AsString());
// TimeSpan ts = dtstart - DateTime.Now;
// player.sendMessage($"timems {(ts.TotalMilliseconds)}");
bool newtarget = false;
if (player.Target == null)
{
player.Target = this;
newtarget = true;
}
else
{
if (player.Target.ObjectId != ObjectId)
{
player.Target = this;
newtarget = true;
}
}
if (newtarget)
{
await player.SendPacketAsync(new MyTargetSelected(ObjectId, player.Level - Template.Level));
StatusUpdate su = new StatusUpdate(this);
su.Add(StatusUpdate.CurHp, (int)CharStatus.CurrentHp);
su.Add(StatusUpdate.MaxHp, (int)MaxHp);
await player.SendPacketAsync(su);
}
}
public override async Task OnSpawnAsync(bool notifyOthers = true)
{
await base.OnSpawnAsync(notifyOthers);
SpawnX = X;
SpawnY = Y;
SpawnZ = Z;
//socialTask = new System.Timers.Timer();
//socialTask.Interval = rnd.Next(10, 30) * 1000;
//socialTask.Elapsed += new System.Timers.ElapsedEventHandler(SocialTask);
//socialTask.Enabled = true;
}
private void SocialTask(object sender, System.Timers.ElapsedEventArgs e)
{
if (!CharMovement.CanMove() || IsAttacking())
return;
CharMovement.MoveTo(RandomThreadSafe.Instance.Next(SpawnX - 90, SpawnX + 90), RandomThreadSafe.Instance.Next(SpawnY - 90, SpawnY + 90), Z);
// broadcastPacket(new SocialAction(ObjID, rnd.Next(8)));
}
public override void StartAi()
{
}
public override async Task OnForcedAttackAsync(L2Player player)
{
await Task.Run(() =>
{
player.AttackingId = ObjectId;
});
}
public override async Task BroadcastUserInfoAsync()
{
foreach (L2Player obj in KnownObjects.Values.OfType<L2Player>())
await obj.SendPacketAsync(new NpcInfo(this));
}
public override async Task DoDieAsync(L2Character killer)
{
await base.DoDieAsync(killer);
if (killer is L2Player)
((L2Player)killer).RedistExp(this);
//Template.roll_drops(this, killer);
//if (TerritorySpawn != null)
// TerritorySpawn.OnDie(this, killer);
//socialTask.Enabled = false;
}
public override async Task OnActionShiftAsync(L2Player player)
{
string text = string.Empty;
//text += $"pdef: {CharacterStat.GetStat(EffectType.PPhysicalDefense)}<br>";
//text += $"patk: {CharacterStat.GetStat(EffectType.PPhysicalAttack)}<br>";
//text += $"curhp: {CurHp}<br>";
//text += $"maxhp: {CharacterStat.GetStat(EffectType.BMaxHp)}<br>";
//text += $"mdef: {CharacterStat.GetStat(EffectType.PMagicalAttack)}<br>";
//text += $"matk: {CharacterStat.GetStat(EffectType.PMagicalDefense)}<br>";
player.ShowHtmPlain(text, null);
await player.SendActionFailedAsync();
}
public override int Attackable => 1;
}
}