public override void OnTickIdle(ObjNPC npc, float delta) { if (npc.Scene == null) { return; } if (npc.IsDead()) { return; } 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); } } } }
public override void OnTickIdle(ObjNPC npc, float delta) { if (npc.Scene == null) { return; } if (npc.IsDead()) { return; } if (npc.IsAggressive()) { if (npc.TableNpc.ViewDistance > 0) { var target = npc.ScanEnemy((float)npc.TableNpc.ViewDistance); if (target != null) { npc.EnterState(BehaviorState.Combat); npc.PushHatre(target, 1); npc.AddEnemy(target.ObjId); target.AddEnemy(npc.ObjId); // 搜索仇恨组 if (npc.tbSceneNpc != null && npc.tbSceneNpc.ChouHenGroupId != -1) { TryToCallPartner(npc, target, 2000); } } } } }
private void FindNpcEnemy(ObjNPC npc, float dist = 10) { try { if (npc != null) { float distSqr = dist * dist; foreach (ObjBase o in npc.Zone.EnumAllVisibleObj()) { try { if (!(o is ObjNPC)) { continue; } var obj = o as ObjNPC; if (!obj.Active) { continue; } if (obj.GetObjType() != ObjType.NPC) { continue; } if (!obj.IsVisibleTo(npc)) { continue; } if (obj.mCamp == npc.mCamp) { continue; } if ((obj.GetPosition() - npc.GetPosition()).LengthSquared() > distSqr) { continue; } npc.EnterState(BehaviorState.Combat); npc.PushHatre(obj, 1); npc.AddEnemy(obj.ObjId); obj.AddEnemy(npc.ObjId); } catch { } } } } catch { } }
public override void OnTickIdle(ObjNPC npc, float delta) { var target = npc.ScanEnemy(50); if (target != null) { npc.EnterState(BehaviorState.Combat); npc.PushHatre(target, 1); npc.AddEnemy(target.ObjId); target.AddEnemy(npc.ObjId); } }
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); } }