mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-21 04:07:48 +00:00
added super basic hate container class which doesnt actually do anything yet
This commit is contained in:
parent
2c9ae60bbf
commit
c162fb0eab
3 changed files with 92 additions and 0 deletions
|
@ -90,6 +90,7 @@
|
||||||
<Compile Include="actors\chara\ai\controllers\Controller.cs" />
|
<Compile Include="actors\chara\ai\controllers\Controller.cs" />
|
||||||
<Compile Include="actors\chara\ai\controllers\MobController.cs" />
|
<Compile Include="actors\chara\ai\controllers\MobController.cs" />
|
||||||
<Compile Include="actors\chara\ai\controllers\PlayerController.cs" />
|
<Compile Include="actors\chara\ai\controllers\PlayerController.cs" />
|
||||||
|
<Compile Include="actors\chara\ai\HateContainer.cs" />
|
||||||
<Compile Include="actors\chara\ai\PathFind.cs" />
|
<Compile Include="actors\chara\ai\PathFind.cs" />
|
||||||
<Compile Include="actors\chara\ai\state\AttackState.cs" />
|
<Compile Include="actors\chara\ai\state\AttackState.cs" />
|
||||||
<Compile Include="actors\chara\ai\state\State.cs" />
|
<Compile Include="actors\chara\ai\state\State.cs" />
|
||||||
|
|
89
FFXIVClassic Map Server/actors/chara/ai/HateContainer.cs
Normal file
89
FFXIVClassic Map Server/actors/chara/ai/HateContainer.cs
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using FFXIVClassic_Map_Server.Actors;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||||
|
{
|
||||||
|
// todo: actually implement enmity properly
|
||||||
|
class HateEntry
|
||||||
|
{
|
||||||
|
public Character actor;
|
||||||
|
public uint cumulativeEnmity;
|
||||||
|
public uint volatileEnmity;
|
||||||
|
public bool isActive;
|
||||||
|
|
||||||
|
public HateEntry(Character actor, uint cumulativeEnmity = 0, uint volatileEnmity = 0, bool isActive = false)
|
||||||
|
{
|
||||||
|
this.actor = actor;
|
||||||
|
this.cumulativeEnmity = cumulativeEnmity;
|
||||||
|
this.volatileEnmity = volatileEnmity;
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class HateContainer
|
||||||
|
{
|
||||||
|
private Dictionary<Character, HateEntry> hateList;
|
||||||
|
private Character owner;
|
||||||
|
|
||||||
|
public HateContainer(Character owner)
|
||||||
|
{
|
||||||
|
this.owner = owner;
|
||||||
|
this.hateList = new Dictionary<Character, HateEntry>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddBaseHate(Character target)
|
||||||
|
{
|
||||||
|
if (!HasHateForTarget(target))
|
||||||
|
hateList.Add(target, new HateEntry(target, 0, 0, true));
|
||||||
|
else
|
||||||
|
Program.Log.Error($"{target.actorName} is already on [{owner.actorId}]{owner.actorName}'s hate list!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearHate(Character target = null)
|
||||||
|
{
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
hateList.Remove(target);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hateList.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateHate(HateEntry entry)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<Character, HateEntry> GetHateList()
|
||||||
|
{
|
||||||
|
// todo: return unmodifiable collection?
|
||||||
|
return hateList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasHateForTarget(Character target)
|
||||||
|
{
|
||||||
|
return hateList.ContainsKey(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Character GetMostHatedTarget()
|
||||||
|
{
|
||||||
|
uint enmity = 0;
|
||||||
|
Character target = null;
|
||||||
|
|
||||||
|
foreach(var entry in hateList.Values)
|
||||||
|
{
|
||||||
|
if (entry.cumulativeEnmity > enmity && entry.isActive)
|
||||||
|
{
|
||||||
|
enmity = entry.cumulativeEnmity;
|
||||||
|
target = entry.actor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,12 +15,14 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
{
|
{
|
||||||
class Mob : Npc
|
class Mob : Npc
|
||||||
{
|
{
|
||||||
|
public HateContainer hateContainer;
|
||||||
public Mob(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot,
|
public Mob(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot,
|
||||||
ushort actorState, uint animationId, string customDisplayName)
|
ushort actorState, uint animationId, string customDisplayName)
|
||||||
: base(actorNumber, actorClass, uniqueId, spawnedArea, posX, posY, posZ, rot, actorState, animationId, customDisplayName)
|
: base(actorNumber, actorClass, uniqueId, spawnedArea, posX, posY, posZ, rot, actorState, animationId, customDisplayName)
|
||||||
{
|
{
|
||||||
this.aiContainer = new AIContainer(this, new MobController(this), new PathFind(this), new TargetFind(this));
|
this.aiContainer = new AIContainer(this, new MobController(this), new PathFind(this), new TargetFind(this));
|
||||||
this.currentSubState = SetActorStatePacket.SUB_STATE_MONSTER;
|
this.currentSubState = SetActorStatePacket.SUB_STATE_MONSTER;
|
||||||
|
this.hateContainer = new HateContainer(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue