直接拿上面写的bool值当作if条件。代码里面的东西就不用看了
- //技能冷却,每0.5秒冷却0.5,让冷却稍微顺滑一点。0.1的话担心资源消耗太大。
- //buff、技能的持续时间也写这里
- if (hasElapsed500Ms)
- {
- //遍历全部agent
- foreach (var agent in Mission.Current.Agents)
- {
- //如果agent还活着并且非坐骑
- if (!agent.IsMount && agent.IsActive())
- {
- //获取agent的技能cd,技能cd-0.5并且大于0
- //新增一些东西,由固定0.5修改为调整xx变量,用来处理加速冷却等机制
- if (WoW_Agents.TryGetValue(agent.Index, out AgentExtend v))
- {
- // 定义技能冷却时间调整值
- float primarySkillCDReduction = 0.5f;
- float additionalSkillCDReduction = 0.5f;
- float passiveSkillCDReduction = 0.5f;
- float magicCombatSkill1CDReduction = 0.5f;
- float magicCombatSkill2CDReduction = 0.5f;
- float magicCombatSkill3CDReduction = 0.5f;
- float magicCombatSkill4CDReduction = 0.5f;
- float heavyStrikeSkillCDReduction = 0.5f;
- // 定义技能持续时间调整值
- float primarySkillDurReduction = 0.5f;
- float additionalSkillDurReduction = 0.5f;
- float passiveSkillDurReduction = 0.5f;
- float buffDurReduction = 0.5f;
- float debuffDurReduction = 0.5f;
- float dotDurReduction = 0.5f;
- // 定义Stamina和Mana的增加值
- float staminaIncreaseValue = 50f;
- float manaIncreaseValue = 0.5f;
- if (v.passiveSkill.Equals("nuyikuangji"))
- {
- staminaIncreaseValue = staminaIncreaseValue + 0.5f;
- // InformationManager.DisplayMessage(new InformationMessage($"{v.passiveSkillDur}"));
- }
- // 应用调整值到技能冷却时间
- v.primarySkillCD = Math.Max(0, v.primarySkillCD - primarySkillCDReduction);
- v.additionalSkillCD = Math.Max(0, v.additionalSkillCD - additionalSkillCDReduction);
- v.passiveSkillCD = Math.Max(0, v.passiveSkillCD - passiveSkillCDReduction);
- v.MagicCombatSkill1CD = Math.Max(0, v.MagicCombatSkill1CD - magicCombatSkill1CDReduction);
- v.MagicCombatSkill2CD = Math.Max(0, v.MagicCombatSkill2CD - magicCombatSkill2CDReduction);
- v.MagicCombatSkill3CD = Math.Max(0, v.MagicCombatSkill3CD - magicCombatSkill3CDReduction);
- v.MagicCombatSkill4CD = Math.Max(0, v.MagicCombatSkill4CD - magicCombatSkill4CDReduction);
- v.heavyStrikeSkillCD = Math.Max(0, v.heavyStrikeSkillCD - heavyStrikeSkillCDReduction);
- // 应用调整值到技能持续时间
- v.primarySkillDur = Math.Max(0, v.primarySkillDur - primarySkillDurReduction);
- v.additionalSkillDur = Math.Max(0, v.additionalSkillDur - additionalSkillDurReduction);
- v.passiveSkillDur = Math.Max(0, v.passiveSkillDur - passiveSkillDurReduction);
- v.BuffDur = Math.Max(0, v.BuffDur - buffDurReduction);
- v.DebuffDur = Math.Max(0, v.DebuffDur - debuffDurReduction);
- v.DotDur = Math.Max(0, v.DotDur - dotDurReduction);
- // 应用增加值到Stamina和Mana
- v.Stamina = Math.Min(v.Stamina + staminaIncreaseValue, 100);
- v.Mana = Math.Min(v.Mana + manaIncreaseValue, 100);
- }
- }
- }
- }
- //ai释放技能系统,每一秒执行一次判定
- //现在玩家释放技能也整合进来了
- if (hasElapsed500Ms || canUse)
- {
- //遍历全部agent
- foreach (var agent in Mission.Current.Agents)
- {
- //如果agent还活着并且非坐骑
- if (!agent.IsMount && agent.IsActive())
- {
- if (agent != Agent.Main || (agent == Agent.Main && canUse))
- {
- //获取agent的技能信息
- if (WoW_Agents.TryGetValue(agent.Index, out AgentExtend v))
- {
- if (agent == Agent.Main)
- {
- canUse = false;//开始检测能不能用技能时,就把玩家的这个标记重置回去
- v.primarySkill = "zhidaojian";//测试用代码
- }
- //如果主特技cd到0可以使用了
- if (v.primarySkillCD <= 0)
- {
- //如果主特技是xxx,则触发什么效果。可以在里面继续写使用条件来优化ai
- if (v.primarySkill == "chongfeng" && v.Stamina >= 5)
- {
- if (WoW_Scripts.AgentRushToAgent(v.NativeAgent))
- {
- InformationManager.DisplayMessage(new InformationMessage("chongfeng"));
- v.Stamina -= 5;
- v.primarySkillCD = 1;
- v.primarySkillDur = 5;
- }
- else
- {
- InformationManager.DisplayMessage(new InformationMessage("con't use chongfeng"));
- }
- }
- if (v.primarySkill == "jianta" && v.Stamina >= 5)
- {
- if (WoW_Scripts.AgentRushToPos(v.NativeAgent))
- {
- InformationManager.DisplayMessage(new InformationMessage("jianta"));
- v.Stamina -= 5;
- v.primarySkillCD = 1;
- v.primarySkillDur = 5;
- }
- else
- {
- InformationManager.DisplayMessage(new InformationMessage("con't use jianta"));
- }
- }
- if (v.primarySkill == "duochongjian" && v.Stamina > 5)
- {
- WoW_Scripts.AgentShootTowardsLookDirection(v.NativeAgent);
- InformationManager.DisplayMessage(new InformationMessage("duochongjian"));
- v.Stamina -= 5;
- v.primarySkillCD = 1;
- }
- }
- if (v.additionalSkillCD <= 0)
- {
- if (v.additionalSkill == "jianyi")
- {
- InformationManager.DisplayMessage(new InformationMessage("jianyi"));
- }
- }
- if (v.passiveSkillCD <= 0)//抽空改一下,神tm释放一个被动
- {
- if (v.passiveSkill == "chongnfeng")
- {
- InformationManager.DisplayMessage(new InformationMessage("chongnfeng"));
- }
- }
- if (v.primarySkill == "jianqizhan")
- { //如果主动技能是xxxx,则实现技能的效果。可以考虑把代码写在其他的文件里,这边简化显示。
- //效果代码,或者调用函数
- v.primarySkillDur = 10f;
- InformationManager.DisplayMessage(new InformationMessage("jianqizhan"));
- }
- if (v.primarySkill == "duochongjian")
- { //如果主动技能是xxxx,则实现技能的效果。可以考虑把代码写在其他的文件里,这边简化显示。
- //效果代码,或者调用函数
- if (v.Stamina >= 5 && v.primarySkillCD == 0)
- {
- WoW_Scripts.AgentShootTowardsLookDirection(v.NativeAgent);
- InformationManager.DisplayMessage(new InformationMessage("duochongjian"));
- v.Stamina -= 5;
- v.primarySkillCD = 1;
- }
- }
- if (v.primarySkill == "daoshan")
- { //如果主动技能是xxxx,则实现技能的效果。可以考虑把代码写在其他的文件里,这边简化显示。
- //效果代码,或者调用函数
- if (v.Stamina >= 5 && v.primarySkillCD == 0)
- {
- WoW_Scripts.DaoShan(v.NativeAgent);
- InformationManager.DisplayMessage(new InformationMessage("daoshan"));
- v.Stamina -= 5;
- v.primarySkillCD = 1;
- }
- }
- if (v.primarySkill == "wangzhibaoku")
- { //如果主动技能是xxxx,则实现技能的效果。可以考虑把代码写在其他的文件里,这边简化显示。
- //效果代码,或者调用函数
- if (v.Stamina >= 5 && v.primarySkillCD == 0)
- {
- WoW_Scripts.WangZhiBaoKu(v.NativeAgent);
- InformationManager.DisplayMessage(new InformationMessage("wangzhibaoku"));
- v.Stamina -= 5;
- v.primarySkillCD = 10;
- }
- }
- if (v.primarySkill == "zhidaojian")
- { //如果主动技能是xxxx,则实现技能的效果。可以考虑把代码写在其他的文件里,这边简化显示。
- //效果代码,或者调用函数
- if (v.Stamina >= 5 && v.primarySkillCD == 0)
- {
- WoW_Scripts.ZhiDaoJian(v.NativeAgent);
- InformationManager.DisplayMessage(new InformationMessage("zhidaojian"));
- v.Stamina -= 5;
- v.primarySkillCD = 1;
- }
- }
- if (v.primarySkill == "ConeOfArrows")
- { //如果主动技能是xxxx,则实现技能的效果。可以考虑把代码写在其他的文件里,这边简化显示。
- //效果代码,或者调用函数
- if (v.Stamina >= 5 && v.primarySkillCD == 0)
- {
- WoW_Scripts.AgentShootConeOfArrows(v.NativeAgent);
- InformationManager.DisplayMessage(new InformationMessage("ConeOfArrows"));
- v.Stamina -= 5;
- v.primarySkillCD = 1;
- }
- }
- }
- }
- }
- }
- }
复制代码
|