PDA

View Full Version : Leashing Mobs


KingMort
05-07-2009, 01:51 AM
Could we make it so that the NPCSPECIALATTK can have the ability to Leash ?? Perhaps set it to leash , and have it reset at 50 feet then lose agro....

MNWatchdog
05-07-2009, 05:12 AM
I would think this could add a lot server overhead with the server constantly calculating mobs distance from spawn point.

Add to that tethering adding probable exploiting.

trevius
05-07-2009, 05:21 AM
Well, in this case, I think you would probably want to weigh the CPU overhead vs the bandwidth utilization. The only time this could possibly cause any CPU usage would be if there were a bunch of mobs all chasing someone at the same time. If that is the case, I would be more concerned about how many position updates need to go out to the client as those can add up quickly if mobs are in close range. As long as they aren't calculating distance too quickly (maybe every couple of seconds), it shouldn't be too bad.

One nice bonus is that this could possibly hinder hackers a bit. If the mob stops chasing players when they try to warp and pull to zone in or something, that would make 1 exploit a little harder to do easily.

Kayen
05-07-2009, 07:36 PM
Its really easy to code a leash there are very simple quest objects that can calculate distance from one npc to another. You can just run it on a timer loop/signal loop.

KingMort
05-07-2009, 10:35 PM
Give me an example :)

Kayen
05-08-2009, 03:56 PM
I didn't test this but it should work theory, just put this on the primary mob. You don't need any code on the leashed mob.

#Place code this on the primary mob
#Lets pretend mob that is leashed to this mob is ID 1001.
#Put this on a say 30 sec timer? Even a minute would be ok. This should cause no huge increase in cpu use at all......

if ($timer eq "LeashCheck") {
$LeashedID = $entity_list->GetMobByNpcTypeID(1001);
$distanceCHK = $LeashedID->CalculateDistance($x, $y, $z);
#This will calculate the distance between this mob at current location
# and the mob that is leashed to it.
if ($distanceCHK >= 500) { #Whatever distance you want
$LeashedID->WipeHateList();
$LeashedID0->GMMove($x, $y, $z, 1);
#Clears hate list of leashed mob and warps it back to first mob.
}
}

cavedude
05-08-2009, 09:32 PM
Check out the gods in potimeb for an example of a leash by coords. Well it's more like a roambox that they cannot leave. You'd just need to add a line to clear their hatelist and you'd be set. Though, I am not opposed to a leash option in the code, perhaps a new table. That would enable us to easily keep fish in water.

MNWatchdog
05-11-2009, 11:56 PM
Check out the gods in potimeb for an example of a leash by coords. Well it's more like a roambox that they cannot leave. You'd just need to add a line to clear their hatelist and you'd be set. Though, I am not opposed to a leash option in the code, perhaps a new table. That would enable us to easily keep fish in water.
...
Knock knock knock
Who is it?
Land Shark.
Oh, come in.
...

KingMort
05-14-2009, 05:26 PM
So Basically what I do there is make an invis mob where I want the mob to leash back too... called say T.pl With your code

if ($timer eq "LeashCheck") {
$LeashedID = $entity_list->GetMobByNpcTypeID(1001);
$distanceCHK = $LeashedID->CalculateDistance($x, $y, $z);
#This will calculate the distance between this mob at current location
# and the mob that is leashed to it.
if ($distanceCHK >= 500) { #Whatever distance you want
$LeashedID->WipeHateList();
$LeashedID0->GMMove($x, $y, $z, 1);
#Clears hate list of leashed mob and warps it back to first mob.
}
}


Raid Mob ID 1001 lets say....

And the mob will Leash Back to that point right?

Just a bit confused as to how this works ..

King

KingMort
05-14-2009, 05:50 PM
Sorry I suck at perl some times... Does not seem to be working I put this script on an invis mob right where the named is..

sub EVENT_AGGRO
{
quest::settimer("LeashCheck",30);
}

sub EVENT_TIMER
{

if ($timer eq "LeashCheck") {
$LeashedID = $entity_list->GetMobByNpcTypeID(2701241);
$distanceCHK = $LeashedID->CalculateDistance($x, $y, $z);
#This will calculate the distance between this mob at current location
# and the mob that is leashed to it.
if ($distanceCHK >= 300) { #Whatever distance you want
$LeashedID->WipeHateList();
$LeashedID->GMMove($x, $y, $z, 1);
#Clears hate list of leashed mob and warps it back to first mob.
}
}

The raid mob being 2701241 as you can see above...

well he won't leash back to where the invis mob is that has this script...

What am I doing wrong?

Kayen
05-15-2009, 12:51 AM
I tested this it works.

However your implementing it wrong. There are two mobs in this leash situation. Lets set it up
NPC #1248 King_Gnoll
NPC #1247 Gnoll_Guard

You want the guard to always leash back to the king if its out of range. You put this code on the King_Gnoll.pl . The code then when runs it gets the ID of the gnoll guard, it then calcs the distance of the Gnoll_Guard from the gnoll king, if the distance is greater then 30 it leashes it back got it?

sub EVENT_AGGRO
{
quest::settimer("LeashCheck",5);
}

sub EVENT_TIMER {

if ($timer eq "LeashCheck") {
$LeashedID = $entity_list->GetMobByNpcTypeID(1247);
$distanceCHK = $LeashedID->CalculateDistance($x, $y, $z);
#quest::shout("$distanceCHK x $LeashedID");
if ($distanceCHK >= 30) {
$LeashedID->WipeHateList();
$LeashedID->GMMove($x, $y, $z, 1);
}
}
}

Kayen
05-15-2009, 01:00 AM
Also there is a syntax error in your code that will not make it work. You could use an invs mob instead of whatever that is up to you if you just want 1 mob leashing back to a point. Replace the king with the invs mob. Though you would need to aggro the invs mob. Better way would be to have two quest files and have the that actual mob send a signal to invs mob when aggroed to start timer.

KingMort
05-15-2009, 03:10 PM
How would I do this exactly ??

That's what I want to do yeah... I have the invis mob at the spawn point where the named is... I want the named to be able to leash back to that spot if he is pulled away too far..

Really appreciate your help sorry for being a n00b I'm more into the world building end of my server.

King

gaeorn
05-15-2009, 05:18 PM
The syntax error with the code you posted is simply a missing curly brace at the end (at least that's all I saw wrong with it).

With that fix, it should work (unless I'm missing something else) as long as the invis mob gets the timer going somehow (agro or signal as suggested earlier in this thread).