mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-08-04 00:31:55 +02:00
added status effect saving
- added some of the packets to add/remove effects (todo: battle packet too)
This commit is contained in:
parent
d9d185d7e6
commit
53207a9ff0
7 changed files with 132 additions and 56 deletions
|
@ -1,5 +1,6 @@
|
|||
using FFXIVClassic_Map_Server.Actors;
|
||||
using FFXIVClassic_Map_Server.lua;
|
||||
using FFXIVClassic_Map_Server.packets.send.actor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -440,6 +441,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
|||
return (uint)id;
|
||||
}
|
||||
|
||||
public ushort GetEffectIdForCharaWork()
|
||||
{
|
||||
return (ushort)(id - 200000);
|
||||
}
|
||||
|
||||
public DateTime GetStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return name;
|
||||
|
@ -480,6 +491,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
|||
return (byte)overwrite;
|
||||
}
|
||||
|
||||
public void SetStartTime(DateTime time)
|
||||
{
|
||||
this.startTime = time;
|
||||
this.lastTick = time;
|
||||
}
|
||||
|
||||
public void SetOwner(Character owner)
|
||||
{
|
||||
this.owner = owner;
|
||||
|
|
|
@ -16,11 +16,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
|||
{
|
||||
private Character owner;
|
||||
private readonly Dictionary<uint, StatusEffect> effects;
|
||||
public static readonly int MAX_EFFECTS = 20;
|
||||
|
||||
public StatusEffectContainer(Character owner)
|
||||
{
|
||||
this.owner = owner;
|
||||
this.effects = new Dictionary<uint, StatusEffect>(20);
|
||||
this.effects = new Dictionary<uint, StatusEffect>();
|
||||
}
|
||||
|
||||
public void Update(DateTime tick)
|
||||
|
@ -54,9 +55,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
|||
(overwritable == (uint)StatusEffectOverwrite.GreaterOrEqualTo && (effect.GetDurationMs() == newEffect.GetDurationMs() || effect.GetMagnitude() == newEffect.GetMagnitude()));
|
||||
}
|
||||
|
||||
if (canOverwrite || effects.ContainsKey(effect.GetEffectId()))
|
||||
if (canOverwrite || effect == null)
|
||||
{
|
||||
if (!silent || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
|
||||
if (!silent || (effect?.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
|
||||
{
|
||||
// todo: send packet to client with effect added message
|
||||
}
|
||||
|
@ -65,8 +66,17 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
|||
effects.Remove(effect.GetEffectId());
|
||||
|
||||
effects.Add(newEffect.GetEffectId(), 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()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RemoveStatusEffect(StatusEffect effect, bool silent = false)
|
||||
|
@ -76,10 +86,16 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
|||
// send packet to client with effect remove message
|
||||
if (!silent || (effect.GetFlags() & (uint)StatusEffectFlags.Silent) == 0)
|
||||
{
|
||||
// todo: send packet to client with effect added message
|
||||
// todo: send packet to client with effect removed message
|
||||
}
|
||||
|
||||
// function onLose(actor, effec)
|
||||
// todo: this is retarded..
|
||||
{
|
||||
var index = Array.IndexOf(effects.Values.ToArray(), effect);
|
||||
owner.charaWork.status[index] = effect.GetEffectIdForCharaWork();
|
||||
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());
|
||||
}
|
||||
|
@ -158,5 +174,13 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai
|
|||
{
|
||||
return effects.Values;
|
||||
}
|
||||
|
||||
void SaveStatusEffectsToDatabase(StatusEffectFlags removeEffectFlags = StatusEffectFlags.None)
|
||||
{
|
||||
if (owner is Player)
|
||||
{
|
||||
Database.SavePlayerStatusEffects((Player)owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,8 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
|
|||
{
|
||||
var damage = utils.AttackUtils.CalculateDamage(owner, target);
|
||||
|
||||
lua.LuaEngine.GetInstance().CallLuaFunction(owner, target, "onAttack", false, damage);
|
||||
// onAttack(actor, target, damage)
|
||||
lua.LuaEngine.CallLuaBattleAction(owner, "onAttack", false, owner, target, damage);
|
||||
|
||||
//var packet = BattleAction1Packet.BuildPacket(owner.actorId, target.actorId);
|
||||
|
||||
|
|
|
@ -684,6 +684,7 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
//Save Player
|
||||
Database.SavePlayerPlayTime(this);
|
||||
Database.SavePlayerPosition(this);
|
||||
Database.SavePlayerStatusEffects(this);
|
||||
}
|
||||
|
||||
public void CleanupAndSave(uint destinationZone, ushort spawnType, float destinationX, float destinationY, float destinationZ, float destinationRot)
|
||||
|
@ -706,7 +707,9 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
//Save Player
|
||||
Database.SavePlayerPlayTime(this);
|
||||
Database.SavePlayerPosition(this);
|
||||
Database.SavePlayerPosition(this);
|
||||
this.statusEffects.RemoveStatusEffectsByFlags((uint)StatusEffectFlags.LoseOnZoning, true);
|
||||
Database.SavePlayerStatusEffects(this);
|
||||
}
|
||||
|
||||
public Area GetZone()
|
||||
|
@ -721,13 +724,16 @@ namespace FFXIVClassic_Map_Server.Actors
|
|||
|
||||
public void Logout()
|
||||
{
|
||||
// todo: really this should be in CleanupAndSave but we might want logout/disconnect handled separately for some effects
|
||||
QueuePacket(LogoutPacket.BuildPacket(actorId));
|
||||
statusEffects.RemoveStatusEffectsByFlags((uint)StatusEffectFlags.LoseOnLogout);
|
||||
CleanupAndSave();
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
QueuePacket(QuitPacket.BuildPacket(actorId));
|
||||
statusEffects.RemoveStatusEffectsByFlags((uint)StatusEffectFlags.LoseOnLogout);
|
||||
CleanupAndSave();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue