Fishes stop following players and there pets on land!

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

Fishes stop following players and there pets on land!

Postby elcotek » Fri Sep 16, 2016 4:15 pm

A little bit constribution for dol. :wink:


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. :) (testet in lough derg)

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
#in StandardMobBrain after:
Code: Select all
if (Body.IsOutOfTetherRange && !Body.InCombat) { blabla }
insert this:
Code: Select all
if (Body.SwimmingIsFollowLivingOnGround(Body)) { Body.StopAttack(); Body.WalkToSpawn(220); }
after:
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;
insert this:
Code: Select all
if (Body.SwimmingIsFollowLivingOnGround(Body)) return;
after :
Code: Select all
protected virtual void CheckPlayerAggro() { //Check if we are already attacking, return if yes if (Body.AttackState) return;
insert this:
Code: Select all
if (Body.SwimmingIsFollowLivingOnGround(Body)) return;
#in mob.cs

after:
Code: Select all
"'/mob ownerid <id>' Sets and saves the OwnerID for this mob.",
insert this:
Code: Select all
"'/mob fish <true/false>' if the target npc is a fish ?.",
after:
Code: Select all
:case "trigger": trigger(client, targetMob, args); break;
insert this:
Code: Select all
case "fish": IsFish(client, targetMob, args); break;
after:
Code: Select all
:info.Add(" + Mob_ID: " + targetMob.InternalID);
insert this:
Code: Select all
info.Add(" + Mob is Fish: " + targetMob.NPCIsFish);
after:
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); }
#in database\mob.cs



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;
and at last line:
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; } }
Brotherland Final RvR/PvE/ToA http://brotherland.phpbb8.de/
User avatar
elcotek
Server Representative
 
Posts: 177
Joined: Mon May 12, 2008 9:28 pm
Website: http://brotherland-2.de
Location: Germany

Re: Fishes stop following players and there pets on land!

Postby Graveen » Fri Sep 16, 2016 10:10 pm

Seems good Elco ! Can you PR to GitHub ? Thank you !!! :)

Just 2 notes:
- NPCTemplate should also handle this
- Basically, we could perhaps auto detect fish. BUT i'm not sure mountain's lakes would have negative Z coords, so you can forget this point if this is not the case.

In all cases, i would accept this PR as is because yeah, it is lacking.
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: Fishes stop following players and there pets on land!

Postby elcotek » Sat Sep 17, 2016 7:07 am

auto detect will not work, for example: an wurm can swimming and can walk land so you must define this in db.

For npctemplates are easy to implement, i will later post a patch but i can't use GitHub atm.

i can post later a complete patch for the actual dol code, but not yet.
Brotherland Final RvR/PvE/ToA http://brotherland.phpbb8.de/
User avatar
elcotek
Server Representative
 
Posts: 177
Joined: Mon May 12, 2008 9:28 pm
Website: http://brotherland-2.de
Location: Germany

Re: Fishes stop following players and there pets on land!

Postby Graveen » Sat Sep 17, 2016 2:50 pm

Thank you, but please use GitHub (if you need help about this, tell us).
This allows us to easily integrate, and see if your code is breaking something else etc...
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest