diff --git a/FFXIVClassic Map Server/actors/Actor.cs b/FFXIVClassic Map Server/actors/Actor.cs index 313b62cc..4e397668 100644 --- a/FFXIVClassic Map Server/actors/Actor.cs +++ b/FFXIVClassic Map Server/actors/Actor.cs @@ -61,7 +61,7 @@ namespace FFXIVClassic_Map_Server.Actors public List classParams; public List positionUpdates; - public DateTime lastMoveUpdate; + protected DateTime lastUpdateScript; protected DateTime lastUpdate; public Actor target; diff --git a/FFXIVClassic Map Server/actors/area/Area.cs b/FFXIVClassic Map Server/actors/area/Area.cs index aa2eb23e..c44b71d4 100644 --- a/FFXIVClassic Map Server/actors/area/Area.cs +++ b/FFXIVClassic Map Server/actors/area/Area.cs @@ -667,11 +667,14 @@ namespace FFXIVClassic_Map_Server.Actors { lock (mActorList) { - foreach (Actor a in mActorList.Values) + foreach (Actor a in mActorList.Values.ToList()) a.Update(tick); - - var deltaTime = (tick - Program.LastTick).TotalMilliseconds; - //LuaEngine.GetInstance().CallLuaFunction(null, this, "onUpdate", true, this, deltaTime); + + if ((tick - lastUpdateScript).TotalMilliseconds > 1500) + { + //LuaEngine.GetInstance().CallLuaFunctionForReturn(LuaEngine.GetScriptPath(this), "onUpdate", true, this, tick); + lastUpdateScript = tick; + } } } diff --git a/FFXIVClassic Map Server/actors/chara/Character.cs b/FFXIVClassic Map Server/actors/chara/Character.cs index 71cd0f4e..491792b0 100644 --- a/FFXIVClassic Map Server/actors/chara/Character.cs +++ b/FFXIVClassic Map Server/actors/chara/Character.cs @@ -136,7 +136,6 @@ namespace FFXIVClassic_Map_Server.Actors this.statusEffects = new StatusEffectContainer(this); // todo: move this somewhere more appropriate - ResetMoveSpeeds(); // todo: base this on equip and shit SetMod((uint)Modifier.AttackRange, 3); SetMod((uint)Modifier.AttackDelay, (Program.Random.Next(30, 60) * 100)); @@ -279,22 +278,8 @@ namespace FFXIVClassic_Map_Server.Actors public void FollowTarget(Actor target, float stepSize = 1.2f, int maxPath = 25, float radius = 0.0f) { - var player = target as Player; - - if (player != null) - { - if (this.target != player) - { - this.target = target; - } - // todo: move this to own function thing - this.oldMoveState = this.moveState; - this.moveState = 2; - updateFlags |= ActorUpdateFlags.Position | ActorUpdateFlags.Speed; - //this.moveSpeeds = player.moveSpeeds; - - PathTo(player.positionX, player.positionY, player.positionZ, stepSize, maxPath, radius); - } + if (target != null) + PathTo(target.positionX, target.positionY, target.positionZ, stepSize, maxPath, radius); } public Int64 GetMod(uint modifier) @@ -690,12 +675,7 @@ namespace FFXIVClassic_Map_Server.Actors } // todo: call onAttack/onDamageTaken - BattleUtils.DamageTarget(this, target, action); - target.OnDamageTaken(this, action, DamageTakenType.Ability); - - if (target is BattleNpc) - ((BattleNpc)target).lastAttacker = this; - + BattleUtils.DamageTarget(this, target, action, DamageTakenType.Attack); AddTP(115); target.AddTP(100); } @@ -708,20 +688,8 @@ namespace FFXIVClassic_Map_Server.Actors this.DelMP(spellCost); // mpCost can be set in script e.g. if caster has something for free spells foreach (BattleAction action in actions) - { if (zone.FindActorInArea(action.targetId) is Character chara) - { - if (chara != null && chara is BattleNpc) - { - ((BattleNpc)chara).hateContainer.UpdateHate(this, action.amount); - ((BattleNpc)chara).lastAttacker = this; - } - - BattleUtils.DamageTarget(this, chara, action); - } - } - - if (target is BattleNpc) + BattleUtils.DamageTarget(this, chara, action, DamageTakenType.Magic); lua.LuaEngine.GetInstance().OnSignal("spellUsed"); } @@ -733,22 +701,8 @@ namespace FFXIVClassic_Map_Server.Actors this.DelTP(skill.tpCost); foreach (BattleAction action in actions) - { if (zone.FindActorInArea(action.targetId) is Character chara) - { - if (chara != null && chara is BattleNpc) - { - ((BattleNpc)chara).hateContainer.UpdateHate(this, action.amount); - ((BattleNpc)chara).lastAttacker = this; - } - - BattleUtils.DamageTarget(this, chara, action); - } - } - - if (target is BattleNpc) - ((BattleNpc)target).lastAttacker = this; - + BattleUtils.DamageTarget(this, chara, action, DamageTakenType.Weaponskill); lua.LuaEngine.GetInstance().OnSignal("weaponskillUsed"); } @@ -821,7 +775,7 @@ namespace FFXIVClassic_Map_Server.Actors public bool IsMonster() { - return this is BattleNpc && !IsAlly(); + return this is BattleNpc; } public bool IsPet() diff --git a/FFXIVClassic Map Server/actors/chara/ai/HateContainer.cs b/FFXIVClassic Map Server/actors/chara/ai/HateContainer.cs index d5a0904b..47086f68 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/HateContainer.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/HateContainer.cs @@ -39,15 +39,11 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai { if (!HasHateForTarget(target)) hateList.Add(target, new HateEntry(target, 1, 0, true)); - else - Program.Log.Error($"{target.actorName} is already on [{owner.actorId}]{owner.actorName}'s hate list!"); } public void UpdateHate(Character target, int damage) { - if (!HasHateForTarget(target)) - AddBaseHate(target); - + AddBaseHate(target); //hateList[target].volatileEnmity += (uint)damage; hateList[target].cumulativeEnmity += (uint)damage; } @@ -55,13 +51,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai public void ClearHate(Character target = null) { if (target != null) - { hateList.Remove(target); - } else - { hateList.Clear(); - } } private void UpdateHate(HateEntry entry) diff --git a/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs b/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs index d823a53e..6711ccad 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/controllers/BattleNpcController.cs @@ -48,7 +48,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers if(owner.aiContainer.IsEngaged()) { - DoCombatTick(tick); + //DoCombatTick(tick); } //Only move if owner isn't dead and is either too far away from their spawn point or is meant to roam @@ -143,8 +143,6 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers owner.aiContainer.pathFind.PreparePath(owner.spawnX, owner.spawnY, owner.spawnZ, 1.5f, 10); neutralTime = lastActionTime; owner.hateContainer.ClearHate(); - owner.ResetMoveSpeeds(); - owner.moveState = 1; lua.LuaEngine.CallLuaBattleFunction(owner, "onDisengage", owner, target, Utils.UnixTimeStampUTC(lastUpdate)); } @@ -215,6 +213,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers Move(); + + if ((tick - lastCombatTickScript).TotalSeconds > 2) + { + lua.LuaEngine.CallLuaBattleFunction(owner, "onCombatTick", owner, owner.target, Utils.UnixTimeStampUTC(tick), contentGroupCharas); + lastCombatTickScript = tick; + } } protected virtual void Move() diff --git a/FFXIVClassic Map Server/actors/chara/ai/controllers/Controller.cs b/FFXIVClassic Map Server/actors/chara/ai/controllers/Controller.cs index e91bf4ed..ab194953 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/controllers/Controller.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/controllers/Controller.cs @@ -11,6 +11,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.controllers { protected Character owner; + protected DateTime lastCombatTickScript; protected DateTime lastUpdate; public bool canUpdate = true; protected bool autoAttackEnabled = true; diff --git a/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs b/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs index 0a925e53..56087d39 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/state/AttackState.cs @@ -38,7 +38,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state if (target == null || target.IsDead()) { - if (owner is BattleNpc) + if (owner.IsMonster() || owner.IsAlly()) target = ((BattleNpc)owner).hateContainer.GetMostHatedTarget(); } else @@ -129,6 +129,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state private bool CanAttack() { + return false; if (!owner.isAutoAttackEnabled) { return false; @@ -141,7 +142,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state // todo: shouldnt need to check if owner is dead since all states would be cleared if (owner.IsDead() || target.IsDead()) { - if (owner is BattleNpc) + if (owner.IsMonster() || owner.IsAlly()) ((BattleNpc)owner).hateContainer.ClearHate(target); owner.aiContainer.ChangeTarget(null); diff --git a/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs b/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs index 8804de8a..f9bbefad 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/state/WeaponSkillState.cs @@ -104,7 +104,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state // todo: this is fuckin stupid, probably only need *one* error packet, not an error for each action var errors = (BattleAction[])actions.Clone(); - owner.OnWeaponSkill(this, actions, ref errors); + owner.OnWeaponSkill(this, actions, ref errors); owner.DoBattleAction(skill.id, skill.battleAnimation, actions); } diff --git a/FFXIVClassic Map Server/actors/chara/ai/utils/BattleUtils.cs b/FFXIVClassic Map Server/actors/chara/ai/utils/BattleUtils.cs index 92684a0f..ed2a1050 100644 --- a/FFXIVClassic Map Server/actors/chara/ai/utils/BattleUtils.cs +++ b/FFXIVClassic Map Server/actors/chara/ai/utils/BattleUtils.cs @@ -76,20 +76,23 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils return damage; } - public static void DamageTarget(Character attacker, Character defender, BattleAction action) + public static void DamageTarget(Character attacker, Character defender, BattleAction action, DamageTakenType type) { if (defender != null) { // todo: other stuff too if (defender is BattleNpc) { - if (!((BattleNpc)defender).hateContainer.HasHateForTarget(attacker)) + var bnpc = defender as BattleNpc; + if (!bnpc.hateContainer.HasHateForTarget(attacker)) { - ((BattleNpc)defender).hateContainer.AddBaseHate(attacker); + bnpc.hateContainer.AddBaseHate(attacker); } - ((BattleNpc)defender).hateContainer.UpdateHate(attacker, action.amount); + bnpc.hateContainer.UpdateHate(attacker, action.amount); + bnpc.lastAttacker = attacker; } defender.DelHP((short)action.amount); + defender.OnDamageTaken(attacker, action, type); } } diff --git a/FFXIVClassic Map Server/actors/chara/npc/BattleNpc.cs b/FFXIVClassic Map Server/actors/chara/npc/BattleNpc.cs index 62b7a1b7..4b94313a 100644 --- a/FFXIVClassic Map Server/actors/chara/npc/BattleNpc.cs +++ b/FFXIVClassic Map Server/actors/chara/npc/BattleNpc.cs @@ -90,12 +90,7 @@ namespace FFXIVClassic_Map_Server.Actors spawnY = posY; spawnZ = posZ; - // todo: read these from db also - detectionType = DetectionType.Sight; - this.moveState = 2; - ResetMoveSpeeds(); despawnTime = 10; - respawnTime = 30; CalculateBaseStats(); } @@ -245,19 +240,7 @@ namespace FFXIVClassic_Map_Server.Actors { if (respawnTime > 0) { - base.Spawn(tick); - - this.isMovingToSpawn = false; - this.ResetMoveSpeeds(); - this.hateContainer.ClearHate(); - zone.BroadcastPacketsAroundActor(this, GetSpawnPackets(null, 0x01)); - zone.BroadcastPacketsAroundActor(this, GetInitPackets()); - charaWork.parameterSave.hp = charaWork.parameterSave.hpMax; - charaWork.parameterSave.mp = charaWork.parameterSave.mpMax; - RecalculateStats(); - - OnSpawn(); - updateFlags |= ActorUpdateFlags.AllNpc; + ForceRespawn(); } } @@ -266,7 +249,6 @@ namespace FFXIVClassic_Map_Server.Actors base.Spawn(Program.Tick); this.isMovingToSpawn = false; - this.ResetMoveSpeeds(); this.hateContainer.ClearHate(); zone.BroadcastPacketsAroundActor(this, GetSpawnPackets(null, 0x01)); zone.BroadcastPacketsAroundActor(this, GetInitPackets()); @@ -302,7 +284,7 @@ namespace FFXIVClassic_Map_Server.Actors // onDeath(monster, player, killer) lua.LuaEngine.CallLuaBattleFunction(this, "onDeath", this, partyMember, lastAttacker); - if(partyMember is Player) + if (partyMember is Player) ((Player)partyMember).AddExp(1500, (byte)partyMember.GetClass(), 5); } } @@ -315,7 +297,7 @@ namespace FFXIVClassic_Map_Server.Actors } positionUpdates?.Clear(); aiContainer.InternalDie(tick, despawnTime); - this.ResetMoveSpeeds(); + //this.ResetMoveSpeeds(); // todo: reset cooldowns lua.LuaEngine.GetInstance().OnSignal("mobkill"); @@ -379,9 +361,6 @@ namespace FFXIVClassic_Map_Server.Actors if (GetMobMod((uint)MobModifier.AttackScript) != 0) lua.LuaEngine.CallLuaBattleFunction(this, "onAttack", this, state.GetTarget(), action.amount); - - if (target is BattleNpc) - ((BattleNpc)target).hateContainer.UpdateHate(this, action.amount); } public override void OnCast(State state, BattleAction[] actions, ref BattleAction[] errors) @@ -391,19 +370,6 @@ namespace FFXIVClassic_Map_Server.Actors if (GetMobMod((uint)MobModifier.SpellScript) != 0) foreach (var action in actions) lua.LuaEngine.CallLuaBattleFunction(this, "onCast", this, zone.FindActorInArea(action.targetId), ((MagicState)state).GetSpell(), action); - - foreach (BattleAction action in actions) - { - if (zone.FindActorInArea(action.targetId) is Character chara) - { - if (chara is BattleNpc) - { - ((BattleNpc)chara).hateContainer.UpdateHate(this, action.amount); - ((BattleNpc)chara).lastAttacker = this; - } - BattleUtils.DamageTarget(this, chara, action); - } - } } public override void OnAbility(State state, BattleAction[] actions, ref BattleAction[] errors) diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index 5e45bc74..5ac7fd6d 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -2188,6 +2188,7 @@ namespace FFXIVClassic_Map_Server.Actors var spell = ((MagicState)state).GetSpell(); // todo: should just make a thing that updates the one slot cause this is dumb as hell UpdateHotbarTimer(spell.id, spell.recastTimeSeconds); + LuaEngine.GetInstance().OnSignal("spellUse"); } public override void OnWeaponSkill(State state, BattleAction[] actions, ref BattleAction[] errors) @@ -2199,8 +2200,16 @@ namespace FFXIVClassic_Map_Server.Actors UpdateHotbarTimer(skill.id, skill.recastTimeSeconds); // todo: this really shouldnt be called on each ws? lua.LuaEngine.CallLuaBattleFunction(this, "onWeaponSkill", this, state.GetTarget(), skill); + LuaEngine.GetInstance().OnSignal("weaponskillUse"); } - + + public override void OnAbility(State state, BattleAction[] actions, ref BattleAction[] errors) + { + base.OnAbility(state, actions, ref errors); + + LuaEngine.GetInstance().OnSignal("abilityUse"); + } + //Handles exp being added, does not handle figuring out exp bonus from buffs or skill/link chains or any of that public void AddExp(int exp, byte classId, int bonusPercent = 0) { diff --git a/FFXIVClassic Map Server/actors/group/Party.cs b/FFXIVClassic Map Server/actors/group/Party.cs index 441ee0b5..385c5a77 100644 --- a/FFXIVClassic Map Server/actors/group/Party.cs +++ b/FFXIVClassic Map Server/actors/group/Party.cs @@ -63,7 +63,7 @@ namespace FFXIVClassic_Map_Server.actors.group List groupMembers = new List(); groupMembers.Add(new GroupMember(id, -1, 0, false, true, Server.GetWorldManager().GetActorInWorld(id).customDisplayName)); foreach (uint charaId in members) - { + { var chara = Server.GetWorldManager().GetActorInWorld(charaId); if (charaId != id && chara != null) groupMembers.Add(new GroupMember(charaId, -1, 0, false, true, chara.customDisplayName)); diff --git a/FFXIVClassic Map Server/lua/LuaEngine.cs b/FFXIVClassic Map Server/lua/LuaEngine.cs index 47071010..d4f50f72 100644 --- a/FFXIVClassic Map Server/lua/LuaEngine.cs +++ b/FFXIVClassic Map Server/lua/LuaEngine.cs @@ -259,7 +259,7 @@ namespace FFXIVClassic_Map_Server.lua return -1; } - private static string GetScriptPath(Actor target) + public static string GetScriptPath(Actor target) { if (target is Player) { diff --git a/data/scripts/ally.lua b/data/scripts/ally.lua index 8e96909d..c90ae2b8 100644 --- a/data/scripts/ally.lua +++ b/data/scripts/ally.lua @@ -41,14 +41,14 @@ function allyGlobal.HelpPlayers(ally, contentGroupCharas, pickRandomTarget) if chara then -- probably a player, or another ally -- todo: queue support actions, heal, try pull hate off player etc - if chara.IsPlayer() then + if chara:IsPlayer() then -- do stuff if not ally.IsEngaged() then if chara.IsEngaged() then allyGlobal.EngageTarget(ally, chara.target, nil); break; end - end + end elseif chara.IsMonster() and chara.IsEngaged() then if not ally.IsEngaged() then allyGlobal.EngageTarget(ally, chara, nil); diff --git a/data/scripts/commands/AbilityCure.lua b/data/scripts/commands/AbilityCure.lua deleted file mode 100644 index 1ffb6814..00000000 --- a/data/scripts/commands/AbilityCure.lua +++ /dev/null @@ -1,13 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - local shortCommandId = bit32.bxor(command, 2700083200); - local ability = worldManager:GetAbility(shortCommandId); - - --player:PlayAnimation(ability.modelAnimation); - - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/ArrowReloadCommand.lua b/data/scripts/commands/ArrowReloadCommand.lua deleted file mode 100644 index 12f3dd34..00000000 --- a/data/scripts/commands/ArrowReloadCommand.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetAbility(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation, 0x756D, command.actorId, ability.animationType); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/AttackAbility.lua b/data/scripts/commands/AttackAbility.lua deleted file mode 100644 index 12f3dd34..00000000 --- a/data/scripts/commands/AttackAbility.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetAbility(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation, 0x756D, command.actorId, ability.animationType); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/ChangeJobCommand.lua b/data/scripts/commands/ChangeJobCommand.lua deleted file mode 100644 index 4cb38f6a..00000000 --- a/data/scripts/commands/ChangeJobCommand.lua +++ /dev/null @@ -1,6 +0,0 @@ -function onEventStarted(player, caller, commandRequest, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) - - player:SetCurrentJob(17); - - player:EndEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/CureMagic.lua b/data/scripts/commands/CureMagic.lua deleted file mode 100644 index f0753c01..00000000 --- a/data/scripts/commands/CureMagic.lua +++ /dev/null @@ -1,3 +0,0 @@ -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - -end \ No newline at end of file diff --git a/data/scripts/commands/CuregaMagic.lua b/data/scripts/commands/CuregaMagic.lua deleted file mode 100644 index 12f3dd34..00000000 --- a/data/scripts/commands/CuregaMagic.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetAbility(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation, 0x756D, command.actorId, ability.animationType); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/EffectMagic.lua b/data/scripts/commands/EffectMagic.lua deleted file mode 100644 index 52830cf7..00000000 --- a/data/scripts/commands/EffectMagic.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetBattleCommand(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/EsunaMagic.lua b/data/scripts/commands/EsunaMagic.lua deleted file mode 100644 index 12f3dd34..00000000 --- a/data/scripts/commands/EsunaMagic.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetAbility(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation, 0x756D, command.actorId, ability.animationType); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/PointSearchAbility.lua b/data/scripts/commands/PointSearchAbility.lua deleted file mode 100644 index ee05e8c4..00000000 --- a/data/scripts/commands/PointSearchAbility.lua +++ /dev/null @@ -1,7 +0,0 @@ - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - - player.Cast(command.actorId, targetActor); - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/RaiseMagic.lua b/data/scripts/commands/RaiseMagic.lua deleted file mode 100644 index 6ff5f5dd..00000000 --- a/data/scripts/commands/RaiseMagic.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetAbility(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/ShotCommand.lua b/data/scripts/commands/ShotCommand.lua deleted file mode 100644 index 6ff5f5dd..00000000 --- a/data/scripts/commands/ShotCommand.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetAbility(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/SongMagic.lua b/data/scripts/commands/SongMagic.lua deleted file mode 100644 index 12f3dd34..00000000 --- a/data/scripts/commands/SongMagic.lua +++ /dev/null @@ -1,14 +0,0 @@ -require("global") - -function onEventStarted(player, command, triggerName, arg1, arg2, arg3, arg4, targetActor, arg5, arg6, arg7, arg8) - - local worldManager = GetWorldManager(); - --local shortCommandId = command.actorId;--bit32:bxor(command.actorId, 2700083200); - local ability = worldManager:GetAbility(command.actorId); - - if ability then - player.SendBattleActionX01Packet(ability.modelAnimation, ability.effectAnimation, 0x756D, command.actorId, ability.animationType); - end - - player:endEvent(); -end \ No newline at end of file diff --git a/data/scripts/commands/magic/Distortion.lua b/data/scripts/commands/magic/Distortion.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/Distortion.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/Healing Trap.lua b/data/scripts/commands/magic/Healing Trap.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/Healing Trap.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/Homing Missle.lua b/data/scripts/commands/magic/Homing Missle.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/Homing Missle.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/Return Trap.lua b/data/scripts/commands/magic/Return Trap.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/Return Trap.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/Stun II.lua b/data/scripts/commands/magic/Stun II.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/Stun II.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/Stun.lua b/data/scripts/commands/magic/Stun.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/Stun.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/Transfer Trap.lua b/data/scripts/commands/magic/Transfer Trap.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/Transfer Trap.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/blizzara.lua b/data/scripts/commands/magic/blizzara.lua index fc035356..8631a116 100644 --- a/data/scripts/commands/magic/blizzara.lua +++ b/data/scripts/commands/magic/blizzara.lua @@ -19,9 +19,6 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) -- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; + return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/blizzard.lua b/data/scripts/commands/magic/blizzard.lua index 1d854b23..e6716947 100644 --- a/data/scripts/commands/magic/blizzard.lua +++ b/data/scripts/commands/magic/blizzard.lua @@ -17,8 +17,5 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/buff trap.lua b/data/scripts/commands/magic/buff trap.lua deleted file mode 100644 index 1d854b23..00000000 --- a/data/scripts/commands/magic/buff trap.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("magic"); - -function onMagicPrepare(caster, target, spell) - return 0; -end; - -function onMagicStart(caster, target, spell) - return 0; -end; - -function onMagicFinish(caster, target, spell, action) - local damage = math.random(10, 100); - - action.worldMasterTextId = 0x765D; - - -- todo: populate a global script with statuses and modifiers - -- magic.HandleAttackMagic(caster, target, spell, action) - action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; - return damage; -end; \ No newline at end of file diff --git a/data/scripts/commands/magic/burst.lua b/data/scripts/commands/magic/burst.lua index 20f3edab..a847f5d8 100644 --- a/data/scripts/commands/magic/burst.lua +++ b/data/scripts/commands/magic/burst.lua @@ -20,8 +20,5 @@ function onMagicFinish(caster, target, spell, action) -- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/fira.lua b/data/scripts/commands/magic/fira.lua index fc035356..8631a116 100644 --- a/data/scripts/commands/magic/fira.lua +++ b/data/scripts/commands/magic/fira.lua @@ -19,9 +19,6 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) -- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; + return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/firaga.lua b/data/scripts/commands/magic/firaga.lua index 20f3edab..c446e177 100644 --- a/data/scripts/commands/magic/firaga.lua +++ b/data/scripts/commands/magic/firaga.lua @@ -19,9 +19,6 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) -- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; + return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/flare.lua b/data/scripts/commands/magic/flare.lua index 20f3edab..a847f5d8 100644 --- a/data/scripts/commands/magic/flare.lua +++ b/data/scripts/commands/magic/flare.lua @@ -20,8 +20,5 @@ function onMagicFinish(caster, target, spell, action) -- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/freeze.lua b/data/scripts/commands/magic/freeze.lua index fc035356..8129043c 100644 --- a/data/scripts/commands/magic/freeze.lua +++ b/data/scripts/commands/magic/freeze.lua @@ -20,8 +20,5 @@ function onMagicFinish(caster, target, spell, action) -- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/holy.lua b/data/scripts/commands/magic/holy.lua index 20f3edab..c446e177 100644 --- a/data/scripts/commands/magic/holy.lua +++ b/data/scripts/commands/magic/holy.lua @@ -19,9 +19,6 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) -- action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; + return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/thundaga.lua b/data/scripts/commands/magic/thundaga.lua index 1d854b23..e6716947 100644 --- a/data/scripts/commands/magic/thundaga.lua +++ b/data/scripts/commands/magic/thundaga.lua @@ -17,8 +17,5 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/thundara.lua b/data/scripts/commands/magic/thundara.lua index 1d854b23..e6716947 100644 --- a/data/scripts/commands/magic/thundara.lua +++ b/data/scripts/commands/magic/thundara.lua @@ -17,8 +17,5 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; return damage; end; \ No newline at end of file diff --git a/data/scripts/commands/magic/thunder.lua b/data/scripts/commands/magic/thunder.lua index 1d854b23..e6716947 100644 --- a/data/scripts/commands/magic/thunder.lua +++ b/data/scripts/commands/magic/thunder.lua @@ -17,8 +17,5 @@ function onMagicFinish(caster, target, spell, action) -- magic.HandleAttackMagic(caster, target, spell, action) action.effectId = bit32.bxor(0x8000000, spell.effectAnimation, 15636); - if target.hateContainer then - target.hateContainer.UpdateHate(caster, damage); - end; return damage; end; \ No newline at end of file diff --git a/data/scripts/content/SimpleContent30010.lua b/data/scripts/content/SimpleContent30010.lua index 48010b06..01e8d699 100644 --- a/data/scripts/content/SimpleContent30010.lua +++ b/data/scripts/content/SimpleContent30010.lua @@ -1,4 +1,5 @@ require ("global") +require ("ally") require ("modifiers") function onCreate(starterPlayer, contentArea, director) @@ -33,6 +34,42 @@ function onCreate(starterPlayer, contentArea, director) end +function onUpdate(area, tick) + local players = area:GetPlayers() + local mobs = area:GetMonsters() + local allies = area:GetAllies() + local resumeChecks = true + for player in players do + if player then + local exitLoop = false + for ally in allies do + if ally then + if not ally:IsEngaged() then + if player:IsEngaged() then + ally.neutral = false + ally.isAutoAttackEnabled = true + ally:SetMod(modifiersGlobal.Speed, 8) + allyGlobal.EngageTarget(ally, player.target) + exitLoop = true + break + -- todo: support scripted paths + elseif ally:GetSpeed() > 0 then + + end + end + end + end + if exitLoop then + resumeChecks = false + break + end + end + end + if not resumeChecks then + return + end +end + function onDestroy() end diff --git a/data/scripts/unique/fst0Battle03/Monster/bloodthirsty_wolf.lua b/data/scripts/unique/fst0Battle03/Monster/bloodthirsty_wolf.lua index e69de29b..a4e24895 100644 --- a/data/scripts/unique/fst0Battle03/Monster/bloodthirsty_wolf.lua +++ b/data/scripts/unique/fst0Battle03/Monster/bloodthirsty_wolf.lua @@ -0,0 +1,22 @@ +require ("modifiers") + +function onSpawn(mob) + mob:SetMod(modifiersGlobal.Speed, 0) +end + +function onDamageTaken(mob, attacker, damage) + if not attacker:IsPlayer() and mob:GetHP() - damage < 0 then + mob:addHP(damage) + end +end + +function onCombatTick(mob, target, tick, contentGroupCharas) + if mob:GetSpeed() == 0 then + mob:SetMod(modifiersGlobal.Speed, 8) + end +end + +function onDisengage(mob) + mob:SetMod(modifiersGlobal.Speed, 0) + mob:Despawn() +end \ No newline at end of file diff --git a/data/scripts/unique/fst0Battle03/Monster/papalymo.lua b/data/scripts/unique/fst0Battle03/Monster/papalymo.lua index afdd66d9..6ce72e68 100644 --- a/data/scripts/unique/fst0Battle03/Monster/papalymo.lua +++ b/data/scripts/unique/fst0Battle03/Monster/papalymo.lua @@ -1,4 +1,5 @@ require ("global") +require ("modifiers") require ("ally") function onSpawn(ally) diff --git a/data/scripts/unique/fst0Battle03/Monster/yda.lua b/data/scripts/unique/fst0Battle03/Monster/yda.lua index 4462774b..c494f047 100644 --- a/data/scripts/unique/fst0Battle03/Monster/yda.lua +++ b/data/scripts/unique/fst0Battle03/Monster/yda.lua @@ -1,12 +1,12 @@ require ("global") - require ("ally") function onSpawn(ally) ally:SetMaxHP(69420) ally:SetHP(ally:GetMaxHP()) - ally.isAutoAttackEnabled = false + ally.isAutoAttackEnabled = false; ally.neutral = false + ally:SetMod(modifiersGlobal.Speed, 0) end function onCombatTick(ally, target, tick, contentGroupCharas) @@ -23,4 +23,4 @@ function onRoam(ally, contentGroupCharas) ally.neutral = false ally.animationId = 0 --allyGlobal.onCombatTick(ally, contentGroupCharas) -end \ No newline at end of file +end