View Full Version : NPC Spawning another NPC
chrismed0
10-06-2012, 06:21 PM
You will have to forgive me if I ask about some of these quest scripts. I can do basic quests but I have to ask about the more complex ones.
I was wanting to make an NPC spawn when another NPC comes in proximity of it.
Basicly like this:
NPC - "A" - stationary.
NPC - "B" - moves toward NPC "A"
When NPC "B" comes within "X" distance of NPC "A" it will spawn NPC "C" at desired location.
I see how it is done with PCs... that looks easy. But not sure what to use or how to write with NPCs.
ChaosSlayerZ
10-06-2012, 08:36 PM
well I don't know how to track distance between 2 npcs, but you can go around that and track them from their path grid
In other words the B will be moving on pre-assigned grid path and when he hits the spot X the event will trigger.
This of course assuming that A is always in the same spot, or at least limited variation of A positions and corresponding B paths
spawning C is easy. it just:
quest::spawn2(int npc_type, int grid, int unused, float x, float y, float z, float heading);
Akkadius
10-06-2012, 08:43 PM
I'm being lazy with this by pasting a few year old example from one of my archives:
Reference the yellow text below pertaining to grabbing an entity based on it's NPC Type ID. You could do this from NPC B and check the distance between it and NPC A inside of a timer loop. Right now it is checking for x and y being within 50 units of each other, you can manipulate this example to your liking.
You may have to do this a bit different if you have several NPC's in the zone with the same type ID, you would have to iterate through an array to do the checking, I don't know your exact scenario.
sub EVENT_SAY{
if($text=~/hail/i){
plugin::UpdateTaskActivity("group", 157, 6, 1);
my $Akkazia = $entity_list->GetNPCByNPCTypeID(3034686);
my $AkkaziaX = $Akkazia->GetX();
my $AkkaziaY = $Akkazia->GetY();
my $AkkaziaZ = $Akkazia->GetZ();
my $myX = $npc->GetX();
my $myY = $npc->GetY();
my $myZ = $npc->GetZ();
if (abs($AkkaziaX - $myX) < 50 && abs($AkkaziaY - $myY) < 50 && !$Found) {
plugin::ClientSay("You found my darling Akkazia! Thank you $name, you have made me so happy!");
plugin::UpdateTaskActivity("group", 157, 7, 1);
plugin::DoAnim("plead");
quest::signalwith(3034686, 1);
$Found = 1;
}
elsif($Found == 1){
plugin::ClientSay("You found my darling Akkazia! Thank you $name, you have made me so happy!");
plugin::DoAnim("plead");
}
else{
plugin::ClientSay("Please find my baby! I haven't been able to find her!");
plugin::DoAnim("plead");
}
}
}
chrismed0
10-07-2012, 04:00 AM
I so wish I knew more about more complex perl script. took me a few months to figure out how all the elements of MQ2 script writting worked but I got to where I could write really complex macros. This looks simular but there are different elements. The basic stuff is easy. cordanaites, timers and proximities looks a lot more complex so I may end up having alot more posts before I get it.
Having the NPC trigger a spawn at a waypoint sounds good. that may work out better then trying to set up stationary NPC.
The object of this is I have an npc_type on a grid that does nothing but a big circle. When hits one end of this circle it will trigger a spawn. When it hits the other side of the circle, eventualy, it will spawn a different NPC (both triggered spawn NPCs will be in the adjacent zone closest to the triggered location.)
I see the "EVENT_WAYPOINT_ARRIVE" event just don't know how to use it. I need more example of this stuff before I can figure out how it works and walk throughs if possible.
lerxst2112
10-07-2012, 06:01 AM
There are plenty of examples of how to use EVENT_WAYPOINT_ARRIVE in the existing quests, 139 of them to be exact. Several of them even spawn a mob at a particular waypoint.
chrismed0
10-07-2012, 10:03 AM
cool I will start combing through them and see what I find. I just hope I understand what I'm looking at LOL
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.