internal void SummonPartner(Msg_CR_SummonPartner msg) { UserInfo userInfo = UserManager.GetUserInfo(msg.obj_id); if (null != userInfo) { // summonpartner PartnerInfo partnerInfo = userInfo.GetPartnerInfo(); if (null != partnerInfo && (TimeUtility.GetServerMilliseconds() - userInfo.LastSummonPartnerTime > partnerInfo.CoolDown || userInfo.LastSummonPartnerTime == 0)) { Data_Unit data = new Data_Unit(); data.m_Id = -1; data.m_LinkId = partnerInfo.LinkId; data.m_CampId = userInfo.GetCampId(); data.m_Pos = userInfo.GetMovementStateInfo().GetPosition3D(); data.m_RotAngle = 0; data.m_AiLogic = partnerInfo.GetAiLogic(); data.m_AiParam[0] = ""; data.m_AiParam[1] = ""; data.m_AiParam[2] = partnerInfo.GetAiParam().ToString(); data.m_IsEnable = true; NpcInfo npc = NpcManager.AddNpc(data); if (null != npc) { AppendAttributeConfig aac = AppendAttributeConfigProvider.Instance.GetDataById(partnerInfo.GetAppendAttrConfigId()); float inheritAttackAttrPercent = partnerInfo.GetInheritAttackAttrPercent(); float inheritDefenceAttrPercent = partnerInfo.GetInheritDefenceAttrPercent(); if (null != aac) { // attack npc.GetBaseProperty().SetAttackBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().AttackBase *inheritAttackAttrPercent)); npc.GetBaseProperty().SetFireDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().FireDamage *inheritAttackAttrPercent); npc.GetBaseProperty().SetIceDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().IceDamage *inheritAttackAttrPercent); npc.GetBaseProperty().SetPoisonDamage(Operate_Type.OT_Absolute, userInfo.GetActualProperty().PoisonDamage *inheritAttackAttrPercent); // defence npc.GetBaseProperty().SetHpMax(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().HpMax *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetEnergyMax(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().EnergyMax *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetADefenceBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().ADefenceBase *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetMDefenceBase(Operate_Type.OT_Absolute, (int)(userInfo.GetActualProperty().MDefenceBase *inheritDefenceAttrPercent)); npc.GetBaseProperty().SetFireERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().FireERD *inheritDefenceAttrPercent); npc.GetBaseProperty().SetIceERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().IceERD *inheritDefenceAttrPercent); npc.GetBaseProperty().SetPoisonERD(Operate_Type.OT_Absolute, userInfo.GetActualProperty().PoisonERD *inheritDefenceAttrPercent); // reset hp & energy npc.SetHp(Operate_Type.OT_Absolute, npc.GetBaseProperty().HpMax); npc.SetEnergy(Operate_Type.OT_Absolute, npc.GetBaseProperty().EnergyMax); } npc.SetAIEnable(true); npc.GetSkillStateInfo().RemoveAllSkill(); npc.BornTime = TimeUtility.GetServerMilliseconds(); List <int> skillList = partnerInfo.GetSkillList(); if (null != skillList) { for (int i = 0; i < skillList.Count; ++i) { SkillInfo skillInfo = new SkillInfo(skillList[i]); npc.GetSkillStateInfo().AddSkill(skillInfo); } } userInfo.LastSummonPartnerTime = TimeUtility.GetServerMilliseconds(); npc.OwnerId = userInfo.GetId(); userInfo.PartnerId = npc.GetId(); if (partnerInfo.BornSkill > 0) { SkillInfo skillInfo = new SkillInfo(partnerInfo.BornSkill); npc.GetSkillStateInfo().AddSkill(skillInfo); } ArkCrossEngineMessage.Msg_RC_CreateNpc builder = DataSyncUtility.BuildCreateNpcMessage(npc); NotifyAllUser(builder); } } } }
private void TickNpcs() { List <NpcInfo> deletes = new List <NpcInfo>(); List <NpcInfo> deletes2 = new List <NpcInfo>(); Msg_RC_NpcDead npcDeadBuilder = new Msg_RC_NpcDead(); for (LinkedListNode <NpcInfo> linkNode = NpcManager.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next) { NpcInfo info = linkNode.Value; if (info.LevelChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged || info.GetLegacyStateInfo().LegacyChanged) { NpcAttrCalculator.Calc(info); info.LevelChanged = false; info.GetSkillStateInfo().BuffChanged = false; info.GetEquipmentStateInfo().EquipmentChanged = false; info.GetLegacyStateInfo().LegacyChanged = false; } // 伙伴自动掉血 if ((int)NpcTypeEnum.Partner == info.NpcType) { UserInfo owner = UserManager.GetUserInfo(info.OwnerId); if (null != owner) { PartnerInfo pi = owner.GetPartnerInfo(); if (null != pi && TimeUtility.GetServerMilliseconds() - pi.LastTickTime > pi.TickInterval) { info.SetHp(Operate_Type.OT_Relative, (int)pi.GetHpCostPerTick(info.GetActualProperty().HpMax)); pi.LastTickTime = TimeUtility.GetServerMilliseconds(); } } } if (info.NeedDelete) { deletes2.Add(info); } else if (info.IsDead()) { if (info.DeadTime <= 0) { info.DeadTime = TimeUtility.GetServerMilliseconds(); //击杀收益计算 CalcKillIncome(info); //解除控制 ReleaseControl(info); //发送npc死亡消息 npcDeadBuilder.npc_id = info.GetId(); NotifyAllUser(npcDeadBuilder); if (info.IsCombatNpc()) { m_StorySystem.SendMessage("objkilled", info.GetId(), GetBattleNpcCount()); m_StorySystem.SendMessage(string.Format("npckilled:{0}", info.GetUnitId()), info.GetId(), GetBattleNpcCount()); if (info.GetUnitId() > 0) { if (m_IsAttemptScene) { if ((int)NpcTypeEnum.BigBoss == info.NpcType) { TryFireAllNpcKilled(); } } else { TryFireAllNpcKilled(); } } } } else if (TimeUtility.GetServerMilliseconds() - info.DeadTime > info.ReleaseTime && info.GfxDead) { deletes.Add(info); } } if (info.IsBorning && IsNpcBornOver(info)) { info.IsBorning = false; info.SetAIEnable(true); info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible); } CheckNpcOwnerId(info); } if (deletes.Count > 0) { Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc(); foreach (NpcInfo ni in deletes) { //发送npc消失消息 destroyNpcBuilder.npc_id = ni.GetId(); destroyNpcBuilder.need_play_effect = true; NotifyAllUser(destroyNpcBuilder); //删除npc NpcManager.RemoveNpc(ni.GetId()); LogSystem.Debug("Npc {0} name {1} is deleted.", ni.GetId(), ni.GetName()); } } if (deletes2.Count > 0) { Msg_RC_DestroyNpc destroyNpcBuilder = new Msg_RC_DestroyNpc(); foreach (NpcInfo ni in deletes2) { //发送npc消失消息 destroyNpcBuilder.npc_id = ni.GetId(); destroyNpcBuilder.need_play_effect = false; NotifyAllUser(destroyNpcBuilder); //删除npc NpcManager.RemoveNpc(ni.GetId()); LogSystem.Debug("Npc {0} name {1} is deleted.", ni.GetId(), ni.GetName()); } } NpcManager.ExecuteDelayAdd(); }