PDA

View Full Version : Scripted NPC assist PC


Figback65
04-06-2015, 12:31 PM
Hello,

I wish I was as smart as you guys lol

I am trying to get a NPC to target a specific PC, then grab the PCs target, and then assist a command like attack or spell or whatever.

All in all, this is what I am trying to accomplish. I have been looking at the veteran reward jester of bristlebane, how he acts and I am trying to replicate that with modifications. After extensive research I cannot get a copy to work. I want to be able to summon a pet while you have or dont have a pet. That is more of a NPC so he can be scripted more deeply for control. Also allows you to bypass any 1 pet issues and accept signals(hopefully). In the end being able to keep a pet up and send signals to it to make it attack on command.


npc types has jester as a normal npc
spells_new has jester as a summoned pet effect
pets has jester as a basic pet
altadv_var has AA to summon jester with pretty normal values
aa_actions has the link to altadv_vars to make the AA a castable spell

Now, with all that in mind. The way the jester is summoned is just like any normal pet for necro or mage. Normal spell pets pop up with caster as the owner and is limited to 1 pet. Jester pops up as a NPC that targets and follows you, grabs clients around you for random actions, summons and casts spells to random targets around as well.

When I try to replicate, even by copying exact spell and renaming it. The jester does not act the same. He comes up as a pet with me as the owner or he will come up as a NPC and will not follow.

Snippets of jester:
This if I am understanding is the targetting part for the script. Where he pops up on you, checks minute distance to find you, then follows?
sub GetRandomClient {
my $ListCheck = 0;
my $LastClient = 0;

for ($ListCheck = 0; $ListCheck < 2000; $ListCheck++) {
$ClientSearch = $entity_list->GetClientByID($ListCheck);
if ($ClientSearch) {
my $DistanceCheck = $ClientSearch->CalculateDistance($x, $y, $z);
if ($DistanceCheck <= 100) {
my $ChooseClient = quest::ChooseRandom(1,2);
if ($ChooseClient == 2) {
return $ClientSearch->GetID();
}
else {
$LastClient = $ClientSearch;
}
}
}

}
return $npc->GetFollowID();
}

Two specific actions I have tried to manipulate for assisting the caster.
if($action == 1) {
$ClientID = GetRandomClient();
if($ClientID > 0) {
$c = $entity_list->GetClientByID($ClientID);
if($c) {
quest::say("How about a little wine to quench your thirst?");
$c->SummonItem(quest::ChooseRandom(64046, 64047), 10);
}
}
}

elsif($action == 9) {
$c = GetRandomClient();
if($c > 0) {
quest::say("You look exhausted.");
$npc->CastSpell(6897, $c, 10, 0);
}
}


I have accomplished this sort of by changing my custom pet summon spells to effect152 for summonpetS for swarm pets but it is more limited.

Is this possible? Do I need to use bots? Could I take part of swarmpet or bot coding and create a custom assist function? What about npc calling a qglobal that is changed for PC in sub EVENT_TARGET_CHANGE, so everytime you change target it re-writes the global so NPC(pet) has a current live assist.

EDIT: Damnit, i meant to post in quest Q&A

Thanks guys.