73 lines
2.5 KiB
Plaintext
73 lines
2.5 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: Name: shovel
|
|
//:: Copyright (c) 2001 Bioware Corp.
|
|
//:://////////////////////////////////////////////
|
|
/*
|
|
This script is executed every time the shovel
|
|
item is activated.
|
|
*/
|
|
//:://////////////////////////////////////////////
|
|
//:: Created By: Adam Walenga
|
|
//:: Created On: September 4th, 2004
|
|
//:://////////////////////////////////////////////
|
|
#include "farm_include"
|
|
#include "farm_config"
|
|
|
|
void Farm_CreateHole (location lLoc)
|
|
{
|
|
object oHole = CreateObject (OBJECT_TYPE_PLACEABLE, "x2_plc_hole_s", lLoc);
|
|
|
|
//Destroy after 10 seconds.
|
|
DestroyObject (oHole, 20.0f);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
object oPlant = GetLocalObject (OBJECT_SELF, "Item_Target");
|
|
|
|
//Check if used on a valid target (must be a plant).
|
|
if (GetStringLeft (GetResRef (oPlant), 6) != "plant_")
|
|
SendMessageToPC (OBJECT_SELF, "This item is only useful when used on " +
|
|
"a plant.");
|
|
|
|
//Check if shovel should break.
|
|
else if (d100() <= FARM_SHOVEL_BREAKAGE)
|
|
{
|
|
SendMessageToPC (OBJECT_SELF, "You're shovel broke while attempting " +
|
|
"to dig up a plant...");
|
|
DestroyObject (GetLocalObject (OBJECT_SELF, "Item_Used"));
|
|
}
|
|
else
|
|
{
|
|
string sTag = GetTag (oPlant);
|
|
int iPosition = FindSubString (sTag, "_");
|
|
int iFarm = StringToInt (GetStringLeft (sTag, iPosition));
|
|
string sOwner = Farm_GetOwner (iFarm);
|
|
|
|
//Determine if the PC is the owner of this farm.
|
|
if (sOwner != "FARM_" + GetPCPlayerName (OBJECT_SELF))
|
|
{
|
|
SendMessageToPC (OBJECT_SELF, "You cannot dig this crop, as you " +
|
|
"don't own the farmland in which it's planted.");
|
|
return;
|
|
}
|
|
|
|
//Play animation, and remove crop placeable.
|
|
ClearAllActions();
|
|
ActionMoveToObject (oPlant, FALSE, 0.5f);
|
|
ActionDoCommand (Farm_CreateHole (GetLocation (oPlant)));
|
|
ActionPlayAnimation (ANIMATION_LOOPING_GET_LOW, 1.0f, 5.0f);
|
|
DelayCommand (0.1f, SetCommandable (FALSE, OBJECT_SELF));
|
|
ActionDoCommand (DestroyObject (oPlant, 2.0f));
|
|
ActionDoCommand (SetCommandable (TRUE, OBJECT_SELF));
|
|
|
|
//Reset plant variable (resref)
|
|
Farm_SetPlantResRef (iFarm, StringToInt (GetSubString (sTag,
|
|
iPosition + 1, GetStringLength (sTag) - (iPosition - 1))), "");
|
|
}
|
|
|
|
//Clear variables no longer needed.
|
|
DeleteLocalObject (OBJECT_SELF, "Item_Used");
|
|
DeleteLocalObject (OBJECT_SELF, "Item_Target");
|
|
}
|