private static ETalkLevel SwichHungerLevel(float attr, PeEntity entity) { Dictionary <ETalkLevel, Item> Items = GetHungerCase(); if (attr <= Items[ETalkLevel.Medium]._value * entity.GetAttribute(AttribType.HungerMax) && attr > Items[ETalkLevel.Low]._value * entity.GetAttribute(AttribType.HungerMax)) { return(ETalkLevel.Medium); } else if (attr <= Items[ETalkLevel.Low]._value * entity.GetAttribute(AttribType.HungerMax)) { return(ETalkLevel.Low); } return(ETalkLevel.Max); }
public List <PeEntity> GetEntitiesFriendly(Vector3 pos, float radius, int playerID, int protoID, bool isDeath, PeEntity exclude = null) { m_Tmp.Clear(); int n = m_Entities.Count; for (int i = 0; i < n; i++) { PeEntity entity = m_Entities[i]; if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath) { continue; } int pid1 = playerID; int pid2 = (int)entity.GetAttribute(AttribType.DefaultPlayerID); if (pid1 == pid2 && (pid1 != 4 || protoID == entity.ProtoID)) { if (PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius) { m_Tmp.Add(m_Entities[i]); } } } return(m_Tmp); }
public bool NearEntityModel(Vector3 pos, float radius, int playerID, bool isDeath, PeEntity exclude = null) { int n = m_Entities.Count; float sqrRadius = radius * radius; for (int i = 0; i < n; i++) { PeEntity entity = m_Entities[i]; if (entity == null || (entity.Equals(exclude)) || !entity.hasView || entity.IsDeath() != isDeath) { continue; } if (NpcRobotDb.Instance != null && entity.Id == NpcRobotDb.Instance.mID) { continue; } int pid = (int)entity.GetAttribute(AttribType.DefaultPlayerID); if (PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= sqrRadius && ForceSetting.Instance.AllyPlayer(playerID, pid)) { return(true); } } return(false); }
public List <PeEntity> GetEntities(Vector3 pos, float radius, int playerID, bool isDeath, PeEntity exclude = null) { m_Tmp.Clear(); int n = m_Entities.Count; for (int i = 0; i < n; i++) { PeEntity entity = m_Entities[i]; if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath) { continue; } int pid = (int)entity.GetAttribute(AttribType.DefaultPlayerID); if ((PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius && ForceSetting.Instance.AllyPlayer(playerID, pid)) || PETools.PEUtil.CanCordialReputation(playerID, pid) ) { m_Tmp.Add(m_Entities[i]); } } return(m_Tmp); }
/// <summary> /// 初始化驯服数据 /// </summary> private void InitTameData(PeEntity master) { if (!Entity) { return; } m_Move = Entity.motionMove as Motion_Move_Motor; m_Master = master; SetctrlType(ECtrlType.Free); if (!m_SkillData.canUse()) { m_SkillData.Reset(MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_L), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_Space), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_pounce) ); } m_PlayerForceDb = new ForceData((int)m_Master.GetAttribute(AttribType.CampID), (int)m_Master.GetAttribute(AttribType.DamageID), (int)m_Master.GetAttribute(AttribType.DefaultPlayerID)); if (m_MountsForceDb == null) { m_MountsForceDb = new ForceData((int)Entity.GetAttribute(AttribType.CampID), (int)Entity.GetAttribute(AttribType.DamageID), (int)Entity.GetAttribute(AttribType.DefaultPlayerID)); } }
public override bool SupplySth(PeEntity entity, CSAssembly asAssembly) { // check self float _curOwn = entity.GetAttribute(AttribType.Energy); if (_curOwn > Energy_Percent_min) { return(false); } //check package List <ItemObject> objs = entity.GetEquipObjs(EeqSelect.energy); if (objs != null && objs.Count > 0) { for (int i = 0; i < objs.Count; i++) { Energy energy = objs[i].GetCmpt <Energy>(); if (energy != null && energy.floatValue.percent > Energy_Percent_min) { return(false); } } } //find In csstorage return(NpcSupply.CsStrargeSupplyExchangeBattery(entity, asAssembly, objs, costId, Energy_num)); }
void OnDamage(SkEntity entity, float damage) { if (null == Entity.peSkEntity || null == entity) { return; } PeEntity peEntity = entity.GetComponent <PeEntity>(); if (peEntity == Entity) { return; } float tansDis = peEntity.IsBoss ? 128f : 64f; int playerID = (int)Entity.peSkEntity.GetAttribute((int)AttribType.DefaultPlayerID); bool canTrans = false; if (GameConfig.IsMultiClient) { if (ForceSetting.Instance.GetForceType(playerID) == EPlayerType.Human) { canTrans = true; } int tarPlayerId = (int)peEntity.GetAttribute(AttribType.DefaultPlayerID); if (ForceSetting.Instance.GetForceType(tarPlayerId) == EPlayerType.Human) { List <PeEntity> entities = EntityMgr.Instance.GetEntities(peEntity.position, tansDis, tarPlayerId, false, peEntity); for (int i = 0; i < entities.Count; i++) { if (!entities[i].Equals(Entity) && entities[i].target != null) { entities[i].target.TransferHatred(Entity, damage); } } } } else { if (ForceSetting.Instance.GetForceID(playerID) == 1) { canTrans = true; } } if (canTrans) { List <PeEntity> entities = EntityMgr.Instance.GetEntities(Entity.peTrans.position, tansDis, playerID, false, Entity); for (int i = 0; i < entities.Count; i++) { if (!entities[i].Equals(Entity) && entities[i].target != null) { entities[i].target.TransferHatred(peEntity, damage); } } } }
public static AttrPer WantByType(PeEntity entity, AttribType _type, AttribType _typeMax, float _eatMin, float _eatMax, bool _bContinue = false) { AttrPer attrper = null; float curPercent = 1.0f; int TypeID = (int)_type; //float eatLimt = _bContinue ? _eatMax : _eatMin; float p = entity.GetAttribute(_type); float pMax = entity.GetAttribute(_typeMax); curPercent = p / pMax; if (curPercent < _eatMax) { attrper = new AttrPer(TypeID, curPercent); } return(attrper); }
public static List <Item> GetPlyerTalkItems(PeEntity entity) { if (entity == null) { return(null); } List <Item> items = new List <Item>(); Item curItem; float Hp = entity.GetAttribute(AttribType.Hp); ETalkLevel HpLevel = SwichAtrrLevel(AttribType.Hp, Hp, entity); if (HpLevel != ETalkLevel.Max) { curItem = GetPlyerTalkItem(AttribType.Hp, HpLevel); curItem.Type = AttribType.Hp; curItem.Level = HpLevel; items.Add(curItem); } float Hunger = entity.GetAttribute(AttribType.Hunger); ETalkLevel Hungerlevel = SwichAtrrLevel(AttribType.Hunger, Hunger, entity); if (Hungerlevel != ETalkLevel.Max) { curItem = GetPlyerTalkItem(AttribType.Hunger, Hungerlevel); curItem.Type = AttribType.Hunger; curItem.Level = Hungerlevel; items.Add(curItem); } float Comfort = entity.GetAttribute(AttribType.Comfort); ETalkLevel Comfortevel = SwichAtrrLevel(AttribType.Comfort, Comfort, entity); if (Comfortevel != ETalkLevel.Max) { curItem = GetPlyerTalkItem(AttribType.Comfort, Comfortevel); curItem.Type = AttribType.Comfort; curItem.Level = Comfortevel; items.Add(curItem); } return(items); }
public void TryAddInTarget(PeEntity SelfEntity, PeEntity TargetEntity, float damage, bool trans = false) { if (TargetEntity == null) { return; } if (!trans && !ContainTarget(TargetEntity)) { AddTarget(TargetEntity); } float tansDis = TargetEntity.IsBoss || SelfEntity.proto == EEntityProto.Doodad ? 128f : 64f; int playerID = (int)SelfEntity.GetAttribute(AttribType.DefaultPlayerID); //(int)SeldEntity.GetAttribute((int)AttribType.DefaultPlayerID); bool canTrans = false; if (GameConfig.IsMultiClient) { //if (ForceSetting.Instance.GetForceType(playerID) == EPlayerType.Human) canTrans = true; } else { //if (ForceSetting.Instance.GetForceID(playerID) == 1) canTrans = true; } if (canTrans) { List <PeEntity> entities = null; if (playerID != 5 && playerID != 6) { entities = EntityMgr.Instance.GetEntities(SelfEntity.peTrans.position, tansDis, playerID, false, SelfEntity); } else { entities = EntityMgr.Instance.GetEntitiesFriendly(SelfEntity.peTrans.position, tansDis, playerID, SelfEntity.ProtoID, false, SelfEntity); } for (int i = 0; i < entities.Count; i++) { if (!entities[i].Equals(SelfEntity) && entities[i].target != null) { entities[i].target.TransferHatred(TargetEntity, damage); } } } }
public static Item GetTalkItemByType(PeEntity entity, AttribType _type, AttribType _typeMax) { Item curItem = null; float typevalue = entity.GetAttribute(_type); ETalkLevel typeLevel = SwichAtrrLevel(_type, typevalue, entity); if (typeLevel != ETalkLevel.Max) { curItem = GetTalkItem(_type, typeLevel); curItem.Type = _type; curItem.TypeMax = _typeMax; curItem.Level = typeLevel; } return(curItem); }
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); }
bool Match(PeEntity entity, Vector3 pos, float radius, int playerID, bool isDeath, PeEntity exclude = null) { if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath) { return(false); } int pid = (int)entity.GetAttribute(AttribType.DefaultPlayerID); if (ForceSetting.Instance.AllyPlayer(playerID, pid) && PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius) { return(true); } return(false); }
bool MatchFriendly(PeEntity entity, Vector3 pos, float radius, int playerID, int prototID, bool isDeath, PeEntity exclude = null) { if (entity == null || (entity.Equals(exclude)) || entity.IsDeath() != isDeath) { return(false); } int pid1 = playerID; int pid2 = (int)entity.GetAttribute(AttribType.DefaultPlayerID); if (pid1 == pid2 && (pid1 != 4 || prototID == entity.ProtoID)) { if (PETools.PEUtil.SqrMagnitudeH(entity.position, pos) <= radius * radius) { return(true); } } return(false); }
/// <summary> /// 初始化坐骑数据(被驯服后数据) /// </summary> private bool InitMountData() { if (!Entity) { return(false); } m_Move = Entity.motionMove as Motion_Move_Motor; m_Move.Stop(); SetctrlType(ECtrlType.Mount); Pathea.FastTravelMgr.Instance.OnFastTravel += OnFastTravel; m_PlayerForceDb = new ForceData((int)m_Master.GetAttribute(AttribType.CampID), (int)m_Master.GetAttribute(AttribType.DamageID), (int)m_Master.GetAttribute(AttribType.DefaultPlayerID)); if (m_MountsForceDb == null) { m_MountsForceDb = new ForceData((int)Entity.GetAttribute(AttribType.CampID), (int)Entity.GetAttribute(AttribType.DamageID), (int)Entity.GetAttribute(AttribType.DefaultPlayerID)); } if (!m_SkillData.canUse()) { m_SkillData.Reset(MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_L), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_Space), MountsSkillDb.GetRandomSkill(Entity.ProtoID, MountsSkillKey.Mskill_pounce) ); } StartMountsForceDb(); DispatchEvent(Entity); //lw:2017.3.13:读档后如果在晚上,怪物不能结束睡觉动作 if (Entity.animCmpt != null) { Entity.animCmpt.SetBool("Sleep", false); } m_Init = true; return(true); }