PDA

View Full Version : Many Mob plugin::() functions


Akkadius
12-04-2010, 08:52 PM
Note: Once again these functions are committed to the repository, so simply checking out the SVN to your plugins folder will allow you to use any of these plugins right away!

These two functions are very simple, one plugin will heal a mob by a certain percentage (1-100%)

So the usage would be plugin::MobHealPercentage(50); to heal 50% of the mob

And very similarily, plugin::MobHealPoints(50); would only heal 50 hitpoints of a mob. Most likely the percentage function would be used more.


###AKKADIUS###
#Usage: plugin::MobHealPercentage(Numberofpercent);
# This script will heal a mob whatever percent amount at the time of trigger
sub MobHealPercentage{
my $npc = plugin::val('$npc');
my $HealPercent = $_[0];
my $curhp = $npc->GetHP();
my $maxhp = $npc->GetMaxHP();
$npc->SetHP($curhp + ($maxhp / 100 * $HealPercent));
}

###AKKADIUS###
#Usage: plugin::MobHealPoints(Hitpoints to heal);
# This script will heal a mob whatever point amount at the time of trigger
sub MobHealPoints{
my $npc = plugin::val('$npc');
my $HealPoints = $_[0];
my $curhp = $npc->GetHP();
my $maxhp = $npc->GetMaxHP();
$npc->SetHP($curhp + $HealPoints);
}

These two functions have "spawn in place" features that automatically do some of the work for you. They are explained in the scripts:

#Usage: plugin::SpawnInPlace(NPCID to spawn in place, [1 = Don't depop what spawns in place]);
#Example plugin::SpawnInPlace(100230, 1);
#The Second arguement for a plugin like this is for an instance where you have eggs spawn drakes and you don't want the eggs to depop

#Usage: plugin::SpawnChest(Chest NPCID to spawn in place, [the integer range you want the chest to randomly spawn from the dead mob]);
#Example plugin::SpawnChest(102032, 100); So in this case the chest would spawn anywhere in 100 integers of the vicinity of the mob. Usually used in a sub_EVENT_DEATH
#Similar to plugin::SpawnInPlace, this plugin will spawn a chest in the same place, or will spawn a chest within a random generated desired range defined in the second arguement

###AKKADIUS###
#Usage: plugin::SpawnInPlace(NPCID to spawn in place, [1 = Don't depop what spawns in place]);
#The Second arguement for a plugin like this is for an instance where you have eggs spawn drakes and you don't want the eggs to depop
sub SpawnInPlace{
my $npc = plugin::val('$npc');
my $NPCID = $_[0];
my $DontDie = $_[1];
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();
if(!$DontDie){
quest::depop();
}
quest::spawn2($NPCID, 0, 0, $x, $y, $z, $h);
}

###AKKADIUS###
#Usage: plugin::SpawnChest(Chest NPCID to spawn in place, [the integer range you want the chest to randomly spawn from the dead mob]);
#Similar to plugin::SpawnInPlace, this plugin will spawn a chest in the same place, or will spawn a chest within a random generated desired range defined in the second arguement
sub SpawnChest{
my $npc = plugin::val('$npc');
my $NPCID = $_[0];
my $Range = $_[1];
my $ChestRange = plugin::RandomRange(1, $Range);
my $x = $npc->GetX();
my $y = $npc->GetY();
my $z = $npc->GetZ();
my $h = $npc->GetHeading();
quest::spawn2($NPCID, 0, 0, $x + ($ChestRange), $y + ($ChestRange), $z, $h);
}



These two functions are really slick, the first function will set the coordinates in which plugin::CheckLeashMob(range); will check the distance before resetting back to the spawn point.

Example shown below the plugins:


###AKKADIUS###
#Usage: plugin::SetLeashMob();
# This script will set the parameters in which the mob will be leashed for when you perform a check.
sub SetLeashMob{
my $npc = plugin::val('$npc');
my $MobX = $npc->GetX();
my $MobY = $npc->GetY();
my $MobZ = $npc->GetZ();
my $MoBH = $npc->GetHeading();
$npc->SetEntityVariable(60, $MobX); # Set X Base Integer
$npc->SetEntityVariable(61, $MobY); # Set Y Base Integer
$npc->SetEntityVariable(62, $MobZ); # Set Z Base Integer
$npc->SetEntityVariable(63, $MobH); # Set H Base Integer - Store for return
}

