Log in

View Full Version : Updated Quest.CPP [SPAWN_NPC] w/ X, Y, Z, H


mByte
01-08-2003, 09:08 PM
Spawn a npc and put it where you want it. (make sure your location is correct!)

SPAWN_NPC NPCID GRIDID X Y Z H

this example spawns a npc from the npc_types and places it at the location given with no grid assigned.

SPAWN_NPC 41419 0 -74 -130 -10

/* New Spawn NPC Code */
/*
mByte
SPAWN_NPC NPCID GRIDID X, Y, Z, H
*/
else if (strstr(command,"SPAWN_NPC") != NULL) {
const NPCType* tmp = 0;
int16 grid = atoi(sep.arg[2]);
float xPos = atoi(sep.arg[4]); // no idea but need to swap X with Y
float yPos = atoi(sep.arg[3]); // no idea but need to swap Y with X
float zPos = atoi(sep.arg[5]);
float hPos = atoi(sep.arg[6]);
if (tmp = database.GetNPCType(atoi(sep.arg[1])))
{
if(xPos == NULL)
xPos = 0;

if(yPos == NULL)
yPos = 0;

if(zPos == NULL)
zPos = 0;

if(hPos == NULL)
hPos = 0;


NPC* npc = new NPC(tmp, 0, xPos, yPos, zPos, hPos);
npc->AddLootTable();
entity_list.AddNPC(npc,true,true);
Sleep(200);
if(npc != 0)
{
if(grid > 0)
npc->AssignWaypoints(grid);

npc->SendPosUpdate();
}
}
ps = true;
}
/* end of New Spawn NPC Code */


I needed this function, so now its yours just replace over the old elseif statment. around line 281 of WesQuest.cpp

another example i use in my server for the that ride the school bus
[Do not use this in the .cpp file]


NPC_SCRIPT 41419{

TRIGGER_TEXT:Hail:{
EMOTE:Glance's over to %CHARNAME%, then returns to his overview of the yard.
}

TRIGGER_ITEM:9131:{
EMOTE:Staggers in disbelief
DO_ANIMATION 6
EMOTE:Shakes his head then looks to %CHARNAME%. Will you help [defend Freeport]?
}

TRIGGER_TEXT:defend Freeport:{
SAY:Great!, The orcs have dispatched an army, You have the praise of Marr with you!
Say:Get to the west gates now you havnt a moment to lose.
SHOUT:Bring me the head of the commanding Orc!

RAIN 1
SPAWN_NPC 55222 0 -117 -74 -10 0
}
}

Fajoobies
01-22-2003, 04:08 AM
ubaar!!!! many thanks from fajoobs

mByte
01-22-2003, 07:33 PM
Should have also noted, with this you do not need a way to add loot as it uses what's in the loottableid.

:)