public override void OnTickCombat(ObjNPC npc, float delta) { if (!npc.CanSkill()) { return; } //判断敌人是否存在 var enemy = GetCanAttack(npc); if (null == enemy) { npc.EnterState(BehaviorState.GoHome); return; } var WillskillId = npc.NormalSkillId; //GetCanDoSkill(npc);//npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { var diffDis = mSkillDistance - 1.0f; if (diffDis < 0) { diffDis = 0; } npc.MoveTo(enemy.GetPosition(), diffDis); } else { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); //if (reCodes == ErrorCodes.OK) //{ // PushSkillCd(npc, WillskillId); //} } } }
public override void OnTickCombat(ObjNPC npc, float delta) { var enemyTarget = GetEnemyCharacter(npc); if (enemyTarget == null) { npc.EnterState(BehaviorState.Idle); return; } if (!npc.CanMove()) { return; } NextSkill = FindFreeSkill(npc, enemyTarget); if (NextSkill == -1) { return; } var tbSkill = Table.GetSkill(NextSkill); if (tbSkill == null) { return; } if ((SkillTargetType)tbSkill.TargetType == SkillTargetType.SELF || (eCampType)tbSkill.CampType == eCampType.Team) { if (npc.IsMoving()) { npc.StopMove(); } if (npc.CanSkill()) { LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; npc.TurnFaceTo(enemyTarget.GetPosition()); npc.UseSkill(ref NextSkill, npc); } return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)tbSkill.TargetType, tbSkill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemyTarget.GetPosition()).Length() > mSkillDistance) { npc.MoveTo(enemyTarget.GetPosition(), mSkillDistance - 0.1f); } else { if (npc.IsMoving()) { npc.StopMove(); } if (npc.CanSkill()) { LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; npc.TurnFaceTo(enemyTarget.GetPosition()); npc.UseSkill(ref NextSkill, enemyTarget); } } }
public override void OnTickCombat(ObjNPC npc, float delta) { CombatTime += 500; if (!npc.CanSkill()) { return; } //判断是否需要状态转换 var nextAi = CheckStateChange(npc); ChangeAi(npc, nextAi); //判断敌人是否存在 var enemy = GetAttackTarget(npc); if (null == enemy || enemy.IsDead() || !enemy.Active) { npc.EnterState(BehaviorState.Idle); npc.SetDirection(npc.BornDirection); npc.BroadcastDirection(); npc.RemoveMeFromOtherEnemyList(); npc.ClearEnemy(); return; } var WillskillId = GetCanDoSkill(npc); //npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } switch ((SkillTargetType)mTableWillskill.TargetType) { case SkillTargetType.SELF: { if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, npc); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } return; } mTableWillskill = Table.GetSkill(npc.TableAI.CommonSkill); if (mTableWillskill == null) { return; } } break; case SkillTargetType.SINGLE: break; case SkillTargetType.CIRCLE: break; case SkillTargetType.SECTOR: break; case SkillTargetType.RECT: break; case SkillTargetType.TARGET_CIRCLE: break; case SkillTargetType.TARGET_RECT: break; case SkillTargetType.TARGET_SECTOR: break; default: break; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { npc.SetDirection(npc.BornDirection); npc.BroadcastDirection(); } else { npc.TurnFaceTo(enemy.GetPosition()); if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } } } }
public override void OnTickCombat(ObjNPC npc, float delta) { if (npc.TableAI.Id == MieShiBuildingAI) { if (!npc.CanSkill()) { return; } if (!npc.CanSkill()) { return; } //判断敌人是否存在 var enemy = GetCanAttack(npc); if (null == enemy) { npc.EnterState(BehaviorState.GoHome); return; } var WillskillId = npc.NormalSkillId; //GetCanDoSkill(npc);//npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { var diffDis = mSkillDistance - 1.0f; if (diffDis < 0) { diffDis = 0; } npc.MoveTo(enemy.GetPosition(), diffDis); } else { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); //if (reCodes == ErrorCodes.OK) //{ // PushSkillCd(npc, WillskillId); //} } } } else { PatrolTime += 500; //判断是否需要状态转换 if (!bAIChange) { var nextAi = CheckToStateChange(npc); if (nextAi > -1) { Logger.Warn("======================ChangeAi============================[179] {0}", npc.mTypeId); ChangeAi(npc, nextAi); bAIChange = true; return; } } base.OnTickCombat(npc, delta); } }
public override void OnTickCombat(ObjNPC npc, float delta) { CombatTime += 500; if (!npc.CanSkill()) { return; } //判断是否需要状态转换 var nextAi = CheckStateChange(npc); ChangeAi(npc, nextAi); //判断敌人是否存在 var enemy = GetAttackTarget(npc); if (null == enemy) { npc.EnterState(BehaviorState.GoHome); return; } //判断敌人是否有效 if (enemy.IsDead() || !enemy.Active) { npc.EnterState(BehaviorState.GoHome); return; } //判断是否太远了 var dis = (npc.GetPosition() - mBackPosition).Length(); if (npc.TableNpc.MaxCombatDistance > 0 && dis >= npc.TableNpc.MaxCombatDistance) { npc.EnterState(BehaviorState.GoHome); return; } var WillskillId = GetCanDoSkill(npc); //npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } switch ((SkillTargetType)mTableWillskill.TargetType) { case SkillTargetType.SELF: { if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, npc); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } return; } mTableWillskill = Table.GetSkill(npc.TableAI.CommonSkill); if (mTableWillskill == null) { return; } } break; case SkillTargetType.SINGLE: break; case SkillTargetType.CIRCLE: break; case SkillTargetType.SECTOR: break; case SkillTargetType.RECT: break; case SkillTargetType.TARGET_CIRCLE: break; case SkillTargetType.TARGET_RECT: break; case SkillTargetType.TARGET_SECTOR: break; default: break; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() > mSkillDistance) { var diffDis = mSkillDistance - 1.0f; if (diffDis < 0) { diffDis = 0; } npc.MoveTo(enemy.GetPosition(), diffDis); } else { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { var reCodes = npc.MustSkill(ref WillskillId, enemy); //npc.UseSkill(ref skillId, enemy); if (reCodes == ErrorCodes.OK) { PushSkillCd(npc, WillskillId); } } } }