fixed some timers

- status icons now display (<3 u ion)
- todo: populate status tables, figure out why effect wont tick down for me
This commit is contained in:
Tahir Akhlaq
2017-07-27 03:58:42 +01:00
parent ddad27a5f9
commit 8bebba64b3
10 changed files with 55 additions and 35 deletions

View File

@@ -126,8 +126,8 @@ namespace FFXIVClassic_Map_Server.Actors
propPacketUtil.AddProperty("charaWork.currentContentGroup");
zone.BroadcastPacketsAroundActor(this, propPacketUtil.Done());
}
}
public void PlayAnimation(uint animId, bool onlySelf = false)
{
if (onlySelf)

View File

@@ -414,7 +414,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public bool Update(DateTime tick)
{
// todo: maybe not tick if already reached duration?
if (tickMs != 0 && (lastTick - startTime).Milliseconds >= tickMs)
if (tickMs != 0 && (lastTick - startTime).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
@@ -422,7 +422,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
LuaEngine.CallLuaStatusEffectFunction(this.owner, this, "onTick", this.owner, this);
}
// todo: handle infinite duration effects?
if (durationMs != 0 && startTime.Millisecond + durationMs >= tick.Millisecond)
if (durationMs != 0 && (tick - startTime).TotalMilliseconds >= durationMs)
{
// todo: call effect's onLose
// todo: broadcast effect lost packet
@@ -436,12 +436,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
return owner;
}
public uint GetEffectId()
public uint GetStatusEffectId()
{
return (uint)id;
}
public ushort GetEffectIdForCharaWork()
public ushort GetStatusId()
{
return (ushort)(id - 200000);
}

View File

@@ -17,7 +17,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
private Character owner;
private readonly Dictionary<uint, StatusEffect> effects;
public static readonly int MAX_EFFECTS = 20;
private bool sendUpdate = false;
public StatusEffectContainer(Character owner)
{
this.owner = owner;
@@ -40,19 +40,31 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
RemoveStatusEffect(effect);
}
if (sendUpdate)
{
}
sendUpdate = false;
}
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));
}
public bool AddStatusEffect(StatusEffect newEffect, bool silent = false)
{
// todo: check flags/overwritable and add effect to list
var effect = GetStatusEffectById(newEffect.GetEffectId());
var effect = GetStatusEffectById(newEffect.GetStatusEffectId());
bool canOverwrite = false;
if (effect != null)
{
var overwritable = effect.GetOverwritable();
canOverwrite = (overwritable == (uint)StatusEffectOverwrite.Always) ||
(overwritable == (uint)StatusEffectOverwrite.GreaterOnly && (effect.GetDurationMs() < newEffect.GetDurationMs() || effect.GetMagnitude() < newEffect.GetMagnitude())) ||
(overwritable == (uint)StatusEffectOverwrite.GreaterOrEqualTo && (effect.GetDurationMs() == newEffect.GetDurationMs() || effect.GetMagnitude() == newEffect.GetMagnitude()));
(overwritable == (uint)StatusEffectOverwrite.GreaterOrEqualTo && (effect.GetDurationMs() <= newEffect.GetDurationMs() || effect.GetMagnitude() <= newEffect.GetMagnitude()));
}
if (canOverwrite || effect == null)
@@ -63,17 +75,18 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
}
if (canOverwrite)
effects.Remove(effect.GetEffectId());
effects.Remove(newEffect.GetStatusEffectId());
effects.Add(newEffect.GetEffectId(), newEffect);
effects.Add(newEffect.GetStatusEffectId(), newEffect);
// todo: this is retarded..
{
var index = Array.IndexOf(effects.Values.ToArray(), newEffect);
owner.charaWork.status[index] = effect.GetEffectIdForCharaWork();
owner.charaWork.statusShownTime[index] = effect.GetDurationMs() / 1000;
this.owner.zone.BroadcastPacketAroundActor(this.owner, SetActorStatusPacket.BuildPacket(this.owner.actorId, (ushort)index, (ushort)effect.GetEffectId()));
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()));
}
sendUpdate = true;
return true;
}
return false;
@@ -81,7 +94,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public void RemoveStatusEffect(StatusEffect effect, bool silent = false)
{
if (effects.ContainsKey(effect.GetEffectId()))
if (effects.ContainsKey(effect.GetStatusEffectId()))
{
// send packet to client with effect remove message
if (!silent || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
@@ -92,12 +105,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
// todo: this is retarded..
{
var index = Array.IndexOf(effects.Values.ToArray(), effect);
owner.charaWork.status[index] = effect.GetEffectIdForCharaWork();
owner.charaWork.status[index] = 0;
owner.charaWork.statusShownTime[index] = uint.MaxValue;
this.owner.zone.BroadcastPacketAroundActor(this.owner, SetActorStatusPacket.BuildPacket(owner.actorId, (ushort)index, (ushort)0));
}
// function onLose(actor, effect
LuaEngine.CallLuaStatusEffectFunction(this.owner, effect, "onLose", this.owner, effect);
effects.Remove(effect.GetEffectId());
effects.Remove(effect.GetStatusEffectId());
sendUpdate = true;
}
}
@@ -105,7 +120,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
foreach (var effect in effects.Values)
{
if (effect.GetEffectId() == effectId)
if (effect.GetStatusEffectId() == effectId)
{
RemoveStatusEffect(effect, silent);
break;
@@ -141,7 +156,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
StatusEffect effect;
if (effects.TryGetValue(id, out effect) && effect.GetEffectId() == id && (tier != 0xFF ? effect.GetTier() == tier : true))
if (effects.TryGetValue(id, out effect) && effect.GetStatusEffectId() == id && (tier != 0xFF ? effect.GetTier() == tier : true))
return effect;
return null;
@@ -152,7 +167,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
var list = new List<StatusEffect>();
foreach (var effect in effects.Values)
{
if ((effect.GetFlags() & flag) > 0)
if ((effect.GetFlags() & flag) != 0)
{
list.Add(effect);
}
@@ -164,7 +179,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{
foreach (var effect in effects.Values)
{
if ((effect.GetFlags() & flag) > 0)
if ((effect.GetFlags() & flag) != 0)
return true;
}
return false;

View File

@@ -33,7 +33,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
}
// todo: check weapon delay/haste etc and use that
if ((tick - startTime).Milliseconds >= 0)
if ((tick - startTime).TotalMilliseconds >= 0)
{
OnComplete();
return true;
@@ -72,7 +72,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
if (list.Count > 0)
{
// todo: actually check proc rate/random chance of whatever effect
effectId = list[0].GetEffectId();
effectId = list[0].GetStatusEffectId();
}
// todo: which is actually the swing packet
//this.errorPacket = BattleActionX01Packet.BuildPacket(target.actorId, owner.actorId, target.actorId, 0, effectId, 0, (ushort)BattleActionX01PacketCommand.Attack, 0, 0);

View File

@@ -1702,7 +1702,7 @@ namespace FFXIVClassic_Map_Server.Actors
//Update select hotbar slots.
public ActorPropertyPacketUtil GetUpdateHotbarPacket(uint playerActorId, List<ushort> slotsToUpdate)
{
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charawork/command", this);
ActorPropertyPacketUtil propPacketUtil = new ActorPropertyPacketUtil("charaWork/command", this);
propPacketUtil.AddProperty("charaWork.commandBorder");
@@ -1797,7 +1797,7 @@ namespace FFXIVClassic_Map_Server.Actors
}
}
//Unequip command
else if (trueCommandId == 2700083200)
else if (trueCommandId == 2700083200 && charaWork.command[trueHotbarSlot] != 0)
{
//Need to get the commandId this way because when unequipping an ability the commandId is 0.
commandId = charaWork.command[trueHotbarSlot] ^ 2700083200;