effect timers now display (<3 ion)

- added source/target to effects
- todo: send battle packet crap
This commit is contained in:
Tahir Akhlaq 2017-07-27 22:19:20 +01:00
parent 8bebba64b3
commit c7b87c0d89
6 changed files with 82 additions and 25 deletions

View File

@ -912,7 +912,7 @@ namespace FFXIVClassic_Map_Server
effect.SetExtra(extra);
// dont wanna send ton of messages on login (i assume retail doesnt)
player.statusEffects.AddStatusEffect(effect, true);
player.statusEffects.AddStatusEffect(effect, null, true);
}
}
}

View File

@ -128,6 +128,18 @@ namespace FFXIVClassic_Map_Server.Actors
}
public List<SubPacket> GetActorStatusPackets()
{
var propPacketUtil = new ActorPropertyPacketUtil("charaWork/status", this);
var i = 0;
foreach (var effect in statusEffects.GetStatusEffects())
{
propPacketUtil.AddProperty($"charaWork.statusShownTime[{i}]");
i++;
}
return propPacketUtil.Done();
}
public void PlayAnimation(uint animId, bool onlySelf = false)
{
if (onlySelf)

View File

@ -353,6 +353,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
// todo: probably use get;set;
private Character owner;
private Character source;
private StatusEffectId id;
private string name; // name of this effect
private DateTime startTime; // when was this effect added
@ -362,8 +363,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
private UInt64 magnitude; // a value specified by scripter which is guaranteed to be used by all effects
private byte tier; // same effect with higher tier overwrites this
private UInt64 extra; // optional value
private StatusEffectFlags flags; // death/erase/dispel etc
private StatusEffectOverwrite overwrite; // how to handle adding an effect with same id (see StatusEfectOverwrite)
private StatusEffectFlags flags; // death/erase/dispel etc
private StatusEffectOverwrite overwrite; // how to handle adding an effect with same id (see StatusEfectOverwrite)
private bool silent = false; // do i send a message on losing effect
public StatusEffect(Character owner, uint id, UInt64 magnitude, uint tickMs, uint durationMs, byte tier = 0)
{
@ -436,6 +438,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
return owner;
}
public Character GetSource()
{
return source;
}
public uint GetStatusEffectId()
{
return (uint)id;
@ -491,6 +498,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
return (byte)overwrite;
}
public bool GetSilent()
{
return silent;
}
public void SetStartTime(DateTime time)
{
this.startTime = time;
@ -502,6 +514,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
this.owner = owner;
}
public void SetSource(Character source)
{
this.source = source;
}
public void SetName(string name)
{
this.name = name;
@ -541,5 +558,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
this.overwrite = (StatusEffectOverwrite)overwrite;
}
public void SetSilent(bool silent)
{
this.silent = silent;
}
}
}

View File

