//刷新守城方的buff private void RefreshDefenderBuff(int buffId, bool isAdd) { var players = Camps[DefenderCampId].Players; if (isAdd) { foreach (var player in players) { player.AddBuff(buffId, 1, player); } } else { foreach (var player in players) { var buffs = player.BuffList.GetBuffById(buffId); if (buffs.Count > 0) { var buff = buffs[0]; var layer = buff.GetLayer(); if (layer > 1) { buff.SetLayer(layer - 1); var replyMsg = new BuffResultMsg(); var buffResult = new BuffResult { SkillObjId = buff.mCasterId, TargetObjId = player.ObjId, BuffTypeId = buffId, BuffId = buff.mId, Type = BuffType.HT_EFFECT, ViewTime = Extension.AddTimeDiffToNet(0) }; if (buff.mBuff.IsView == 1) { buffResult.Param.Add(buff.GetLastSeconds()); buffResult.Param.Add(buff.GetLayer()); buffResult.Param.Add(buff.m_nLevel); } replyMsg.buff.Add(buffResult); player.BroadcastBuffList(replyMsg); GetBuff.DoEffect(this, player, buff, 0); } else { MissBuff.DoEffect(this, player, buff); player.DeleteBuff(buff, eCleanBuffType.Clear); } } else { Logger.Error("In RefreshDefenderBuff(). DeleteBuff error! buffs.Count == 0! player name = {0}", player.GetName()); } } } }
//广播地面火球效果 private void PosGuideBefore(ObjCharacter caster, ObjPlayer target, Vector2 pos, int d) { //var mTable = Table.GetSkill(5150); if (target == null) { return; } var buffId = 1060; var replyMsg = new BuffResultMsg(); var temp = new BuffResult { Type = BuffType.HT_EFFECT, BuffTypeId = buffId, ViewTime = Extension.AddTimeDiffToNet(d) }; temp.Param.Add(5150); temp.TargetObjId = target.ObjId; temp.Param.Add((int)(pos.X * 100)); temp.Param.Add((int)(pos.Y * 100)); temp.Param.Add((int)(caster.GetDirection().X *1000)); temp.Param.Add((int)(caster.GetDirection().Y *1000)); temp.Param.Add(1500); //mTable.CastParam[1] replyMsg.buff.Add(temp); target.BroadcastBuffList(replyMsg); SceneServerControl.Timer.CreateTrigger(DateTime.Now.AddMilliseconds(1400 + d), () => { FireCast(pos); }); if (MyRandom.Random(10000) < 5000) { DropItem(2, MyRandom.Random(MinGold, MaxGold), pos); var max = pos2.Count; if (IsInspired(target)) { max = Math.Max(GoldNumInspireMax, 0); } else { max = Math.Max(GoldNumMax, 0); } // 修改掉落的堆数 走配置 跟是否鼓舞有关系 oldList = pos2.RandRange(0, max); for (int i = 0; i < oldList.Count; ++i) { DropItem(2, MyRandom.Random(MinGold, MaxGold), oldList[i]); } } }
public void PushBuffMsg(Zone _this, BuffResultMsg temp) { if (_this.buffList.buff.Count < 1) { _this.buffList = temp; } else { foreach (var i in temp.buff) { _this.buffList.buff.Add(i); } } if (_this.BuffTrigger == null) { _this.BuffTrigger = SceneServerControl.Timer.CreateTrigger(DateTime.Now.AddMilliseconds(ObjCharacter.BroadcastCd), () => { BuffSend(_this); }); } }
//Buff效果广播 public void BroadcastBuffList(ObjCharacter _this, BuffResultMsg msg) { if (!_this.mActive) { return; } if (null == _this.Zone) { return; } if (msg.buff.Count <= 0) { return; } if (ObjCharacter.BroadcastType == 1) { _this.Zone.PushBuffMsg(msg); return; } SceneServer.Instance.ServerControl.SyncBuff(_this.EnumAllVisiblePlayerIdExclude(), msg); }
public void SyncBuff(BuffResultMsg msg) { { var __list4 = msg.buff; var __listCount4 = __list4.Count; for (var __i4 = 0; __i4 < __listCount4; ++__i4) { var buff = __list4[__i4]; { var time = Extension.FromServerBinary((long)buff.ViewTime); if (time > Game.Instance.ServerTime) { var span = time - Game.Instance.ServerTime; StartCoroutine(WaitAddBuff(span, buff)); } else { AddBuff(buff); } } } } }
/// <summary> /// 死亡时 /// </summary> /// <param name="_this"></param> /// <param name="characterId"></param> /// <param name="delayView"></param> /// <param name="damage"></param> public void OnDie(AutoPlayer _this, ulong characterId, int delayView, int damage = 0) { var replyMsg = new BuffResultMsg(); replyMsg.buff.Add(new BuffResult { TargetObjId = _this.ObjId, Type = BuffType.HT_DIE, ViewTime = Extension.AddTimeDiffToNet(delayView) }); _this.BroadcastBuffList(replyMsg); _this.Skill.StopCurrentSkill(); _this.RemoveMeFromOtherEnemyList(); _this.ClearEnemy(); //Drop.MonsterKill(this, characterId); try { _this.Scene.OnNpcDie(_this, characterId); } catch (Exception e) { Logger.Error(e); } _this.EnterState(BehaviorState.Die); //mTrigger = SceneServerControl.Timer.CreateTrigger(DateTime.Now.AddMilliseconds(TableNpc.CorpseTime), Disapeare); try { _this.Script.OnDie(_this, characterId, delayView, damage); } catch (Exception e) { Logger.Error(e); } }
public void PushBuffMsg(BuffResultMsg temp) { mImpl.PushBuffMsg(this, temp); }
//Buff效果广播 public virtual void BroadcastBuffList(BuffResultMsg msg) { mImpl.BroadcastBuffList(this, msg); }
//Buff所在场景,承受者,Buff实例,触发点,特定参数(伤害值,治疗值),另一个个Obj参数(释放者,击杀者等等不一定) public void DoBuff(Scene scene, ObjCharacter obj, BuffData buff, int delayView, eEffectEventType eventType, int Param = 0, ObjCharacter otherObj = null, int checkParam = 0) { if (null == buff) { return; } if (!buff.GetActive()) { return; //没有激活的Buff不生效 } if (!buff.IsCoolDown()) { return; } //该BUFF产生的伤害统计 var thisbuffdamage = new Dictionary <int, int>(); //该BuFF产生的治疗统计 var thisbuffhealth = new Dictionary <int, int>(); //该BuFF产生的回蓝统计 var thisbuffmana = new Dictionary <int, int>(); var tb_buff = buff.mBuff; for (var j = 0; j != tb_buff.effectid.Length; ++j) { if (!CheckEffectOk(buff, obj, eventType, j, checkParam)) { continue; } //执行BUFF效果需要 switch ((eEffectType)tb_buff.effectid[j]) { case eEffectType.DoDamage: { BuffEffect.DO_DAMAGE(thisbuffdamage, scene, obj, buff, j, CheckEventResetHitType(eventType)); } break; case eEffectType.DoHealth: { BuffEffect.DO_HEALTH(thisbuffhealth, scene, obj, buff, j, CheckEventResetHitType(eventType)); } break; case eEffectType.RefAttr: BuffEffect.REF_ATTR(scene, obj, buff, j); break; case eEffectType.PositionChange: BuffEffect.POSITION_CHANGE(scene, obj, buff, j); break; case eEffectType.ProAddBuff: BuffEffect.PRO_ADD_BUFF(scene, obj, buff, j); break; case eEffectType.DamageHealth: { if (Param > 0) { BuffEffect.DAMAGE_HEALTH(scene, obj, Param, buff, j); } } break; case eEffectType.DispelBuff: { BuffEffect.DispelBuff(eventType, scene, obj, buff, j); } break; case eEffectType.SpecialState: { BuffEffect.SPEIALSTATE(eventType, scene, obj, buff, j); } break; case eEffectType.CreateMonsterType1: { BuffEffect.CREATER_MONSTER1TYPE(scene, obj, buff, j); } break; case eEffectType.ModifySkill: { BuffEffect.NO_MODIFYSKILL(eventType, scene, obj, buff, j); } break; case eEffectType.ModifyBuff: { BuffEffect.NO_MODIFYBUFF(eventType, scene, obj, buff, j); } break; case eEffectType.ModifyModel: { BuffEffect.NO_MODIFYMODEL(eventType, obj, buff); } break; case eEffectType.CreateMonster: { BuffEffect.CREATER_MONSTER(eventType, scene, obj, buff, j); } break; case eEffectType.ExpModify: { BuffEffect.EXP_MODIFY(eventType, scene, obj, buff, j); } break; case eEffectType.ExpModify2: { BuffEffect.EXP_MODIFY2(eventType, scene, obj, buff, j); } break; case eEffectType.DoMana: { BuffEffect.DO_MANA(thisbuffmana, scene, obj, buff, j, CheckEventResetHitType(eventType)); } break; case eEffectType.KillSelf: { BuffEffect.Kill_SELF(scene, obj, buff, j); } break; case eEffectType.DoSkill: { BuffEffect.DoSkill(scene, obj, otherObj, buff, j); } break; case eEffectType.HpInRangeTriggerBuff: { BuffEffect.HP_TRIGGER_ADDBUFF(scene, obj, buff, j); } break; case eEffectType.AddExp: { BuffEffect.EXP_ADD(eventType, scene, obj, buff, j); break; } } buff.AddCoolDownTime(); } CalcAttrDamage(thisbuffdamage, buff); if (thisbuffdamage.Count > 0 || thisbuffhealth.Count > 0 || thisbuffmana.Count > 0) { var caster = buff.GetCaster(); if (caster != null) { var replyMsg = new BuffResultMsg(); //发送伤害 foreach (var thisdamage in thisbuffdamage) { var damagevalue = thisdamage.Value; var absorbDamage = 0; obj.DoDamage(eHitType.Hit, buff, caster, delayView, ref damagevalue, thisdamage.Key, ref absorbDamage); //if (absorbDamage > 0) //{ // 吸收 // replyMsg.buff.Add(new BuffResult // { // SkillObjId = caster.ObjId, // TargetObjId = obj.ObjId, // BuffTypeId = buff.GetBuffId(), // Type = BuffType.HT_NODAMAGE, // Damage = damagevalue, // ViewTime = Extension.AddTimeDiffToNet(delayView) // }); //} if (damagevalue > 0) { if (thisdamage.Key == (int)eDamageType.FireAttr) { var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_Fire_DAMAGE, delayView); replyMsg.buff.Add(result); continue; } else if (thisdamage.Key == (int)eDamageType.IceAttr) { var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_Ice_DAMAGE, delayView); replyMsg.buff.Add(result); continue; } else if (thisdamage.Key == (int)eDamageType.PoisonAttr) { var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_Poison_DAMAGE, delayView); replyMsg.buff.Add(result); continue; } CauseCrit.DoEffect(scene, caster, buff, damagevalue); WasCrit.DoEffect(scene, obj, buff, damagevalue); //Logger.Info("伤害类型:{0},伤害值:{1}", thisdamage.Key, damagevalue); if (buff.m_HitType == eHitType.Hit) { var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_NORMAL, delayView); replyMsg.buff.Add(result); } else if (buff.m_HitType == eHitType.Lucky) { var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_CRITICAL, delayView); replyMsg.buff.Add(result); } else if (buff.m_HitType == eHitType.Excellent) { var result = NetBuffResult(scene, buff, thisdamage.Key, damagevalue, BuffType.HT_EXCELLENT, delayView); replyMsg.buff.Add(result); } //击中回复生效 var HitRecoveryValue = caster.GetAttribute(eAttributeType.HitRecovery); if (HitRecoveryValue > 0) { var healthvalue = HitRecoveryValue; caster.DoHealth(eHitType.Hit, buff, caster, ref healthvalue, 8); //Logger.Info("治疗类型:{0},治疗值:{1}",8, healthvalue); var nowHp = caster.GetAttribute(eAttributeType.HpNow); if (scene != null && scene.isNeedDamageModify) { if (Scene.IsNeedChangeHp(caster) != null) { nowHp = (int)(nowHp / scene.BeDamageModify); } } replyMsg.buff.Add(new BuffResult { SkillObjId = caster.ObjId, TargetObjId = caster.ObjId, BuffTypeId = buff.GetBuffId(), Type = BuffType.HT_HEALTH, Damage = healthvalue, ViewTime = Extension.AddTimeDiffToNet(delayView), Param = { 0, nowHp } }); } //本Buff的吸血效果(给释放方的) for (var j = 0; j != tb_buff.effectid.Length; ++j) { if (tb_buff.effectid[j] == 18 && tb_buff.effectparam[j, 1] == 0) //有吸血效果,并且是释放者 { BuffEffect.DAMAGE_HEALTH(scene, obj, damagevalue, buff, j, thisbuffhealth); } } //伤害反弹 if (thisdamage.Key != (int)eDamageType.Rebound && thisdamage.Key != (int)eDamageType.Blood) { var DamageReboundValue = obj.GetAttribute(eAttributeType.DamageReboundPro); if (DamageReboundValue > 0) { var damageReboundValue = damagevalue * DamageReboundValue / 10000; if (damageReboundValue > 0) { //caster.DoHealth(eHitType.Hit, buff, caster, ref healthvalue, 8); caster.DoRealDamage(eHitType.Hit, buff, obj, delayView, ref damageReboundValue, (int)eDamageType.Rebound); //Logger.Info("伤害类型:{0},伤害值:{1}", eDamageType.Rebound, damageReboundValue); var nowHp = caster.GetAttribute(eAttributeType.HpNow); if (scene != null && scene.isNeedDamageModify) { if (Scene.IsNeedChangeHp(caster) != null) { nowHp = (int)(nowHp / scene.BeDamageModify); } } replyMsg.buff.Add(new BuffResult { SkillObjId = obj.ObjId, TargetObjId = caster.ObjId, BuffTypeId = buff.GetBuffId(), Type = BuffType.HT_REBOUND, Damage = damageReboundValue, ViewTime = Extension.AddTimeDiffToNet(delayView), Param = { 0, nowHp } }); } } } } else if (absorbDamage <= 0) { //免疫 replyMsg.buff.Add(new BuffResult { SkillObjId = caster.ObjId, TargetObjId = obj.ObjId, BuffTypeId = buff.GetBuffId(), Type = BuffType.HT_NODAMAGE, Damage = damagevalue, ViewTime = Extension.AddTimeDiffToNet(delayView) }); } } //发送治疗 foreach (var thishealth in thisbuffhealth) { if (obj.GetAttribute(eAttributeType.HpNow) == obj.GetAttribute(eAttributeType.HpMax)) { continue; } var healthvalue = thishealth.Value; obj.DoHealth(eHitType.Hit, buff, caster, ref healthvalue, thishealth.Key); //Logger.Info("治疗类型:{0},治疗值:{1}", thishealth.Key, healthvalue); var nowHp = obj.GetAttribute(eAttributeType.HpNow); if (scene != null && scene.isNeedDamageModify) { if (Scene.IsNeedChangeHp(obj) != null) { nowHp = (int)(nowHp / scene.BeDamageModify); } } replyMsg.buff.Add(new BuffResult { SkillObjId = caster.ObjId, TargetObjId = obj.ObjId, BuffTypeId = buff.GetBuffId(), Type = BuffType.HT_HEALTH, Damage = healthvalue, ViewTime = Extension.AddTimeDiffToNet(delayView), Param = { 0, nowHp } }); } //发送回蓝 foreach (var thishealth in thisbuffmana) { var healthvalue = thishealth.Value; obj.DoMana(eHitType.Hit, buff, caster, ref healthvalue, thishealth.Key); //Logger.Info("回蓝类型:{0},回蓝值:{1}", thishealth.Key, healthvalue); replyMsg.buff.Add(new BuffResult { SkillObjId = caster.ObjId, TargetObjId = obj.ObjId, BuffTypeId = buff.GetBuffId(), Type = BuffType.HT_MANA, Damage = healthvalue, ViewTime = Extension.AddTimeDiffToNet(delayView) }); } obj.BroadcastBuffList(replyMsg); } } }