/// <summary> /// 实际战斗时取的数值 /// 技能为0和4时,取武器攻击 /// 1时,取手雷 /// 2时,取火炮 /// </summary> //public int GetPlayerAp() //{ // PlayerCsvData pCsv = (PlayerCsvData)m_caster.m_csvData; // int lv = m_caster.GetPropNum(eCreatureProp.Lv); // int maxAp = 0; // //int maxAp = m_caster.GetPlayerPropVal(pCsv.BaseAp, pCsv.ApGrow, lv); // //if (m_skillIndex == -1 || m_skillIndex == 0 || m_skillIndex == 4) // // maxAp += m_caster.GetEquipAp(eEquipType.HandRight); // //else if (m_skillIndex == 1) // // maxAp += m_caster.GetEquipAp(eEquipType.Grenade); // //else if (m_skillIndex == 2) // // maxAp += m_caster.GetEquipAp(eEquipType.Back); // maxAp += m_caster.GetBuffAp(maxAp); // return maxAp; //} /// <summary> /// 1.技能伤害数值,是通过普攻*val%计算得出的 /// 1.如果施法者是载具,其实还是用的主人的数值 /// 返回1:需要播放受击动作 /// </summary> public int OnHurt(int skillVal) { if (m_rec == null) { return(0); } if (m_rec.CheckState(eBuffState.God)) { return(0); } // 设置主角保护 //if (m_rec.IsMaster() && m_rec.bMasterProtect()) //{ // return 1; //} //if (m_rec.IsMaster()) //{ // m_rec.SetMasterProtect(); //} // 施法者是载具时,数值结算用主人的 //if (m_caster.GetMaster() != null) //{ // m_caster = m_caster.GetMaster(); //} // 触发施法者的攻击命中BUFF,触发受击者的受击BUFF,在伤害之前 m_caster.OnCreateAtkBuff(m_skillIndex, m_rec); m_rec.OnCreateHitBuff(m_caster); bool bCrit = false; //伤害 = 攻击 * 攻击 /(攻击 + k * 防御)*(0.9 / 1.1) int k = 1; int ap = m_caster.GetPropNum(eCreatureProp.Ap); int dp = m_rec.GetPropNum(eCreatureProp.Dp); // 玩家普攻伤害 int hurtVal = (int)(new FixedPoint(ap * ap) / new FixedPoint((ap + k * dp))).value; // 技能伤害,倍数 hurtVal = (int)(new FixedPoint(hurtVal) * (FixedPoint.N_1 + new FixedPoint(skillVal) * new FixedPoint(0.01f))).value; // 计算暴击 int CritChance = m_caster.GetPropNum(eCreatureProp.CritChance); if (GameManager.Inst.GetRand(0, 100, 1) <= CritChance * 0.1f) { bCrit = true; int CritDamage = m_caster.GetPropNum(eCreatureProp.CritDamage); hurtVal = (int)(new FixedPoint(hurtVal) * (FixedPoint.N_1 + new FixedPoint(CritDamage * 0.001f))).value; } // 连击累加 int comboNum = m_caster.GetComboNum(); if (comboNum > 300) { comboNum = 300; } hurtVal = (int)(new FixedPoint(hurtVal) * (new FixedPoint(comboNum) * new FixedPoint(0.01f) + FixedPoint.N_1)).value; int curHp = m_rec.GetPropNum(eCreatureProp.CurHp); int nextHp = curHp - hurtVal; if (nextHp <= 0) { nextHp = 0; } m_rec.SetPropNum(eCreatureProp.CurHp, nextHp); // 充能 UpdateChargeSkill(m_caster, hurtVal); // 解除受击者睡眠BUFF UpdateBuff(m_rec); // 主角相关 // 经验计算 GetExp(m_rec); // 主角连击 //if (m_caster != null && m_caster.IsMaster()) //{ // m_caster.OnComboAdd(); //} UpdateUI_ShowHpHUD(m_rec, -hurtVal, bCrit); return(1); }
public static BuffBase AddBuff(CCreature caster, CCreature receiver, int buffId, Vector2d startPos, Vector2d skillPos, Vector2d dir, int skillIndex = 0, object obj = null) { // 接受者无敌时 if (receiver != null) { if (receiver.IsDie() || receiver.CheckState(eBuffState.WindBlowsUp)) { return(null); } if (caster != receiver && receiver.CheckState(eBuffState.God)) { return(null); } } // 非瞬间伤害的其他所有BUFF,如果是持续的,并且buffid相同时,重置生命时间 SkillBuffCsvData buffData = CsvManager.Inst.GetCsv <SkillBuffCsv>((int)eAllCSV.eAC_SkillBuff).GetData(buffId); if (buffData == null) { Debug.LogError("无buffid,策划检测检查配置表:" + buffId); return(null); } // 状态BUFF的处理 // 接受者霸体时,不再添加其他状态BUFF if (receiver != null && receiver.CheckState(eBuffState.SuperArmor)) { if (buffData.logicId == (int)eBuffType.state || buffData.logicId == (int)eBuffType.repel || buffData.logicId == (int)eBuffType.pullPos ) { return(null); } } // 相同BUFF的叠加处理 if (buffData.IsCont && receiver != null && buffData.logicId != (int)eBuffType.damage) { BuffBase stateBuff = receiver.GetBuffByCsvId(buffId); // 1.相同BUFFID // 2.相同施法者 // 3.相同施法者,相同触发器(暂无) if (stateBuff != null && stateBuff.m_caster == caster) { //Debug.Log("有相同buff。。。" + buffId); // 相同施法者的持续性BUFF,内部可以计算叠加次数和伤害 stateBuff.ResetTime(); return(stateBuff); } } BuffBase buff = CBuffMgr.Create(buffId); //Debug.Log("技能流程:创建BUFF:" + buffId + " " + buff.m_buffData.name + " 类型:" + (eBuffType)buff.m_buffData.logicId); if (buff == null) { Debug.LogError("添加BUFF为空:" + buffId); return(null); } // 最终的接收者,由配表决定 if (buff.m_buffData.targetType == 0) { } else if (buff.m_buffData.targetType == 1) { receiver = caster; } buff.m_caster = caster; buff.m_rec = receiver; buff.m_startPos = startPos; buff.m_skillIndex = skillIndex; buff.m_skillPos = skillPos; buff.m_skillDir = dir; buff.m_extendParam = obj; // 持续性的才加到人物身上,当角色挂掉时,要清除身上的BUFF if (buff.IsCont() && receiver != null) { // 因为BUFF改变的速度,攻击力等都是在初始化时,遍历BUFF增减数值,所以要先add receiver.AddBuff(buff); buff.Init(); } else { buff.Init(); buff.Destroy(); } return(buff); }