1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-21 20:27:47 +00:00

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

@ -1814,10 +1814,14 @@ namespace FFXIVClassic_Map_Server
{ {
var duration = effect.GetDurationMs() + effect.GetStartTime().Millisecond - Program.Tick.Millisecond; var duration = effect.GetDurationMs() + effect.GetStartTime().Millisecond - Program.Tick.Millisecond;
queries += Environment.NewLine + $"REPLACE INTO characters_statuseffect(characterId, statusId, magnitude, duration, tick, tier, extra) VALUES ({player.actorId}, {effect.GetEffectId()}, {effect.GetMagnitude()}, {duration}, {effect.GetTickMs()}, {effect.GetTier()}, {effect.GetExtra()});"; queries += Environment.NewLine + $"REPLACE INTO characters_statuseffect(characterId, statusId, magnitude, duration, tick, tier, extra) VALUES ({player.actorId}, {effect.GetStatusEffectId()}, {effect.GetMagnitude()}, {duration}, {effect.GetTickMs()}, {effect.GetTier()}, {effect.GetExtra()});";
}
if (queries.Length > 0)
{
MySqlCommand cmd = new MySqlCommand(queries, conn);
cmd.ExecuteNonQuery();
} }
MySqlCommand cmd = new MySqlCommand(queries, conn);
cmd.ExecuteNonQuery();
} }
catch (MySqlException e) catch (MySqlException e)
{ {

View file

@ -43,6 +43,7 @@ namespace FFXIVClassic_Map_Server.Actors
public List<Vector3> positionUpdates = new List<Vector3>(); public List<Vector3> positionUpdates = new List<Vector3>();
public DateTime lastMoveUpdate; public DateTime lastMoveUpdate;
protected DateTime lastUpdate;
public Actor target; public Actor target;
public bool hasMoved = false; public bool hasMoved = false;
@ -161,7 +162,7 @@ namespace FFXIVClassic_Map_Server.Actors
updateMs = 150; updateMs = 150;
} }
if (forceUpdate || (hasMoved && ((this is Player) || diffTime.Milliseconds >= updateMs))) if (forceUpdate || (hasMoved && ((this is Player) || diffTime.TotalMilliseconds >= updateMs)))
{ {
hasMoved = (this.positionUpdates != null && this.positionUpdates.Count > 0); hasMoved = (this.positionUpdates != null && this.positionUpdates.Count > 0);
if (hasMoved) if (hasMoved)

View file

@ -617,7 +617,7 @@ namespace FFXIVClassic_Map_Server.Actors
foreach (Actor a in mActorList.Values) foreach (Actor a in mActorList.Values)
a.Update(tick); a.Update(tick);
var deltaTime = (tick - Program.LastTick).Milliseconds; var deltaTime = (tick - Program.LastTick).TotalMilliseconds;
LuaEngine.GetInstance().CallLuaFunction(null, this, "onUpdate", true, deltaTime); LuaEngine.GetInstance().CallLuaFunction(null, this, "onUpdate", true, deltaTime);
} }
} }

View file

@ -28,8 +28,6 @@ namespace FFXIVClassic_Map_Server.actors.area
public Int64 pathCalls; public Int64 pathCalls;
public Int64 pathCallTime; public Int64 pathCallTime;
protected DateTime lastUpdate;
public Zone(uint id, string zoneName, ushort regionId, string classPath, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool isIsolated, bool isInn, bool canRideChocobo, bool canStealth, bool isInstanceRaid, bool loadNavMesh = false) public Zone(uint id, string zoneName, ushort regionId, string classPath, ushort bgmDay, ushort bgmNight, ushort bgmBattle, bool isIsolated, bool isInn, bool canRideChocobo, bool canStealth, bool isInstanceRaid, bool loadNavMesh = false)
: base(id, zoneName, regionId, classPath, bgmDay, bgmNight, bgmBattle, isIsolated, isInn, canRideChocobo, canStealth, isInstanceRaid) : base(id, zoneName, regionId, classPath, bgmDay, bgmNight, bgmBattle, isIsolated, isInn, canRideChocobo, canStealth, isInstanceRaid)
{ {
@ -170,16 +168,18 @@ namespace FFXIVClassic_Map_Server.actors.area
var diffTime = tick - lastUpdate; var diffTime = tick - lastUpdate;
// arbitrary cap // arbitrary cap
if (diffTime.Milliseconds >= 33) if (diffTime.TotalMilliseconds >= 33)
{ {
} }
if (diffTime.Seconds >= 10) if (diffTime.TotalSeconds >= 10)
{ {
if (this.pathCalls > 0) if (this.pathCalls > 0)
{ {
Program.Log.Error("Number of pathfinding calls {0} average time {1}", pathCalls, pathCallTime / pathCalls); Program.Log.Error("Number of pathfinding calls {0} average time {1}", pathCalls, pathCallTime / pathCalls);
} }
// todo: this is stupid debug stuff that needs to fuck off
lastUpdate = tick;
} }
} }

View file

@ -414,7 +414,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public bool Update(DateTime tick) public bool Update(DateTime tick)
{ {
// todo: maybe not tick if already reached duration? // 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: call effect's onTick
// todo: maybe keep a global lua object instead of creating a new one each time we wanna call a script // 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); LuaEngine.CallLuaStatusEffectFunction(this.owner, this, "onTick", this.owner, this);
} }
// todo: handle infinite duration effects? // 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: call effect's onLose
// todo: broadcast effect lost packet // todo: broadcast effect lost packet
@ -436,12 +436,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
return owner; return owner;
} }
public uint GetEffectId() public uint GetStatusEffectId()
{ {
return (uint)id; return (uint)id;
} }
public ushort GetEffectIdForCharaWork() public ushort GetStatusId()
{ {
return (ushort)(id - 200000); return (ushort)(id - 200000);
} }

