PDA

View Full Version : Scripted waypoints with the scripting engine.


Malevolent
04-30-2002, 12:07 PM
Previously, I used a database to do this. This time, I've used the scripting engine. The performance is about the same, so far as I can tell.

You can try it out in the lab, just zone to butcherblock.

Let me attach the script file I'm using before going into the code.

This attached quest file will move the sirens bane in a kind of elipse around the shore in butcherblock.

Malevolent
04-30-2002, 12:09 PM
I had a problem with the triggers all going off at the same time. I fixed this by just assigning some really large random number.
In NPC.CPP, specifically in the constructor:


SetWayPointStep(0);
waypoint_timer = new Timer(30000+rand()%20000);
waypoint_timer->Start();

In NPC.CPP, specifically in process:


/*********************************************
Waypoints
*********************************************/


if (ismovinghome==false && !IsEngaged()){
if (waypoint_timer->Check()){
if (this->GetWayPointStep() < 6){

if (!this->IsCorpse() && !this->IsClient())
this->CheckQuests(zone->GetShortName(), "WAYPOINT_CHECK", this->GetNPCTypeID());

} else
{
this->SetWayPointStep(0);
}

waypoint_timer->Start(50000+rand()%25000);

}

}

Malevolent
04-30-2002, 12:10 PM
In npc.h, add these parts to the public members of the NPC class.


/************************************************** ****
WayPoints
************************************************** ****/

void SetWayPointStep(uint32 step){ Step=step;}
uint32 GetWayPointStep(){return Step;}
uint32 Step;

/************************************************** ****
Mob quest engine
************************************************** ****/
void CheckQuests(char* zonename, char * message, int32 npc_id, int32 item_id = 0, bool IsDoorScript = false);
bool IsEnd(char* string);
bool IsCommented(char* string);
char * rmnl(char* nstring);
char * strreplace(char* searchstring, char* searchquery, char* replacement);


And add this to the private member:

Timer* waypoint_timer;

Malevolent
04-30-2002, 12:11 PM
Use this hacked and dirt wesquests.cpp:

Malevolent
04-30-2002, 12:17 PM
Oh, and in npc.h in public: I have

void SetIsMovingHome(bool ToF) { ismovinghome=ToF;}
bool GetIsMovingHome() { return ismovinghome;}

And I moved
float org_x, org_y, org_z, org_heading; up from protected to public.