public void RunAttrAgent(PeEntity peEntity) { //npc self List <NpcRandomTalkDb.Item> Items = NpcRandomTalkDb.GetTalkItems(peEntity); for (int i = 0; i < Items.Count; i++) { if (Items[i] == null || Items[i].Type == AttribType.Max || Items[i].Level == ETalkLevel.Max) { continue; } if (!NpcEatDb.CanEatByAttr(peEntity, Items[i].Type, Items[i].TypeMax, false)) { AddAgentInfo(new AgentInfo(Items[i].TalkType, ENpcSpeakType.TopHead, true)); } } //ask for Player // PeEntity palyer = null; // //int playerID = (int)peEntity.GetAttribute (AttribType.DefaultPlayerID); // if (GameConfig.IsMultiClient) // { // //get main palyer peEntity // } // else // { // if (PeCreature.Instance != null) // { // palyer = PeCreature.Instance.mainPlayer; // } // } // if(palyer != null) // { // Items = NpcRandomTalkDb.GetPlyerTalkItems(palyer); // for (int i = 0; i < Items.Count; i++) // { // if (Items[i] == null || Items[i].Type == AttribType.Max || Items[i].Level == ETalkLevel.Max) // continue; // // AddAgentInfo(new AgentInfo(Items[i].TalkType,ENpcSpeakType.TopHead,true)); // } // } // // NpcRandomTalkDb.Item item = NpcRandomTalkDb.Get(ENpcTalkType.Day_to_day); // AddAgentInfo(new AgentInfo(item.TalkType,ENpcSpeakType.TopHead,true)); RunAgent(); }
public static bool NpcMissionReady(PeEntity npc) { if (npc == null) { return(false); } if (npc.NpcCmpt == null) { return(false); } CSCreator mCScreator = npc.NpcCmpt.Creater; if (mCScreator == null) { mCScreator = CSMain.GetCreator(CSConst.ciDefMgCamp); } if (mCScreator == null || mCScreator.Assembly == null) { return(false); } ItemAsset.ItemObject item; if (npc.UseItem != null && NpcEatDb.CanEatSthFromStorages(npc, mCScreator.Assembly.Storages, out item)) { npc.UseItem.Use(item); } for (int i = 0; i < RecruitBuff.Length; i++) { npc.skEntity.CancelBuffById(RecruitBuff[i]); } for (int i = 0; i < InFeildBuff.Length; i++) { SkillSystem.SkEntity.MountBuff(npc.skEntity, InFeildBuff[i], new List <int>(), new List <float>()); } return(true); }
public static AttrPer WantByType(PeEntity entity, AttribType _type, AttribType _typeMax, bool _bContinue = false) { AttrPer attrper = null; float curPercent = 1.0f; int TypeID = (int)_type; Items items = NpcEatDb.GetIitems(TypeID); if (items == null) { return(null); } //float eatLimt = _bContinue ? items.mEatMax : items.mEatMin; float Hp = entity.GetAttribute(_type); float HpMax = entity.GetAttribute(_typeMax); curPercent = Hp / HpMax; if (curPercent < items.mEatMax) { attrper = new AttrPer(TypeID, curPercent); } return(attrper); }