//能否遭受技能的攻击 public bool canSufferSkillDamage() { bool shouldSuffer = true; BT_BuffOrDebuff immunityBuff = getBuffOrDebuff(CMsgHeader.BUFF_DEBUFF_IMMUNITY); if (immunityBuff != null && immunityBuff.round > 0) { shouldSuffer = false; } if (!shouldSuffer) { CMsgSkillBuffDebuffEffect msg = new CMsgSkillBuffDebuffEffect(this, immunityBuff); _war.addMsgToRecorder(msg); } return(shouldSuffer); }
//能否释放技能 -- 根据Debuff的状态来决定 public bool canCastSkillAcc2BuffOrDebuff(BT_Skill sk, int skType) { bool canCast = true; if (skType == SkillOpData.Common_Skill) { BT_BuffOrDebuff sealDebuff = getBuffOrDebuff(CMsgHeader.BUFF_DEBUFF_SEAL, false); if (sealDebuff != null && _lastLun == 0) { canCast = false; CMsgSkillBuffDebuffEffect msg = new CMsgSkillBuffDebuffEffect(this, sealDebuff); msg.arg1 = sk.id; _war.addMsgToRecorder(msg); } } return(canCast); }
//返回实现伤害值 public int sufferAttack(BT_Hurt damage, BT_Monster enemy) { int finalDamage = MathHelper.MidpointRounding(damage.damageVal); //技能来的攻击 if ((damage.hurtType == BT_Hurt_Type.HURT_SKILL || damage.hurtType == BT_Hurt_Type.HURT_ANGRY_SKILL) && canSufferSkillDamage() == false) { finalDamage = 0; } #region 各种buff or defbuff处理... //伤害全部防御技能 short bufDebuffType = CMsgHeader.BUFF_DEBUFF_GOLDDEFENSE; BT_BuffOrDebuff goldShieldBuf = getBuffOrDebuff(bufDebuffType); if (goldShieldBuf != null && --goldShieldBuf.round >= 0) { finalDamage = 0; CMsgSkillBuffDebuffEffect msg = new CMsgSkillBuffDebuffEffect(this, goldShieldBuf); _war.addMsgToRecorder(msg); _buffArr[bufDebuffType] = goldShieldBuf; } //伤害加深 bufDebuffType = CMsgHeader.BUFF_DEBUFF_HURTUP; BT_BuffOrDebuff hurtUpDebuff = getBuffOrDebuff(bufDebuffType, false); if (hurtUpDebuff != null && --hurtUpDebuff.round >= 0) { int rDamage = MathHelper.MidpointRounding(damage.damageVal * (1 + hurtUpDebuff.rate * Consts.oneHundred)); CMsgSkillBuffDebuffEffect msg = new CMsgSkillBuffDebuffEffect(this, hurtUpDebuff); msg.arg1 = MathHelper.MidpointRounding(damage.damageVal); msg.arg2 = rDamage; _war.addMsgToRecorder(msg); _debuffArr[bufDebuffType] = hurtUpDebuff; finalDamage = rDamage; } //反弹部分伤害到敌人... bufDebuffType = CMsgHeader.BUFF_DEBUFF_REBOUND; BT_BuffOrDebuff reboundBuff = getBuffOrDebuff(bufDebuffType); if (reboundBuff != null && --reboundBuff.round >= 0 && enemy.alive) { float rebound = damage.damageVal * reboundBuff.rate * Consts.oneHundred; damage.damageVal -= rebound; enemy.sufferNormalAttack(MathHelper.MidpointRounding(rebound), this, true); _buffArr[bufDebuffType] = reboundBuff; finalDamage = MathHelper.MidpointRounding(damage.damageVal); } //护盾技能... bufDebuffType = CMsgHeader.BUFF_DEBUFF_DEFENSE; BT_BuffOrDebuff shieldBuff = getBuffOrDebuff(bufDebuffType); if (shieldBuff != null && shieldBuff.suckDmg > 0) { int beforeShield = shieldBuff.suckDmg; if (beforeShield > damage.damageVal) { shieldBuff.suckDmg -= MathHelper.MidpointRounding(damage.damageVal); finalDamage = 0; } else { damage.damageVal -= beforeShield; shieldBuff.suckDmg = 0; finalDamage = MathHelper.MidpointRounding(damage.damageVal); } CMsgSkillBuffDebuffEffect msg = new CMsgSkillBuffDebuffEffect(this, shieldBuff); msg.arg1 = beforeShield; msg.arg2 = shieldBuff.suckDmg; _war.addMsgToRecorder(msg); _buffArr[bufDebuffType] = shieldBuff; } #endregion setCurAtt(_curAtt - finalDamage); return(finalDamage); }