mirror of
				https://bitbucket.org/Ioncannon/project-meteor-server.git
				synced 2025-05-20 08:26:59 -04:00 
			
		
		
		
	Pass BattleCommand to scripts.
This commit is contained in:
		| @@ -872,8 +872,8 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|                     break; | ||||
|             } | ||||
|  | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnDamageTaken, "onDamageTaken", attacker, this, action); | ||||
|              | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnDamageTaken, "onDamageTaken", attacker, this, skill, action, actionContainer); | ||||
|  | ||||
|             //TP gain formula seems to be something like 5 * e ^ ( -0.667 * [defender's level] ) * damage taken, rounded up | ||||
|             //This should be completely accurate at level 50, but isn't totally accurate at lower levels. | ||||
|             //Don't know if store tp impacts this | ||||
| @@ -1024,38 +1024,38 @@ namespace FFXIVClassic_Map_Server.Actors | ||||
|         public void OnEvade(Character attacker, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null) | ||||
|         { | ||||
|             SetProc((ushort)HitType.Evade); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnEvade, "onEvade", attacker, this, action, actionContainer); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnEvade, "onEvade", attacker, this, skill, action, actionContainer); | ||||
|         } | ||||
|  | ||||
|         //Called when this character blocks attacker's action | ||||
|         public void OnBlock(Character attacker, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null) | ||||
|         { | ||||
|             SetProc((ushort)HitType.Block); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnBlock, "onBlock", attacker, this, action, actionContainer); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnBlock, "onBlock", attacker, this, skill, action, actionContainer); | ||||
|         } | ||||
|  | ||||
|         //Called when this character parries attacker's action | ||||
|         public void OnParry(Character attacker, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null) | ||||
|         { | ||||
|             SetProc((ushort)HitType.Parry); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnParry, "onParry", attacker, this, action, actionContainer); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnParry, "onParry", attacker, this, skill, action, actionContainer); | ||||
|         } | ||||
|  | ||||
|         //Called when this character misses | ||||
|         public void OnMiss(Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null) | ||||
|         { | ||||
|             SetProc((ushort)HitType.Miss); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnMiss, "onMiss", this, defender, action, actionContainer); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnMiss, "onMiss", this, defender, skill, action, actionContainer); | ||||
|         } | ||||
|  | ||||
|         public void OnHit(Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null) | ||||
|         { | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnHit, "onHit", this, defender, action, actionContainer); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnHit, "onHit", this, defender, skill, action, actionContainer); | ||||
|         } | ||||
|  | ||||
|         public void OnCrit(Character defender, BattleCommand skill, CommandResult action, CommandResultContainer actionContainer = null) | ||||
|         { | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnHit, "onCrit", this, defender, action, actionContainer); | ||||
|             statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnCrit, "onCrit", this, defender, skill, action, actionContainer); | ||||
|         } | ||||
|  | ||||
|         //The order of messages that appears after using a command is: | ||||
|   | ||||
| @@ -46,12 +46,12 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai | ||||
|  | ||||
|             // list of effects to remove | ||||
|             var removeEffects = new List<StatusEffect>(); | ||||
|             for (int i = 0; i < effects.Values.Count; i++) | ||||
|             var effectsList = effects.Values; | ||||
|             for (int i = effectsList.Count - 1; i >= 0; i--) | ||||
|             { | ||||
|                 // effect's update function returns true if effect has completed | ||||
|                 if (effects.Values.ElementAt(i).Update(tick)) | ||||
|                      removeEffects.Add(effects.Values.ElementAt(i)); | ||||
|  | ||||
|                 if (effectsList.ElementAt(i).Update(tick, resultContainer)) | ||||
|                     removeEffects.Add(effectsList.ElementAt(i)); | ||||
|             } | ||||
|  | ||||
|             // remove effects from this list | ||||
|   | ||||
| @@ -21,7 +21,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|         { | ||||
|             this.startTime = DateTime.Now; | ||||
|             this.skill = Server.GetWorldManager().GetBattleCommand(skillId); | ||||
|             var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "ability", "onAbilityPrepare", owner, target, skill); | ||||
|             var returnCode = skill.CallLuaFunction(owner, "ability", "onAbilityPrepare", owner, target, skill); | ||||
|  | ||||
|             this.target = (skill.mainTarget & ValidTarget.SelfOnly) != 0 ? owner : target; | ||||
|  | ||||
| @@ -39,7 +39,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|  | ||||
|         public override void OnStart() | ||||
|         { | ||||
|             var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "ability", "onAbilityStart", owner, target, skill); | ||||
|             var returnCode = skill.CallLuaFunction(owner, "ability", "onAbilityStart", owner, target, skill); | ||||
|  | ||||
|             if (returnCode != 0) | ||||
|             { | ||||
|   | ||||
| @@ -24,7 +24,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|             this.startPos = owner.GetPosAsVector3(); | ||||
|             this.startTime = DateTime.Now; | ||||
|             this.spell = Server.GetWorldManager().GetBattleCommand(spellId); | ||||
|             var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicPrepare", owner, target, spell); | ||||
|             var returnCode = spell.CallLuaFunction(owner, "magic", "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)); | ||||
| @@ -49,7 +49,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|  | ||||
|         public override void OnStart() | ||||
|         { | ||||
|             var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onMagicStart", owner, target, spell); | ||||
|             var returnCode = spell.CallLuaFunction(owner, "magic", "onMagicStart", owner, target, spell); | ||||
|  | ||||
|             if (returnCode != 0) | ||||
|             { | ||||
| @@ -68,7 +68,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|                     Player p = (Player)owner; | ||||
|                     if (spell.comboStep == 1 || ((p.playerWork.comboNextCommandId[0] == spell.id || p.playerWork.comboNextCommandId[1] == spell.id))) | ||||
|                     { | ||||
|                         lua.LuaEngine.CallLuaBattleCommandFunction(owner, spell, "magic", "onCombo", owner, target, spell); | ||||
|                         spell.CallLuaFunction(owner, "magic", "onCombo", owner, target, spell); | ||||
|                         spell.isCombo = true; | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
| @@ -20,9 +20,9 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|             base(owner, target) | ||||
|         { | ||||
|             this.startTime = DateTime.Now; | ||||
|             //this.target = skill.targetFind. | ||||
|             this.skill = Server.GetWorldManager().GetBattleCommand(skillId); | ||||
|             var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillPrepare", owner, target, skill); | ||||
|  | ||||
|             var returnCode = skill.CallLuaFunction(owner, "weaponskill", "onSkillPrepare", owner, target, skill); | ||||
|  | ||||
|             this.target = (skill.mainTarget & ValidTarget.SelfOnly) != 0 ? owner : target; | ||||
|  | ||||
| @@ -40,7 +40,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|  | ||||
|         public override void OnStart() | ||||
|         { | ||||
|             var returnCode = lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onSkillStart", owner, target, skill); | ||||
|             var returnCode = skill.CallLuaFunction(owner, "weaponskill", "onSkillStart", owner, target, skill); | ||||
|  | ||||
|             if (returnCode != 0) | ||||
|             { | ||||
| @@ -57,8 +57,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|                 { | ||||
|                     //If there is a position bonus | ||||
|                     if (skill.positionBonus != BattleCommandPositionBonus.None) | ||||
|                         //lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onPositional", owner, target, skill); | ||||
|                         skill.CallLuaFunction(owner, "onPositional", owner, target, skill); | ||||
|                         skill.CallLuaFunction(owner, "weaponskill", "onPositional", owner, target, skill); | ||||
|  | ||||
|                     //Combo stuff | ||||
|                     if (owner is Player) | ||||
| @@ -70,8 +69,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.state | ||||
|                             //If owner is a player and the skill being used is part of the current combo | ||||
|                             if (p.playerWork.comboNextCommandId[0] == skill.id || p.playerWork.comboNextCommandId[1] == skill.id) | ||||
|                             { | ||||
|                                 lua.LuaEngine.CallLuaBattleCommandFunction(owner, skill, "weaponskill", "onCombo", owner, target, skill); | ||||
|                                 skill.CallLuaFunction(owner, "onCombo", owner, target, skill); | ||||
|                                 skill.CallLuaFunction(owner, "weaponskill", "onCombo", owner, target, skill); | ||||
|                                 skill.isCombo = true; | ||||
|                             } | ||||
|                             //or if this just the start of a combo | ||||
|   | ||||
| @@ -278,7 +278,7 @@ namespace FFXIVClassic_Map_Server.actors.chara.ai.utils | ||||
|             { | ||||
|                 target.AddHP(action.amount, actionContainer); | ||||
|  | ||||
|                 target.statusEffects.CallLuaFunctionByFlag((uint) StatusEffectFlags.ActivateOnHealed, "onHealed", caster, target, action, actionContainer); | ||||
|                 target.statusEffects.CallLuaFunctionByFlag((uint)StatusEffectFlags.ActivateOnHealed, "onHealed", caster, target, skill, action, actionContainer); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user