View file

@ -17,7 +17,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
private Character owner; private Character owner;
private readonly Dictionary<uint, StatusEffect> effects; private readonly Dictionary<uint, StatusEffect> effects;
public static readonly int MAX_EFFECTS = 20; public static readonly int MAX_EFFECTS = 20;
private bool sendUpdate = false;
public StatusEffectContainer(Character owner) public StatusEffectContainer(Character owner)
{ {
this.owner = owner; this.owner = owner;
@ -40,19 +40,31 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{ {
RemoveStatusEffect(effect); 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) public bool AddStatusEffect(StatusEffect newEffect, bool silent = false)
{ {
// todo: check flags/overwritable and add effect to list // todo: check flags/overwritable and add effect to list
var effect = GetStatusEffectById(newEffect.GetEffectId()); var effect = GetStatusEffectById(newEffect.GetStatusEffectId());
bool canOverwrite = false; bool canOverwrite = false;
if (effect != null) if (effect != null)
{ {
var overwritable = effect.GetOverwritable(); var overwritable = effect.GetOverwritable();
canOverwrite = (overwritable == (uint)StatusEffectOverwrite.Always) || canOverwrite = (overwritable == (uint)StatusEffectOverwrite.Always) ||
(overwritable == (uint)StatusEffectOverwrite.GreaterOnly && (effect.GetDurationMs() < newEffect.GetDurationMs() || effect.GetMagnitude() < newEffect.GetMagnitude())) || (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) if (canOverwrite || effect == null)
@ -63,17 +75,18 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
} }
if (canOverwrite) if (canOverwrite)
effects.Remove(effect.GetEffectId()); effects.Remove(newEffect.GetStatusEffectId());
effects.Add(newEffect.GetEffectId(), newEffect); effects.Add(newEffect.GetStatusEffectId(), newEffect);
// todo: this is retarded.. // todo: this is retarded..
{ {
var index = Array.IndexOf(effects.Values.ToArray(), newEffect); var index = Array.IndexOf(effects.Values.ToArray(), newEffect);
owner.charaWork.status[index] = effect.GetEffectIdForCharaWork(); owner.charaWork.status[index] = newEffect.GetStatusId();
owner.charaWork.statusShownTime[index] = effect.GetDurationMs() / 1000; 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)effect.GetEffectId())); this.owner.zone.BroadcastPacketAroundActor(this.owner, SetActorStatusPacket.BuildPacket(this.owner.actorId, (ushort)index, (ushort)newEffect.GetStatusId()));
} }
sendUpdate = true;
return true; return true;
} }
return false; return false;
@ -81,7 +94,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
public void RemoveStatusEffect(StatusEffect effect, bool silent = false) 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 // send packet to client with effect remove message
if (!silent || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0) if (!silent || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
@ -92,12 +105,14 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
// todo: this is retarded.. // todo: this is retarded..
{ {
var index = Array.IndexOf(effects.Values.ToArray(), effect); 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)); 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); 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) foreach (var effect in effects.Values)
{ {
if (effect.GetEffectId() == effectId) if (effect.GetStatusEffectId() == effectId)
{ {
RemoveStatusEffect(effect, silent); RemoveStatusEffect(effect, silent);
break; break;
@ -141,7 +156,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{ {
StatusEffect effect; 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 effect;
return null; return null;
@ -152,7 +167,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
var list = new List<StatusEffect>(); var list = new List<StatusEffect>();
foreach (var effect in effects.Values) foreach (var effect in effects.Values)
{ {
if ((effect.GetFlags() & flag) > 0) if ((effect.GetFlags() & flag) != 0)
{ {
list.Add(effect); list.Add(effect);
} }
@ -164,7 +179,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
{ {
foreach (var effect in effects.Values) foreach (var effect in effects.Values)
{ {
if ((effect.GetFlags() & flag) > 0) if ((effect.GetFlags() & flag) != 0)
return true; return true;
} }
return false; 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 // todo: check weapon delay/haste etc and use that
if ((tick - startTime).Milliseconds >= 0) if ((tick - startTime).TotalMilliseconds >= 0)
{ {
OnComplete(); OnComplete();
return true; return true;
@ -72,7 +72,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
if (list.Count > 0) if (list.Count > 0)
{ {
// todo: actually check proc rate/random chance of whatever effect // 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 // 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); //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. //Update select hotbar slots.
public ActorPropertyPacketUtil GetUpdateHotbarPacket(uint playerActorId, List<ushort> slotsToUpdate) 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"); propPacketUtil.AddProperty("charaWork.commandBorder");
@ -1797,7 +1797,7 @@ namespace FFXIVClassic_Map_Server.Actors
} }
} }
//Unequip command //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. //Need to get the commandId this way because when unequipping an ability the commandId is 0.
commandId = charaWork.command[trueHotbarSlot] ^ 2700083200; commandId = charaWork.command[trueHotbarSlot] ^ 2700083200;

View file

@ -492,7 +492,7 @@ namespace FFXIVClassic_Map_Server.lua
{ {
bool playerNull = player == null; bool playerNull = player == null;
if (playerNull && param.Length >= 2) if (playerNull && param.Length >= 2)
player = Server.GetWorldManager().GetPCInWorld(param[1] + " " + param[2]); player = Server.GetWorldManager().GetPCInWorld(param[1].Contains("\"") ? param[1] : param[1] + " " + param[2]);
// load from scripts/commands/gm/ directory // load from scripts/commands/gm/ directory
var path = String.Format("./scripts/commands/gm/{0}.lua", cmd.ToLower()); var path = String.Format("./scripts/commands/gm/{0}.lua", cmd.ToLower());