Aschbourne_PRC8/_module/nss/_craft_lauter.nss

235 lines
6.9 KiB
Plaintext
Raw Permalink Normal View History

2024-06-14 10:48:20 -04:00
void CreateAnObject(string sResource, object oPC, int iProduct);
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 lautering is complete before starting another batch.");
DestroyObject(oItem);
return;
}
string sItemTag = GetTag(oItem);
string sProduct = "INVALID";
int iProduct = 1;
int iDifficulty = 0;
int iRandom;
int iSkillGain;
location lFire = GetLocation(OBJECT_SELF);
string sSuccess = "You have successfully lautered the "+GetName(oItem)+".";
string sFail = "The wort is contaminated with impurities and unuseable.";
if (sItemTag=="item_mash_001") //corn
{
sProduct = "item_wort_001";
iDifficulty=100;
}
if (sItemTag=="item_mash_002") //wheat
{
sProduct = "item_wort_002";
iDifficulty=50;
}
if (sItemTag=="item_mash_003") //rice
{
sProduct = "item_wort_003";
iDifficulty=-100;
}
if (sItemTag=="item_mash_004") //oats
{
sProduct = "item_wort_004";
iDifficulty=-50;
}
if (sItemTag=="item_mash_005") //barley
{
sProduct = "item_wort_005";
iDifficulty=200;
}
if (sItemTag=="item_mash_006") //sorghum
{
sProduct = "item_wort_006";
iDifficulty=50;
}
if (sItemTag=="item_mash_007") //acorn
{
sProduct = "item_wort_007";
iDifficulty=350;
}
if (sProduct=="INVALID")
{
SendMessageToPC(oPC,"You may not lauter this object into any form of wort!");
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
object oWater = GetItemPossessedBy(oPC,"ITEM_BUCKETOFWATER");
if (oWater==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You must have a full bucket of water in order to lauter this mash.",oPC,FALSE);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
DestroyObject(oWater,0.1);
DelayCommand(1.0,CreateAnObject("item001",oPC,1));
object oSugar = GetItemPossessedBy(oPC,"item_syrup_003");
if (oSugar==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You must have some sugar in order to lauter this mash.",oPC,FALSE);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
DestroyObject(oSugar,0.2);
int iBrewSkill = GetCampaignInt("UOACraft","iBrewSkill",oPC);
2024-06-14 10:48:20 -04:00
int iBrewChance = iBrewSkill;
if (iBrewChance<350)
{
iBrewChance = GetAbilityScore(oPC,ABILITY_DEXTERITY)*5;
iBrewChance = iBrewChance+(GetAbilityScore(oPC,ABILITY_WISDOM)*3);
iBrewChance = iBrewChance+(GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*2);
iBrewChance = iBrewChance*3;
if (iBrewChance>350)iBrewChance=350;
if (iBrewSkill > iBrewChance) iBrewChance=iBrewSkill;
}
SetLocalInt(OBJECT_SELF,"iAmInUse",99);
DelayCommand(12.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0));
DestroyObject(oItem,0.1);
iBrewChance = iBrewChance-iDifficulty;
if (iBrewChance<1)iBrewChance=1;
//Play animations for craft process
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,6.0));
AssignCommand(oPC,DelayCommand(6.0,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,3.0)));
AssignCommand(oPC,DelayCommand(9.0,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,3.0)));
DelayCommand(0.1,PlaySound("as_cv_smithwatr1"));
DelayCommand(1.0,PlaySound("al_na_lavapool1"));
DelayCommand(8.0,PlaySound("as_cv_pipegroan3"));
object oTemp = CreateObject(OBJECT_TYPE_PLACEABLE,"plc_dustplume",GetLocation(OBJECT_SELF));
DestroyObject(oTemp,10.5);
AssignCommand(oTemp,DelayCommand(4.0,PlaySound("as_cv_winch1")));
AssignCommand(oTemp,DelayCommand(7.0,PlaySound("as_cv_winch1")));
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<=iBrewChance)
{
if (Random(1000) >= iBrewSkill)
{
if (d10(1)+1 >= iBrewChance/100) iSkillGain = 1;
}
iProduct = 1;
if ((Random(1000)+500)<=iBrewChance) iProduct++;
if (iBrewSkill==1000) iProduct = 2;
DelayCommand(11.0,PlaySound("as_na_splash1"));
AssignCommand(GetArea(oPC),DelayCommand(12.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE)));
AssignCommand(GetArea(oPC),DelayCommand(12.1,CreateAnObject(sProduct,oPC,iProduct)));
}
else
{
AssignCommand(GetArea(oPC),DelayCommand(12.0,FloatingTextStringOnCreature(sFail,oPC,FALSE)));
DelayCommand(10.0,PlaySound("as_cv_sewermisc3"));
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 = "";
iBrewSkill++;
sOldSkill2 = IntToString(iBrewSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iBrewSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iBrewSkill <= 1000)
{
//DelayCommand(13.0,SetTokenPair(oPC,13,3,iBrewSkill));
DelayCommand(12.5,SetCampaignInt("UOACraft","iBrewSkill",iBrewSkill,oPC));
2024-06-14 10:48:20 -04:00
DelayCommand(12.5,SendMessageToPC(oPC,"=================================="));
DelayCommand(12.5,SendMessageToPC(oPC,"Your skill in brewing has gone up!"));
DelayCommand(12.5,SendMessageToPC(oPC,"Current brewing skill : "+ sOldSkill+"%"));
DelayCommand(12.5,SendMessageToPC(oPC,"=================================="));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(12.4,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
}
void CreateAnObject(string sResource, object oPC, int iProduct)
{
CreateItemOnObject(sResource,oPC,1);
iProduct = iProduct - 1;
if (iProduct>0) DelayCommand(0.1,CreateAnObject(sResource,oPC,iProduct));
return;
}