Combat fixes

Add actor update flag for hotbar to send hotbar changes all at once.
Add script for equipping all actions for a class/job.

Fix multiple script errors.
Fix multiple status flag errors
Fix battle command db errors
Fix error in spawnnpc and yolo.
This commit is contained in:
Yogurt 2019-06-01 21:21:21 -07:00
parent a92ece58c1
commit 3104478263
20 changed files with 149 additions and 48 deletions

View file

@ -31,6 +31,7 @@ namespace FFXIVClassic_Map_Server.Actors
Stats = 0x100,
Status = 0x200,
StatusTime = 0x400,
Hotbar = 0x800,
AllNpc = 0xDF,
AllPlayer = 0x13F

View file

@ -26,13 +26,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state
this.spell = Server.GetWorldManager().GetBattleCommand(spellId);
var returnCode = spell.CallLuaFunction(owner, "onMagicPrepare", owner, target, spell);
//Modify spell based on status effects. Need to do it here because they can modify cast times
List<StatusEffect> effects = owner.statusEffects.GetStatusEffectsByFlag((uint)(StatusEffectFlags.ActivateOnCastStart));
//modify skill based on status effects
//Do this here to allow buffs like Resonance to increase range before checking CanCast()
foreach (var effect in effects)
lua.LuaEngine.CallLuaStatusEffectFunction(owner, effect, "onMagicCast", owner, effect, spell);
owner.statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnCastStart, "onMagicCast", owner, spell);
this.target = (spell.mainTarget & ValidTarget.SelfOnly) != 0 ? owner : target;

View file

@ -123,6 +123,8 @@ namespace FFXIVClassic_Map_Server.Actors
private List<Director> ownedDirectors = new List<Director>();
private Director loginInitDirector = null;
List<ushort> hotbarSlotsToUpdate = new List<ushort>();
public PlayerWork playerWork = new PlayerWork();
public Session playerSession;
@ -1841,7 +1843,14 @@ namespace FFXIVClassic_Map_Server.Actors
}
QueuePackets(propPacketUtil.Done());
}
if ((updateFlags & ActorUpdateFlags.Hotbar) != 0)
{
UpdateHotbar(hotbarSlotsToUpdate);
hotbarSlotsToUpdate.Clear();
updateFlags ^= ActorUpdateFlags.Hotbar;
}
@ -1857,12 +1866,11 @@ namespace FFXIVClassic_Map_Server.Actors
//Update commands and recast timers for the entire hotbar
public void UpdateHotbar()
{
List<ushort> slotsToUpdate = new List<ushort>();
for (ushort i = charaWork.commandBorder; i < charaWork.commandBorder + 30; i++)
{
slotsToUpdate.Add(i);
hotbarSlotsToUpdate.Add(i);
}
UpdateHotbar(slotsToUpdate);
updateFlags |= ActorUpdateFlags.Hotbar;
}
//Updates the hotbar and recast timers for only certain hotbar slots
@ -1934,7 +1942,6 @@ namespace FFXIVClassic_Map_Server.Actors
ushort lowHotbarSlot = (ushort)(hotbarSlot - charaWork.commandBorder);
ushort maxRecastTime = (ushort)(ability != null ? ability.maxRecastTimeSeconds : 5);
uint recastEnd = Utils.UnixTimeStampUTC() + maxRecastTime;
List<ushort> slotsToUpdate = new List<ushort>();
Database.EquipAbility(this, classId, (ushort) (hotbarSlot - charaWork.commandBorder), commandId, recastEnd);
//If the class we're equipping for is the current class (need to find out if state_mainSkill is supposed to change when you're a job)
@ -1946,8 +1953,8 @@ namespace FFXIVClassic_Map_Server.Actors
charaWork.parameterTemp.maxCommandRecastTime[lowHotbarSlot] = maxRecastTime;
charaWork.parameterSave.commandSlot_recastTime[lowHotbarSlot] = recastEnd;
slotsToUpdate.Add(hotbarSlot);
UpdateHotbar(slotsToUpdate);
hotbarSlotsToUpdate.Add(hotbarSlot);
updateFlags |= ActorUpdateFlags.Hotbar;
}
@ -1983,25 +1990,23 @@ namespace FFXIVClassic_Map_Server.Actors
Database.EquipAbility(this, GetCurrentClassOrJob(), (ushort)(lowHotbarSlot2), 0xA0F00000 ^ charaWork.command[hotbarSlot2], charaWork.parameterSave.commandSlot_recastTime[lowHotbarSlot2]);
//Update slots on client
List<ushort> slotsToUpdate = new List<ushort>();
slotsToUpdate.Add(hotbarSlot1);
slotsToUpdate.Add(hotbarSlot2);
UpdateHotbar(slotsToUpdate);
hotbarSlotsToUpdate.Add(hotbarSlot1);
hotbarSlotsToUpdate.Add(hotbarSlot2);
updateFlags |= ActorUpdateFlags.Hotbar;
}
public void UnequipAbility(ushort hotbarSlot, bool printMessage = true)
{
List<ushort> slotsToUpdate = new List<ushort>();
ushort trueHotbarSlot = (ushort)(hotbarSlot + charaWork.commandBorder - 1);
ushort trueHotbarSlot = (ushort)(hotbarSlot + charaWork.commandBorder);
uint commandId = charaWork.command[trueHotbarSlot];
Database.UnequipAbility(this, (ushort)(trueHotbarSlot - charaWork.commandBorder));
Database.UnequipAbility(this, hotbarSlot);
charaWork.command[trueHotbarSlot] = 0;
slotsToUpdate.Add(trueHotbarSlot);
hotbarSlotsToUpdate.Add(trueHotbarSlot);
if(printMessage)
if (printMessage && commandId != 0)
SendGameMessage(Server.GetWorldManager().GetActor(), 30604, 0x20, 0, 0xA0F00000 ^ commandId);
UpdateHotbar(slotsToUpdate);
updateFlags |= ActorUpdateFlags.Hotbar;
}
//Finds the first hotbar slot with a given commandId.