PDA

View Full Version : Fish out of water? No longer! I think!


Dibalamin
09-26-2009, 01:29 PM
sub EVENT_COMBAT {
if ($Combat_State == 1) {
quest::settimer("Water",1);
}

if ($Combat_State == 0) {
quest::stoptimer("Water");
}
}

sub EVENT_TIMER {
my $z = $npc->GetZ();
if ($z>=VARBYZONE) {
$npc->WipeHateList();
$mob->sethp($mob->GetMaxHP());
quest::stoptimer("Water");
$
}
}

I haven't tested this as of yet, I just finished the code, but this should work and also have a minimal impact on server performance. Basically, when a fish is aggro'd it will start a timer. As that timer ticks away it will continually check it's Z, once that Z breaks the plane of the water in a zone it will wipe the mobs hate list, sending it home and full heal it. Change the VARBYZONE to match the Z water line in the zone you are working with.

If anyone can offer some improvements to the code, feel free.

ojamajoe
09-26-2009, 01:49 PM
This is a great idea!

Shin Noir
09-26-2009, 02:08 PM
There's an inwater flag on mobs, used for the ruleset of Watermaps, not sure those are mapped out but there's essentially a bunch of checks to verify this, but I think until pathing is done on the zone it doesn't quite work right? Could be wrong.. but assuming this check is properly done it'd be as easy as adding to mob.h some form of inline bool InWater() const { return inWater; } and then you should be able to call $mob->InWater() to get a TRUE/FALSE Return of it being there or not.

Also with your code the mob i don't think would immediately return to his home point? He may stand there out of water, and then eventually decide to return... better than chasing you out!

Dibalamin
09-26-2009, 06:27 PM
I'd tried the $mob function with InWater() before and didn't have much luck with it. I assumed it might have been an incomplete function in the source or a mis-communication between the server source, water file and DB. Again, just theorizing...

Shin Noir
09-26-2009, 06:31 PM
well that function doesn't exist. It's actually a mob property, which I don't think you can call with a quest object as is. That above line would have to be added for $mob->InWater() to work. But regardless, yeah, it's likely work in progress that will be part of getting all the paths repaired for mobs to route with.

Dibalamin
09-26-2009, 08:24 PM
sub EVENT_COMBAT {
if ($combat_state == 1) {
quest::settimer("Water",1);
}

if ($combat_state == 0) {
quest::stoptimer("Water");
}
}

sub EVENT_TIMER {
#quest::shout("Water, water, water");
my $z = $npc->GetZ();
if ($z>=XX) {
$npc->WipeHateList();
$mob->sethp($mob->GetMaxHP());
quest::stoptimer("Water");
}
}

Ok fixed, update the XX in red to the Z coords and you'll be good to go till the pathing stuff gets implemented =).