public override void OnTickIdle(ObjNPC npc, float delta) { if (!npc.CanMove()) { return; } if (npc.IsMoving()) { return; } if (mPtIdx < 0 || mPtIdx >= ListDestination.Count) { npc.Disapeare(); return; } if (mTime > DateTime.Now) { return; } if (MoveResult.AlreadyThere == npc.MoveTo(ListDestination[mPtIdx])) { mPtIdx++; mTime = DateTime.Now.AddSeconds(WaitTime); } }
public override void OnTickGoHome(ObjNPC npc, float delta) { if (!npc.IsMoving()) { npc.EnterState(BehaviorState.Idle); } }
//战斗 public override void OnEnterCombat(ObjNPC npc) { //先停止移动 if (npc.IsMoving()) { npc.StopMove(); } //保存下进入战斗时的位置,距离这个位置太远了就要回家 //mBackPosition = npc.GetPosition(); var enemyTarget = GetEnemyCharacter(npc); //获得目标 //npc.Scene.FindCharacter(npc.LastEnemyId); if (null != enemyTarget) { npc.TurnFaceTo(enemyTarget.GetPosition()); LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; } SkillSort(npc); npc.SetSkill(1000); ////保存普攻数据 //if (-1 != npc.NormalSkillId) //{ // mTableNormalSkill = Table.GetSkill(npc.NormalSkillId); // //计算普攻技能距离 // mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableNormalSkill.TargetType, mTableNormalSkill.TargetParam); // //上来先来个cd,要不攻击者一攻击怪一瞬间怪就反击 // npc.SetSkill(1000); // //int milliseconds = mTableNormalSkill.Cd <= 0 ? 3000 : mTableNormalSkill.Cd; // //mNextNormalAttackTime = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); //} ////保存普攻数据 //if (-1 != npc.TableAI.CommonSkill) //{ // mTableNormalSkill = Table.GetSkill(npc.TableAI.CommonSkill); // //计算普攻技能距离 // mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableNormalSkill.TargetType, mTableNormalSkill.TargetParam); // //上来先来个cd,要不攻击者一攻击怪一瞬间怪就反击 // int milliseconds = mTableNormalSkill.Cd <= 0 ? 3000 : mTableNormalSkill.Cd; // mNextNormalAttackTime = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); //} //CombatTime = 0; //for (int i = 0; i != 4; ++i) //{ // if (npc.TableAI.SpecialSkill[i] == -1) continue; // PushSkillCd(npc, npc.TableAI.SpecialSkill[i], npc.TableAI.InitCd[i]); //} }
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 OnTickGoHome(ObjNPC npc, float delta) { if (!npc.IsMoving()) { if ((npc.BornPosition - npc.GetPosition()).LengthSquared() < 1.5f) { npc.EnterState(BehaviorState.Idle); } else { npc.MoveTo(npc.BornPosition); } } }
public override void OnTickIdle(ObjNPC npc, float delta) { if (!npc.CanMove()) { return; } if (npc.IsMoving()) { return; } if (mStayTime > DateTime.Now) { return; } if (ListDestination.Count <= 0) { return; } if (MoveResult.AlreadyThere == npc.MoveTo(ListDestination[mPtIdx])) { if (mForward) { mPtIdx++; if (mPtIdx >= ListDestination.Count) { mForward = false; mPtIdx = ListDestination.Count - 2; } } else { mPtIdx--; if (mPtIdx < 0) { mForward = true; mPtIdx = 1; } } mStayTime = DateTime.Now.AddSeconds(WaitTime); } }
//战斗 public override void OnEnterCombat(ObjNPC npc) { var retinue = npc as ObjRetinue; if (retinue == null) { return; } if (retinue.Owner == null) { return; } //先停止移动 if (npc.IsMoving()) { npc.StopMove(); } mTableNormalSkill = Table.GetSkill(npc.TableAI.CommonSkill); //保存下进入战斗时的位置,距离这个位置太远了就要回家 //mBackPosition = npc.GetPosition(); var enemyTarget = retinue.Owner.Skill.EnemyTarget; //获得目标 //npc.Scene.FindCharacter(npc.LastEnemyId); if (null != enemyTarget) { npc.TurnFaceTo(enemyTarget.GetPosition()); LastTargetId = enemyTarget.ObjId; } //保存普攻数据 if (-1 != npc.NormalSkillId) { //mTableNormalSkill = Table.GetSkill(npc.NormalSkillId); //计算普攻技能距离 //mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableNormalSkill.TargetType, mTableNormalSkill.TargetParam); //上来先来个cd,要不攻击者一攻击怪一瞬间怪就反击 npc.SetSkill(1000); //int milliseconds = mTableNormalSkill.Cd <= 0 ? 3000 : mTableNormalSkill.Cd; //mNextNormalAttackTime = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); } }
public override void OnTickIdle(ObjNPC npc, float delta) { if (npc.IsAggressive()) { if (npc.TableNpc.ViewDistance > 0) { var target = ScanEnemy(npc, (float)npc.TableNpc.ViewDistance); if (target != null) { npc.EnterState(BehaviorState.Combat); npc.PushHatre(target, 1); npc.AddEnemy(target.ObjId); target.AddEnemy(npc.ObjId); return; } } } if (!npc.CanMove()) { return; } if (npc.IsMoving()) { return; } if (mPtIdx < 0 || mPtIdx >= ListDestination.Count) { //npc.Disapeare(); return; } if (mTime > DateTime.Now) { return; } if (MoveResult.AlreadyThere == npc.MoveTo(ListDestination[mPtIdx])) { mPtIdx++; mTime = DateTime.Now.AddSeconds(WaitTime); } }
//战斗 public override void OnEnterCombat(ObjNPC npc) { ChangeAi(npc, npc.TableNpc.mAI); //先停止移动 if (npc.IsMoving()) { npc.StopMove(); } //保存下进入战斗时的位置,距离这个位置太远了就要回家 mBackPosition = npc.GetPosition(); //获得目标 var enemy = npc.Scene.FindCharacter(npc.LastEnemyId); if (null != enemy) { npc.TurnFaceTo(enemy.GetPosition()); } //保存普攻数据 if (-1 != npc.TableAI.CommonSkill) { mTableNormalSkill = Table.GetSkill(npc.TableAI.CommonSkill); //计算普攻技能距离 mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableNormalSkill.TargetType, mTableNormalSkill.TargetParam); //上来先来个cd,要不攻击者一攻击怪一瞬间怪就反击 var milliseconds = mTableNormalSkill.Cd <= 0 ? 3000 : mTableNormalSkill.Cd; mNextNormalAttackTime = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); } CombatTime = 0; for (var i = 0; i != 4; ++i) { if (npc.TableAI.SpecialSkill[i] == -1) { continue; } PushSkillCd(npc, npc.TableAI.SpecialSkill[i], npc.TableAI.InitCd[i]); } }
public override void OnTickGoHome(ObjNPC npc, float delta) { if (!npc.IsMoving()) { if ((npc.BornPosition - npc.GetPosition()).LengthSquared() < 1.5f) { npc.EnterState(BehaviorState.Idle); } else { npc.MoveTo(npc.BornPosition, 1); } } if (DateTime.Now > TimeToReset) { npc.SetPosition(npc.BornPosition); npc.EnterState(BehaviorState.Idle); TimeToReset = TimeToReset.AddYears(100); } }
public override void OnTickGoHome(ObjNPC npc, float delta) { var retinue = npc as ObjRetinue; if (retinue == null) { return; } if (retinue.Owner == null) { return; } if (!npc.IsMoving()) { if ((npc.BornPosition - npc.GetPosition()).LengthSquared() < 1.5f) { npc.EnterState(BehaviorState.Idle); } else { npc.MoveTo(retinue.Owner.GetPosition(), 1); } } }
//战斗 public override void OnEnterCombat(ObjNPC npc) { //先停止移动 if (npc.IsMoving()) { npc.StopMove(); } //保存下进入战斗时的位置,距离这个位置太远了就要回家 //mBackPosition = npc.GetPosition(); var enemyTarget = GetEnemyCharacter(npc); //获得目标 if (null != enemyTarget) { npc.TurnFaceTo(enemyTarget.GetPosition()); LastTargetId = enemyTarget.ObjId; SelectLastTarger = true; } SkillSort(npc); npc.SetSkill(1000); }
//战斗 public override void OnEnterCombat(ObjNPC npc) { //先停止移动 if (npc.IsMoving()) { npc.StopMove(); } //保存下进入战斗时的位置,距离这个位置太远了就要回家 mBackPosition = npc.GetPosition(); //获得目标 var enemy = npc.Scene.FindCharacter(npc.LastEnemyId); if (null != enemy) { npc.TurnFaceTo(enemy.GetPosition()); } npc.BroadcastDirection(); //保存普攻数据 if (-1 != npc.NormalSkillId) { mTableNormalSkill = Table.GetSkill(npc.NormalSkillId); //计算普攻技能距离 mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableNormalSkill.TargetType, mTableNormalSkill.TargetParam); //上来先来个cd,要不攻击者一攻击怪一瞬间怪就反击 GenNextNormalAttackTime(); } mNoMoveTime = 0; }
public override void OnTickCombat(ObjNPC npc, float delta) { ObjCharacter enemy = null; //判断敌人是否存在 if (npc.TableAI == null) { enemy = npc.GetMaxHatre(); } else { 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; } //如果有普通 if (null != mTableNormalSkill) { //跟着敌人打 if ((npc.GetPosition() - enemy.GetPosition()).Length() <= mSkillDistance) { npc.TurnFaceTo(enemy.GetPosition()); if (npc.IsMoving()) { GenNextNormalAttackTime(100); npc.StopMove(); } if (DateTime.Now >= mNextNormalAttackTime) { npc.Seperate(enemy, mSkillDistance / 3); var skillId = npc.NormalSkillId; npc.UseSkill(ref skillId, enemy); GenNextNormalAttackTime(); mNoMoveTime = 0; //攻击了一次就把自己站在原地的累计时间清空 } } else { var targetPos = npc.CalculatePostionToEnemy(enemy, mSkillDistance / 3); if (MoveResult.CannotReach == npc.MoveTo(targetPos)) { //如果长时间无法到达目的地说明卡怪了, 就回去 mNoMoveTime += delta; if (mNoMoveTime >= MAX_NO_MOVE_TIME) { npc.EnterState(BehaviorState.GoHome); } } else { mNoMoveTime = 0; } } } }
public override void OnTickCombat(ObjNPC npc, float delta) { var retinue = npc as ObjRetinue; if (retinue == null) { return; } if (retinue.Owner == null || retinue.Owner.Scene == null) { retinue.Scene.LeaveScene(retinue); return; } var myPos = retinue.GetPosition(); var ownerPos = retinue.Owner.GetPosition(); if (mNextNormalAttackTime > DateTime.Now) { return; } var distance = (myPos - ownerPos).LengthSquared(); //if (distance > 400) //{ // var diff = GetRandomPostion(); // diff += ownerPos; // npc.SetCheckPostion(diff); // //retinue.MoveTo(ownerPos, 2); // npc.EnterState(BehaviorState.GoHome); // return; //} if (distance > 64) { retinue.MoveTo(ownerPos, 2); return; //var p = myPos + Vector2.Normalize(ownerPos - myPos) * 2; //retinue.MoveTo(p); } var tag = retinue.Owner.Scene.GetObstacleValue(ownerPos.X, ownerPos.Y); if (tag == SceneObstacle.ObstacleValue.Walkable) //自身在安全区禁止攻击 { return; } var enemyTarget = GetEnemyCharacter(retinue); if (enemyTarget == null) { npc.EnterState(BehaviorState.GoHome); return; } if (enemyTarget.GetObjType() == ObjType.PLAYER) { tag = enemyTarget.Scene.GetObstacleValue(ownerPos.X, ownerPos.Y); if (tag == SceneObstacle.ObstacleValue.Walkable) //对方在安全区禁止攻击 { return; } } LastTargetId = enemyTarget.ObjId; var WillskillId = GetCanDoSkill(npc); //npc.NormalSkillId; var mTableWillskill = Table.GetSkill(WillskillId); if (mTableWillskill == null) { return; } mSkillDistance = SkillManager.GetSkillDistance((SkillTargetType)mTableWillskill.TargetType, mTableWillskill.TargetParam); //跟着敌人打 if ((npc.GetPosition() - enemyTarget.GetPosition()).Length() > mSkillDistance) { npc.MoveTo(enemyTarget.GetPosition(), mSkillDistance - 0.3f); } else { if (npc.IsMoving()) { npc.StopMove(); } if (npc.UseSkill(ref WillskillId, enemyTarget) == ErrorCodes.OK) { //int cd = mTableNormalSkill.Cd; //if (cd < mTableNormalSkill.CommonCd) //{ // cd = mTableNormalSkill.CommonCd; //} //int milliseconds = cd <= 0 ? DEFAULT_NORMAL_ATTACK_INTERVAL_MILLISECONDS : cd; //mNextNormalAttackTime = DateTime.Now + TimeSpan.FromMilliseconds(milliseconds); 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) { 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); } } } }