mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
stubbed some more functions from kj's ai stuff
- fixed some typos - cleaned some debug code
This commit is contained in:
@@ -171,35 +171,6 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
if (this.target != player)
|
||||
{
|
||||
#region super important performance critical code
|
||||
|
||||
this.ChangeState(SetActorStatePacket.MAIN_STATE_MOUNTED);
|
||||
|
||||
var chatMode = Program.Random.Next(13);
|
||||
var emphasis = Program.Random.Next(9);
|
||||
var drag = Program.Random.Next(7);
|
||||
|
||||
chatMode = chatMode.Clamp(1, 12);
|
||||
|
||||
string oni = "ONI";
|
||||
string chan = "CHA";
|
||||
|
||||
for (var i = 0; i < emphasis; ++i)
|
||||
oni += "I";
|
||||
|
||||
for (var i = 0; i < drag; ++i)
|
||||
chan += "A";
|
||||
|
||||
oni += "-";
|
||||
chan += "N";
|
||||
|
||||
// imouto aggro
|
||||
player.SendMessage((uint)chatMode, "Rowena", oni + chan);
|
||||
// sing for onii
|
||||
this.PlayAnimation(Program.Random.Next(0, 2) == 1 ? (uint)67111904 : (uint)67108902);
|
||||
|
||||
#endregion
|
||||
|
||||
this.target = target;
|
||||
}
|
||||
this.moveState = player.moveState;
|
||||
@@ -221,7 +192,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(DateTime tick)
|
||||
public override void Update(DateTime tick)
|
||||
{
|
||||
// todo: actual ai controllers
|
||||
// todo: mods to control different params instead of hardcode
|
||||
|
@@ -47,6 +47,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
controller.Update(tick);
|
||||
}
|
||||
|
||||
public void CheckCompletedStates()
|
||||
{
|
||||
while (states.Count > 0 && states.Peek().IsCompleted())
|
||||
{
|
||||
states.Peek().Cleanup();
|
||||
states.Pop();
|
||||
}
|
||||
}
|
||||
|
||||
public void InterruptStates()
|
||||
{
|
||||
while (states.Count > 0 && states.Peek().CanInterrupt())
|
||||
@@ -73,21 +82,51 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
|
||||
public bool CanChangeState()
|
||||
{
|
||||
return states.Count == 0 || states.First().CanInterrupt();
|
||||
return states.Count == 0 || states.Peek().CanInterrupt();
|
||||
}
|
||||
|
||||
public void ChangeTarget(Character target)
|
||||
{
|
||||
if (controller != null)
|
||||
{
|
||||
controller.ChangeTarget(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeState(State state)
|
||||
{
|
||||
if (states.Count < 10)
|
||||
if (GetCurrentState() != null)
|
||||
{
|
||||
if (states.Count <= 10)
|
||||
{
|
||||
CheckCompletedStates();
|
||||
states.Push(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("shit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ForceChangeState(State state)
|
||||
{
|
||||
if (states.Count <= 10)
|
||||
{
|
||||
CheckCompletedStates();
|
||||
states.Push(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("shit");
|
||||
throw new Exception("force shit");
|
||||
}
|
||||
}
|
||||
|
||||
public State GetCurrentState()
|
||||
{
|
||||
return states.Peek() ?? null;
|
||||
}
|
||||
|
||||
public DateTime GetLatestUpdate()
|
||||
{
|
||||
return latestUpdate;
|
||||
@@ -157,11 +196,31 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
InternalMobSkill(target, mobSkillId);
|
||||
}
|
||||
|
||||
public void InternalEngage(Character target)
|
||||
public void InternalChangeTarget(Character target)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool InternalEngage(Character target)
|
||||
{
|
||||
if (IsEngaged())
|
||||
{
|
||||
if (this.owner.target != target)
|
||||
{
|
||||
ChangeTarget(target);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CanChangeState() || (GetCurrentState() != null && GetCurrentState().IsCompleted()))
|
||||
{
|
||||
ForceChangeState(new AttackState(this.owner, target));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void InternalDisengage()
|
||||
{
|
||||
|
||||
|
@@ -363,7 +363,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
private byte tier; // same effect with higher tier overwrites this
|
||||
private Dictionary<string, UInt64> variables; // list of variables which belong to this effect, to be set/retrieved with GetVariable(key), SetVariable(key, val)
|
||||
private StatusEffectFlags flags; // death/erase/dispel etc
|
||||
private StatusEffectOverwrite overwrite; //
|
||||
private StatusEffectOverwrite overwrite; // how to handle adding an effect with same id (see StatusEfectOverwrite)
|
||||
|
||||
public StatusEffect(Character owner, uint id, int magnitude, uint tickMs, uint durationMs, byte tier = 0)
|
||||
{
|
||||
@@ -602,5 +602,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool HasStatusEffectsByFlag(uint flag)
|
||||
{
|
||||
foreach (var effect in effects)
|
||||
{
|
||||
if ((effect.GetFlags() & flag) > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
|
||||
public virtual void ChangeTarget(Character target)
|
||||
{
|
||||
owner.aiContainer.InternalEngage(target);
|
||||
owner.aiContainer.InternalChangeTarget(target);
|
||||
}
|
||||
|
||||
public bool IsAutoAttackEnabled()
|
||||
|
@@ -24,6 +24,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
|
||||
public override bool Engage(Character target)
|
||||
{
|
||||
// todo: check distance, last swing time, status effects
|
||||
this.owner.aiContainer.InternalEngage(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
base(owner, target)
|
||||
{
|
||||
this.startTime = DateTime.Now;
|
||||
// todo: should handle everything here instead of on next tick..
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
@@ -32,7 +33,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
public override void OnComplete()
|
||||
{
|
||||
|
||||
isCompleted = true;
|
||||
}
|
||||
|
||||
public override void TryInterrupt()
|
||||
|
@@ -20,6 +20,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
|
||||
protected SubPacket errorPacket;
|
||||
|
||||
protected bool isCompleted;
|
||||
|
||||
public State(Character owner, Character target)
|
||||
{
|
||||
this.owner = owner;
|
||||
@@ -29,9 +31,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
}
|
||||
|
||||
public virtual void Update(DateTime tick) { }
|
||||
public virtual void OnStart() { }
|
||||
public virtual void OnStart() { }
|
||||
public virtual void OnInterrupt() { }
|
||||
public virtual void OnComplete() { }
|
||||
public virtual void OnComplete() { isCompleted = true; }
|
||||
|
||||
public virtual void TryInterrupt() { }
|
||||
|
||||
@@ -47,5 +49,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
||||
this.interrupt = interrupt;
|
||||
}
|
||||
|
||||
public bool IsCompleted()
|
||||
{
|
||||
return isCompleted;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -85,6 +85,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
isStatic = true;
|
||||
}
|
||||
}
|
||||
GenerateActorName((int)actorNumber);
|
||||
this.aiContainer = new AIContainer(this, null, new PathFind(this), new TargetFind(this));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user