//#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); 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 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,6) != "CURED_") { CopyItem(oItem,oPC,TRUE); FloatingTextStringOnCreature("You cannot tan this item!",oPC,FALSE); DestroyObject(oItem); return; } //int iTanChance = GetTokenPair(oPC,14,10); int iTanSkill = GetCampaignInt("UOACraft","iTanSkill",oPC); //int iTanSkill = iTanChance; int iTanChance = iTanSkill; int iTanAcid = 1; int iSalt = 1; string sPeltSuccess; string sPeltFail; if (iTanChance <350) { iTanChance = GetAbilityScore(oPC,ABILITY_WISDOM)*3; iTanChance = iTanChance + GetAbilityScore(oPC,ABILITY_INTELLIGENCE) + GetAbilityScore(oPC,ABILITY_DEXTERITY); iTanChance = iTanChance * 6; if (iTanChance >350) iTanChance = 350; if (iTanSkill > iTanChance) iTanChance = iTanSkill; } if (sItemTag == "CURED_TINY") { //iTanChance = iTanChance - 350; //iTanAcid = 3; // remove this sPeltResRef = "tanned001"; sPeltFailResRef = "cured016"; sPeltSuccess = "You carefully tan the tiny cured hide."; sPeltFail = "You fail to tan the tiny cured hide."; } if (sItemTag == "CURED_TINYBLACK") { iTanChance = iTanChance - 50; sPeltResRef = "tanned002"; sPeltFailResRef = "cured017"; sPeltSuccess = "You carefully tan the tiny cured black hide."; sPeltFail = "You fail to tan the tiny cured black hide."; } if (sItemTag == "CURED_TINYWHITE") { iSalt=2; iTanChance = iTanChance - 100; sPeltResRef = "tanned003"; sPeltFailResRef = "cured018"; sPeltSuccess = "You carefully tan the tiny cured white hide."; sPeltFail = "You fail to tan the tiny cured white hide."; } if (sItemTag == "CURED_SMALL") { iSalt = 2; iTanChance = iTanChance - 150; sPeltResRef = "tanned004"; sPeltFailResRef = "cured019"; sPeltSuccess = "You carefully tan the small cured hide."; sPeltFail = "You fail to tan the small cured hide."; } if (sItemTag == "CURED_SMALLBLACK") { iSalt=2; iTanChance = iTanChance - 200; sPeltResRef = "tanned005"; sPeltFailResRef = "cured020"; sPeltSuccess = "You carefully tan the small cured black hide."; sPeltFail = "You fail to tan the small cured black hide."; } if (sItemTag == "CURED_SMALLWHITE") { iSalt=2; iTanAcid=2; iTanChance = iTanChance - 250; sPeltResRef = "tanned006"; sPeltFailResRef = "cured021"; sPeltSuccess = "You carefully tan the small cured white hide."; sPeltFail = "You fail to tan the small cured white hide."; } if (sItemTag == "CURED_MEDIUM") { iTanAcid=2; iSalt=2; iTanChance = iTanChance - 300; sPeltResRef = "tanned007"; sPeltFailResRef = "cured022"; sPeltSuccess = "You carefully tan the medium cured hide."; sPeltFail = "You fail to tan the medium cured hide."; } if (sItemTag == "CURED_MEDIUMBLACK") { iTanAcid=2; iSalt=2; iTanChance = iTanChance - 350; sPeltResRef = "tanned008"; sPeltFailResRef = "cured023"; sPeltSuccess = "You carefully tan the medium cured black hide."; sPeltFail = "You fail to tan the medium cured black hide."; } if (sItemTag == "CURED_MEDIUMWHITE") { iTanAcid=2; iSalt=3; iTanChance = iTanChance - 400; sPeltResRef = "tanned009"; sPeltFailResRef = "cured024"; sPeltSuccess = "You carefully tan the medium cured white hide."; sPeltFail = "You fail to tan the medium cured white hide."; } if (sItemTag == "CURED_LARGE") { iTanAcid=3; iSalt=3; iTanChance = iTanChance - 450; sPeltResRef = "tanned010"; sPeltFailResRef = "cured025"; sPeltSuccess = "You carefully tan the large cured hide."; sPeltFail = "You fail to tan the large cured hide."; } if (sItemTag == "CURED_LARGEBLACK") { iTanAcid=3; iSalt=3; iTanChance = iTanChance - 500; sPeltResRef = "tanned011"; sPeltFailResRef = "cured026"; sPeltSuccess = "You carefully tan the large cured black hide."; sPeltFail = "You fail to tan the large cured black hide."; } if (sItemTag == "CURED_LARGEWHITE") { iTanAcid=3; iSalt=4; iTanChance = iTanChance - 550; sPeltResRef = "tanned012"; sPeltFailResRef = "cured027"; sPeltSuccess = "You carefully tan the large cured white hide."; sPeltFail = "You fail to tan the large cured white hide."; } if (sItemTag == "CURED_XLARGE") { iTanAcid=4; iSalt=4; iTanChance = iTanChance - 600; sPeltResRef = "tanned013"; sPeltFailResRef = "cured028"; sPeltSuccess = "You carefully tan the extra large cured hide."; sPeltFail = "You fail to tan the extra large cured hide."; } if (sItemTag == "CURED_XLARGEBLACK") { iTanAcid=4; iSalt=4; iTanChance = iTanChance - 650; sPeltResRef = "tanned014"; sPeltFailResRef = "cured029"; sPeltSuccess = "You carefully tan the extra large cured black hide."; sPeltFail = "You fail to tan the extra large cured black hide."; } if (sItemTag == "CURED_XLARGEWHITE") { iTanAcid=4; iSalt=4; iTanChance = iTanChance - 700; sPeltResRef = "tanned015"; sPeltFailResRef = "cured030"; sPeltSuccess = "You carefully tan the extra large cured white hide."; sPeltFail = "You fail to tan the extra large cured white hide."; } if (iTanChance < 1) { FloatingTextStringOnCreature("You have no idea how to tan this hide.",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } iTanChance = iTanChance + 200; //<-- ensures more successes. (50% on the hardest) if (GetNumItems(oPC,"ITEM_TANNICACID") < iTanAcid) { FloatingTextStringOnCreature("You do not have enough tannic acid to tan this cured hide.",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } if (GetNumItems(oPC,"ITEM_TANNERSSALT") < iSalt) { FloatingTextStringOnCreature("You do not have enough tanner's salt to tan this cured 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_TANNERSSALT"); DestroyObject(oTemp); oTemp = GetItemPossessedBy(oPC,"ITEM_TANNICACID"); int iTanAcidCount = 0; iTanAcidCount = GetNumStackedItems(oTemp); DestroyObject(oTemp); if (iTanAcidCount iTanAcid) { iTanAcidCount = iTanAcidCount - iTanAcid; SendMessageToPC(oPC,"You should get back "+IntToString(iTanAcidCount)+" tannic acid"); DelayCommand(1.0,CreateAnObject("tannicacid",oPC,iTanAcidCount)); } } if (iSalt>1) DelayCommand(1.0,GetNextItemPossessedBy(oPC,"ITEM_TANNERSSALT")); if (iSalt>2) DelayCommand(3.0,GetNextItemPossessedBy(oPC,"ITEM_TANNERSSALT")); if (iSalt>3) DelayCommand(5.0,GetNextItemPossessedBy(oPC,"ITEM_TANNERSSALT")); // if (iTanAcid>1) DelayCommand(2.0,GetNextItemPossessedBy(oPC,"ITEM_TANNICACID")); // if (iTanAcid>2) DelayCommand(4.0,GetNextItemPossessedBy(oPC,"ITEM_TANNICACID")); // if (iTanAcid>3) DelayCommand(6.0,GetNextItemPossessedBy(oPC,"ITEM_TANNICACID")); AssignCommand(oPC,PlaySound("as_na_splash2")); AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,6.0)); //PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE,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_pipeflush3"))); 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,10,iTanSkill)); DelayCommand(6.0,SetCampaignInt("UOACraft","iTanSkill",iTanSkill,oPC)); DelayCommand(6.0,SendMessageToPC(oPC,"==================================")); DelayCommand(6.0,SendMessageToPC(oPC,"Your skill in tanning has gone up!")); DelayCommand(6.0,SendMessageToPC(oPC,"Current tanning skill : "+ sOldSkill+"%")); DelayCommand(6.0,SendMessageToPC(oPC,"==================================")); if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(5.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP"))); } } } 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) { 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"); DelayCommand(1.0,CreateAnObject("tannicacid",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)); return; }