//#include "_persist_01a" #include "nw_i0_plot" void GetNextItemPossessedBy(object oPC, string sItemTag); object CreatePlaceable(string sObject, location lPlace, float fDuration); void CreateAnObject(string sResource, object oPC, int iStackSize); void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode); void main() { int iUseMode = 0; if (GetInventoryDisturbType()!= INVENTORY_DISTURB_TYPE_ADDED) { iUseMode = 99; if (GetLastDisturbed() == OBJECT_SELF) { DestroyObject(GetInventoryDisturbItem()); return; } } object oPC = GetLastDisturbed(); object oItem = GetInventoryDisturbItem(); if (iUseMode == 0) { // 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. if (GetLocalInt(OBJECT_SELF,"iAmInUse") != 0) { CopyItem(oItem,oPC,TRUE); SendMessageToPC(oPC,"You must wait till the hide in the tanning bath is done before starting another."); DestroyObject(oItem); return; } string sItemTag = GetTag(oItem); string sPeltResRef = ""; string sPeltFailResRef = ""; if (GetStringLeft(sItemTag,7) != "TANNED_") { CopyItem(oItem,oPC,TRUE); FloatingTextStringOnCreature("This item is not a tanned hide!",oPC,FALSE); DestroyObject(oItem); return; } int iTanMode = GetLocalInt(oPC,"iTanningMode"); //int iTanChance = GetTokenPair(oPC,14,11); //int iTanSkill = iTanChance; int iTanSkill = GetCampaignInt("UOACraft","iLeatherSkill",oPC); int iTanChance = iTanSkill; int iTanOil = 1; int iBeeswax = 1; int iKindling =1; string sPeltSuccess; string sPeltFail; if (iTanChance <350) { iTanChance = GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*3; iTanChance = iTanChance + GetAbilityScore(oPC,ABILITY_WISDOM) + GetAbilityScore(oPC,ABILITY_DEXTERITY); iTanChance = iTanChance * 6; if (iTanChance >350) iTanChance = 350; if (iTanSkill > iTanChance) iTanChance = iTanSkill; } string sBaseResRef = ""; string sBaseMessage = ""; string sBaseMessage2 = ""; if (iTanMode !=0) { sBaseResRef = "softleather"; sBaseMessage = "You carefully soften the "; sBaseMessage2 = "You fail to soften the "; } else { sBaseResRef = "hardleather"; sBaseMessage = "You carefully harden the "; sBaseMessage2 = "You fail to harden the "; } if (sItemTag == "TANNED_TINY") { sPeltResRef = sBaseResRef+"001"; sPeltFailResRef = "cured016"; sPeltSuccess = sBaseMessage + "tiny tanned hide."; sPeltFail = sBaseMessage2+"tiny tanned hide."; } if (sItemTag == "TANNED_TINYBLACK") { iTanChance = iTanChance - 50; sPeltResRef = sBaseResRef+"002"; sPeltFailResRef = "cured017"; sPeltSuccess = sBaseMessage + "tiny tanned black hide."; sPeltFail = sBaseMessage2+"tiny tanned black hide."; } if (sItemTag == "TANNED_TINYWHITE") { iTanChance = iTanChance - 100; sPeltResRef = sBaseResRef+"003"; sPeltFailResRef = "cured018"; sPeltSuccess = sBaseMessage + "tiny tanned white hide."; sPeltFail = sBaseMessage2+"tiny tanned white hide."; } if (sItemTag == "TANNED_SMALL") { iTanChance = iTanChance - 150; sPeltResRef = sBaseResRef+"004"; sPeltFailResRef = "cured019"; sPeltSuccess = sBaseMessage + "small tanned hide."; sPeltFail = sBaseMessage2+"small tanned hide."; } if (sItemTag == "TANNED_SMALLBLACK") { iTanChance = iTanChance - 200; sPeltResRef = sBaseResRef+"005"; sPeltFailResRef = "cured020"; sPeltSuccess = sBaseMessage + "small tanned black hide."; sPeltFail = sBaseMessage2+"small tanned black hide."; } if (sItemTag == "TANNED_SMALLWHITE") { iTanChance = iTanChance - 250; sPeltResRef = sBaseResRef+"006"; sPeltFailResRef = "cured021"; sPeltSuccess = sBaseMessage + "small tanned white hide."; sPeltFail = sBaseMessage2+"small tanned white hide."; } if (sItemTag == "TANNED_MEDIUM") { iTanChance = iTanChance - 300; iTanOil = 2; iBeeswax = 2; sPeltResRef = sBaseResRef+"007"; sPeltFailResRef = "cured022"; sPeltSuccess = sBaseMessage + "medium tanned hide."; sPeltFail = sBaseMessage2+"medium tanned hide."; } if (sItemTag == "TANNED_MEDIUMBLACK") { iTanChance = iTanChance - 350; iTanOil = 2; iBeeswax = 2; sPeltResRef = sBaseResRef+"008"; sPeltFailResRef = "cured023"; sPeltSuccess = sBaseMessage + "medium tanned black hide."; sPeltFail = sBaseMessage2+"medium tanned black hide."; } if (sItemTag == "TANNED_MEDIUMWHITE") { iTanChance = iTanChance - 400; iTanOil = 2; iBeeswax = 2; sPeltResRef = sBaseResRef+"009"; sPeltFailResRef = "cured024"; sPeltSuccess = sBaseMessage + "medium tanned white hide."; sPeltFail = sBaseMessage2+"medium tanned white hide."; } if (sItemTag == "TANNED_LARGE") { iTanChance = iTanChance - 450; iTanOil = 3; iBeeswax = 3; iKindling = 2; sPeltResRef = sBaseResRef+"010"; sPeltFailResRef = "cured025"; sPeltSuccess = sBaseMessage + "large tanned hide."; sPeltFail = sBaseMessage2+"large tanned hide."; } if (sItemTag == "TANNED_LARGEBLACK") { iTanChance = iTanChance - 500; iTanOil = 3; iBeeswax = 3; iKindling = 2; sPeltResRef = sBaseResRef+"011"; sPeltFailResRef = "cured026"; sPeltSuccess = sBaseMessage + "large tanned black hide."; sPeltFail = sBaseMessage2+"large tanned black hide."; } if (sItemTag == "TANNED_LARGEWHITE") { iTanChance = iTanChance - 550; iTanOil = 3; iBeeswax = 3; iKindling = 2; sPeltResRef = sBaseResRef+"012"; sPeltFailResRef = "cured027"; sPeltSuccess = sBaseMessage + "large tanned white hide."; sPeltFail = sBaseMessage2+"large tanned white hide."; } if (sItemTag == "TANNED_XLARGE") { iTanChance = iTanChance - 600; iTanOil = 4; iBeeswax = 4; iKindling = 2; sPeltResRef = sBaseResRef+"013"; sPeltFailResRef = "cured028"; sPeltSuccess = sBaseMessage + "extra large tanned hide."; sPeltFail = sBaseMessage2+"extra large tanned hide."; } if (sItemTag == "TANNED_XLARGEBLACK") { iTanChance = iTanChance - 650; iTanOil = 4; iBeeswax = 4; iKindling = 2; sPeltResRef = sBaseResRef+"014"; sPeltFailResRef = "cured029"; sPeltSuccess = sBaseMessage + "extra large tanned black hide."; sPeltFail = sBaseMessage2+"extra large tanned black hide."; } if (sItemTag == "TANNED_XLARGEWHITE") { iTanChance = iTanChance - 700; iTanOil = 4; iBeeswax = 4; iKindling = 2; sPeltResRef = sBaseResRef+"015"; sPeltFailResRef = "cured030"; sPeltSuccess = sBaseMessage + "extra large tanned white hide."; sPeltFail = sBaseMessage2+"extra large tanned white hide."; } if (iTanChance < 1) { FloatingTextStringOnCreature("You have no idea how to work this hide.",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } iTanChance = iTanChance + 200; //<-- ensures more successes. (50% on the hardest) if (iTanMode != 0) { if (GetNumItems(oPC,"ITEM_TANNINGOIL") < iTanOil) { FloatingTextStringOnCreature("You do not have enough tanning oil to soften this tanned hide.",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } } if (iTanMode == 0) { if (GetNumItems(oPC,"ITEM_BEESWAX") < iBeeswax) { FloatingTextStringOnCreature("You do not have enough beeswax to harden this tanned hide.",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } } if (GetNumItems(oPC,"ITEM_KINDLING") < iKindling) { FloatingTextStringOnCreature("You do not have enough kindling to work this tanned hide.",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } SetLocalInt(OBJECT_SELF,"iAmInUse",99); DelayCommand(8.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0)); object oTemp = OBJECT_INVALID; oTemp = GetItemPossessedBy(oPC,"ITEM_KINDLING"); DestroyObject(oTemp); if (iKindling>1) DelayCommand(4.0,GetNextItemPossessedBy(oPC,"ITEM_KINDLING")); if (iKindling>2) DelayCommand(5.0,GetNextItemPossessedBy(oPC,"ITEM_KINDLING")); if (iKindling>3) DelayCommand(6.0,GetNextItemPossessedBy(oPC,"ITEM_KINDLING")); int iStackSize = 0; if (iTanMode == 0) { oTemp = GetItemPossessedBy(oPC,"ITEM_BEESWAX"); iStackSize = GetNumStackedItems(oTemp); DestroyObject(oTemp); if (iStackSize < iBeeswax) { iBeeswax = iBeeswax - iStackSize; DelayCommand(2.0,GetNextStackedItem(oPC,"ITEM_BEESWAX",iBeeswax,1)); } else { if (iStackSize > iBeeswax) { iStackSize = iStackSize - iBeeswax; DelayCommand(1.0,CreateAnObject("beeswax",oPC,iStackSize)); } } } else { oTemp = GetItemPossessedBy(oPC,"ITEM_TANNINGOIL"); iStackSize = GetNumStackedItems(oTemp); DestroyObject(oTemp); if (iStackSize < iTanOil) { iTanOil = iTanOil - iStackSize; DelayCommand(2.0,GetNextStackedItem(oPC,"ITEM_TANNINGOIL",iTanOil,99)); } else { if (iStackSize > iTanOil) { iStackSize = iStackSize - iTanOil; DelayCommand(1.0,CreateAnObject("tanningoil",oPC,iStackSize)); } } } AssignCommand(oPC,PlaySound("as_na_splash2")); AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,6.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; vFire = vSelf + (AngleToVector(fSelf) * 0.5); location lFire = Location(oArea,vFire,fSelf); object oFire = CreatePlaceable("plc_dustplume", lFire, 6.0); AssignCommand(oFire,DelayCommand(2.0,PlaySound("as_cv_smithbelo1"))); AssignCommand(oFire,DelayCommand(3.0,PlaySound("as_cv_smithbelo1"))); AssignCommand(oFire,DelayCommand(4.0,PlaySound("as_cv_smithbelo1"))); AssignCommand(oFire,DelayCommand(5.0,PlaySound("as_cv_smithbelo1"))); DelayCommand(3.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SMOKE_PUFF,FALSE),GetLocation(oFire),6.0)); AssignCommand(oFire,PlaySound("as_na_steamlong1")); int iRandom = Random(1000); int iSuccess = 0; int iSkillGain = 0; if (iRandom < iTanChance) { iSuccess = 1; } DelayCommand(6.0,DestroyObject(oItem)); if (iSuccess == 1) { DelayCommand(6.0,FloatingTextStringOnCreature(sPeltSuccess,oPC,FALSE)); DelayCommand(6.0,CreateAnObject(sPeltResRef,oPC,1)); iRandom = Random(1000); if (iRandom >= iTanSkill) { if (d10(1)+1 >= iTanChance/100) iSkillGain = 1; } } else { DelayCommand(6.0,FloatingTextStringOnCreature(sPeltFail,oPC,FALSE)); if (Random(1000) <= iTanSkill) { DelayCommand(7.0,FloatingTextStringOnCreature("You manage to recover the ruined hide....",oPC,FALSE)); DelayCommand(7.0,CreateAnObject(sPeltFailResRef,oPC,1)); } } //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 = ""; iTanSkill++; sOldSkill2 = IntToString(iTanSkill); sOldSkill = "."+GetStringRight(sOldSkill2,1); if (iTanSkill > 9) { sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill; } else { sOldSkill = "0"+sOldSkill; } if (iTanSkill <= 1000) { //DelayCommand(6.0,SetTokenPair(oPC,14,11,iTanSkill)); DelayCommand(6.0,SetCampaignInt("UOACraft","iLeatherSkill",iTanSkill,oPC)); DelayCommand(6.0,SendMessageToPC(oPC,"=========================================")); DelayCommand(6.0,SendMessageToPC(oPC,"Your skill in leatherworking has gone up!")); DelayCommand(6.0,SendMessageToPC(oPC,"Current leatherworking skill : "+ sOldSkill+"%")); DelayCommand(6.0,SendMessageToPC(oPC,"=========================================")); if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(5.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP"))); } } } // end of iUseMode = 0 (added item to inventory) section if (iUseMode == 99) { if (GetTag(oItem) == "SWITCH_HARDEN") { SetLocalInt(oPC,"iTanningMode",0); FloatingTextStringOnCreature("Switching to 'Harden Leather' Mode...",oPC,FALSE); } if (GetTag(oItem) == "SWITCH_SOFTEN") { SetLocalInt(oPC,"iTanningMode",99); FloatingTextStringOnCreature("Switching to 'Soften Leather' Mode...",oPC,FALSE); } DestroyObject(oItem); } } void CreateAnObject(string sResource, object oPC, int iStackSize) { CreateItemOnObject(sResource,oPC,iStackSize); return; } void GetNextItemPossessedBy(object oPC, string sItemTag) { object oTemp = GetItemPossessedBy(oPC,sItemTag); DestroyObject(oTemp); 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; } void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode) { 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)+" tannic acid"); if (iMode == 1) { DelayCommand(1.0,CreateAnObject("beeswax",oPC,iStackCount)); } else { DelayCommand(1.0,CreateAnObject("tanningoil",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)); return; }