//复活 private bool DaoJuRevive(FightPlayer a, int p, PlayerEx package, GameConfig c) { string target = a.Action.Target; FightPlayer t = m_teamA.FirstOrDefault(x => x.ID == target) as FightPlayer; if (t == null) t = m_teamB.FirstOrDefault(x => x.ID == target) as FightPlayer; if (t == null || t.IsLive) return false; //检查使用限制.. //if (!SupplyLimit(note, c)) return false; if (a.Player.RemoveGoods(p, GoodsSource.DaoJuRevive)) { ActionResult result = new ActionResult(target); //百分比复活生命 int hp = (int)(t.Life.ShengMing * c.Value.GetDoubleOrDefault("A")); int mp = (int)(t.Life.MoFa * c.Value.GetDoubleOrDefault("B")) - t.MP; if (mp < 0) mp = 0; t.AddHPAndMP(hp, mp); if (hp > 0) { result.Value["HP"] = hp; result.Value["ShengMing"] = t.HP; } if (mp > 0) { result.Value["MP"] = mp; result.Value["MoFa"] = t.MP; } result.ActionFlag |= ActionFlag.Supply; a.Action.Result = new List<ActionResult>() { result }; a.Action.FightCount = FightAction.HasAction; m_actions.Add(a.Action); return true; } return false; }
/// <summary> /// 攻击 /// </summary> /// <param name="target">接受攻击者</param> /// <returns></returns> public override ActionResult Attack(FightObject target) { ActionResult result = new ActionResult(target.ID); bool meingZhong = CheckMingZhong(target); if (meingZhong) { if (m_Par != null) { if (m_Par.Config.SubType == SkillSub.Attack) { m_Par.UseC = target.ExistsBuffer(m_Par.BufferID); } else { m_Par.UseC = false; } } //计算倍率.. double beiShu = CalculatedRate(target, result); // int gongJi = GetGongJi(target); double xiShou = GetXiShou(target); // 战斗公式 int w = (int)(gongJi * (1 - xiShou) * beiShu); w -= target.Life.KangShangHai; // B是否进行了防御 bool fangyu = CheckFangYu(target); if (fangyu) { result.ActionFlag |= ActionFlag.FangYu; //w = w * 6 / 10; w = w >> 1; //50% } WriteShangHai(result, target, w); bool fanji = CheckFanJi(target); if (fanji) { result.ActionFlag |= ActionFlag.FanJi; result.Value["FanJi"] = FanAttack(target); } ChangeShengMing(result, m_a, target); // 添加附带的Buffer. TryAddBuffer(result, target); return result; } else { //闪避 result.ActionFlag |= ActionFlag.ShanBi; } return result; }
/// <summary> /// 免死的技能(修身) /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillNoDeath(FightObject fighter, int level, GameConfig gc) { TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); AttackParameter par = new AttackParameter(gc, level); var targets = FriendTargets(fighter, targetType, par); if (targets.Count == 0) return false; var config = par.LevelConfig; if (config == null) return false; double a = config.GetDoubleOrDefault("A"); int r = config.GetIntOrDefault("Round"); if (r <= 0) return false; List<ActionResult> results = new List<ActionResult>(); foreach (var target in targets) { ActionResult result = new ActionResult(target.ID); SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, a); target.AddBuffer(buf); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; results.Add(result); } fighter.Action.Result = results; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
/// <summary> /// 增强防御的技能 /// 石壁/神龙(主动) /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillIncreaseDefense(FightObject fighter, int level, GameConfig gc) { TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); AttackParameter par = new AttackParameter(gc, level); var targets = FriendTargets(fighter, targetType, par); if (targets.Count == 0) return false; var config = par.LevelConfig; if (config == null) return false; double a = config.GetDoubleOrDefault("A"); double b = config.GetDoubleOrDefault("B"); if (a == 0 && b == 0) return false; int r = config.GetIntOrDefault("Round"); if (r <= 0) return false; double c; if (gc.Name == BufferType.ShiBi) { c = a + ((fighter.Life.TiZhi / 50) * b); } else { c = a + ((fighter.Life.JingShen / 50) * b); } if (c <= 0) return false; List<ActionResult> results = new List<ActionResult>(); foreach (var target in targets) { //添加Buffer ActionResult result = new ActionResult(target.ID); SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, c); target.AddBuffer(buf); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; results.Add(result); } fighter.Action.Result = results; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
///// <summary> ///// 自身产生Buffer(开刃/沼气/焚烧) ///// </summary> ///// <param name="fighter"></param> ///// <param name="level"></param> ///// <param name="gc"></param> //private bool SkillAddBuffer(FightObject fighter, int level, GameConfig gc) //{ // SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, Byte.MaxValue, gc.Value); // fighter.AddBuffer(buf); // fighter.Action.Value = new Variant(); // ActionResult result = new ActionResult(fighter.ID); // result.ActionFlag |= ActionFlag.AddBuff; // result.Value["AddBuffer"] = buf; // fighter.Action.Result = new List<ActionResult>() { result }; // fighter.Action.FightCount = FightAction.HasAction; // m_actions.Add(fighter.Action); // return true; //} /// <summary> /// 治疗的技能 /// 回春/母育/祭祀/神谕 /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillCure(FightObject fighter, int level, GameConfig gc) { TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); AttackParameter par = new AttackParameter(gc, level); var targets = FriendTargets(fighter, targetType, par); if (targets.Count == 0) return false; var config = par.LevelConfig; if (config == null) return false; double a = config.GetDoubleOrDefault("A"); double b = config.GetDoubleOrDefault("B"); double c = config.GetDoubleOrDefault("C"); //double d = config.GetDoubleOrDefault("D"); int r = config.GetIntOrDefault("Round"); List<ActionResult> results = new List<ActionResult>(); foreach (var target in targets) { ActionResult result = new ActionResult(target.ID); result.ActionFlag |= ActionFlag.Supply; int hp = target.TryHP(a) + (int)(fighter.Life.JingShen * b); target.AddHPAndMP(hp, 0); result.Value["HP"] = hp; //result.Value["ShengMing"] = target.HP; result.Value["ShengMing"] = new MVPair(target.Life.ShengMing, target.HP); //添加Buffer if (r > 0) { SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r, gc.Value, c); target.AddBuffer(buf); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; } results.Add(result); } fighter.Action.Result = results; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
/// <summary> /// 在攻击敌方时(冲锋/封尘/冻结) /// 直接产生Buffer的技能 /// </summary> /// <param name="fighter"></param> private bool SkillCreateBuffer(FightObject fighter, int level, GameConfig gc) { if (fighter == null || gc == null || gc.Value == null) { return false; } string newbuffer = gc.Value.GetStringOrDefault("BufferID"); GameConfig g = GameConfigAccess.Instance.FindOneById(newbuffer); if (g == null) { return false; } List<FightObject> targets; TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType", 1); if (targetType == TargetType.Single) { targets = FilterTargets(fighter); } else { targets = EnemyTargets(fighter, targetType, new AttackParameter(gc, level)); } //产生石化/混乱/冰冻 fighter.Action.Value = new Variant(); if (targets.Count == 0) { return false; } SkillBuffer buf = new SkillBuffer(g.Name, fighter.ID, level, 1, gc.Value); //修正次数. int round = buf.LevelConfig.GetIntOrDefault("Round", 1); buf.RemainingNumber = round; targets[0].AddBuffer(buf); ActionResult result = new ActionResult(targets[0].ID); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; fighter.Action.Result = new List<ActionResult> { result }; if (targetType != TargetType.Single) { for (int i = 1; i < targets.Count; i++) { SkillBuffer bufi = new SkillBuffer(g.Name, fighter.ID, level, 1, gc.Value); bufi.RemainingNumber = round; targets[i].AddBuffer(bufi); ActionResult resulti = new ActionResult(targets[i].ID); resulti.ActionFlag |= ActionFlag.AddBuff; resulti.Value["AddBuffer"] = bufi; fighter.Action.Result.Add(resulti); } } fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
private void WriteShangHai(ActionResult result, FightObject target, int w) { w = Math.Max(1, w); target.HP -= w; result.Value["ShangHai"] = w; }
/// <summary> /// 开刃/沼气/焚烧 (主动) /// 添加(流血/中毒/灼烧) /// </summary> /// <param name="r"></param> /// <param name="target"></param> /// <param name="level"></param> /// <param name="buffer"></param> /// <returns></returns> private bool TryAddBuffer(ActionResult r, FightObject target, int level, SkillBuffer buffer) { Variant levelConfig = buffer.LevelConfig; if (levelConfig == null) return false; //根据概率计算出是否产生附加Buffer if (RandomHit(levelConfig.GetDoubleOrDefault("C"))) { int senderSkillType = buffer.Config.GetIntOrDefault("SkillType"); bool pass = CheckSkillType(senderSkillType); if (pass) { //Round:int Buffer可持续回合数 int round = levelConfig.GetIntOrDefault("Round"); //A:double 生成的Buffer的值 double v = levelConfig.GetDoubleOrDefault("A"); if (buffer.ID == BufferType.KaiRen) { IncreaseBuffer(BufferType.DaMo, ref round, ref v); } else if (buffer.ID == BufferType.ZhaoQi) { IncreaseBuffer(BufferType.DiMai, ref round, ref v); } else if (buffer.ID == BufferType.FenShao) { IncreaseBuffer(BufferType.XuanJi, ref round, ref v); } string newID = buffer.Config.GetStringOrDefault("BufferID"); GameConfig buffConfig = GameConfigAccess.Instance.FindOneById(newID); SkillBuffer newBuff = new SkillBuffer(buffConfig.Name, m_a.ID, m_Par.Level, round, buffer.Config, v); if (target.AddBuffer(newBuff)) { r.Value["AddBuffer"] = newBuff; } return true; } } return false; }
/// <summary> /// 添加附带的Buffer /// (开刃/沼气/焚烧 (主动) 森严/凝固/凝霜/附骨(被动)) /// 可能产生(流血/中毒/灼烧/混乱/石化//冰冻/附骨) /// </summary> /// <param name="target">接受攻击者</param> protected virtual void TryAddBuffer(ActionResult r, FightObject target) { if (target.HP <= 0) return; //// 开刃/沼气/焚烧 (主动) 添加(流血/中毒/灼烧) //foreach (var buffer in m_a.Buffers) //{ // if (buffer.Name == BufferType.KaiRen || buffer.Name == BufferType.ZhaoQi || buffer.Name == BufferType.FenShao) // { // if (TryAddBuffer(r, target, buffer.Level, buffer)) // { // return; // } // } //} // TODO:开刃/沼气/焚烧 (主动改为被动) 添加(流血/中毒/灼烧) // 森严/凝固/凝霜/附骨(被动) 添加(混乱/石化/冰冻/附骨) if (m_a.FixBuffer != null) { foreach (var skill in m_a.FixBuffer) { if (skill.Value.Item2.SubType != SkillSub.AddBuffer) continue; if (TryAddBuffer(r, target, skill.Value.Item1, skill.Value.Item2)) { return; } } } }
/// <summary> /// 计算倍率.. /// </summary> private double CalculatedRate(FightObject target, ActionResult result) { double beiShu = 1.0; // 是否保护别人 if (target.ProtectOther) { target.ProtectOther = false; result.ActionFlag |= ActionFlag.ProtectOther; beiShu = 0.6; } // 是否受保护 else if (target.Protect) { result.ActionFlag |= ActionFlag.Protect; beiShu = 0.4; } // 是否有合击 if (m_heji) { result.ActionFlag |= ActionFlag.HeJi; beiShu *= m_a.Life.HeJiShangHai; } // 是否有暴击 bool baoJi = CheckBaoJi(target); if (baoJi) { result.ActionFlag |= ActionFlag.BaoJi; beiShu *= m_a.Life.BaoJiShangHai; } //beiShu += BufferAddAttack(target); beiShu *= (1 + BufferAddAttack(target)); return beiShu; }
/// <summary> /// 反击.... /// </summary> /// <param name="target"></param> /// <returns></returns> protected virtual ActionResult FanAttack(FightObject target) { ActionResult result = new ActionResult(m_a.ID); double beiShu = 1; // 是否有暴击 bool baoJi = RandomHit(target.Life.BaoJiLv + 0.02 * (target.Level - m_a.Level)); if (baoJi) { beiShu *= target.Life.BaoJiShangHai; result.ActionFlag |= ActionFlag.BaoJi; } int w = (int)(target.Life.GongJi * (1 - m_a.Life.WuLiXiShou) * beiShu) - m_a.Life.KangShangHai; WriteShangHai(result, m_a, w); ChangeShengMing(result, target, m_a); return result; }
/// <summary> /// 修改生命值. /// </summary> /// <param name="target">接受攻击者</param> /// <param name="w"></param> /// <returns></returns> protected int ChangeShengMing(ActionResult result, FightObject sender, FightObject target) { int xiuShen = 0; if (target.HP <= 0) { SkillBuffer b = target.FindBuffer(BufferType.XiuShen); if (b != null) { xiuShen = Convert.ToInt32(b.V); result.Value["XiuShen"] = xiuShen; result.ActionFlag |= ActionFlag.XiuShen; target.HP = xiuShen; } else { target.HP = 0; target.Buffers.Clear(); //target.Buffers.RemoveAll(x => x.CanRemove); if (target is FightApc) { ((FightApc)target).Killer = sender; } } } result.Value["ShengMing"] = new MVPair(target.Life.ShengMing, target.HP); return xiuShen; }
//加血 private bool DaoJuSupply(FightPlayer a, int p, PlayerEx package, GameConfig c) { string target = a.Action.Target; FightPlayer t = m_teamA.FirstOrDefault(x => x.ID == target) as FightPlayer; if (t == null) t = m_teamB.FirstOrDefault(x => x.ID == target) as FightPlayer; if (t == null || t.Over) return false; //检查使用限制.. //if (!SupplyLimit(note, c)) return false; int hp = t.TryHP(c.Value.GetDoubleOrDefault("HP")); int mp = t.TryMP(c.Value.GetDoubleOrDefault("MP")); if (hp == 0 && mp == 0) return false; bool needHP = t.Life.ShengMing > t.HP; bool needMP = t.Life.MoFa > t.MP; if ((needHP && hp > 0) || (needMP && mp > 0)) { if (a.Player.RemoveGoods(p, GoodsSource.DaoJuSupply)) { t.AddHPAndMP(hp, mp); ActionResult result = new ActionResult(target); if (hp > 0) { result.Value["HP"] = hp; result.Value["ShengMing"] = t.HP; } if (mp > 0) { result.Value["MP"] = mp; result.Value["MoFa"] = t.MP; } result.ActionFlag |= ActionFlag.Supply; a.Action.Result = new List<ActionResult>() { result }; a.Action.FightCount = FightAction.HasAction; m_actions.Add(a.Action); return true; } } return false; }
/// <summary> /// 复活的技能(回生) /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillRevive(FightObject fighter, int level, GameConfig gc) { TargetType targetType = (TargetType)gc.Value.GetIntOrDefault("TargetType"); List<FightObject> targets = null; if (targetType == TargetType.TeamAll) { targets = fighter.Team.Where(x => x.HP == 0).ToList(); } else { FightObject t; if (fighter.FType == FighterType.Pet || fighter.FType == FighterType.Player) { string targetID = fighter.Action.Target; t = fighter.Team.FirstOrDefault(x => x.ID == targetID); } else { t = fighter.Team.FirstOrDefault(x => x.HP == 0); } if (t != null && t.HP == 0) { targets = new List<FightObject>(1); targets.Add(t); } } if (targets == null || targets.Count == 0) { return false; } var results = new List<ActionResult>(targets.Count); foreach (FightObject target in targets) { var config = gc.Value.GetVariantOrDefault(level.ToString()); if (config == null) return false; double a = config.GetDoubleOrDefault("A"); double b = config.GetDoubleOrDefault("B"); ActionResult result = new ActionResult(target.ID); result.ActionFlag |= ActionFlag.Supply; int hp = target.TryHP(a); int mp = target.TryMP(b); target.AddHPAndMP(hp, mp); result.Value["HP"] = hp; result.Value["MP"] = mp; result.Value["ShengMing"] = new MVPair(target.Life.ShengMing, target.HP); result.Value["MoFa"] = new MVPair(target.Life.MoFa, target.MP); results.Add(result); } fighter.Action.Result = results; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
/// <summary> // 森严/凝固/凝霜/附骨(被动) // 添加(混乱/石化/冰冻/附骨) /// </summary> /// <param name="r"></param> /// <param name="target"></param> /// <param name="level"></param> /// <param name="gc"></param> /// <returns></returns> private bool TryAddBuffer(ActionResult r, FightObject target, int level, GameConfig gc) { Variant levelConfig = gc.Value.GetVariantOrDefault(level.ToString()); if (levelConfig == null) return false; //根据概率计算出是否产生附加Buffer if (RandomHit(levelConfig.GetDoubleOrDefault("C"))) { int senderSkillType = gc.Value.GetIntOrDefault("SkillType"); bool pass = CheckSkillType(senderSkillType); if (pass) { string newbuffer = gc.Value.GetStringOrDefault("BufferID"); GameConfig buffConfig = GameConfigAccess.Instance.FindOneById(newbuffer); //Round:int Buffer可持续回合数 int round = levelConfig.GetIntOrDefault("Round"); //A:double 生成的Buffer的值 double v = levelConfig.GetDoubleOrDefault("A"); //每1点精神会增加的伤害(附骨) double b = levelConfig.GetDoubleOrDefault("B"); if (b > 0) { v += (b * m_a.Life.JingShen); } SkillBuffer bf = new SkillBuffer(buffConfig.Name, m_a.ID, level, round, gc.Value, v); if (target.AddBuffer(bf)) { r.Value["AddBuffer"] = bf; } return true; } } return false; }
/// <summary> /// 增加攻击次数(蓄力) /// </summary> /// <param name="fighter"></param> /// <param name="level"></param> /// <param name="gc"></param> private bool SkillXuli(FightObject fighter, int level, GameConfig gc) { var config = gc.Value.GetVariantOrDefault(level.ToString()); if (config == null) return false; int r = config.GetIntOrDefault("Round"); SkillBuffer buf = new SkillBuffer(gc.Name, fighter.ID, level, r + 1, gc.Value); fighter.AddBuffer(buf); fighter.Action.Value = new Variant(); ActionResult result = new ActionResult(fighter.ID); result.ActionFlag |= ActionFlag.AddBuff; result.Value["AddBuffer"] = buf; fighter.Action.Result = new List<ActionResult>() { result }; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); return true; }
/// <summary> /// 抓捕 /// </summary> /// <param name="fighter"></param> private void ZhuaPu(FightPlayer fighter) { string targetID = fighter.Action.Target; FightBB bb = m_teamB.FirstOrDefault(x => x.ID == targetID) as FightBB; if (bb != null && bb.IsLive) { ActionResult result = new ActionResult(targetID); fighter.Action.Result = new List<ActionResult>() { result }; fighter.Action.FightCount = FightAction.HasAction; m_actions.Add(fighter.Action); string petID = bb.APC.Value.GetStringOrDefault("PetID"); if (string.IsNullOrEmpty(petID)) { //不可捕捉 result.Value["Msg"] = TipManager.GetMessage(ClientReturn.ZhuaPu1); return; } var pet = GameConfigAccess.Instance.FindOneById(petID); if (pet == null) //|| pet.MainType != MainType.Pet { //不可捕捉 result.Value["Msg"] = TipManager.GetMessage(ClientReturn.ZhuaPu1); return; } //增加的捕捉机率 double addP = 0; if (!string.IsNullOrEmpty(fighter.Action.Parameter)) { //扣除一个网.. const string clapnetID = "G_d000011"; if (BurdenManager.Remove(fighter.Player.B0, clapnetID)) { fighter.Player.UseClapnet++; addP = 0.5; } //else //{ // result.Value["Msg"] = "请使用捕兽网"; // return; //} } double lv = fighter.CP + bb.ClapP + addP; Variant mv = MemberAccess.MemberInfo(fighter.Player.MLevel); if (mv != null) { lv *=(1+ mv.GetDoubleOrDefault("ZhuaPuLv")); } if (Sinan.Extensions.NumberRandom.RandomHit(lv)) { //实行抓捕 if (!fighter.Player.AddGoodsNobingOne(petID, GoodsSource.Clap)) { //包袱已满 result.Value["Msg"] = TipManager.GetMessage(ClientReturn.ZhuaPu2); return; } result.Value["PetID"] = petID; //捕捉成功 result.Value["Msg"] = TipManager.GetMessage(ClientReturn.ZhuaPu3); bb.HP = 0; } else { //捕捉失败 result.Value["Msg"] = TipManager.GetMessage(ClientReturn.ZhuaPu4); return; } } }