
Here are my idea to stop mobs like fishes, follows players and pets on land!
I have this code today test and i think it work.

And sorry: I have atm not the time to crate patches
here is the code you need:
if done:
Not all mobs (like wurm) in water with the swimming flag are fishes, so we need the new fish flag for now!
Create an mob with aggro and range and toggle the fish flag to true by /mob fish set /mob swimming so your fish can be a fish^^
After all, the (fish) will no longer follows you and return to there spawanpoint if you are not in water!
#in GameNPC
- Code: Select all
#region Swimming npc follow stop /// <summary> /// Swimming npc walk to spawn if target is on ground /// </summary> /// <param name="SwimmingIsFollowLivingOnGround">NPC Walk to Spawn if true</param> /// <returns>true if target is not swimming and body is an fish Walk to Spawn</returns> public virtual bool SwimmingIsFollowLivingOnGround(GameNPC Body) { GamePlayer petOwner = null; GameLiving ownerPet = null; Body = this; if (Body.NPCIsFish == false) //only fishes will stop following return false; if (Body.IsAlive == false) return false; //Swimming npc don't follow player owner and there pets if (Body is GameNPC && Body.Brain is IControlledBrain == false && Body.TargetObject != null) { if (Body.TargetObject is GameNPC && (Body.TargetObject as GameNPC).Brain is IControlledBrain) { petOwner = ((Body.TargetObject as GameNPC).Brain as IControlledBrain).Owner as GamePlayer; ownerPet = Body.TargetObject as GameNPC; } //Single player if (Body.TargetObject is GamePlayer && ownerPet == null && !Body.IsReturningHome && ((GamePlayer)Body.TargetObject).IsSwimming == false) { return true; } //Pet owner if (Body.TargetObject == petOwner && petOwner is GamePlayer && ownerPet != null && petOwner != null && !Body.IsReturningHome && petOwner.IsSwimming == false) { return true; } //The pet if (Body.TargetObject == ownerPet && ownerPet.IsWithinRadius(petOwner, 200) && petOwner is GamePlayer && ownerPet != null && petOwner != null && !Body.IsReturningHome && petOwner.IsSwimming == false) { // if (Body.Z >= Body.CurrentZone.Waterlevel) { return true; } } } return false; } #endregion
- Code: Select all
if (Body.IsOutOfTetherRange && !Body.InCombat) { blabla }
- Code: Select all
if (Body.SwimmingIsFollowLivingOnGround(Body)) { Body.StopAttack(); Body.WalkToSpawn(220); }
- Code: Select all
protected virtual void CheckNPCAggro() if (Body.AttackState) return; foreach (GameNPC npc in Body.GetNPCsInRadius((ushort)AggroRange)) { if (!GameServer.ServerRules.IsAllowedToAttack(Body, npc, true)) continue;
- Code: Select all
if (Body.SwimmingIsFollowLivingOnGround(Body)) return;
- Code: Select all
protected virtual void CheckPlayerAggro() { //Check if we are already attacking, return if yes if (Body.AttackState) return;
- Code: Select all
if (Body.SwimmingIsFollowLivingOnGround(Body)) return;
after:
- Code: Select all
"'/mob ownerid <id>' Sets and saves the OwnerID for this mob.",
- Code: Select all
"'/mob fish <true/false>' if the target npc is a fish ?.",
- Code: Select all
:case "trigger": trigger(client, targetMob, args); break;
- Code: Select all
case "fish": IsFish(client, targetMob, args); break;
- Code: Select all
:info.Add(" + Mob_ID: " + targetMob.InternalID);
- Code: Select all
info.Add(" + Mob is Fish: " + targetMob.NPCIsFish);
- Code: Select all
private void hood(GameClient client, GameNPC targetMob, string[] args)
insert this:
- Code: Select all
private void IsFish(GameClient client, GameNPC targetMob, string[] args) { targetMob.NPCIsFish ^= true; targetMob.UpdateNPCEquipmentAppearance(); targetMob.SaveIntoDatabase(); client.Out.SendMessage("Mob is fish flag is set to " + targetMob.NPCIsFish, eChatType.CT_System, eChatLoc.CL_SystemWindow); }
after:
- Code: Select all
private byte m_visibleWeaponSlots;
insert this:
- Code: Select all
private bool m_npcIsFish;
after this:
- Code: Select all
m_gender = 0;
insert this:
- Code: Select all
m_npcIsFish = false;
- Code: Select all
/// <summary> /// if this NPC is an fish ? /// </summary> [DataElement(AllowDbNull = true)] public bool NPCIsFish { get { return m_npcIsFish; } set { m_npcIsFish = value; Dirty = true; } }