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 current distillation is complete before starting another batch."); DestroyObject(oItem); return; } string sItemTag = GetTag(oItem); string sProduct1 = "INVALID"; string sProduct2; int iProduct = 1; int iDifficulty = 0; int iRandom; int iSkillGain; int iMaxProduce; location lFire = GetLocation(OBJECT_SELF); string sSuccess = "You have successfully distilled the "+GetName(oItem)+"."; string sFail = "The liquid is contaminated with impurities and unuseable."; if (sItemTag=="item_juice_031") //Sugarcane Extract { sProduct1 = "item_syrup_003"; //Sugar sProduct2 = "item_syrup_004"; //Caramel iDifficulty=50; iProduct = GetNumStackedItems(oItem); //Stackable starting product } if (sItemTag=="ITEM_MAPLESAP") //Maple Sap { sProduct1 = "item_syrup_001"; //Maple Syrup sProduct2 = "item_syrup_002"; //Molasses iDifficulty=50; } if (sItemTag=="item_wort_001") //Corn Wort { iMaxProduce=1; sProduct1 = "item_wort_008"; //Distilled Corn Wort iDifficulty=150; } if (sItemTag=="item_wort_008") //Corn Wort { iMaxProduce=1; sProduct1 = "item_wort_009"; //Twice-Distilled Corn Wort iDifficulty=200; } if (sItemTag=="item_wort_009") //Corn Wort { iMaxProduce=1; sProduct1 = "item_wort_010"; //Thrice-Distilled Corn Wort iDifficulty=250; } if (sItemTag=="item_wort_007") //acorn Wort { iMaxProduce=1; sProduct1 = "item_wort_011"; //Distilled acorn Wort iDifficulty=250; } if (sItemTag=="item_wort_011") //acorn Wort { iMaxProduce=1; sProduct1 = "item_wort_012"; //Twice-Distilled acorn Wort iDifficulty=300; } if (sItemTag=="item_wort_012") //acorn Wort { iMaxProduce=1; sProduct1 = "item_wort_013"; //Thrice-Distilled acorn Wort iDifficulty=350; } if (sItemTag=="item_wort_003") //Rice Wort { iMaxProduce=1; sProduct1 = "item_wort_014"; //Distilled Rice Wort iDifficulty=100; } if (sItemTag=="item_wort_014") //Rice Wort { iMaxProduce=1; sProduct1 = "item_wort_015"; //Twice-Distilled Rice Wort iDifficulty=150; } if (sItemTag=="item_wort_015") //Rice Wort { iMaxProduce=1; sProduct1 = "item_wort_016"; //Thrice-Distilled Rice Wort iDifficulty=200; } if (sItemTag=="drink_cup_001") //Cup of Apple Cider { iMaxProduce=1; sProduct1 = "item_juice_041"; //Vinegar iDifficulty=-50; } if (sItemTag=="SEED_POTATO") //Potatoes { iMaxProduce=1; sProduct1 = "item_wort_017"; iDifficulty = 100; } if (sItemTag=="item_wort_017") // { iMaxProduce=1; sProduct1 = "item_wort_018"; iDifficulty = 200; } if (sItemTag=="item_wort_018") // { iMaxProduce=1; sProduct1 = "item_wort_019"; iDifficulty = 300; } if (GetNumStackedItems(oItem)>1) { int iStack = GetNumStackedItems(oItem)-1; CreateAnObject(GetResRef(oItem),oPC,iStack); } if (sProduct1=="INVALID") { SendMessageToPC(oPC,"You may not distill this item!"); 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; PlaySound("as_cv_sewermisc3"); DelayCommand(2.5,PlaySound("al_na_lavapool1")); AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,12.0)); 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 (iMaxProduce>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(sProduct1,oPC,iProduct))); if (sProduct2!="")AssignCommand(GetArea(oPC),DelayCommand(12.2,CreateAnObject(sProduct2,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; }