mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
stubbed some more states
- stubbed some ability stuff - moved packet things to loop instead of session only - added mob roaming and aggro - todo: fix target find/detection/pathfinding speed/line of sight/line aoe length etc - todo: see "// todo:" in code
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FFXIVClassic.Common;
|
||||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.actors.chara.npc;
|
||||
using FFXIVClassic_Map_Server.actors;
|
||||
@@ -28,7 +29,11 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
{
|
||||
public HateContainer hateContainer;
|
||||
public AggroType aggroType;
|
||||
public bool neutral;
|
||||
private uint despawnTime;
|
||||
private uint spawnDistance;
|
||||
|
||||
private float spawnX, spawnY, spawnZ;
|
||||
public BattleNpc(int actorNumber, ActorClass actorClass, string uniqueId, Area spawnedArea, float posX, float posY, float posZ, float rot,
|
||||
ushort actorState, uint animationId, string customDisplayName)
|
||||
: base(actorNumber, actorClass, uniqueId, spawnedArea, posX, posY, posZ, rot, actorState, animationId, customDisplayName)
|
||||
@@ -43,14 +48,31 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
|
||||
this.hateContainer = new HateContainer(this);
|
||||
this.allegiance = CharacterTargetingAllegiance.BattleNpcs;
|
||||
|
||||
spawnX = posX;
|
||||
spawnY = posY;
|
||||
spawnZ = posZ;
|
||||
|
||||
// todo: read this from db
|
||||
aggroType = AggroType.Sight;
|
||||
this.moveState = 2;
|
||||
ResetMoveSpeeds();
|
||||
this.meleeRange = 1.5f;
|
||||
despawnTime = 10;
|
||||
}
|
||||
|
||||
public override void Update(DateTime tick)
|
||||
{
|
||||
// todo:
|
||||
this.aiContainer.Update(tick);
|
||||
this.statusEffects.Update(tick);
|
||||
}
|
||||
|
||||
public override bool CanAttack()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
///<summary> // todo: create an action object? </summary>
|
||||
public bool OnAttack(AttackState state)
|
||||
{
|
||||
@@ -60,16 +82,77 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
public override void Spawn(DateTime tick)
|
||||
{
|
||||
base.Spawn(tick);
|
||||
|
||||
this.isMovingToSpawn = false;
|
||||
this.ResetMoveSpeeds();
|
||||
this.ChangeState(SetActorStatePacket.MAIN_STATE_PASSIVE);
|
||||
}
|
||||
|
||||
public override void Die(DateTime tick)
|
||||
{
|
||||
base.Die(tick);
|
||||
if (IsAlive())
|
||||
{
|
||||
aiContainer.InternalDie(tick, despawnTime);
|
||||
|
||||
this.ResetMoveSpeeds();
|
||||
this.positionX = oldPositionX;
|
||||
this.positionY = oldPositionY;
|
||||
this.positionZ = oldPositionZ;
|
||||
this.isAtSpawn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var err = $"[{actorId}][{customDisplayName}] {positionX} {positionY} {positionZ} {GetZoneID()} tried to die ded";
|
||||
Program.Log.Error(err);
|
||||
//throw new Exception(err);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRoam(DateTime tick)
|
||||
{
|
||||
// todo: move this to battlenpccontroller..
|
||||
bool foundActor = false;
|
||||
|
||||
// leash back to spawn
|
||||
if (!IsCloseToSpawn())
|
||||
{
|
||||
isMovingToSpawn = true;
|
||||
aiContainer.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isMovingToSpawn = false;
|
||||
}
|
||||
|
||||
// dont bother checking for any in-range players if going back to spawn
|
||||
if (!this.isMovingToSpawn && this.aggroType != AggroType.None)
|
||||
{
|
||||
foreach (var player in zone.GetActorsAroundActor<Player>(this, 50))
|
||||
{
|
||||
uint levelDifference = (uint)Math.Abs(this.charaWork.parameterSave.state_mainSkillLevel - player.charaWork.parameterSave.state_mainSkillLevel);
|
||||
|
||||
if (levelDifference < 10 && ((BattleNpcController)aiContainer.GetController()).CanAggroTarget(player))
|
||||
hateContainer.AddBaseHate(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
aiContainer.pathFind.PathInRange(spawnX, spawnY, spawnZ, 1.0f, 35.0f);
|
||||
}
|
||||
|
||||
public uint GetDespawnTime()
|
||||
{
|
||||
return despawnTime;
|
||||
}
|
||||
|
||||
public void SetDespawnTime(uint seconds)
|
||||
{
|
||||
despawnTime = seconds;
|
||||
}
|
||||
|
||||
public bool IsCloseToSpawn()
|
||||
{
|
||||
return this.isAtSpawn = Utils.DistanceSquared(positionX, positionY, positionZ, spawnX, spawnY, spawnZ) <= 2500.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -396,7 +396,8 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||
|
||||
public override void Update(DateTime tick)
|
||||
{
|
||||
|
||||
// todo: can normal npcs have status effects?
|
||||
aiContainer.Update(tick);
|
||||
}
|
||||
|
||||
//A party member list packet came, set the party
|
||||
|
Reference in New Issue
Block a user