Aschbourne_PRC8/_module/nss/_craft_mash.nss
Jaysyn904 5d27edafba Major update
Fixed CCOH, Fixed starting GP, Fixed DMFI languages, Fix cep weapon appearances, Fixed new player start up system.  Added PC deleter.  Added ACP 4.1.  Full compile.  Updated release archive.
2024-09-16 23:40:48 -04:00

220 lines
6.5 KiB
Plaintext

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 mash is done 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 mashed the "+GetName(oItem)+".";
string sFail = "The mash is contaminated with impurities and unuseable.";
if (sItemTag=="ITEM_MEAL_001") //corn
{
sProduct = "item_mash_001";
iDifficulty=50;
}
if (sItemTag=="ITEM_MEAL_002") //wheat
{
sProduct = "item_mash_002";
iDifficulty=0;
}
if (sItemTag=="ITEM_MEAL_003") //rice
{
sProduct = "item_mash_003";
iDifficulty=-150;
}
if (sItemTag=="ITEM_MEAL_004") //oats
{
sProduct = "item_mash_004";
iDifficulty=-50;
}
if (sItemTag=="ITEM_MEAL_005") //barley
{
sProduct = "item_mash_005";
iDifficulty=50;
}
if (sItemTag=="ITEM_MEAL_006") //sorghum
{
sProduct = "item_mash_006";
iDifficulty=-100;
}
if (sItemTag=="ITEM_MEAL_007") //acorn
{
sProduct = "item_mash_007";
iDifficulty=150;
}
if (sProduct=="INVALID")
{
SendMessageToPC(oPC,"You may only mash grain meal!");
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 mash this meal.",oPC,FALSE);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
int iBrewSkill = GetCampaignInt("UOACraft","iBrewSkill",oPC);
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);
DestroyObject(oWater,0.1);
DelayCommand(1.0,CreateAnObject("item001",oPC,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_na_grassmove1"));
DelayCommand(3.0,PlaySound("as_na_grassmove2"));
DelayCommand(5.0,PlaySound("as_na_grassmove1"));
DelayCommand(8.0,PlaySound("as_na_grassmove2"));
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(1050)<=iBrewChance) iProduct++;
if (Random(1100)<=iBrewChance) iProduct++;
if (Random(1150)<=iBrewChance) iProduct++;
if (Random(1200)<=iBrewChance) iProduct++;
if (iBrewSkill==1000) iProduct = 6;
DelayCommand(10.0,PlaySound("as_cv_smithwatr2"));
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_sewermisc1"));
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));
DelayCommand(12.5,SendMessageToPC(oPC,"=================================="));
DelayCommand(12.5,SendMessageToPC(oPC,"Your skill in nrewing 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;
}