//:://///////////////////////////////////////////// //:: sc_farmer_field //::////////////////////////////////////////////// /* */ //::////////////////////////////////////////////// //:: Created By: Almion the Bard //:: Created On: 06/26/2002 //::////////////////////////////////////////////// // This is a daily routine script for a farmer NPC. It checks the time of day // and has him do animated tasks around the farm depending on the time. The // tasks are based around waypoints that are placed in the different areas where // you want him to perform the tasks. // // Placed in user defined area of the NPC's heartbeat event ////////////////////////////////////////////////// void main() { int nUser = GetUserDefinedEventNumber(); object oFieldpoint = GetLocalObject(OBJECT_SELF, "FIELD_WAYPOINT"); // FIELD_WAYPOINT is the tag of all the waypoints in the field that the // farmer will work if (nUser == 1001) //OnHrtbt { if ((!IsInConversation(OBJECT_SELF))&&(!GetIsInCombat(OBJECT_SELF))) { int nRandom = d6(); while (nRandom == GetLocalInt (OBJECT_SELF, "LAST_FIELD_WAYPOINT")) nRandom = d6(); if (!GetIsObjectValid(oFieldpoint) && GetLocalInt(OBJECT_SELF, "RPO_Flee") == FALSE) { oFieldpoint = GetNearestObject(OBJECT_TYPE_WAYPOINT, OBJECT_SELF, nRandom); if (GetIsObjectValid(oFieldpoint) && oFieldpoint != OBJECT_SELF && FindSubString(GetTag(oFieldpoint),"FIELD") >=0 ) { //Move to the Waypoint in the Field SetLocalInt(OBJECT_SELF, "LAST_FIELD_WAYPOINT", nRandom); SetLocalInt(OBJECT_SELF, "FARMER_STATE", 1); SetLocalObject(OBJECT_SELF, "FIELD_WAYPOINT", oFieldpoint); ActionMoveToObject(oFieldpoint); ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 0.0,10.0); ActionDoCommand(SetLocalObject(OBJECT_SELF, "FIELD_WAYPOINT", OBJECT_INVALID)); } } // Reset My Actions SetLocalObject(OBJECT_SELF, "FIELD_WAYPOINT", OBJECT_INVALID); SetLocalInt(OBJECT_SELF, "FARMER_STATE", 0); } } else if(nUser == 1008) // DISTURBED { object oDisturber = GetLastDisturbed(); if (GetIsObjectValid(oDisturber)) { ClearAllActions(); int nDisturbed = GetLocalInt(oDisturber, "RPO_Disturbed_" + GetName(OBJECT_SELF)); if (nDisturbed == 0) ActionSpeakString("Leave me alone or I shall call them guards!"); else if (nDisturbed == 1) ActionSpeakString("I told ya to leave me alone! Be warned scum!"); else { SetLocalInt(OBJECT_SELF, "RPO_Flee", TRUE); ActionSpeakString("Guards! Guards! Protect me from this thief!", TALKVOLUME_SHOUT); ActionMoveToObject(GetObjectByTag("OFFGuard"), TRUE); ActionDoCommand(SetLocalInt(OBJECT_SELF, "RPO_Flee", FALSE)); AdjustReputation(oDisturber, GetObjectByTag("OFFGuard"), -100); nDisturbed = -1; } nDisturbed++; SetLocalInt(oDisturber, "RPO_Disturbed_" + GetName(OBJECT_SELF), nDisturbed); } } }