#include "nw_i0_plot" void CreateAnObject(string sResource, object oPC, int iStackSize); void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef); void GetNextItemPossessedBy(object oPC, string sItemTag); object CreatePlaceable(string sObject, location lPlace, float fDuration); void main() { object oPC = GetLastDisturbed(); object oSelf = OBJECT_SELF; object oItem = GetInventoryDisturbItem(); string sItemTag = GetTag(oItem); string sTagSelf = GetTag(oSelf); string sItemResRef; int iCookSkill = GetCampaignInt("UOACraft","iCookSkill",oPC); int iCookChance = iCookSkill; int iDifficulty; string sComponent1; string sComponent2; string sComponent3; string sComponent1Name; string sComponent2Name; string sComponent3Name; string sComponentResRef; int iComponent1; int iComponent2; int iComponent3; int iComponent1Stackable; int iComponent2Stackable; int iComponent3Stackable; int iStackSize; int iRandom; int iSkillGain; object oTemp; string sSuccess; string sFail; int iItemStackSize=1; 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; } if (GetInventoryDisturbType()== INVENTORY_DISTURB_TYPE_ADDED) { // 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 bag may be destroyed."); return; } // End of compatability portion. CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); FloatingTextStringOnCreature("You can only cook by selecting a recipe.",oPC,FALSE); return; } if (GetLocalInt(oSelf,"iAmInUse")!=0) { FloatingTextStringOnCreature("You can only cook one thing at a time!",oPC,FALSE); CopyObject(oItem,GetLocation(oSelf),oSelf,GetTag(oItem)); DestroyObject(oItem); return; } int iRecipeNumber = StringToInt(GetStringRight(sItemTag,3)); sItemResRef = "food_"+GetStringRight(sItemTag,3); iComponent1 = 1; iComponent2 = 0; iComponent3 = 0; sSuccess = "The meat cooks to a tender juiciness."; sFail = "You have burned the meat to a crisp!"; switch (iRecipeNumber) { case 1: //BBQ Ancient Dire Bear Meat { iDifficulty = 500; sComponent1 = "MEAT_ANCIENTDIREBEAR"; sComponent1Name = "raw ancient dire bear meat"; break; } case 2: { sComponent1 = "MEAT_BADGER"; sComponent1Name = "raw badger meat"; break; } case 3: { sComponent1 = "MEAT_BAT"; sComponent1Name = "raw bat meat"; break; } case 4: { iDifficulty = 350; sComponent1 = "MEAT_BLACKBEAR"; sComponent1Name = "raw black bear meat"; break; } case 5: { iDifficulty = 400; sComponent1 = "MEAT_BROWNBEAR"; sComponent1Name = "raw brown bear meat"; break; } case 6: { iDifficulty = 350; sComponent1 = "MEAT_COUGAR"; sComponent1Name = "raw cougar meat"; break; } case 7: { sComponent1 = "MEAT_COW"; sComponent1Name = "raw cow meat"; break; } case 8: { sComponent1 = "MEAT_CRAGCAT"; sComponent1Name = "raw crag cat meat"; iDifficulty = 350; break; } case 9: { sComponent1 = "MEAT_DEER"; sComponent1Name = "raw deer meat"; break; } case 10: { sComponent1 = "MEAT_DIREBADGER"; sComponent1Name = "raw dire badger meat"; break; } case 11: { sComponent1 = "MEAT_DIREBEAR"; sComponent1Name = "raw dire bear meat"; iDifficulty = 450; break; } case 12: { sComponent1 = "MEAT_DIRERAT"; sComponent1Name = "raw dire rat meat"; break; } case 13: { sComponent1 = "MEAT_DIRETIGER"; sComponent1Name = "raw dire tiger meat"; iDifficulty = 450; break; } case 14: { sComponent1 = "MEAT_DIREWOLF"; sComponent1Name = "raw dire wolf meat"; iDifficulty = 375; break; } case 15: { sComponent1 = "MEAT_DOG"; sComponent1Name = "raw dog meat"; break; } case 16: { sComponent1 = "MEAT_GRIZZLYBEAR"; sComponent1Name = "raw grizzly bear meat"; iDifficulty = 425; break; } case 17: { sComponent1 = "MEAT_JAGUAR"; sComponent1Name = "raw jaguar meat"; iDifficulty = 350; break; } case 18: { sComponent1 = "MEAT_LEOPARD"; sComponent1Name = "raw leopard meat"; iDifficulty = 375; break; } case 19: { sComponent1 = "MEAT_LION"; sComponent1Name = "raw lion meat"; iDifficulty = 400; break; } case 20: { sComponent1 = "MEAT_MALARPANTHER"; sComponent1Name = "raw malar panther meat"; iDifficulty = 475; break; } case 21: { sComponent1 = "MEAT_OX"; sComponent1Name = "raw ox meat"; break; } case 22: { sComponent1 = "MEAT_PANTHER"; sComponent1Name = "raw panther meat"; iDifficulty = 300; break; } case 23: { sComponent1 = "MEAT_POLARBEAR"; sComponent1Name = "raw polar bear meat"; iDifficulty = 450; break; } case 24: { sComponent1 = "MEAT_RAT"; sComponent1Name = "raw rat meat"; break; } case 25: { sComponent1 = "MEAT_WHITESTAG"; sComponent1Name = "raw white stag meat"; break; } case 26: { sComponent1 = "MEAT_WINTERWOLF"; sComponent1Name = "raw winter wolf meat"; iDifficulty = 400; break; } case 27: { sComponent1 = "MEAT_WOLF"; sComponent1Name = "raw wolf meat"; break; } case 28: { sComponent1 = "MEAT_WORG"; sComponent1Name = "raw worg meat"; iDifficulty = 350; break; } case 29: { iComponent1Stackable=1; sComponent1 = "MEAT_RawFishFillet"; sComponent1Name = "raw fish fillets"; sSuccess = "The fillet cooks to a tender juiciness."; sFail = "You have burned the fillet to a crisp!"; //iDifficulty = ; break; } case 30: { sComponent1 = "MEAT_WOLLYRAZORBACK"; sComponent1Name = "wooly razorback meat"; break; } case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: default: } CopyObject(oItem,GetLocation(oSelf),oSelf,GetTag(oItem)); DestroyObject(oItem); //Check for components if (GetNumItems(oPC,sComponent1) < iComponent1) { FloatingTextStringOnCreature("You do not have enough "+sComponent1Name+" to do this.",oPC,FALSE); return; } if (iComponent2 > 0) { if (GetNumItems(oPC,sComponent2) < iComponent2) { FloatingTextStringOnCreature("You do not have enough "+sComponent2Name+" to do this.",oPC,FALSE); return; } } if (iComponent3 > 0) { if (GetNumItems(oPC,sComponent3) < iComponent3) { FloatingTextStringOnCreature("You do not have enough "+sComponent3Name+" to do this.",oPC,FALSE); return; } } // Remove all components if (iComponent1Stackable != 0) { oTemp = GetItemPossessedBy(oPC,sComponent1); sComponentResRef = GetResRef(oTemp); iStackSize = GetNumStackedItems(oTemp); DestroyObject(oTemp); if (iStackSize < iComponent1) { iComponent1 = iComponent1 - iStackSize; DelayCommand(2.0,GetNextStackedItem(oPC,sComponent1,iComponent1,1,sComponentResRef)); } else { if (iStackSize > iComponent1) { iStackSize = iStackSize - iComponent1; DelayCommand(1.0,CreateAnObject(sComponentResRef,oPC,iStackSize)); } } } else { for (iComponent1; iComponent1>0; iComponent1--) { GetNextItemPossessedBy(oPC,sComponent1); } } if (sComponent2 != "") { if (iComponent2Stackable != 0) { oTemp = GetItemPossessedBy(oPC,sComponent2); sComponentResRef = GetResRef(oTemp); iStackSize = GetNumStackedItems(oTemp); DestroyObject(oTemp); if (iStackSize < iComponent2) { iComponent2 = iComponent2 - iStackSize; DelayCommand(2.0,GetNextStackedItem(oPC,sComponent2,iComponent2,1, sComponentResRef)); } else { if (iStackSize > iComponent2) { iStackSize = iStackSize - iComponent2; DelayCommand(1.0,CreateAnObject(sComponentResRef,oPC,iStackSize)); } } } else { for (iComponent2; iComponent2>0; iComponent2--) { GetNextItemPossessedBy(oPC,sComponent2); } } } if (sComponent3 != "") { if (iComponent3Stackable != 0) { oTemp = GetItemPossessedBy(oPC,sComponent3); sComponentResRef = GetResRef(oTemp); iStackSize = GetNumStackedItems(oTemp); DestroyObject(oTemp); if (iStackSize < iComponent3) { iComponent3 = iComponent3 - iStackSize; DelayCommand(2.0,GetNextStackedItem(oPC,sComponent3,iComponent3,1, sComponentResRef)); } else { if (iStackSize > iComponent3) { iStackSize = iStackSize - iComponent3; DelayCommand(1.0,CreateAnObject(sComponentResRef,oPC,iStackSize)); } } } else { for (iComponent3; iComponent3>0; iComponent3--) { GetNextItemPossessedBy(oPC,sComponent3); } } } SetLocalInt(oSelf,"iAmInUse",99); DelayCommand(15.0,SetLocalInt(oSelf,"iAmInUse",0)); //Assign Animations AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,15.0)); location lSelf = GetLocation(OBJECT_SELF); float fSelf = GetFacing(OBJECT_SELF)+180.0; vector vSelf = GetPosition(OBJECT_SELF); object oArea = GetArea(OBJECT_SELF); vector vFire; int vDirection; location lFire; object oFire; if (GetStringRight(sTagSelf,1)=="1") { vFire = vSelf + (AngleToVector(fSelf) * 0.7); lFire = Location(oArea,vFire,fSelf); oFire = CreatePlaceable("plc_flamemedium", lFire, 14.3); } else { vFire = vSelf + (AngleToVector(fSelf) * 0.1); lFire = Location(oArea,vFire,fSelf); oFire = CreatePlaceable("plc_dustplume", lFire, 14.3); } DelayCommand(2.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_HIT_FIRE,FALSE),GetLocation(oFire),1.0)); DelayCommand(5.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPECIAL_PINK_ORANGE,FALSE),GetLocation(oFire),1.0)); DelayCommand(8.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPECIAL_RED_WHITE,FALSE),GetLocation(oFire),1.0)); DelayCommand(10.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPARKS_PARRY,FALSE),GetLocation(oFire),1.0)); DelayCommand(12.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_HIT_FIRE,FALSE),GetLocation(oFire),1.0)); DelayCommand(14.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_SPECIAL_WHITE_ORANGE,FALSE),GetLocation(oFire),1.0)); switch (StringToInt(GetStringRight(sTagSelf,1))) { case 1: //Oven { PlaySound("al_cv_furnace1"); PlaySound("al_cv_firelarge1"); DelayCommand(4.5,PlaySound("al_cv_furnace1")); DelayCommand(4.5,PlaySound("al_cv_firelarge1")); DelayCommand(9.0,PlaySound("al_cv_furnace1")); DelayCommand(9.0,PlaySound("al_cv_firelarge1")); break; } case 3: //campfire & spit { PlaySound("al_cv_firepit1"); DelayCommand(4.5,PlaySound("al_cv_firepit1")); DelayCommand(9.0,PlaySound("al_cv_firepit1")); break; } case 4: //campfire & pot { PlaySound("al_cv_firecppot1"); DelayCommand(4.5,PlaySound("al_cv_firecppot1")); DelayCommand(9.0,PlaySound("al_cv_firecppot1")); break; } default:// campfire & perma-campfire { PlaySound("al_cv_firecamp1"); DelayCommand(4.5,PlaySound("al_cv_firecamp1")); DelayCommand(9.0,PlaySound("al_cv_firecamp1")); break; } } iCookChance=iCookChance-iDifficulty; if (iCookChance<1)iCookChance=1; 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; } DelayCommand(14.8,PlaySound("as_na_steamshrt2")); AssignCommand(GetArea(oPC),DelayCommand(15.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE))); AssignCommand(GetArea(oPC),DelayCommand(15.1,CreateAnObject(sItemResRef,oPC,iItemStackSize))); } else { DelayCommand(14.8,PlaySound("as_cv_woodbreak3")); AssignCommand(GetArea(oPC),DelayCommand(15.0,FloatingTextStringOnCreature(sFail,oPC,FALSE))); 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(14.5,SetCampaignInt("UOACraft","iCookSkill",iCookSkill,oPC)); DelayCommand(14.5,SendMessageToPC(oPC,"==================================")); DelayCommand(14.5,SendMessageToPC(oPC,"Your skill in cooking has gone up!")); DelayCommand(14.5,SendMessageToPC(oPC,"Current cooking skill : "+ sOldSkill+"%")); DelayCommand(14.5,SendMessageToPC(oPC,"==================================")); if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(14.4,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP"))); } } } void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef) { object oTemp = GetItemPossessedBy(oPC,sItemTag); int iStackCount = GetNumStackedItems(oTemp); int iTemp = iCount - iStackCount; iStackCount = iStackCount-iCount; DestroyObject(oTemp); if (iStackCount > 0) { SendMessageToPC(oPC,"You should get back "+IntToString(iStackCount)); DelayCommand(1.0,CreateAnObject(sStackResRef,oPC,iStackCount)); } // this next line *should* recursively call this function if the number of // stacked items does not meet the required number of items to be destroyed. if (iTemp > 0) DelayCommand(1.0,GetNextStackedItem(oPC,sItemTag,iTemp, iMode, sStackResRef)); return; } void GetNextItemPossessedBy(object oPC, string sItemTag) { object oTemp = GetItemPossessedBy(oPC,sItemTag); DestroyObject(oTemp); return; } void CreateAnObject(string sResource, object oPC, int iStackSize) { CreateItemOnObject(sResource,oPC,iStackSize); return; } object CreatePlaceable(string sObject, location lPlace, float fDuration) { object oPlaceable = CreateObject(OBJECT_TYPE_PLACEABLE,sObject,lPlace,FALSE); if (fDuration != 0.0) DestroyObject(oPlaceable,fDuration); return oPlaceable; }