private bool TryCastSkill(UserInfo user, CharacterInfo target, float powDis) { float dis = (float)Math.Sqrt(powDis); int category = GetCanCastSkillId(user, dis); if (-1 != category) { if (user.GetSkillStateInfo().IsSkillActivated()) { SkillInfo curSkill = user.GetSkillStateInfo().GetCurSkillInfo(); if (null != curSkill) { if (TimeUtility.GetLocalMilliseconds() - curSkill.StartTime > curSkill.ConfigData.LockInputTime) { user.SkillController.PushSkill((SkillCategory)category, target.GetMovementStateInfo().GetPosition3D()); } } } else { user.SkillController.PushSkill((SkillCategory)category, target.GetMovementStateInfo().GetPosition3D()); } return(true); } return(false); }
public override int RefixHpDamage(CharacterInfo obj, int impactId, int hpDamage, int senderId, ref bool isCritical, int impactOwnerId) { if (obj == null) { return(hpDamage); } if (impactOwnerId != senderId) { return(hpDamage); } UserInfo sender = obj.SceneContext.GetCharacterInfoById(senderId) as UserInfo; if (sender == null) { return(hpDamage); } CombatStatisticInfo combat_info = sender.GetCombatStatisticInfo(); if (combat_info == null) { return(hpDamage); } ImpactInfo impactinfo = sender.GetSkillStateInfo().GetImpactInfoById(impactId); if (impactinfo == null || impactinfo.ConfigData.ExtraParams.Count < 1) { return(hpDamage); } int triggerCount = 0; string effect = ""; string mountPoint = ""; try { if (impactinfo.ConfigData.ExtraParams.Count > 4) { triggerCount = int.Parse(impactinfo.ConfigData.ExtraParams[0]); effect = impactinfo.ConfigData.ExtraParams[2]; mountPoint = impactinfo.ConfigData.ExtraParams[3]; if (combat_info.MultiHitCount != 0 && combat_info.MultiHitCount % triggerCount == 0) { AppendDamage(sender, obj, impactinfo, hpDamage); AppendImpact(sender, obj, impactinfo); } if (!String.IsNullOrEmpty(effect) && !String.IsNullOrEmpty(mountPoint)) { EventImpactLogicEffect(obj, effect, mountPoint, 2.0f); } } } catch (Exception ex) { LogSystem.Error("parse append damage param error:\n" + ex.Message + "\n" + ex.StackTrace); } return(hpDamage); }
public override int RefixHpDamage(CharacterInfo obj, int impactId, int hpDamage, int senderId, ref bool isCritical, int impactOwnerId) { if (obj == null) { return(hpDamage); } if (senderId != impactOwnerId) { return(hpDamage); } UserInfo sender = obj.SceneContext.GetCharacterInfoById(senderId) as UserInfo; if (sender == null) { return(hpDamage); } CombatStatisticInfo combat_info = sender.GetCombatStatisticInfo(); if (combat_info == null) { return(hpDamage); } ImpactInfo impactinfo = sender.GetSkillStateInfo().GetImpactInfoById(impactId); if (impactinfo == null || impactinfo.ConfigData.ExtraParams.Count < 1) { return(hpDamage); } int criticalCount = 0; try { criticalCount = int.Parse(impactinfo.ConfigData.ExtraParams[0]); if (combat_info.MultiHitCount != 0 && combat_info.MultiHitCount % criticalCount == 0) { if (!isCritical) { hpDamage = (int)(hpDamage * sender.GetActualProperty().CriticalPow); isCritical = true; } } } catch (Exception ex) { LogSystem.Error("parse HitCriticalTrigger param error:\n" + ex.Message); } return(hpDamage); }
public override int RefixHpDamage(CharacterInfo obj, int impactId, int hpDamage, int senderId, ref bool isCritical, int impactOnwerId) { //LogSystem.Debug("---in hit recover"); if (obj == null) { return(hpDamage); } if (senderId != impactOnwerId) { return(hpDamage); } UserInfo sender = obj.SceneContext.GetCharacterInfoById(senderId) as UserInfo; if (sender == null) { return(hpDamage); } CombatStatisticInfo combat_info = sender.GetCombatStatisticInfo(); if (combat_info == null) { return(hpDamage); } ImpactInfo impactinfo = sender.GetSkillStateInfo().GetImpactInfoById(impactId); if (impactinfo == null || impactinfo.ConfigData.ExtraParams.Count < 1) { return(hpDamage); } int triggerCount = 0; try { triggerCount = int.Parse(impactinfo.ConfigData.ExtraParams[0]); if (combat_info.MultiHitCount != 0 && combat_info.MultiHitCount % triggerCount == 0) { Recover(sender, impactinfo, combat_info.MultiHitCount, combat_info.LastHitTime); } } catch (Exception ex) { LogSystem.Error("parse HitRcover count param error:\n" + ex.Message); } return(hpDamage); }
private void DebugLog(int key_code, int what) { UserInfo playerself = WorldSystem.Instance.GetPlayerSelf(); if (null == playerself) { return; } /// if ((int)Keyboard.Event.Up == what) { List <SkillInfo> skill_info = playerself.GetSkillStateInfo().GetAllSkill(); if (null != skill_info) { foreach (SkillInfo value in skill_info) { LogSystem.Debug("skill id : {0}, skill level : {1}, skill pos : {2}", value.SkillId, value.SkillLevel, (SlotPosition)value.Postions.Presets[0]); } } CharacterProperty info = playerself.GetActualProperty(); if (null != info) { LogSystem.Debug("PlayerInfo ||| HpMax : {0}, MpMax : {1}, Ad : {2}, ADp : {3}, Mdp : {4}, CriRate : {5}, CriDamage : {6}, bHitDR : {7}, cHitDR : {8}, fireDam : {9}, iceDam : {10}, poisonDam : {11}, fireERD : {12}, iceERD : {13}, poisonERD : {14}, ||| Level : {15}, Money : {16}, Gold : {17}, Stamina : {18}, AttrScore : {19}, CurExp : {20}", info.HpMax, info.EnergyMax, info.AttackBase, info.ADefenceBase, info.MDefenceBase, info.Critical, info.CriticalPow, info.CriticalBackHitPow, info.CriticalCrackPow, info.FireDamage, info.IceDamage, info.PoisonDamage, info.FireERD, info.IceERD, info.PoisonERD, playerself.GetLevel(), LobbyClient.Instance.CurrentRole.Money, LobbyClient.Instance.CurrentRole.Gold, LobbyClient.Instance.CurrentRole.CurStamina, playerself.FightingScore, LobbyClient.Instance.CurrentRole.Exp); LogSystem.Debug("PlayerInfo ||| MpMax : {0}, Mp : {1}", info.EnergyMax, playerself.Energy); } CharacterInfo partner = WorldSystem.Instance.GetCharacterById(playerself.PartnerId); if (null != partner) { CharacterProperty partnerInfo = partner.GetActualProperty(); if (null != partnerInfo) { LogSystem.Debug("PartnerpartnerInfo ||| HpMax : {0}, MpMax : {1}, Ad : {2}, ADp : {3}, Mdp : {4}, CriRate : {5}, CriDamage : {6}, bHitDR : {7}, cHitDR : {8}, fireDam : {9}, iceDam : {10}, poisonDam : {11}, fireERD : {12}, iceERD : {13}, poisonERD : {14}", partnerInfo.HpMax, partnerInfo.EnergyMax, partnerInfo.AttackBase, partnerInfo.ADefenceBase, partnerInfo.MDefenceBase, partnerInfo.Critical, partnerInfo.CriticalPow, partnerInfo.CriticalBackHitPow, partnerInfo.CriticalCrackPow, partnerInfo.FireDamage, partnerInfo.IceDamage, partnerInfo.PoisonDamage, partnerInfo.FireERD, partnerInfo.IceERD, partnerInfo.PoisonERD); } } } }
private int GetCanCastSkillId(UserInfo user, float dis) { if (null == user) { return(-1); } List <int> skillsCanCast = new List <int>(); int start = (int)SkillCategory.kAttack; int end = (int)SkillCategory.kSkillD; for (int i = start; i <= end; i++) { SkillNode node = user.SkillController.GetHead((SkillCategory)i); if (null != node) { SkillInfo skillInfo = user.GetSkillStateInfo().GetSkillInfoById(node.SkillId); if (null != skillInfo) { if (skillInfo.ConfigData.SkillRangeMax >= dis && skillInfo.ConfigData.SkillRangeMin <= dis) { if (!skillInfo.IsInCd(TimeUtility.GetServerMilliseconds())) { skillsCanCast.Add(i); } } } } } int count = skillsCanCast.Count; if (count > 0) { return(skillsCanCast[CrossEngineHelper.Random.Next(count)]); } return(-1); }
private UserInfo CreateArenaTarget(ArenaTargetInfo target) { if (target == null) { return(null); } int image_res_id = target.HeroId; UserInfo image_player = m_UserMgr.AddUser(image_res_id); if (null != image_player) { image_player.SceneContext = m_SceneContext; int campid = NetworkSystem.Instance.CampId == (int)CampIdEnum.Blue ? (int)CampIdEnum.Red : (int)CampIdEnum.Blue; image_player.SetCampId(campid); Data_Unit unit = m_CurScene.StaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(campid)) as Data_Unit; if (null != unit) { image_player.GetAiStateInfo().AiLogic = unit.m_AiLogic; image_player.SetAIEnable(true); image_player.GetMovementStateInfo().SetPosition(unit.m_Pos); image_player.GetMovementStateInfo().SetFaceDir(unit.m_RotAngle); } image_player.SetLevel(target.Level); image_player.SetNickName(target.Nickname); image_player.SkillController = new SwordManSkillController(image_player, GfxModule.Skill.GfxSkillSystem.Instance); if (null != m_SpatialSystem) { m_SpatialSystem.AddObj(image_player.SpaceObject); } /// skills if (null != target.Skills) { image_player.GetSkillStateInfo().RemoveAllSkill(); int skill_ct = target.Skills.Count; for (int i = 0; i < skill_ct; i++) { SkillInfo info = target.Skills[i]; if (null != info) { SkillCategory cur_skill_pos = SkillCategory.kNone; if (info.Postions.Presets[0] == SlotPosition.SP_A) { cur_skill_pos = SkillCategory.kSkillA; } else if (info.Postions.Presets[0] == SlotPosition.SP_B) { cur_skill_pos = SkillCategory.kSkillB; } else if (info.Postions.Presets[0] == SlotPosition.SP_C) { cur_skill_pos = SkillCategory.kSkillC; } else if (info.Postions.Presets[0] == SlotPosition.SP_D) { cur_skill_pos = SkillCategory.kSkillD; } info.Category = cur_skill_pos; image_player.GetSkillStateInfo().AddSkill(info); WorldSystem.Instance.AddSubSkill(image_player, info.SkillId, cur_skill_pos, info.SkillLevel); } } } Data_PlayerConfig playerData = PlayerConfigProvider.Instance.GetPlayerConfigById(image_player.GetLinkId()); if (null != playerData && null != playerData.m_FixedSkillList && playerData.m_FixedSkillList.Count > 0) { foreach (int skill_id in playerData.m_FixedSkillList) { SkillInfo info = new SkillInfo(skill_id, 1); image_player.GetSkillStateInfo().AddSkill(info); } } image_player.ResetSkill(); /// equips if (null != target.Equips) { int equip_ct = target.Equips.Length; for (int i = 0; i < equip_ct; i++) { ItemDataInfo image_equip = target.Equips[i]; if (null != image_equip) { image_player.GetEquipmentStateInfo().ResetEquipmentData(i); image_equip.ItemConfig = ItemConfigProvider.Instance.GetDataById(image_equip.ItemId); if (null != image_equip.ItemConfig) { image_player.GetEquipmentStateInfo().SetEquipmentData(i, image_equip); } } } } /// if (null != target.Legacys) { int legacy_ct = target.Legacys.Length; for (int i = 0; i < legacy_ct; i++) { ItemDataInfo image_legacy = target.Legacys[i]; if (null != image_legacy && image_legacy.IsUnlock) { image_player.GetLegacyStateInfo().ResetLegacyData(i); image_legacy.ItemConfig = ItemConfigProvider.Instance.GetDataById(image_legacy.ItemId); if (null != image_legacy.ItemConfig) { image_player.GetLegacyStateInfo().SetLegacyData(i, image_legacy); } } } image_player.GetLegacyStateInfo().UpdateLegacyComplexAttr(); } foreach (ArenaXSoulInfo x in target.XSoulInfo) { ItemDataInfo item = new ItemDataInfo(); item.ItemId = x.ItemId; item.Level = x.Level; item.Experience = x.Experience; item.UpdateLevelByExperience(); ItemConfig config = ItemConfigProvider.Instance.GetDataById(item.ItemId); if (config == null) { continue; } item.ItemConfig = config; XSoulPartInfo part = new XSoulPartInfo((XSoulPart)config.m_WearParts, item); part.ShowModelLevel = x.ModelLevel; image_player.GetXSoulInfo().SetXSoulPartData((XSoulPart)config.m_WearParts, part); } image_player.SetPartnerInfo(target.ActivePartner); SetArenaCharacterCoefficient(image_player); UserAttrCalculator.Calc(image_player); image_player.SetHp(Operate_Type.OT_Absolute, image_player.GetActualProperty().HpMax); image_player.SetRage(Operate_Type.OT_Absolute, 0); image_player.SetEnergy(Operate_Type.OT_Absolute, image_player.GetActualProperty().EnergyMax); target.CreatedPartners.Clear(); int total_hp = image_player.GetActualProperty().HpMax; //LogSystem.Error("---challenge target hp=" + image_player.GetActualProperty().HpMax); foreach (PartnerInfo partner in target.FightPartners) { NpcInfo partner_npc = CreateParterner(image_player, partner); if (partner_npc != null) { target.CreatedPartners.Add(partner.Id, partner_npc); //LogSystem.Error("---parnter {0} hp={1}", partner.Id, partner_npc.GetBaseProperty().HpMax); total_hp += partner_npc.GetBaseProperty().HpMax; } } //LogSystem.Error("-----challenge target total hp=" + total_hp); EntityManager.Instance.CreateUserView(image_player.GetId()); UserView image_view = EntityManager.Instance.GetUserViewById(image_player.GetId()); image_view.UpdateEquipment(); image_view.UpdateXSoulEquip(); } SyncGfxUserInfo(image_player.GetId()); return(image_player); }
private void PursuitHandler(UserInfo user, AiCommandDispatcher aiCmdDispatcher, long deltaTime) { if (user.IsDead()) { user.GetMovementStateInfo().IsMoving = false; return; } if (user.IsUnderControl()) { user.GetMovementStateInfo().IsMoving = false; return; } if (user.GetSkillStateInfo().IsSkillActivated()) { user.GetMovementStateInfo().IsMoving = false; return; } UserAiStateInfo info = user.GetAiStateInfo(); AiData_UserSelf_General data = GetAiData(user); if (null != data) { CharacterInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(user, info.Target); if (null != target) { float dist = (float)user.GetActualProperty().AttackRange; float distGoHome = (float)user.GohomeRange; Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D(); Vector3 srcPos = user.GetMovementStateInfo().GetPosition3D(); float powDist = Geometry.DistanceSquare(srcPos, targetPos); float powDistToHome = Geometry.DistanceSquare(srcPos, info.HomePos); TryCastSkill(user, target, powDist); // 大于攻击距离 跑向目标 if (powDist > m_AttackRange * m_AttackRange) { info.Time += deltaTime; if (info.Time > m_IntervalTime) { info.Time = 0; if (!user.UnityPathFinding) { AiLogicUtility.PathToTargetWithoutObstacle(user, data.FoundPath, targetPos, m_IntervalTime, true, this); } else { if (info.PreviousState != (int)AiStateId.PathFinding) { user.PathFindingFinished = false; GfxSystem.UserSelfGeneralPathToTarget(user, targetPos); ChangeToState(user, (int)AiStateId.PathFinding); } else { AiLogicUtility.PathToTargetWithoutObstacle(user, data.FoundPath, targetPos, m_IntervalTime, true, this); } } } } else { user.GetMovementStateInfo().IsMoving = false; NotifyUserMove(user); } } else { user.GetMovementStateInfo().IsMoving = false; NotifyUserMove(user); info.Time = 0; ChangeToState(user, (int)AiStateId.Idle); } } }