Merged in skeletonhorn/ffxiv-classic-server-ai-fork/develop (pull request #9)

Combat fixes
This commit is contained in:
yogurt 2019-06-02 04:25:22 +00:00
commit 8f92fde00e
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

@ -223,7 +223,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers
protected virtual void Move()
{
if (!owner.aiContainer.CanFollowPath())
if (!owner.aiContainer.CanFollowPath() || owner.statusEffects.HasStatusEffectsByFlag(StatusEffectFlags.PreventMovement))
{
return;
}

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.

View File

@ -61,4 +61,47 @@ TargetFindAOEType =
Circle = 1,
Cone = 2,
Box = 3
}
StatusEffectFlags =
{
None = 0,
--Loss flags - Do we need loseonattacking/caststart? Could just be done with activate flags
LoseOnDeath = bit32.lshift(1, 0), -- effects removed on death
LoseOnZoning = bit32.lshift(1, 1), -- effects removed on zoning
LoseOnEsuna = bit32.lshift(1, 2), -- effects which can be removed with esuna (debuffs)
LoseOnDispel = bit32.lshift(1, 3), -- some buffs which player might be able to dispel from mob
LoseOnLogout = bit32.lshift(1, 4), -- effects removed on logging out
LoseOnAttacking = bit32.lshift(1, 5), -- effects removed when owner attacks another entity
LoseOnCastStart = bit32.lshift(1, 6), -- effects removed when owner starts casting
LoseOnAggro = bit32.lshift(1, 7), -- effects removed when owner gains enmity (swiftsong)
LoseOnClassChange = bit32.lshift(1, 8), --Effect falls off whhen changing class
--Activate flags
ActivateOnCastStart = bit32.lshift(1, 9), --Activates when a cast starts.
ActivateOnCommandStart = bit32.lshift(1, 10), --Activates when a command is used, before iterating over targets. Used for things like power surge, excruciate.
ActivateOnCommandFinish = bit32.lshift(1, 11), --Activates when the command is finished, after all targets have been iterated over. Used for things like Excruciate and Resonance falling off.
ActivateOnPreactionTarget = bit32.lshift(1, 12), --Activates after initial rates are calculated for an action against owner
ActivateOnPreactionCaster = bit32.lshift(1, 13), --Activates after initial rates are calculated for an action by owner
ActivateOnDamageTaken = bit32.lshift(1, 14),
ActivateOnHealed = bit32.lshift(1, 15),
--Should these be rolled into DamageTaken?
ActivateOnMiss = bit32.lshift(1, 16), --Activates when owner misses
ActivateOnEvade = bit32.lshift(1, 17), --Activates when owner evades
ActivateOnParry = bit32.lshift(1, 18), --Activates when owner parries
ActivateOnBlock = bit32.lshift(1, 19), --Activates when owner evades
ActivateOnHit = bit32.lshift(1, 20), --Activates when owner hits
ActivateOnCrit = bit32.lshift(1, 21), --Activates when owner crits
--Prevent flags. Sleep/stun/petrify/etc combine these
PreventSpell = bit32.lshift(1, 22), -- effects which prevent using spells, such as silence
PreventWeaponSkill = bit32.lshift(1, 23), -- effects which prevent using weaponskills, such as pacification
PreventAbility = bit32.lshift(1, 24), -- effects which prevent using abilities, such as amnesia
PreventAttack = bit32.lshift(1, 25), -- effects which prevent basic attacks
PreventMovement = bit32.lshift(1, 26), -- effects which prevent movement such as bind, still allows turning in place
PreventTurn = bit32.lshift(1, 27), -- effects which prevent turning, such as stun
PreventUntarget = bit32.lshift(1, 28), -- effects which prevent changing targets, such as fixation
Stance = bit32.lshift(1, 29) -- effects that do not have a timer
}

View File

@ -16,4 +16,5 @@ end;
function onSkillFinish(caster, target, skill, action, actionContainer)
--Need a way to get all targets with hate for player
--target.hateContainer.UpdateHate(caster, -840);
action.DoAction(caster, target, skill, actionContainer);
end;

View File

@ -20,8 +20,7 @@ function onSkillFinish(caster, target, skill, action, actionContainer)
if buff ~= nil then
--30329: Your Raging Strike removes your Raging Strike effect.
local remAction = caster.statusEffects.RemoveStatusEffect(buff, actionContainer, 30329);
actionContainer.AddAction(remAction);
caster.statusEffects.RemoveStatusEffect(buff, actionContainer, 30329);
else
--DoAction handles rates, buffs, dealing damage
action.DoAction(caster, target, skill, actionContainer);

View File

@ -1,5 +1,5 @@
require("global");
require("weaponskill");
require("ability");
function onSkillPrepare(caster, target, skill)
return 0;

View File

@ -0,0 +1,42 @@
require("global");
require("modifiers");
properties = {
permissions = 0,
parameters = "s",
description =
[[
equips all your class and job actions
]],
}
classToActions = {
[2] = { Start = 27100, End = 27119},
[3] = { Start = 27140, End = 27159},
[4] = { Start = 27180, End = 27199},
[7] = { Start = 27220, End = 27239},
[8] = { Start = 27260, End = 27279},
[22] = { Start = 27300, End = 27319},
[23] = { Start = 27340, End = 27359}
}
function onTrigger(player, argc)
local messageId = MESSAGE_TYPE_SYSTEM_ERROR;
local sender = "equipactions";
classId = player.GetClass()
if classToActions[classId] then
s = classToActions[classId].Start
e = classToActions[classId].End
print('h')
for i = 0, 30 do
player.UnequipAbility(i, false)
end
for commandid = s, e do
if GetWorldManager():GetBattleCommand(commandid) then
player:EquipAbilityInFirstOpenSlot(player:GetCurrentClassOrJob(), commandid);
end
end
end
end

View File

@ -95,7 +95,6 @@ function onTrigger(player, argc, name, width, height, blockCount)
local sender = "spawnnpc";
if player and (modelIds[name] != nil) then
print("t")
local pos = player:GetPos();
local x = tonumber(pos[0]);
local y = tonumber(pos[1]);
@ -113,11 +112,12 @@ function onTrigger(player, argc, name, width, height, blockCount)
actor.ChangeNpcAppearance(modelIds[name]);
actor.SetMaxHP(5000);
actor.SetHP(5000);
actor.SetMod(modifiersGlobal.HasShield, 1);
actor.SetMod(modifiersGlobal.CanBlock, 1);
actor.SetMod(modifiersGlobal.AttackRange, 3);
actor.SetMod(modifiersGlobal.Speed, 5);
actor.SetMod(modifiersGlobal.MovementSpeed, 5);
actor.SetMobMod(mobModifiersGlobal.Roams, 1);
actor.SetMobMod(mobModifiersGlobal.RoamDelay, 3);
actor.SetMobMod(mobModifiersGlobal.RoamDelay, 10);
actor.charaWork.parameterSave.state_mainSkillLevel = 52;
actor.moveState = 3;
end;
end;

View File

@ -163,11 +163,12 @@ function onTrigger(player, argc, width, height, blockCount)
actor.ChangeNpcAppearance(2200905);
actor.SetMaxHP(5000);
actor.SetHP(5000);
actor.SetMod(modifiersGlobal.HasShield, 1);
actor.SetMod(modifiersGlobal.CanBlock, 1);
actor.SetMod(modifiersGlobal.AttackRange, 3);
actor.SetMod(modifiersGlobal.Speed, 5);
actor.SetMod(modifiersGlobal.MovementSpeed, 5);
actor.SetMobMod(mobModifiersGlobal.Roams, 1);
actor.SetMobMod(mobModifiersGlobal.RoamDelay, 3);
actor.SetMobMod(mobModifiersGlobal.RoamDelay, 10);
actor.charaWork.parameterSave.state_mainSkillLevel = 52;
actor.moveState = 3;
end
end

View File

@ -8,6 +8,6 @@ end;
function onCommandFinish(effect, owner, skill, actionContainer)
--27259: Light Shot
if skill.id == 27259 then
defender.statusEffects.RemoveStatusEffect(effect, actionContainer, 30331, false);
owner.statusEffects.RemoveStatusEffect(effect, actionContainer, 30331, false);
end
end;

View File

@ -5,6 +5,7 @@ require("battleutils")
--There isn't really any information on this, but due to the fact it falls off BEFORE the target is hit,
--I'm assuming it increases a spell's accuracy modifier instead of giving actual magic accuracy
function onCommandStart(effect, owner, skill, actionContainer)
print('dark seal')
if skill.GetActionType() == ActionType.Magic then
--50 is random guess.
skill.accuracyModifier = skill.accuracyModifier + 50;

View File

@ -3,8 +3,8 @@ require("modifiers")
--Battle Voice grants HP_Boost and it sets max hp to 125% normal amount and heals for the difference between current
--This doesn't seem like the correct way to do this. If max HP changes between gainign and losing wont this break?
function onGain(owner, effect, actionContainer)
local newMaxHP = target.GetMaxHP() * 1.25;
local healAmount = newMaxHP - target.GetMaxHP();
local newMaxHP = owner.GetMaxHP() * 1.25;
local healAmount = newMaxHP - owner.GetMaxHP();
owner.SetMaxHP(newMaxHP);
owner.AddHP(healAmount);

View File

@ -11,5 +11,6 @@ function onCommandStart(effect, owner, skill, actionContainer)
end
skill.recastTimeMs = skill.recastTimeMs - (reduction * skill.recastTimeMs);
owner.statusEffects.RemoveStatusEffect(effect, actionContainer, 30331, false);
end
end;

View File

@ -2,7 +2,7 @@ require("modifiers")
require("battleutils")
--Forces crit of a single WS action from rear.
function onMagicCast(caster, effect, skill)
function onMagicCast(effect, caster, skill)
skill.mpCost = skill.mpCost / 2;
end;

View File

@ -4,7 +4,7 @@ require("battleutils")
--Increases range of a single spell, no clue by how much, 25% is a random guess
--It isn't clear if it has an effect on the aoe portion of skills or just the normal range, i've seen people on the OF say both.
--It also increased height of skills
function onMagicCast(caster, effect, skill)
function onMagicCast(effect, caster, skill)
skill.range = skill.range * 1.25;
skill.rangeHeight = skill.rangeHeight * 1.25;
end;

View File

@ -1,8 +1,18 @@
require("modifiers")
require("battleutils")
function onMagicCast(caster, effect, skill)
skill.aoeType = TargetFindAOEType.Circle;
skill.aoeRange = 15;
skill.validTarget = 31
end
--Cure, Cura, Regen, Esuna, Enhancing spells (Hardcoded as Stoneskin and Sanguine since we dont have a good way to check what's an enhancing spell)
supportedSpells = [27346, 27347, 27358, 27357, 27350, 27307]
function onMagicCast(effect, caster, skill)
if supportedSpells[skill.id] then
skill.aoeType = TargetFindAOEType.Circle;
skill.aoeRange = 15;
end
end
function onCommandFinish(effect, owner, skill, actionContainer)
if supportedSpells[skill.id] then
owner.statusEffects.RemoveStatusEffect(effect, actionContainer, 30331, false);
end
end;

View File

@ -151,7 +151,7 @@ INSERT INTO `server_battle_commands` VALUES (27199,'overpower',4,30,1,768,17152,
INSERT INTO `server_battle_commands` VALUES (27220,'hawks_eye',7,6,3,31,16415,0,0,0,0,0,0,100,1,0,0,0,0,0,10,2,223106,15,1,0,0,90,0,0,14,516,2,3,234889732,0,0,0,0,0,30328,3,4,0,0);
INSERT INTO `server_battle_commands` VALUES (27221,'quelling_strike',7,22,3,31,16415,0,0,0,0,0,0,100,1,0,0,0,0,0,10,2,223104,30,1,0,0,60,0,0,14,614,2,3,234889830,0,0,0,0,0,30328,3,4,0,0);
INSERT INTO `server_battle_commands` VALUES (27222,'decoy',7,2,3,31,16415,0,0,0,0,0,0,100,1,0,0,0,0,0,10,2,223108,60,1,0,0,90,100,0,14,565,2,3,234889781,0,0,0,0,0,30328,3,4,0,0);
INSERT INTO `server_battle_commands` VALUES (27223,'chameleon',7,42,3,31,16415,0,0,0,0,0,0,100,1,0,0,0,0,0,10,2,0,0,0,0,0,180,0,0,14,504,2,3,234889720,0,0,0,0,0,30328,3,4,0,0);
INSERT INTO `server_battle_commands` VALUES (27223,'chameleon',7,42,3,31,16415,0,0,0,0,0,0,100,1,0,0,0,0,0,10,2,0,0,0,0,0,180,0,0,14,504,2,3,234889720,0,0,0,0,0,30101,3,0,0,0);
INSERT INTO `server_battle_commands` VALUES (27224,'barrage',7,34,64,31,16415,0,0,0,0,0,0,100,1,0,0,0,0,0,10,2,223220,60,1,0,0,90,0,0,14,683,2,3,234889899,0,0,0,0,0,30328,3,4,0,0);
INSERT INTO `server_battle_commands` VALUES (27225,'raging_strike',7,14,64,31,16415,0,0,0,0,0,0,100,1,0,0,0,0,0,10,2,223221,4294967295,1,0,0,10,0,0,14,632,2,3,234889848,0,0,0,0,0,30328,3,4,0,0);
INSERT INTO `server_battle_commands` VALUES (27226,'swiftsong',7,26,64,31,16445,1,20,0,0,0,1,100,1,0,0,0,0,0,10,2,223224,180,1,0,0,10,100,0,1,150,1,3,16781462,0,0,0,0,0,30328,4,4,0,0);
@ -243,4 +243,4 @@ commit;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-06-01 0:52:09
-- Dump completed on 2019-06-01 21:15:51

View File

@ -68,7 +68,7 @@ INSERT INTO `server_statuseffects` VALUES (223075,'featherfoot',131097,2,0,0,0,0
INSERT INTO `server_statuseffects` VALUES (223078,'enduring_march',9,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223081,'bloodbath',1048601,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223083,'foresight',262169,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223091,'keen_flurry',9,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223091,'keen_flurry',1033,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223094,'invigorate',9,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223097,'collusion',1048601,1,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223104,'quelling_strike',1041,2,0,0,0,0);
@ -77,7 +77,7 @@ INSERT INTO `server_statuseffects` VALUES (223108,'decoy',4113,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223127,'bloodletter',21,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223129,'protect',9,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223133,'stoneskin',16393,1,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223173,'covered',21,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223173,'covered',4105,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223180,'regen',9,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223181,'refresh',9,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223182,'regain',9,2,0,0,0,0);
@ -99,9 +99,10 @@ INSERT INTO `server_statuseffects` VALUES (223218,'dread_spike',16649,2,0,0,0,0)
INSERT INTO `server_statuseffects` VALUES (223219,'blood_for_blood',8209,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223220,'barrage',3081,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223221,'raging_strike2',537985297,1,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223224,'swiftsong',137,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223227,'cleric_stance',8209,1,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223228,'blissful_mind',536871185,1,1000,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223229,'dark_seal2',409,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223229,'dark_seal2',1033,2,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223230,'resonance2',2569,1,0,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223231,'excruciate',2098185,2,3000,0,0,0);
INSERT INTO `server_statuseffects` VALUES (223232,'necrogenesis',1048585,1,0,0,0,0);
@ -147,4 +148,4 @@ commit;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-05-29 23:06:54
-- Dump completed on 2019-06-01 21:15:54