fixed mob loading from db

- todo: see todos in code (all 169 of them)
This commit is contained in:
Tahir Akhlaq 2017-09-07 22:02:02 +01:00
parent 7c30b95c4b
commit 645a1fb4fb
12 changed files with 169 additions and 82 deletions

View file

@ -109,7 +109,6 @@ namespace FFXIVClassic_Map_Server.Actors
this.moveSpeeds[2] = SetActorSpeedPacket.DEFAULT_RUN;
this.moveSpeeds[3] = SetActorSpeedPacket.DEFAULT_ACTIVE;
// todo: make this halal
this.moveState = this.oldMoveState;
this.updateFlags |= ActorUpdateFlags.Speed;
}
@ -649,13 +648,13 @@ namespace FFXIVClassic_Map_Server.Actors
rotation = (float)dRot;
}
// todo: is this legit?
public bool IsFacing(float x, float z, float angle = 40.0f)
{
angle = (float)(Math.PI * angle / 180);
return Math.Abs(Vector3.GetAngle(positionX, positionZ, x, z) - rotation) < angle;
}
// todo: is this legit?
public bool IsFacing(Actor target, float angle = 40.0f)
{
if (target == null)

View file

@ -182,18 +182,15 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public void Clear()
{
// todo:
path?.Clear();
pathFlags = PathFindFlags.None;
distanceFromPoint = 0.0f;
}
private float GetSpeed()
{
float baseSpeed = owner.GetSpeed();
// todo: get actual speed crap
if (!(owner is Player))
{
if (owner is BattleNpc)

View file

@ -381,7 +381,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
this.durationMs = durationMs;
this.tier = tier;
// todo: use tick instead of now?
this.startTime = DateTime.Now;
this.lastTick = startTime;
}
@ -415,19 +414,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
// return true when duration has elapsed
public bool Update(DateTime tick)
{
// todo: maybe not tick if already reached duration?
if (tickMs != 0 && (tick - lastTick).TotalMilliseconds >= tickMs)
{
// todo: call effect's onTick
// todo: maybe keep a global lua object instead of creating a new one each time we wanna call a script
lastTick = tick;
LuaEngine.CallLuaStatusEffectFunction(this.owner, this, "onTick", this.owner, this);
}
// todo: handle infinite duration effects?
if (durationMs != 0 && (tick - startTime).TotalMilliseconds >= durationMs)
{
// todo: call effect's onLose
// todo: broadcast effect lost packet
return true;
}
return false;

View file

@ -73,7 +73,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
32001 [@2B([@IF($E4($EB(1),$EB(2)),you,[@IF($E9(7),[@SHEETEN(xtx/displayName,2,$E9(7),1,1)],$EB(2))])])] [@IF($E4($EB(1),$EB(2)),resist,resists)] the effect of [@SHEET(xtx/status,$E8(11),3)].
32002 [@SHEET(xtx/status,$E8(11),3)] fails to take effect.
*/
// todo: check flags/overwritable and add effect to list
var effect = GetStatusEffectById(newEffect.GetStatusEffectId());
bool canOverwrite = false;
if (effect != null)
@ -100,7 +99,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
effects.Add(newEffect.GetStatusEffectId(), newEffect);
newEffect.SetSilent(silent);
// todo: this is retarded..
{
var index = Array.IndexOf(effects.Values.ToArray(), newEffect);
owner.charaWork.status[index] = newEffect.GetStatusId();
@ -128,7 +126,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
}
// todo: this is retarded..
{
var index = Array.IndexOf(effects.Values.ToArray(), effect);
owner.charaWork.status[index] = 0;

View file

@ -150,7 +150,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
validTarget = flags;
// todo: maybe this should only be set if successfully added?
this.targetPosition = target.GetPosAsVector3();
AddTarget(target, false);
}
@ -161,7 +160,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public void FindWithinArea(Character target, ValidTarget flags, TargetFindAOETarget aoeTarget)
{
validTarget = flags;
// todo: maybe we should keep a snapshot which is only updated on each tick for consistency
// are we creating aoe circles around target or self
if (aoeTarget == TargetFindAOETarget.Self)
this.targetPosition = owner.GetPosAsVector3();
@ -182,7 +180,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
findType = TargetFindCharacterType.PlayerToPlayer;
// todo: handle player parties
if (masterTarget.currentParty != null)
{
if ((validTarget & (ValidTarget.Ally | ValidTarget.PartyMember)) != 0)
@ -273,7 +270,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
private void AddAllInParty(Character target, bool withPet)
{
// todo:
var party = target.currentParty as Party;
if (party != null)
{
@ -294,10 +290,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
var actors = owner.zone.GetActorsAroundActor<BattleNpc>(owner, 50);
// todo: should we look for Characters instead in case player is charmed by BattleNpc
foreach (BattleNpc actor in actors)
{
// todo:
AddTarget(actor, false);
}
}

View file

@ -63,7 +63,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
public override bool Engage(Character target)
{
// todo: check distance, last swing time, status effects
var canEngage = this.owner.aiContainer.InternalEngage(target);
if (canEngage)
{
@ -140,7 +139,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
if (tick >= waitTime)
{
// todo: aggro cooldown
neutralTime = tick.AddSeconds(5);
if (owner.aiContainer.pathFind.IsFollowingPath())
{
@ -154,7 +152,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
}
}
// todo:
waitTime = tick.AddSeconds(10);
owner.OnRoam(tick);
@ -171,11 +168,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
{
foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
{
if (!owner.isMovingToSpawn && owner.aiContainer.pathFind.AtPoint() && owner.aggroType != AggroType.None)
if (!owner.isMovingToSpawn && owner.aiContainer.pathFind.AtPoint() && owner.detectionType != DetectionType.None)
{
uint levelDifference = (uint)Math.Abs(owner.charaWork.parameterSave.state_mainSkillLevel - player.charaWork.parameterSave.state_mainSkillLevel);
if (levelDifference <= 10 || (owner.aggroType & AggroType.IgnoreLevelDifference) != 0 && CanAggroTarget(player))
if (levelDifference <= 10 || (owner.detectionType & DetectionType.IgnoreLevelDifference) != 0 && CanAggroTarget(player))
{
owner.hateContainer.AddBaseHate(player);
break;
@ -287,7 +284,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
public bool CanAggroTarget(Character target)
{
if (owner.neutral || owner.aggroType == AggroType.None || owner.IsDead())
if (owner.neutral || owner.detectionType == DetectionType.None || owner.IsDead())
{
return false;
}
@ -326,7 +323,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
var distance = Utils.Distance(owner.positionX, owner.positionY, owner.positionZ, target.positionX, target.positionY, target.positionZ);
bool detectSight = forceSight || (owner.aggroType & AggroType.Sight) != 0;
bool detectSight = forceSight || (owner.detectionType & DetectionType.Sight) != 0;
bool hasSneak = false;
bool hasInvisible = false;
bool isFacing = owner.IsFacing(target);
@ -344,7 +341,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
}
if ((owner.aggroType & AggroType.LowHp) != 0 && target.GetHPP() < 75)
if ((owner.detectionType & DetectionType.LowHp) != 0 && target.GetHPP() < 75)
return CanSeePoint(target.positionX, target.positionY, target.positionZ);
if (detectSight && !hasInvisible && isFacing)

View file

@ -45,7 +45,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
}
else
{
// todo: check within attack range
owner.LookAt(target);
}
}

View file

@ -21,14 +21,15 @@ using FFXIVClassic_Map_Server.packets.send;
namespace FFXIVClassic_Map_Server.Actors
{
[Flags]
enum AggroType
enum DetectionType
{
None = 0x00,
Sight = 0x01,
Scent = 0x02,
Sound = 0x04,
LowHp = 0x08,
IgnoreLevelDifference = 0x10
None = 0x00,
Sight = 0x01,
Scent = 0x02,
Sound = 0x04,
LowHp = 0x08,
IgnoreLevelDifference = 0x10,
Magic = 0x20,
}
enum KindredType
@ -49,7 +50,7 @@ namespace FFXIVClassic_Map_Server.Actors
class BattleNpc : Npc
{
public HateContainer hateContainer;
public AggroType aggroType;
public DetectionType detectionType;
public KindredType kindredType;
public bool neutral;
private uint despawnTime;
@ -82,7 +83,7 @@ namespace FFXIVClassic_Map_Server.Actors
spawnZ = posZ;
// todo: read these from db also
aggroType = AggroType.Sight;
detectionType = DetectionType.Sight;
this.moveState = 2;
ResetMoveSpeeds();
despawnTime = 10;
@ -113,14 +114,14 @@ namespace FFXIVClassic_Map_Server.Actors
return subpackets;
}
public uint GetAggroType()
public uint GetDetectionType()
{
return (uint)aggroType;
return (uint)detectionType;
}
public void SetAggroType(uint aggroType)
public void SetDetectionType(uint detectionType)
{
this.aggroType = (AggroType)aggroType;
this.detectionType = (DetectionType)detectionType;
}
public override void Update(DateTime tick)