###AKKADIUS###
#Usage: plugin::CheckLeashMob(Range);
# This script will check the parameters in which the Leash was set and check against the arguement declared, if comes back true, the mob is reset to its leash set point.
sub CheckLeashMob{
my $npc = plugin::val('$npc');
my $LeashAmount = $_[0];
my $GetLeashX = $npc->GetEntityVariable(60);
my $GetLeashY = $npc->GetEntityVariable(61);
my $GetLeashZ = $npc->GetEntityVariable(62);
my $StoredHeading = $npc->GetEntityVariable(63);
my $MobX = $npc->GetX();
my $MobY = $npc->GetY();
my $MobZ = $npc->GetZ();
my $DifferenceX = $GetLeashX - $MobX;
my $DifferenceY = $GetLeashY - $MobY;
my $DifferenceZ = $GetLeashZ - $MobZ;
my $FinX = abs($DifferenceX);
my $FinY = abs($DifferenceY);
my $FinZ = abs($DifferenceZ);
if ($FinX > $LeashAmount || $FinY > $LeashAmount || $FinZ > $LeashAmount){
$npc->GMMove($GetLeashX, $GetLeashY, $GetLeashZ, $StoredHeading); #Returns back to original point if mob goes beyond the throttled integer range
}
}





sub EVENT_SPAWN{
my $npc_name = $npc->GetCleanName();
quest::shout("Veeshan where are you!");
quest::we(15, "You hear a dragon roar in the distance, coming from the Dreadlands of Kunark");
$npc->CameraEffect(2000, 9);
quest::settimer("spawn",1);
quest::doanim(44);
plugin::NamedLogging("$npc_name has spawned in [$zoneln]");
}

sub EVENT_TIMER{
plugin::NamedTimerUtils();
if ($timer eq "spawn"){
plugin::SetLeashMob();
quest::stoptimer("spawn");
}
if ($timer eq "CheckLeash"){
plugin::CheckLeashMob(130);
quest::stoptimer("CheckLeash");
quest::settimer("CheckLeash", 3);
}
}

sub EVENT_COMBAT
{
plugin::NpcCombatUtils();
my $npc_name = $npc->GetCleanName();
if($combat_state == 1)
{
$NextActivate = 95;
$x = $npc->GetX();
$y = $npc->GetY();
$z = $npc->GetZ();
$h = $npc->GetHeading();
quest::setnexthpevent($NextActivate);
$npc->CameraEffect(2000, 7);
quest::stoptimer("repeatsay");
quest::settimer("CheckLeash", 1);
}
if($combat_state == 0)
{
$npc->CameraEffect(2000, 7);
quest::settimer("repeatsay", 600);
quest::stoptimer("CheckLeash");
}
}

trevius
12-07-2010, 04:41 AM
You have been submitting plugins like crazy, lol! Gotta love plugins :)

BTW, you should be able to use guard points for leashing, so you don't need the SetLeashMob plugin at all and can just handle leashing by checking dist from the guardpoints. Also, an IsEngaged check probably wouldn't hurt either.


Here is a simple rewrite (untested!):
#Usage: plugin::Leash(LeashDist, NoEngageCheck=0);
#Example: plugin::Leash(100);
# This script will check the distance from the NPC's current guard point (spawn or waypoints).
# If they are further away from that point than the specified distance, it returns them to their guard point.
# LeashDist is the max distance an NPC can be before they get leashed back by this plugin
# NoEngageCheck is an optional field which disables the IsEngaged() check as a requirement before leashing (set to 1 to enable)
# The Plugin also returns 1 if the NPC gets leashed and 0 if not.

sub Leash{
my $npc = plugin::val('$npc');
my $LeashDist = $_[0];
my $NoEngageCheck = $_[1];
# Don't bother further checks if NPC isn't engaged unless the check is disabled
if ($npc->IsEngaged() == 1 || $NoEngageCheck)
{
my $GuardX = $npc->GetGuardPointX();
my $GuardY = $npc->GetGuardPointY();
my $GuardZ = $npc->GetGuardPointZ();
my $CurDist = $npc->CalculateDistance($GuardX, $GuardY, $GuardZ);
if ($CurDist > $LeashDist)
{
# Get their current heading, since there is currently no way to get Guard Heading (yet)
my $CurH = $npc->GetHeading();
# Return them to their Guard Point
$npc->GMMove($GuardX, $GuardY, $GuardZ, $CurH);
# Wipe the NPC's hate list as well
$npc->WipeHateList();
return 1;
}
}
return 0;
}

Akkadius
12-07-2010, 01:26 PM
I'm not opposed to simplifying anything at all, the only thing that has me concerned about completely replacing my function is if someone wanted to create a whole new leash point in the middle of a fight. I thought about using spawn or guard points before but thought this would be more flexible.

Could probably put them both in, and when I get to making a big cheat sheet of all the functions I could explain it in there.

Oh, and when anyone gets a chance to test this let me know.

Bdiddy
12-15-2010, 11:23 PM
How would you use the Heal plugin if you wanted one mob to heal another mob? Can you give an example?

joligario
09-17-2011, 09:10 AM
Just a heads up.

In SetLeashMob:

my $MoBH = $npc->GetHeading();

should be:

my $MobH = $npc->GetHeading();