/* Script generated by Lilac Soul's NWN Script Generator, v. 2.3 For download info, please visit: http://nwvault.ign.com/View.php?view=Other.Detail&id=4683&id=625 */ //Put this script OnEnter #include "events_inc" void main() { object oPC = GetEnteringObject(); if (!GetIsPC(oPC)) return; if(GetLocalInt(OBJECT_SELF, "NPCGenerated") == FALSE) { string sResRef; string sRace; string sGender; int i; int n; location loc; string sSpot; object oNPC; string sArea = GetLocalString(OBJECT_SELF, "Area"); //Determine the number of waypoints for NPC spawning for(n=1; n>0; n++) { sSpot = IntToString(n); if (GetWaypointByTag(sArea+"_SPAWN_"+sSpot) == OBJECT_INVALID) { n--; break; } } //Generate and spawn NPCs for(i=1; i<=n; i++) { sRace = "hu"; switch (Random(2)) { case 0: sGender = "_m"; break; case 1: sGender = "_f"; break; } sResRef = "anc_npc_"+sRace+sGender; sSpot = IntToString(i); loc = GetLocation(GetWaypointByTag(sArea+"_SPAWN_"+sSpot)); oNPC = CreateObject(OBJECT_TYPE_CREATURE, sResRef, loc); SetPlotFlag(oNPC, TRUE); SetLocalString(oNPC, "Waypoint", sArea+"_SPAWN_"+sSpot); SetLocalInt(oNPC, "Commoner", TRUE); SetLocalInt(oNPC, "Rumor", Random(3)+1); } SetLocalInt(OBJECT_SELF, "NPCGenerated", TRUE); } //Done generating and spawning NPCs ExploreAreaForPlayer(GetArea(oPC), oPC); EndEscortEvent(oPC); //Set this town as the PC's spawn point string sLastTown = GetCampaignString(CharacterDB(oPC), "TOWN_SPAWN"); if (sLastTown != "WP_AREA_ALVERTON") SetCampaignString(CharacterDB(oPC), "TOWN_SPAWN", "WP_AREA_ALVERTON"); }