Aschbourne_PRC8/_module/nss/_kill_plant.nss
GetOffMyYarn 7030eb2235 added things
added a crafting tool merchant,
added a training hall (not quite working yet)
fixed crafting issues,
exchanged the small cave area
2024-09-01 14:11:15 -04:00

127 lines
5.4 KiB
Plaintext

void CreatePlaceable(string sObject, location lPlace, float fDuration)
{
object oPlaceable = CreateObject(OBJECT_TYPE_PLACEABLE,sObject,lPlace,FALSE);
if (fDuration != 0.0)
DestroyObject(oPlaceable,fDuration);
}
void main()
{
object oPC = GetLastDamager();
int iCanDestroy = 0;
int iAmTree=0;
if (GetLocalInt(OBJECT_SELF,"iAmDeadAlready")!=0) return;
SetLocalInt(OBJECT_SELF,"iAmDeadAlready",99);
if (GetTag(OBJECT_SELF) == "PLANT_WHEAT")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You gather the remaining straw into a bundle.",oPC,FALSE)));
CreateItemOnObject("strawbundle",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_BLACKIRIS")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a black iris tuber.",oPC,FALSE)));
CreateItemOnObject("blackiristuber",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_YELLOWIRIS")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a yellow iris tuber.",oPC,FALSE)));
CreateItemOnObject("yellowiristuber",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_BLUEIRIS")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a blue iris tuber.",oPC,FALSE)));
CreateItemOnObject("blueiristuber",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_REDIRIS")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a red iris tuber.",oPC,FALSE)));
CreateItemOnObject("rediristuber",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_WHITEIRIS")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a white iris tuber.",oPC,FALSE)));
CreateItemOnObject("whiteiristuber",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_REDTULIP")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a bulb from the red tulip.",oPC,FALSE)));
CreateItemOnObject("redtulipbulb",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_BLACKTULIP")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a bulb from the black tulip.",oPC,FALSE)));
CreateItemOnObject("blacktulipbulb",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_WHITETULIP")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a bulb from the white tulip.",oPC,FALSE)));
CreateItemOnObject("whitetulipbulb",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_YELLOWTULIP")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a bulb from the yellow tulip.",oPC,FALSE)));
CreateItemOnObject("yellowtulipbulb",oPC,1);
}
if (GetTag(OBJECT_SELF) == "PLANT_BLUETULIP")
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,5.0));
PlaySound("as_an_crittgnaw3");
AssignCommand(oPC,DelayCommand(4.0,FloatingTextStringOnCreature("You also dig up a bulb from the blue tulip.",oPC,FALSE)));
CreateItemOnObject("bluetulipbulb",oPC,1);
}
// This section determines if the plant is a player-planted one (which has a chance not to respawn)
// Or a module-designed one placed outside of a plantable field, which will respawn 100% of the time.
// As a side-note, the player *can* accidentally be outside the field and kill a player-made plant
// that is within the field itself, causing 100% respawn rates at the edges of the fields.
// As of this time I have no idea how to address this issue short of placing a local
// variable on the plant itself if it is player-planted and checking for this instead.
if (GetLocalInt(oPC,"iAmInField") == 99) iCanDestroy = 99;
if (GetLocalInt(oPC,"iAmInWaterField") == 99) iCanDestroy = 99;
if (GetStringLeft(GetTag(OBJECT_SELF),5)=="TREE_")
{
iCanDestroy = 0;
iAmTree=99;
}
if (iCanDestroy == 99)
{
if (d10(1) >5) return;
}
string sSelf = GetResRef(OBJECT_SELF);
location lSelf = GetLocation(OBJECT_SELF);
object oSelf;
if (iAmTree!=0)
{
oSelf = CreateObject(OBJECT_TYPE_PLACEABLE, "choppedtree",lSelf,FALSE);
}
else
{
oSelf = CreateObject(OBJECT_TYPE_PLACEABLE, "temporaryplaceho",lSelf,FALSE);
}
AssignCommand(oSelf,DelayCommand(1800.0,CreatePlaceable(sSelf,lSelf,0.0)));
DestroyObject(oSelf,1830.0);
}