//:://///////////////////////////////////////////// //:: Name: farm_plant_ou //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* OnUsed event for crop placeables. This script will, under the right circumstances, will generate crop loot (seeds and/or food). */ //::////////////////////////////////////////////////////// //:: Created By: Adam Walenga //:: Created On: September 5th, 2004 //:: Small bug fixed by -Seeker- on 18th of March, 2005 //::////////////////////////////////////////////////////// #include "farm_include" #include "farm_config" #include "eds_include" void main() { object oPlayer = GetLastUsedBy(); SpeakString (GetTag (OBJECT_SELF)); // Calcutate farmnumber from tag string farmTag = GetTag( OBJECT_SELF ); string farmNumber; int i = 0; string temp = GetSubString( farmTag, i, 1 ); while (temp != "_") { farmNumber = farmNumber + temp; i++; temp = GetSubString( farmTag, i, 1 ); } //Check if time to generate loot. if (!EDS_CheckDelay (OBJECT_SELF, "Is_Lootable")) return; //Check if looting is limited to the farm owner. else if ((FARM_LIMIT_LOOTING) && (Farm_GetOwner (StringToInt (farmNumber) ) != ("FARM_" + GetPCPlayerName (oPlayer)))) { SendMessageToPC (oPlayer, "Warning - This is private property!"); return; } EDS_SetDelay (OBJECT_SELF, "Is_Lootable", IntToFloat (GetMaxHitPoints (OBJECT_SELF) * 60)); int iCount = 1; int iFoodCount = Random (GetReflexSavingThrow (OBJECT_SELF)) + 1; string sResRef = GetResRef (OBJECT_SELF); string sPlant = GetStringRight (sResRef, GetStringLength (sResRef) - 6);\ object oObject = GetFirstItemInInventory (OBJECT_SELF); //Clear current inventory before generating new items. while (GetIsObjectValid (oObject)) { DestroyObject (oObject); oObject = GetNextItemInInventory (OBJECT_SELF); } //Create random amound of food items based on Reflex save. for (; iCount <= iFoodCount; iCount++) CreateItemOnObject ("food_" + sPlant); //Check if to produce seeds. if (d100() <= GetWillSavingThrow (OBJECT_SELF)) { int iSeedCount = Random (GetFortitudeSavingThrow (OBJECT_SELF)) + 1; //Create random amount of seed items based on Fortitude save. for (iCount = 1; iCount <= iSeedCount; iCount++) CreateItemOnObject ("seed_" + sPlant); } }