//#include "_persist_01a" void CreateAnObject(string sResource, object oPC, int iStackSize); object CreatePlaceable(string sObject, location lPlace, float fDuration); void main() { object oPC = GetLastDisturbed(); object oItem = GetInventoryDisturbItem(); string sItemTag = GetTag(oItem); if (GetInventoryDisturbType()!= INVENTORY_DISTURB_TYPE_ADDED) { if (sItemTag=="SWITCH_VLOWHEAT") { SetLocalInt(oPC,"iHeat",1); FloatingTextStringOnCreature("Smelting forge is now set to use very low heat.",oPC,FALSE); } if (sItemTag=="SWITCH_LOWHEAT") { SetLocalInt(oPC,"iHeat",2); FloatingTextStringOnCreature("Smelting forge is now set to use low heat.",oPC,FALSE); } if (sItemTag=="SWITCH_MEDIUMHEAT") { SetLocalInt(oPC,"iHeat",3); FloatingTextStringOnCreature("Smelting forge is now set to use normal heat.",oPC,FALSE); } if (sItemTag=="SWITCH_HIGHHEAT") { SetLocalInt(oPC,"iHeat",4); FloatingTextStringOnCreature("Smelting forge is now set to use high heat.",oPC,FALSE); } if (sItemTag=="SWITCH_VHIGHHEAT") { SetLocalInt(oPC,"iHeat",5); FloatingTextStringOnCreature("Smelting forge is now set to use very high heat.",oPC,FALSE); } CopyObject(oItem,GetLocation(oPC),OBJECT_SELF,GetTag(oItem)); DestroyObject(oItem); return; } // 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) { FloatingTextStringOnCreature("You must wait for this batch of ore to finish smelting..",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } string sIngotResRef = ""; int iStackSize = 0; int iMaxStack = 5; string sSuccess = ""; if (GetStringLeft(sItemTag,3) != "ORE") { CopyItem(oItem,oPC,TRUE); FloatingTextStringOnCreature("You cannot smelt this item!",oPC,FALSE); DestroyObject(oItem); return; } //int iSmeltChance = GetTokenPair(oPC,14,2); int iSmeltSkill = GetCampaignInt("UOACraft","iSmeltSkill",oPC); int iSmeltChance = iSmeltSkill; //int iSmeltSkill = iSmeltChance; string sOre; if (iSmeltChance <350) { iSmeltChance = GetAbilityScore(oPC,ABILITY_STRENGTH)*3; iSmeltChance = iSmeltChance + GetAbilityScore(oPC,ABILITY_DEXTERITY) + GetAbilityScore(oPC,ABILITY_WISDOM); iSmeltChance = iSmeltChance * 3; if (iSmeltChance >350) iSmeltChance = 350; if (iSmeltSkill > iSmeltChance) iSmeltChance = iSmeltSkill; } if (sItemTag == "ORE_IRON") { if (iSmeltChance < 250) iSmeltChance = 250; sIngotResRef = "ingot001"; sOre = "Iron"; } if (sItemTag == "ORE_DULL") { if (iSmeltChance <650) iSmeltChance = 0; sIngotResRef = "ingot002"; iSmeltChance = iSmeltChance - 100; sOre = "Dull Copper"; } if (sItemTag == "ORE_SHADOW") { if (iSmeltChance <700) iSmeltChance = 0; sIngotResRef = "ingot003"; iSmeltChance = iSmeltChance - 150; sOre = "Shadow Iron"; } if (sItemTag == "ORE_COPPER") { if (iSmeltChance <750) iSmeltChance = 0; sIngotResRef = "ingot004"; iSmeltChance = iSmeltChance - 200; sOre = "Copper"; } if (sItemTag == "ORE_BRONZE") { if (iSmeltChance <800) iSmeltChance = 0; sIngotResRef = "ingot005"; iSmeltChance = iSmeltChance - 250; sOre = "Bronze"; } if (sItemTag == "ORE_GOLD") { if (iSmeltChance <850) iSmeltChance = 0; sIngotResRef = "ingot006"; iSmeltChance = iSmeltChance - 300; sOre = "Gold"; } if (sItemTag == "ORE_AGAPITE") { if (iSmeltChance <900) iSmeltChance = 0; sIngotResRef = "ingot007"; iSmeltChance = iSmeltChance - 350; sOre = "Agapite"; } if (sItemTag == "ORE_VERITE") { if (iSmeltChance <950) iSmeltChance = 0; sIngotResRef = "ingot008"; iSmeltChance = iSmeltChance - 400; sOre = "Verite"; } if (sItemTag == "ORE_VALORITE") { if (iSmeltChance <990) iSmeltChance = 0; sIngotResRef = "ingot009"; iSmeltChance = iSmeltChance - 450; sOre = "Valorite"; } if (sItemTag == "ORE_SILVER") { if (iSmeltChance <800) iSmeltChance = 0; sIngotResRef = "ingot010"; iSmeltChance = iSmeltChance - 250; sOre = "Silver"; } if (sItemTag == "ORE_MITHRIL") { if (iSmeltChance <950) iSmeltChance = 0; sIngotResRef = "ingot011"; iSmeltChance = iSmeltChance - 400; sOre = "Mithril"; } if (sItemTag == "ORE_ADAMANTITE") { if (iSmeltChance <990) iSmeltChance = 0; sIngotResRef = "ingot012"; iSmeltChance = iSmeltChance - 450; sOre = "Adamantite"; } if (sItemTag == "ORE_PLATINUM") { if (iSmeltChance <900) iSmeltChance = 0; sIngotResRef = "ingot013"; iSmeltChance = iSmeltChance - 350; sOre = "Platinum"; } if (iSmeltChance < 1) { FloatingTextStringOnCreature("You have no idea how to smelt this ore.",oPC,FALSE); CopyItem(oItem,oPC,TRUE); DestroyObject(oItem); return; } string sFlame= ""; int iHeat = GetLocalInt(oPC,"iHeat"); float fAngleToVector = 0.4; switch(iHeat) { case 1: { fAngleToVector = 0.5; iMaxStack = iMaxStack+3; iSmeltChance = iSmeltChance-250; if (iSmeltChance <1) iSmeltChance=1; sFlame = "plc_flamesmall"; break; } case 2: { fAngleToVector = 0.6; iMaxStack = iMaxStack+1; iSmeltChance = iSmeltChance-100; if (iSmeltChance <1) iSmeltChance=1; sFlame = "plc_flamesmall"; break; } case 4: { fAngleToVector = 0.2; iMaxStack = iMaxStack-2; iSmeltChance = iSmeltChance+100; sFlame = "plc_flamelarge"; break; } case 5: { fAngleToVector = 0.3; iMaxStack = iMaxStack -3; iSmeltChance = iSmeltChance+250; sFlame = "plc_flamelarge"; } default: { sFlame = "plc_flamemedium"; break; } } location lSelf = GetLocation(OBJECT_SELF); float fSelf = GetFacing(OBJECT_SELF); vector vSelf = GetPosition(OBJECT_SELF); object oArea = GetArea(OBJECT_SELF); vector vFire; int vDirection; vFire = vSelf + (AngleToVector(fSelf) * fAngleToVector); location lFire = Location(oArea,vFire,fSelf); object oFire = CreatePlaceable(sFlame, lFire, 6.0); AssignCommand(oPC,PlaySound("al_cv_firebowl1")); AssignCommand(oPC,PlaySound("as_cv_mineshovl1")); AssignCommand(oPC,PlaySound("al_na_waterpipe1")); AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,4.0)); PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE,1.0,6.0); SetLocalInt(OBJECT_SELF,"iAmInUse",99); DelayCommand(7.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0)); //ensure at least 1 respawn 10 minutes after used... //this is to prevent a broken placeable that is used, with a 'in use' delay //which would cancel the respawn if (GetLocalInt(OBJECT_SELF,"iAmSetToRespawn")!=99) { SetLocalInt(OBJECT_SELF,"iAmSetToRespawn",99); DelayCommand(600.0,ExecuteScript("_onclose_clear",OBJECT_SELF)); } int iRandom = 0; int iSuccess = 0; int iSkillGain = 0; if (Random(1000) <= iSmeltChance) { iSuccess = 1; iStackSize =1; iMaxStack--; if (iMaxStack >0) { for (iMaxStack; iMaxStack >0; iMaxStack--) { if (Random(1000) <= iSmeltChance) iStackSize++; } } DelayCommand(5.0,AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_TALK_PLEADING,1.0,1.0))); DelayCommand(6.0,CreateAnObject(sIngotResRef,oPC,iStackSize)); sSuccess = "You successfully smelt the ore into "+IntToString(iStackSize)+" "+sOre+" Ingot"; if (iStackSize ==1) { sSuccess = sSuccess+"."; } else { sSuccess = sSuccess+"s."; } DelayCommand(6.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE)); DelayCommand(5.8,PlaySound("as_cv_minepick2")); DelayCommand(6.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_COM_HIT_FIRE,FALSE),OBJECT_SELF,2.0)); } else { DelayCommand(5.0,AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_PAUSE_TIRED,1.0,1.0))); DelayCommand(6.0,FloatingTextStringOnCreature("You burn away the ore and are left with nothing Useful.",oPC,FALSE)); DelayCommand(5.8,PlaySound("as_na_steamshrt2")); DelayCommand(6.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,EffectVisualEffect(VFX_COM_HIT_ACID,FALSE),OBJECT_SELF,2.0)); } DelayCommand(6.0,DestroyObject(oItem)); if (iSuccess == 1) { iRandom = Random(1000); if (iRandom > iSmeltSkill) { if (d10(1)+1 >= iSmeltSkill/100) iSkillGain = 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 = ""; iSmeltSkill++; sOldSkill2 = IntToString(iSmeltSkill); sOldSkill = "."+GetStringRight(sOldSkill2,1); if (iSmeltSkill > 9) { sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill; } else { sOldSkill = "0"+sOldSkill; } if (iSmeltSkill <= 1000) { //DelayCommand(6.0,SetTokenPair(oPC,14,2,iSmeltSkill)); DelayCommand(6.0,SetCampaignInt("UOACraft","iSmeltSkill",iSmeltSkill,oPC)); DelayCommand(6.0,SendMessageToPC(oPC,"===================================")); DelayCommand(6.0,SendMessageToPC(oPC,"Your skill in smelting has gone up!")); DelayCommand(6.0,SendMessageToPC(oPC,"Current smelting skill : "+ sOldSkill+"%")); DelayCommand(6.0,SendMessageToPC(oPC,"===================================")); } } } 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; }