Aschbourne_PRC8/_module/nss/_craft_juice.nss
GetOffMyYarn 69879d6957 Areas and Fixes
Added CCOH and missing areas
Changed some areas to be craftable,
Fixed some on death issues,
Fixed the Gaurd
2024-08-30 11:38:44 -04:00

421 lines
12 KiB
Plaintext

#include "aps_include"
void CreateAnObject(string sResource, object oPC);
void main()
{
if (GetInventoryDisturbType()!= INVENTORY_DISTURB_TYPE_ADDED)
{
if (GetLastDisturbed() == OBJECT_SELF)
{
DestroyObject(GetInventoryDisturbItem());
return;
}
return;
}
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
// The following 3 lines are to ensure compatability with UOAbigal's Persistent Token System.
// You can replace them with whatever 'no-drop' code you have or comment them out.
string sNoDropFlag = (GetStringLeft(GetTag(oItem),6));
if (sNoDropFlag == "NoDrop" || sNoDropFlag == "TOKEN_"||sNoDropFlag=="_TBOX_")
return;
if (GetBaseItemType(oItem)==BASE_ITEM_LARGEBOX)
{
DestroyObject(oItem);
SendMessageToPC(oPC,"To avoid possible dupe exploits, the container placed in this mill may be destroyed.");
return;
}
// End of compatability portion.
if (GetLocalInt(OBJECT_SELF,"iAmInUse") != 0)
{
CopyItem(oItem,oPC,TRUE);
SendMessageToPC(oPC,"You must wait until the press is done before starting another batch.");
DestroyObject(oItem);
return;
}
string sItemTag = GetTag(oItem);
string sProduct = "INVALID";
int iDifficulty = 0;
int iRandom;
int iSkillGain;
int iGlassType=0;
location lFire = GetLocation(OBJECT_SELF);
string sSuccess = "You have successfully pressed the "+GetName(oItem)+" into juice.";
string sFail = "The juice is contaminated and unuseable.";
if (sItemTag=="ITEM_YELLOWAPPLE") //Apple Juice
{
sProduct = "item_juice_001";
iDifficulty=150;
}
if (sItemTag=="ITEM_GREENAPPLE") //Apple Juice
{
sProduct = "item_juice_001";
iDifficulty=150;
}
if (sItemTag=="ITEM_REDAPPLE") //Apple Juice
{
sProduct = "item_juice_001";
iDifficulty=150;
}
if (sItemTag=="SEED_CARROT") //Juice
{
sProduct = "item_juice_002";
iDifficulty=100;
}
if (sItemTag=="SEED_GRAPE1") //Juice
{
sProduct = "item_juice_003";
iDifficulty=0;
}
if (sItemTag=="SEED_GRAPE2") //Juice
{
sProduct = "item_juice_004";
iDifficulty=0;
}
if (sItemTag=="SEED_GRAPE3") //Juice
{
sProduct = "item_juice_005";
iDifficulty=0;
}
if (sItemTag=="SEED_BLACKBERRY") //Juice
{
sProduct = "item_juice_006";
iDifficulty=0;
}
if (sItemTag=="SEED_BLUEBERRY") //Juice
{
sProduct = "item_juice_007";
iDifficulty=0;
}
if (sItemTag=="SEED_CELERY") //Juice
{
sProduct = "item_juice_008";
iDifficulty=100;
}
if (sItemTag=="ITEM_CHERRY") //Juice
{
sProduct = "item_juice_009";
iDifficulty=50;
}
if (sItemTag=="ITEM_COCONUT") //Juice
{
sProduct = "item_juice_010";
sSuccess = "You have successfully pressed the milk from the "+GetName(oItem)+".";
sFail = "The milk is contaminated and unuseable.";
iDifficulty=150;
}
if (sItemTag=="SEED_CRANBERRY") //Juice
{
sProduct = "item_juice_011";
iDifficulty=50;
}
if (sItemTag=="ITEM_DATE") //Juice
{
sProduct = "item_juice_012";
iDifficulty=50;
}
if (sItemTag=="ITEM_ELDERBERRY") //Juice
{
sProduct = "item_juice_013";
iDifficulty=-50;
}
if (sItemTag=="ITEM_FIG") //Juice
{
sProduct = "item_juice_014";
iDifficulty=100;
}
if (sItemTag=="SEED_GOOSEBERRY") //Juice
{
sProduct = "item_juice_015";
iDifficulty=50;
}
if (sItemTag=="ITEM_GRAPEFRUIT") //Juice
{
sProduct = "item_juice_016";
iDifficulty=50;
}
if (sItemTag=="SEED_JUNIPERBERRY") //Juice
{
sProduct = "item_juice_017";
iDifficulty=150;
}
if (sItemTag=="ITEM_KIWI") //Juice
{
sProduct = "item_juice_018";
iDifficulty=0;
}
if (sItemTag=="ITEM_LEMON") //Juice
{
sProduct = "item_juice_019";
iDifficulty=-100;
}
if (sItemTag=="ITEM_FRUITLIME") //Juice
{
sProduct = "item_juice_020";
iDifficulty=-100;
}
if (sItemTag=="ITEM_MANGO") //Juice
{
sProduct = "item_juice_021";
iDifficulty=-50;
}
if (sItemTag=="SEED_MAYAPPLE") //Juice
{
sProduct = "item_juice_022";
iDifficulty=100;
}
if (sItemTag=="ITEM_ORANGE") //Juice
{
sProduct = "item_juice_023";
iDifficulty=-200;
}
if (sItemTag=="ITEM_PEAR") //Juice
{
sProduct = "item_juice_024";
iDifficulty=-50;
}
if (sItemTag=="ITEM_PLUM") //Juice
{
sProduct = "item_juice_025";
iDifficulty=-100;
}
if (sItemTag=="SEED_RASPBERRY") //Juice
{
sProduct = "item_juice_026";
iDifficulty=0;
}
if (sItemTag=="ITEM_TANGERINE") //Juice
{
sProduct = "item_juice_027";
iDifficulty=-100;
}
if (sItemTag=="SEED_TOMATO") //Juice
{
sProduct = "item_juice_028";
iDifficulty=-150;
}
if (sItemTag=="SEED_TURNIP") //Juice
{
sProduct = "item_juice_029";
iDifficulty=0;
}
if (sItemTag=="SEED_BEETS") //Juice
{
sProduct = "item_juice_030";
iDifficulty=100;
}
if (sItemTag=="SEED_SUGARCANE") //Juice
{
sProduct = "item_juice_031";
sSuccess = "You have successfully extracted the fluids from the "+GetName(oItem)+".";
sFail = "The extract is contaminated and unuseable.";
iDifficulty=300;
}
if (sItemTag=="ITEM_WATERMELON") //Juice
{
sProduct = "item_juice_032";
iDifficulty=-200;
}
if (sItemTag=="ITEM_ALMOND") //Juice
{
sProduct = "item_juice_033";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=250;
}
if (sItemTag=="SEED_GARLIC") //Juice
{
sProduct = "item_juice_034";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=250;
}
if (sItemTag=="SEED_CORN") //Juice
{
sProduct = "item_juice_035";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=200;
}
if (sItemTag=="SEED_COTTON") //Juice
{
sProduct = "item_juice_036";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=150;
}
if (sItemTag=="ITEM_OLIVE") //Juice
{
sProduct = "item_juice_037";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=50;
}
if (sItemTag=="SEED_PEANUTS") //Juice
{
sProduct = "item_juice_038";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=100;
}
if (sItemTag=="ITEM_PECAN") //Juice
{
sProduct = "item_juice_039";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=150;
}
if (sItemTag=="ITEM_WALNUT") //Juice
{
sProduct = "item_juice_040";
sSuccess = "You have successfully pressed the oil from the "+GetName(oItem)+".";
sFail = "The oil is contaminated and unuseable.";
iGlassType=1;
iDifficulty=150;
}
if (sProduct=="INVALID")
{
SendMessageToPC(oPC,"You may not press this object into any form of juice!");
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
object oGlass;
if (iGlassType==0)
{
oGlass = GetItemPossessedBy(oPC,"ITEM_GLASSBOTTLE");
if (oGlass==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You must have an empty glass bottle to collect juices.",oPC,FALSE);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
}
else
{
oGlass = GetItemPossessedBy(oPC,"ITEM_GLASSVIAL");
if (oGlass==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You must have an empty glass vial to extract oils.",oPC,FALSE);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
}
//DestroyObject(oGlass,0.1);
int iCookSkill = GetPersistentInt(oPC,"iCookSkill","UOACraft");
int iCookChance = iCookSkill;
if (iCookChance<350)
{
iCookChance = GetAbilityScore(oPC,ABILITY_WISDOM)*5;
iCookChance = iCookChance+(GetAbilityScore(oPC,ABILITY_DEXTERITY)*3);
iCookChance = iCookChance+(GetAbilityScore(oPC,ABILITY_CHARISMA)*2);
iCookChance = iCookChance*3;
if (iCookChance>350)iCookChance=350;
if (iCookSkill > iCookChance) iCookChance=iCookSkill;
}
SetLocalInt(OBJECT_SELF,"iAmInUse",99);
DelayCommand(6.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0));
DestroyObject(oItem,0.1);
iCookChance = iCookChance-iDifficulty;
if (iCookChance<1)iCookChance=1;
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,6.0));
PlaySound("al_cv_pump");
DelayCommand(1.0,PlaySound("as_na_steamlong2"));
DelayCommand(3.0,PlaySound("al_cv_pump"));
DelayCommand(0.5,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SMOKE_PUFF),lFire));
DelayCommand(2.5,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SMOKE_PUFF),lFire));
DelayCommand(4.5,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SMOKE_PUFF),lFire));
iRandom = Random(1000)+Random(1000)+Random(800);//Adjusted difficulty downwards by a small percent to make lowlevel cooks succeed a bit more.
iRandom = iRandom/3;
if (iRandom<=iCookChance)
{
if (Random(1000) >= iCookSkill)
{
if (d10(1)+1 >= iCookChance/100) iSkillGain = 1;
}
DestroyObject(oGlass,5.1);
DelayCommand(4.5,AssignCommand(oPC,PlaySound("as_na_steamshrt2")));
DelayCommand(5.5,PlaySound("as_na_splash2"));
AssignCommand(GetArea(oPC),DelayCommand(6.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE)));
AssignCommand(GetArea(oPC),DelayCommand(6.1,CreateAnObject(sProduct,oPC)));
}
else
{
AssignCommand(GetArea(oPC),DelayCommand(6.0,FloatingTextStringOnCreature(sFail,oPC,FALSE)));
DelayCommand(4.0,AssignCommand(oPC,PlaySound("as_cv_pipeflush3")));
return;
}
//Ensure no more than 1 skill gain every 10 seconds to avoid token droppage.
if (iSkillGain ==1)
{
if (GetLocalInt(oPC,"iSkillGain")!= 0)
{
iSkillGain = 0;
}
else
{
SetLocalInt(oPC,"iSkillGain",99);
DelayCommand(10.0,SetLocalInt(oPC,"iSkillGain",0));
}
}
if (iSkillGain ==1)
{
string sOldSkill = "";
string sOldSkill2 = "";
iCookSkill++;
sOldSkill2 = IntToString(iCookSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iCookSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iCookSkill <= 1000)
{
//DelayCommand(13.0,SetTokenPair(oPC,13,3,iCookSkill));
DelayCommand(6.5,SetPersistentInt(oPC,"iCookSkill",iCookSkill,0,"UOACraft"));
DelayCommand(6.5,SendMessageToPC(oPC,"=================================="));
DelayCommand(6.5,SendMessageToPC(oPC,"Your skill in cooking has gone up!"));
DelayCommand(6.5,SendMessageToPC(oPC,"Current cooking skill : "+ sOldSkill+"%"));
DelayCommand(6.5,SendMessageToPC(oPC,"=================================="));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(6.4,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
}
void CreateAnObject(string sResource, object oPC)
{
CreateItemOnObject(sResource,oPC,1);
return;
}