Pass BattleCommand to scripts.

This commit is contained in:
Yogurt
2019-05-29 20:19:44 -07:00
parent d7c383d04a
commit 6127ad44cc
6 changed files with 23 additions and 25 deletions

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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);
}
}