Aschbourne_PRC8/_module/nss/_craft_tink.nss
Jaysyn904 5d27edafba Major update
Fixed CCOH, Fixed starting GP, Fixed DMFI languages, Fix cep weapon appearances, Fixed new player start up system.  Added PC deleter.  Added ACP 4.1.  Full compile.  Updated release archive.
2024-09-16 23:40:48 -04:00

868 lines
31 KiB
Plaintext

//#include "_persist_01a"
#include "nw_i0_plot"
void CreateAnObject(string sResource, object oPC, int iStackCount);
object CreatePlaceable(string sObject, location lPlace, float fDuration);
void GetNextItemPossessedBy(object oPC, string sItemTag);
void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef);
void main()
{
int iAdded = 0;
if (GetInventoryDisturbType()!= INVENTORY_DISTURB_TYPE_REMOVED) iAdded =99;
object oTemp = OBJECT_INVALID;
object oSelf = OBJECT_SELF;
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
string sItem = GetTag(oItem);
string sItemResRef = GetResRef(oItem);
int iHaveAllParts = 0;
int iInvalidItem = 0;
object oTool = GetItemPossessedBy(oPC,"TinkersToolset");
int iToolUsed = GetLocalInt(oPC,"iToolWillBreak");
string sComponent1 = "";
string sComponent2 = "";
string sComponent3 = "";
string sComponent1Name = "";
string sComponent2Name = "";
string sComponent3Name = "";
string sComponentResRef = "";
int iComponent1 = 1; // assumes at least 1 resource is needed
int iComponent2 = 0;
int iComponent3 = 0;
int iComponent1Stackable = 1; // assumes ingots, which are stackable
int iComponent2Stackable = 0;
int iComponent3Stackable = 0;
int iStackSize = 0;
int iFailStackable = 0;
string sCraft = "";
string sSuccessString = "";
string sFailString = "";
string sSoundSuccess = "";
string sSoundFail = "";
effect eSuccess;
effect eFail;
int iFillWithThis = GetLocalInt(oPC,"iFillWithThis");
int iSuccessAnimation = 0;
int iFailAnimation = 0;
int iStackCount =1;
int iStackable = 0; //Stackable finished product
int iComponent1Needed; //Number of glass arrowheads dropped into station to fill
int iComponent1Max; //Number of vials of potion PC has to fill glass items with
int iTemp;
int iCount1;
int iCount2;
int iCount3;
string sItem1ResRef;
string sItem2ResRef;
string sItem3ResRef;
float fDelay;
// 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 (iAdded == 99)
{
int iValid = 0;
if (sItem=="GLASS_ARROWHEAD_POOR") iValid=99;
if (sItem=="GLASS_ARROWHEAD_NORMAL") iValid=99;
if (sItem=="GLASS_ARROWHEAD_EXCEPTIONAL") iValid=99;
if (sItem=="GLASS_BOLTTIP_POOR") iValid=99;
if (sItem=="GLASS_BOLTTIP_NORMAL") iValid=99;
if (sItem=="GLASS_BOLTTIP_EXCEPTIONAL") iValid=99;
if (iValid==0)
{
FloatingTextStringOnCreature("This is not a glass projectile!",oPC,FALSE);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
}
if (iAdded==0) //immediately copy/destroy the token object
{
CopyObject(oItem,GetLocation(oSelf),oSelf,GetTag(oItem));
DestroyObject(oItem);
}
//Check for Switch/Selector activation (Fill with acid, etc)
if (GetStringLeft(sItemResRef,10)=="flagswitch")
{
string sFillMessage;
if (sItem=="SWITCH_WEAKACID")
{
SetLocalInt(oPC,"iFillWithThis",0); //Fill With Weak Acid
sFillMessage = "Now prepared to fill containers with weak acid";
}
if (sItem=="SWITCH_MODERATEACID")
{
SetLocalInt(oPC,"iFillWithThis",1); //Fill With Moderate Acid
sFillMessage = "Now prepared to fill containers with moderate acid";
}
if (sItem=="SWITCH_STRONGACID")
{
SetLocalInt(oPC,"iFillWithThis",2); //Fill With Strong Acid
sFillMessage = "Now prepared to fill containers with strong acid";
}
if (sItem=="SWITCH_VERYSTRONGACID")
{
SetLocalInt(oPC,"iFillWithThis",3); //Fill With Very Strong Acid
sFillMessage = "Now prepared to fill containers with very strong acid";
}
FloatingTextStringOnCreature(sFillMessage,oPC,FALSE);
return;
}
//check for tool
if (oTool==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You do not have any tools to work with..",oPC,FALSE);
if (iAdded==99)
{
CopyItem(oItem,oPC,TRUE); //Return stackable PC dropped into table
DestroyObject(oItem);
}
return;
}
//Check for 'in use'
if (GetLocalInt(oSelf,"iAmInUse")!=0)
{
FloatingTextStringOnCreature("Only one item at a time may be tinkered here..",oPC,FALSE);
if (iAdded==99)
{
CopyItem(oItem,oPC,TRUE); //Return stackable PC dropped into table
DelayCommand(0.1,DestroyObject(oItem));
}
return;
}
SetLocalInt(oSelf,"iAmInUse",99);
DelayCommand(7.0,SetLocalInt(oSelf,"iAmInUse",0));
//int iGlassSkill = GetTokenPair(oPC,14,5);
int iGlassSkill = GetCampaignInt("UOACraft","iTinkerSkill",oPC);
int iGlassChance = iGlassSkill;
if (iGlassChance <350)
{
iGlassChance = GetAbilityScore(oPC,ABILITY_DEXTERITY)*5;
iGlassChance = iGlassChance+(GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*3);
iGlassChance = iGlassChance+(GetAbilityScore(oPC,ABILITY_STRENGTH)*2);
iGlassChance = iGlassChance *3;
if (iGlassChance > 350) iGlassChance = 350;
if (iGlassSkill > iGlassChance) iGlassChance = iGlassSkill;
}
if (iAdded==0)
{
if (GetStringRight(sItemResRef,3)=="001") // Tinkers toolkit
{
iComponent1 =2;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
sCraft = "tinkerstoolset";
sSuccessString = "You successfully create a new tinker toolset.";
sFailString = "Your measurements are off and as a result the toolset is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="008") //shovel
{
iComponent1 =4;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 50;
sCraft = "shovel";
sSuccessString = "You successfully create a new shovel.";
sFailString = "The measurements are off and as a result the shovel is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="005") // sewing kit
{
iComponent1 =3;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 10;
sCraft = "sewingkit";
sSuccessString = "You successfully create a tailor's sewing kit.";
sFailString = "Your measurements are off and as a result the sewing kit is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="006") // miners pick
{
iComponent1 =4;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 50;
sCraft = "minerspick";
sSuccessString = "You successfully create a new miner's pick.";
sFailString = "The measurements are off and as a result the miner's pick is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="007") // miners pickaxe
{
iComponent1 =4;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 50;
sCraft = "minerspickaxe";
sSuccessString = "You successfully create a new miner's pickaxe.";
sFailString = "The measurements are off and as a result the miner's pickaxe is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="009") // woodcutters axe
{
iComponent1 =5;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 250;
sCraft = "woodsmansaxe";
sSuccessString = "You successfully create a new woodcutting axe.";
sFailString = "The measurements are off and as a result the axe is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="012") // herbalist knife
{
iComponent1 =3;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 20;
sCraft = "herbalistsknife";
sSuccessString = "You successfully create a new herbalist's knife.";
sFailString = "The measurements are off and as a result the knife is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="079") // Orchard Blade
{
iComponent1 =5;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 250;
sCraft = "orchardblade";
sSuccessString = "You successfully create a new orchard blade..";
sFailString = "The measurements are off and as a result the blade is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="080") // Fillet Knife
{
iComponent1 =3;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 300;
sCraft = "filletknife";
sSuccessString = "You successfully create a new fillet knife..";
sFailString = "The measurements are off and as a result the knife is unuseable.";
}
if (GetStringRight(sItemResRef,3)=="081") // Glass Arrowhead
{
//iComponent1Stackable=0;
iStackable=1;
iComponent1 =5;
sComponent1 = "INGOT_GLASS";
sComponent1Name = "glass ingots";
iComponent2 =1;
sComponent2 = "ITEM_SMALLCASTMOLD";
sComponent2Name = "small cast molds";
iGlassChance = iGlassChance - 500;
sCraft = "glassarrowhea";
iTemp = 50; //50 max stack
sFailString = "The measurements are off and as a result the arrowheads shatter.";
}
if (GetStringRight(sItemResRef,3)=="082") // Glass Bolt Tip
{
//iComponent1Stackable=0;
iStackable=1;
iComponent1 =5;
sComponent1 = "INGOT_GLASS";
sComponent1Name = "glass ingots";
iComponent2 =1;
sComponent2 = "ITEM_SMALLCASTMOLD";
sComponent2Name = "small cast molds";
iGlassChance = iGlassChance - 500;
sCraft = "glassbolttip";
iTemp = 50; //50 max stack
sFailString = "The measurements are off and as a result the bolt tips shatter.";
}
if (GetStringRight(sItemResRef,3)=="083") // Glass Sling Bullets
{
//iComponent1Stackable=0;
iStackable=1;
iComponent1 =10;
sComponent1 = "INGOT_GLASS";
sComponent1Name = "glass ingots";
iComponent2 =1;
sComponent2 = "ITEM_SMALLCASTMOLD";
sComponent2Name = "small cast molds";
iGlassChance = iGlassChance - 600;
sCraft = "glassbullet";
iTemp = 99; //50 max stack
sFailString = "The measurements are off and as a result the glass bullets shatter.";
}
if (GetStringRight(sItemResRef,3)=="089") // Excavation Tools
{
//iComponent1Stackable=0;
//iStackable=1;
iComponent1 =6;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
iGlassChance = iGlassChance - 400;
sCraft = "item_excavation";
sFailString = "The measurements are off and as a result the excavation tools are useless.";
}
if (GetStringRight(sItemResRef,3)=="112") // Carpenters Tools
{
//iComponent1Stackable=0;
//iStackable=1;
iComponent1 =4;
sComponent1 = "INGOT_IRON";
sComponent1Name = "iron ingots";
//iGlassChance = iGlassChance - 400;
sCraft = "carpenters_tools";
sFailString = "The measurements are off and as a result the carpenters tools are useless.";
}
}
if (iAdded==99) //fill containers
{
//if (sItem=="GLASS_ARROWHEAD_POOR") iValid=99;
//if (sItem=="GLASS_ARROWHEAD_NORMAL") iValid=99;
//if (sItem=="GLASS_ARROWHEAD_EXCEPTIONAL") iValid=99;
//if (sItem=="GLASS_BOLTTIP_POOR") iValid=99;
//if (sItem=="GLASS_BOLTTIP_NORMAL") iValid=99;
//if (sItem=="GLASS_BOLTTIP_EXCEPTIONAL") iValid=99;
if (iFillWithThis==0)
{
if (sItem=="GLASS_ARROWHEAD_POOR") sCraft="glassarrowhea004";
if (sItem=="GLASS_ARROWHEAD_NORMAL") sCraft="glassarrowhea005";
if (sItem=="GLASS_ARROWHEAD_EXCEPTIONAL") sCraft="glassarrowhea006";
if (sItem=="GLASS_BOLTTIP_POOR") sCraft="glassbolttip004";
if (sItem=="GLASS_BOLTTIP_NORMAL") sCraft="glassbolttip005";
if (sItem=="GLASS_BOLTTIP_EXCEPTIONAL") sCraft="glassbolttip006";
if (sItem=="GLASS_BULLET_POOR") sCraft = "acidbullet001";
if (sItem=="GLASS_BULLET_NORMAL") sCraft = "acidbullet002";
if (sItem=="GLASS_BULLET_EXCEPTIONAL") sCraft = "acidbullet003";
if (GetStringLeft(sItem,13)=="GLASS_BULLET_") iGlassChance = iGlassChance - 200;
sComponent1="ACID_WEAK";
sComponent1Name = "weak acid";
if (iGlassChance<1) iGlassChance=1;
}
if (iFillWithThis==1)
{
if (sItem=="GLASS_ARROWHEAD_POOR") sCraft="glassarrowhea007";
if (sItem=="GLASS_ARROWHEAD_NORMAL") sCraft="glassarrowhea008";
if (sItem=="GLASS_ARROWHEAD_EXCEPTIONAL") sCraft="glassarrowhea009";
if (sItem=="GLASS_BOLTTIP_POOR") sCraft="glassbolttip007";
if (sItem=="GLASS_BOLTTIP_NORMAL") sCraft="glassbolttip008";
if (sItem=="GLASS_BOLTTIP_EXCEPTIONAL") sCraft="glassbolttip009";
if (sItem=="GLASS_BULLET_POOR") sCraft = "acidbullet004";
if (sItem=="GLASS_BULLET_NORMAL") sCraft = "acidbullet005";
if (sItem=="GLASS_BULLET_EXCEPTIONAL") sCraft = "acidbullet006";
if (GetStringLeft(sItem,13)=="GLASS_BULLET_") iGlassChance = iGlassChance - 200;
sComponent1="ACID_MODERATE";
sComponent1Name = "moderate acid";
iGlassChance=iGlassChance-100;
if (iGlassChance<1) iGlassChance=1;
}
if (iFillWithThis==2)
{
if (sItem=="GLASS_ARROWHEAD_POOR") sCraft="glassarrowhea010";
if (sItem=="GLASS_ARROWHEAD_NORMAL") sCraft="glassarrowhea011";
if (sItem=="GLASS_ARROWHEAD_EXCEPTIONAL") sCraft="glassarrowhea012";
if (sItem=="GLASS_BOLTTIP_POOR") sCraft="glassbolttip010";
if (sItem=="GLASS_BOLTTIP_NORMAL") sCraft="glassbolttip011";
if (sItem=="GLASS_BOLTTIP_EXCEPTIONAL") sCraft="glassbolttip012";
if (sItem=="GLASS_BULLET_POOR") sCraft = "acidbullet007";
if (sItem=="GLASS_BULLET_NORMAL") sCraft = "acidbullet008";
if (sItem=="GLASS_BULLET_EXCEPTIONAL") sCraft = "acidbullet009";
if (GetStringLeft(sItem,13)=="GLASS_BULLET_") iGlassChance = iGlassChance - 200;
sComponent1="ACID_STRONG";
sComponent1Name = "strong acid";
iGlassChance=iGlassChance-250;
if (iGlassChance<1) iGlassChance=1;
}
if (iFillWithThis==3)
{
if (sItem=="GLASS_ARROWHEAD_POOR") sCraft="glassarrowhea013";
if (sItem=="GLASS_ARROWHEAD_NORMAL") sCraft="glassarrowhea014";
if (sItem=="GLASS_ARROWHEAD_EXCEPTIONAL") sCraft="glassarrowhea015";
if (sItem=="GLASS_BOLTTIP_POOR") sCraft="glassbolttip013";
if (sItem=="GLASS_BOLTTIP_NORMAL") sCraft="glassbolttip014";
if (sItem=="GLASS_BOLTTIP_EXCEPTIONAL") sCraft="glassbolttip015";
if (sItem=="GLASS_BULLET_POOR") sCraft = "acidbullet010";
if (sItem=="GLASS_BULLET_NORMAL") sCraft = "acidbullet011";
if (sItem=="GLASS_BULLET_EXCEPTIONAL") sCraft = "acidbullet012";
iGlassChance=iGlassChance-500;
if (GetStringLeft(sItem,13)=="GLASS_BULLET_") iGlassChance = iGlassChance - 200;
sComponent1="ACID_VERYSTRONG";
sComponent1Name = "very strong acid";
if (iGlassChance<1) iGlassChance=1;
}
iComponent1Needed = GetNumStackedItems(oItem);
//This is inside the 'dropped a stack inside the tinker station' section
//And has no bearing on the glass ingot crash
object oItem2 = GetItemPossessedBy(OBJECT_SELF,GetTag(oItem)); //This ensures accurate count of a split stack
iComponent1Needed = GetNumStackedItems(oItem2);
if (iComponent1Needed==0)
{
SendMessageToPC(oPC,"An error has occured in trying to determine the number of stacked items placed into the lathe.");
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
return;
}
iComponent1Max = GetNumItems(oPC,sComponent1);
if (iComponent1Needed>iComponent1Max)
{
iComponent1 = iComponent1Max; //Limit to number of potions
iTemp = iComponent1Max; //Limit end product to number of potions
iComponent1Needed = iComponent1Needed - iComponent1Max; //determine how many to return to player
CreateAnObject(sItemResRef,oPC,iComponent1Needed); //return unneeded tips to player (Not nuff pots to fill them)
sSuccessString = "You only have enough "+sComponent1Name+" to fill "+IntToString(iComponent1)+" "+GetName(oItem);
FloatingTextStringOnCreature(sSuccessString,oPC,FALSE);
}
else
{
iComponent1 = iComponent1Needed; //Limit to number of arrowheads/bolt tips/etc
iTemp = iComponent1;
}
//if PC has no materials to work with then return the dropped stackable from the container tot he PC
if (iComponent1Max==0)
{
FloatingTextStringOnCreature("You do not have any "+sComponent1Name+" left to use.",oPC,1);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
return;
}
//Do not check for finished quality of stacked items manufactured
//(i.e. check success/fail on each only.. cos we are working only on
// 1 quality of stacked item here.. filling poor quality glass arrowheads, for example)
//instead of manufacturing poor/normal/exceptional quality empty arrowheads
iStackable=2;
}
//***************************code should be ok to here*************************
//inserted stackable resource commands here
// this section searches for and destroys stacked resources called for by the pattern selected
//WriteTimestampedLogEntry("Begin Search for components");
if (GetNumItems(oPC,sComponent1) < iComponent1)
{
//WriteTimestampedLogEntry("Too Few Components for component 1");
FloatingTextStringOnCreature("You do not have enough "+sComponent1Name+" to do this.",oPC,FALSE);
//these 2 lines of code look like the crashing event
if (iAdded==99)
{
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
}
//------
return;
}
//WriteTimestampedLogEntry("Component1 check successful");
if (iComponent2 > 0)
{
if (GetNumItems(oPC,sComponent2) < iComponent2)
{
//WriteTimestampedLogEntry("Too few components for component 2");
FloatingTextStringOnCreature("You do not have enough "+sComponent2Name+" to do this.",oPC,FALSE);
if (iAdded==99)
{
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
}
return;
}
}
//WriteTimestampedLogEntry("Component 2 check successful");
if (iComponent3 > 0)
{
if (GetNumItems(oPC,sComponent3) < iComponent3)
{
FloatingTextStringOnCreature("You do not have enough "+sComponent3Name+" to do this.",oPC,FALSE);
if (iAdded==99)
{
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
}
return;
}
}
fDelay=0.1;
if (iComponent1Stackable != 0)
{
//WriteTimestampedLogEntry("Begin Component 1 destruction");
oTemp = GetItemPossessedBy(oPC,sComponent1);
//WriteTimestampedLogEntry("GetItemPossessedBy successful");
if (oTemp==OBJECT_INVALID)
{
SendMessageToPC(oPC,"ERROR -- Locating components for destruction.");
return;
}
sComponentResRef = GetResRef(oTemp);
iStackSize = GetNumStackedItems(oTemp);
//WriteTimestampedLogEntry("Destroying object");
DestroyObject(oTemp);
//WriteTimestampedLogEntry("Destroyed Object - Successful");
if (iStackSize < iComponent1)
{
iComponent1 = iComponent1 - iStackSize;
DelayCommand(2.0,GetNextStackedItem(oPC,sComponent1,iComponent1,1,sComponentResRef));
}
else
{
if (iStackSize > iComponent1)
{
//WriteTimestampedLogEntry("Returning unused stack");
iStackSize = iStackSize - iComponent1;
DelayCommand(1.0,CreateAnObject(sComponentResRef,oPC,iStackSize));
}
}
}
else
{
for (iComponent1; iComponent1>0; iComponent1--)
{
//WriteTimestampedLogEntry("Destroying Non-Stacked items (inside loop)");
fDelay = fDelay+0.5;
DelayCommand(fDelay,GetNextItemPossessedBy(oPC,sComponent1));
}
}
//WriteTimestampedLogEntry("Component 1 completed");
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--)
{
fDelay = fDelay+0.5;
DelayCommand(fDelay,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--)
{
fDelay = fDelay+0.5;
DelayCommand(fDelay,GetNextItemPossessedBy(oPC,sComponent3));
}
}
}
// end of inserted stackable item checker/deleter
//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));
}
AssignCommand(oPC,PlaySound("as_cv_smithmet2"));
AssignCommand(oPC,PlaySound("as_cv_minepick1"));
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,4.0));
eFail = EffectVisualEffect(VFX_COM_BLOOD_SPARK_LARGE,FALSE);
eSuccess = EffectVisualEffect(VFX_COM_HIT_FROST,FALSE);
iSuccessAnimation = ANIMATION_LOOPING_TALK_PLEADING;
iFailAnimation = ANIMATION_LOOPING_TALK_FORCEFUL;
sSoundFail = "as_an_woodpeckr1";
sSoundSuccess = "as_cv_bell1";
int iRandom = Random(1000);
int iSuccess = 0;
int iSkillGain = 0;
string sOldSkill = "";
string sOldSkill2 = "";
if (iStackable!=2)
{
if (iRandom <= iGlassChance)
{
iSuccess = 1;
if (iStackable==1)
{
for (iTemp; iTemp>0; iTemp--)
{
iRandom = Random(1000);
if (iRandom <= iGlassChance-250) // Check for Exceptional
{
iCount3++;
}
else
{
if (iRandom <= iGlassChance-100) // Check for normal
{
iCount2++;
}
else
{
if (iRandom <= iGlassChance+100) iCount1++; // Check for poor
}
}
}
if (GetStringRight(sItemResRef,3)=="081") //make glass arrowheads
{
sItem1ResRef = "glassarrowhea001";
sItem2ResRef = "glassarrowhea002";
sItem3ResRef = "glassarrowhea003";
sSuccessString = "Glass Arrowheads created - ("+IntToString(iCount1)+" Poor) ("+IntToString(iCount2)+" Normal) ("+IntToString(iCount3)+" Exceptional) and some kindling";
}
if (GetStringRight(sItemResRef,3)=="082") //make glass bolt tips
{
sItem1ResRef = "glassbolttip001";
sItem2ResRef = "glassbolttip002";
sItem3ResRef = "glassbolttip003";
sSuccessString = "Glass Bolt Tips created - ("+IntToString(iCount1)+" Poor) ("+IntToString(iCount2)+" Normal) ("+IntToString(iCount3)+" Exceptional) and some kindling";
}
if (GetStringRight(sItemResRef,3)=="083") //make glass sling bullets
{
sItem1ResRef = "glassbullet001";
sItem2ResRef = "glassbullet002";
sItem3ResRef = "glassbullet003";
sSuccessString = "Glass Sling Bullets created - ("+IntToString(iCount1)+" Poor) ("+IntToString(iCount2)+" Normal) ("+IntToString(iCount3)+" Exceptional) and some kindling";
}
DelayCommand(5.8,CreateAnObject(sItem1ResRef,oPC,iCount1));
DelayCommand(5.9,CreateAnObject(sItem2ResRef,oPC,iCount2));
DelayCommand(6.0,CreateAnObject(sItem3ResRef,oPC,iCount3));
DelayCommand(5.0,AssignCommand(oPC,ActionPlayAnimation(iSuccessAnimation,1.0,1.0)));
DelayCommand(6.0,FloatingTextStringOnCreature(sSuccessString,oPC,FALSE));
DelayCommand(5.8,PlaySound(sSoundSuccess));
DelayCommand(6.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eSuccess,oSelf,2.0));
}
else
if (iStackable==0)
{
DelayCommand(5.0,AssignCommand(oPC,ActionPlayAnimation(iSuccessAnimation,1.0,1.0)));
DelayCommand(6.0,CreateAnObject(sCraft,oPC,iStackCount));
DelayCommand(6.0,FloatingTextStringOnCreature(sSuccessString,oPC,FALSE));
DelayCommand(5.8,PlaySound(sSoundSuccess));
DelayCommand(6.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eSuccess,oSelf,2.0));
}
}
else
{
DelayCommand(5.0,AssignCommand(oPC,ActionPlayAnimation(iFailAnimation,1.0,1.0)));
DelayCommand(6.0,FloatingTextStringOnCreature(sFailString,oPC,FALSE));
DelayCommand(6.0,PlaySound(sSoundFail));
DelayCommand(6.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eFail,oSelf,2.0));
}
}
//Check for success if filling arrowheads, etc
if (iStackable==2)
{
//SendMessageToPC(oPC,"iTemp = "+IntToString(iTemp));
for (iTemp; iTemp>0; iTemp--)
{
if (Random(1000)<=iGlassChance) iStackSize++;
}
if (iStackSize>0)
{
iSuccess=1;
sSuccessString = "You have filled "+IntToString(iStackSize)+" "+GetName(oItem)+" with "+sComponent1Name+".";
DelayCommand(5.0,AssignCommand(oPC,ActionPlayAnimation(iSuccessAnimation,1.0,1.0)));
DelayCommand(6.0,CreateAnObject(sCraft,oPC,iStackSize));
DelayCommand(6.0,FloatingTextStringOnCreature(sSuccessString,oPC,FALSE));
DelayCommand(5.8,PlaySound(sSoundSuccess));
DelayCommand(6.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eSuccess,oSelf,2.0));
}
if (iStackSize==0)
{
sFailString = "You were unable to fill any of the "+GetName(oItem)+" with "+sComponent1Name+".";
DelayCommand(5.0,AssignCommand(oPC,ActionPlayAnimation(iFailAnimation,1.0,1.0)));
DelayCommand(6.0,FloatingTextStringOnCreature(sFailString,oPC,FALSE));
DelayCommand(6.0,PlaySound(sSoundFail));
DelayCommand(6.0,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eFail,oSelf,2.0));
}
}
if (iAdded==99) DelayCommand(1.0,DestroyObject(oItem));
if (iSuccess == 1)
{
iToolUsed++;
iRandom = Random(1000);
if (iRandom >= iGlassSkill)
{
if (d10(1)+1 >= iGlassChance/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 = "";
iGlassSkill++;
sOldSkill2 = IntToString(iGlassSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iGlassSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iGlassSkill <= 1000)
{
//DelayCommand(5.0,SetTokenPair(oPC,14,5,iGlassSkill));
DelayCommand(6.0,SetCampaignInt("UOACraft","iTinkerSkill",iGlassSkill,oPC));
DelayCommand(6.0,SendMessageToPC(oPC,"================================="));
DelayCommand(6.0,SendMessageToPC(oPC,"Your Tinkering skill has gone up!"));
DelayCommand(6.0,SendMessageToPC(oPC,"Current Tinkering skill : "+ sOldSkill+"%"));
DelayCommand(6.0,SendMessageToPC(oPC,"================================="));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(5.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
if (iToolUsed >= 100)
{
DelayCommand(7.0,FloatingTextStringOnCreature("Your Tinker's Toolset wears out as you craft the item.",oPC,FALSE));
iToolUsed = 0;
DestroyObject(oTool,6.5);
}
SetLocalInt(oPC,"iToolWillBreak",iToolUsed);
}
void CreateAnObject(string sResource, object oPC, int iStackCount)
{
CreateItemOnObject(sResource,oPC,iStackCount);
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 GetNextItemPossessedBy(object oPC, string sItemTag)
{
object oTemp = GetItemPossessedBy(oPC,sItemTag);
if (oTemp==OBJECT_INVALID)
{
SendMessageToPC(oPC,"ERROR -- Locating components for destruction."+sItemTag);
return;
}
DestroyObject(oTemp);
return;
}
void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef)
{
//major debug code
//string sEntry = "GetNextStackedItem - "+sItemTag ;
//WriteTimestampedLogEntry(sEntry);
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;
}