@ -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.lua;
using FFXIVClassic_Map_Server.actors.area;
@ -43,7 +44,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
if (sendUpdate)
{
owner.zone.BroadcastPacketsAroundActor(owner, owner.GetActorStatusPackets());
}
sendUpdate = false;
@ -51,10 +52,10 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public bool AddStatusEffect(uint id, UInt64 magnitude, double tickMs, double durationMs, byte tier = 0)
{
return AddStatusEffect(new StatusEffect(this.owner, id, magnitude, (uint)(tickMs * 1000), (uint)(durationMs * 1000), tier));
return AddStatusEffect(new StatusEffect(this.owner, id, magnitude, (uint)(tickMs * 1000), (uint)(durationMs * 1000), tier), owner);
}
public bool AddStatusEffect(StatusEffect newEffect, bool silent = false)
public bool AddStatusEffect(StatusEffect newEffect, Character source, bool silent = false)
{
// todo: check flags/overwritable and add effect to list
var effect = GetStatusEffectById(newEffect.GetStatusEffectId());
@ -69,24 +70,31 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
if (canOverwrite || effect == null)
{
if (!silent || (effect?.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
// send packet to client with effect added message
if (!silent || !effect.GetSilent() || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
{
// todo: send packet to client with effect added message
//foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
// player.QueuePacket(packets.send.actor.battle.BattleActionX01Packet.BuildPacket(player.actorId, effect.GetSource().actorId, owner.actorId, 0, effect.GetStatusEffectId(), 0, effect.GetStatusId(), 0, 0));
}
// wont send a message about losing effect here
if (canOverwrite)
effects.Remove(newEffect.GetStatusEffectId());
effects.Add(newEffect.GetStatusEffectId(), newEffect);
// todo: this is retarded..
if (effects.Count < MAX_EFFECTS)
{
var index = Array.IndexOf(effects.Values.ToArray(), newEffect);
owner.charaWork.status[index] = newEffect.GetStatusId();
owner.charaWork.statusShownTime[index] = (uint)(DateTime.Now.AddMilliseconds(newEffect.GetDurationMs()) - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
this.owner.zone.BroadcastPacketAroundActor(this.owner, SetActorStatusPacket.BuildPacket(this.owner.actorId, (ushort)index, (ushort)newEffect.GetStatusId()));
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();
owner.charaWork.statusShownTime[index] = Utils.UnixTimeStampUTC() + (newEffect.GetDurationMs() / 1000);
this.owner.zone.BroadcastPacketAroundActor(this.owner, SetActorStatusPacket.BuildPacket(this.owner.actorId, (ushort)index, (ushort)newEffect.GetStatusId()));
}
sendUpdate = true;
}
sendUpdate = true;
return true;
}
return false;
@ -97,9 +105,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
if (effects.ContainsKey(effect.GetStatusEffectId()))
{
// send packet to client with effect remove message
if (!silent || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
if (!silent || !effect.GetSilent() || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
{
// todo: send packet to client with effect removed message
//foreach (var player in owner.zone.GetActorsAroundActor<Player>(owner, 50))
// player.QueuePacket(packets.send.actor.battle.BattleActionX01Packet.BuildPacket(player.actorId, effect.GetSource().actorId, owner.actorId, 0, effect.GetStatusEffectId(), 0, effect.GetStatusId(), 0, 0));
}
// todo: this is retarded..
@ -109,7 +119,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
owner.charaWork.statusShownTime[index] = uint.MaxValue;
this.owner.zone.BroadcastPacketAroundActor(this.owner, SetActorStatusPacket.BuildPacket(owner.actorId, (ushort)index, (ushort)0));
}
// function onLose(actor, effect
// function onLose(actor, effect)
LuaEngine.CallLuaStatusEffectFunction(this.owner, effect, "onLose", this.owner, effect);
effects.Remove(effect.GetStatusEffectId());
sendUpdate = true;
@ -132,8 +142,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
var newEffect = new StatusEffect(this.owner, effect);
newEffect.SetOwner(this.owner);
return AddStatusEffect(newEffect) ? newEffect : null;
// todo: should source be copied too?
return AddStatusEffect(newEffect, effect.GetSource()) ? newEffect : null;
}
public bool RemoveStatusEffectsByFlags(uint flags, bool silent = false)

View File

@ -93,7 +93,20 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
private void DoRoamTick(DateTime tick)
{
var battleNpc = owner as BattleNpc;
if (battleNpc != null)
{
if (battleNpc.hateContainer.GetHateList().Count > 0)
{
Engage(battleNpc.hateContainer.GetMostHatedTarget());
return;
}
else if (battleNpc.currentLockedTarget != 0)
{
}
}
}
private void DoCombatTick(DateTime tick)

View File

@ -17,11 +17,11 @@ namespace FFXIVClassic_Map_Server.Actors
[Flags]
enum AggroType
{
None,
Sight,
Scent,
LowHp,
IgnoreLevelDifference
None = 0x00,
Sight = 0x01,
Scent = 0x02,
LowHp = 0x04,
IgnoreLevelDifference = 0x08
}
class BattleNpc : Npc