//Script Name: spawn_horses ////////////////////////////////////////// //Created By: Genisys (Guile) //Created On: 9/17/08 ///////////////////////////////////////// /* This script goes in the OnEnter Event for an Area or a Tracks Trigger. (Preferrably an Area's OnEnter Event) (The PC will not notice the NPC's being spawned in) This script will spawn in an NPC at the proper way point and destroy it after an amount of time set by you. You MUST create the first walk waypoint for the NPC (put the npc in the module right click on it) (select create way point, then delete the NPC) If you wish for the NPC to walk around create more walk waypoint by moving the NPC and creating more way points as instructed above. */ //////////////////////////////////////// //Required Horse Include #include "x3_inc_horse" //PROTOTYPE DECLARED void SpawnNPC(string sTag, string sResref, float fSeconds); void SetOwnership(object oReference); //Main Script void main() { //Define the PC object oPC = GetEnteringObject(); object oPoint = GetObjectByTag("stable_pt"); //Stop here if it's not a PC entering! if(!GetIsPC(oPC)) {return;} //Spawn the horses and their owner! SpawnNPC("X3_HORSE001", "x3_horse001", 600.0); SpawnNPC("X3_HORSE002", "x3_horse002", 600.0); SpawnNPC("X3_HVYWARHORSE6", "x3_hvywarhorse6", 600.0); SpawnNPC("X3_JOUSTHORSE2", "x3_jousthorse2", 600.0); SpawnNPC("NW_MALEKID01", "malekid002", 600.0); //Make the horses belong to the kid running the stables.. DelayCommand(1.0, SetOwnership(oPoint)); //NOTE: This options is NOT for spawning in multiple NPCs with the same tagname! //I recommend that you create copies of the NPCs and spawn them in seperately. //(each copied NPC needs thier own tagname / resref name & walk waypoints!) //Enter any additional code here if your merging this script.. //Main Script End } /////////////////////DO NOT TOUCH ANYTHING BELOW!///////////////////// //PROTOTYPE DEFINED void SpawnNPC(string sTag, string sResref, float fSeconds) { object oTarget; object oObject = GetWaypointByTag("WP_"+sTag+"_01"); if (!GetIsObjectValid(GetNearestObjectByTag(sTag, oObject))) { CreateObject(OBJECT_TYPE_CREATURE, sResref, GetLocation(oObject)); } oTarget = GetObjectByTag(sTag); DelayCommand(fSeconds, DestroyObject(oTarget, 0.0)); //PROTOTYPE END } void SetOwnership(object oReference) { object oHorse1 = GetNearestObjectByTag("X3_HORSE001", oReference); object oHorse2 = GetNearestObjectByTag("X3_HORSE002", oReference); object oHorse3 = GetNearestObjectByTag("X3_HVYWARHORSE6", oReference); object oHorse4 = GetNearestObjectByTag("X3_JOUSTHORSE2", oReference); object oOwner = GetNearestObjectByTag("NW_MALEKID01", oReference); HorseSetOwner(oHorse1, oOwner, FALSE); HorseSetOwner(oHorse2, oOwner, FALSE); HorseSetOwner(oHorse3, oOwner, FALSE); HorseSetOwner(oHorse4, oOwner, FALSE); DelayCommand(0.5, AssignCommand(oHorse1, ClearAllActions())); DelayCommand(0.6, AssignCommand(oHorse1, ClearAllActions())); DelayCommand(0.7, AssignCommand(oHorse1, ClearAllActions())); DelayCommand(0.8, AssignCommand(oHorse1, ClearAllActions())); }