How does the '/killAll' command work? How are objects assigned the 'enemy' attribute other than using the XML tag?
Basically can someone explain what this code does?
Code:
class KillAll : Command
{
public KillAll() : base("killAll", Ranks.Admin)
{
}
protected override bool Process(Player player, RealmTime time, string[] args)
{
var iterations = 0;
var lastKilled = -1;
var killed = 0;
var mobName = args.Aggregate((s, a) => string.Concat(s, " ", a));
while (killed != lastKilled)
{
lastKilled = killed;
foreach (var i in player.Owner.Enemies.Values.Where(e =>
e.ObjectDesc?.ObjectId != null && e.ObjectDesc.ObjectId.ContainsIgnoreCase(mobName)))
{
i.Death(time);
killed++;
}
if (++iterations >= 5)
break;
}
player.SendInfo($"{killed} enemy killed!");
return true;
}
}
I am interested because the object in nexus called 'mb shopkeeper1' is deemed an enemy and is therefore removed when entering '/killAll'. I want to try and remove this.