Aschbourne_PRC8/_module/nss/_craft_loom.nss
GetOffMyYarn 69879d6957 Areas and Fixes
Added CCOH and missing areas
Changed some areas to be craftable,
Fixed some on death issues,
Fixed the Gaurd
2024-08-30 11:38:44 -04:00

221 lines
7.1 KiB
Plaintext

//#include "_persist_01a"
#include "nw_i0_plot"
#include "aps_include"
void CreateAnObject(string sResource, object oPC, int iStackSize);
void GetNextItemPossessedBy(object oPC, string sItemTag);
void main()
{
object oItem = GetInventoryDisturbItem();
object oPC = GetLastDisturbed();
object oSelf = OBJECT_SELF;
string sTag = GetTag(oItem);
string sSuccess = "";
string sFail = "";
string sItemResRef = "";
int iComponent1 = 0;
string sComponent1 = "";
string sComponent1Name = "";
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 craft by removing pattern tokens from this station.",oPC,FALSE);
return;
}
CopyObject(oItem,GetLocation(oSelf),oSelf,GetTag(oItem));
//int iClothSkill = GetTokenPair(oPC,13,4); // Clothmaking
int iClothSkill = GetPersistentInt(oPC,"iClothSkill","UOACraft");
int iClothChance = iClothSkill;
if (iClothChance < 350)
{
iClothChance = GetAbilityScore(oPC,ABILITY_DEXTERITY)*5;
iClothChance = iClothChance+(GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*3);
iClothChance = iClothChance+(GetAbilityScore(oPC,ABILITY_WISDOM)*2);
iClothChance = iClothChance*3;
if (iClothChance>350)iClothChance=350;
if (iClothSkill > iClothChance) iClothChance=iClothSkill;
}
effect vEffect;
int iDifficulty = 0;
if (sTag == "P_CLOTH_NORMAL")
{
sSuccess = "You carefully weave the threads upon the loom to create a bolt of normal cloth.";
sFail = "The threads begin to break and snap as you fail in your attempt to create the cloth.";
sItemResRef = "boltofcloth001";
iComponent1 = 5;
sComponent1 = "THREAD_COTTON"; // Spindle of Normal Thread
sComponent1Name = "spindles of thread";
vEffect = EffectVisualEffect(VFX_DUR_PROT_STONESKIN,FALSE);
}
if (sTag == "P_CLOTH_WOOL")
{
iDifficulty = 500;
sSuccess = "You carefully weave the yarn upon the loom to create a bolt of wool cloth.";
sFail = "The yarn breaks in several places as you fail in your attempt to create the cloth.";
sItemResRef = "boltofcloth002";
iComponent1 = 5;
sComponent1 = "THREAD_WOOL"; // ball of wool yarn
sComponent1Name = "balls of wool yarn";
vEffect = EffectVisualEffect(VFX_DUR_PROT_BARKSKIN,FALSE);
}
if (sTag == "P_CLOTH_SILK")
{
iDifficulty = 750;
sSuccess = "You carefully weave the silken threads upon the loom to create a bolt of silk cloth.";
sFail = "The threads begin to break and snap as you fail in your attempt to create the cloth.";
sItemResRef = "boltofcloth003";
iComponent1 = 5;
sComponent1 = "THREAD_SILK"; // Spindle of silk thread
sComponent1Name = "spindles of silk thread";
vEffect = EffectVisualEffect(VFX_DUR_PROT_GREATER_STONESKIN,FALSE);
}
// check for components
if (GetNumItems(oPC,sComponent1) < iComponent1)
{
FloatingTextStringOnCreature("You do not have enough "+sComponent1Name+" to do this.",oPC,FALSE);
DestroyObject(oItem);
return;
}
if (GetLocalInt(oSelf,"iAmInUse")!=0)
{
FloatingTextStringOnCreature("You can only weave one bolt at a time.",oPC,FALSE);
DestroyObject(oItem);
return;
}
SetLocalInt(oSelf,"iAmInUse",99);
DelayCommand(13.1,SetLocalInt(oSelf,"iAmInUse",0));
if (iDifficulty > iClothChance)
{
FloatingTextStringOnCreature("You do not know how to weave this material into cloth yet.",oPC,FALSE);
DestroyObject(oItem);
return;
}
// Set Anvil to 'in use'
SetLocalInt(OBJECT_SELF,"iAmInUse",99);
DelayCommand(12.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,vEffect,oSelf,12.0);
float fPause = 1.0;
// Remove Components
for (iComponent1; iComponent1>0; iComponent1--)
{
fPause = fPause+2.0;
AssignCommand(oPC,DelayCommand(fPause,GetNextItemPossessedBy(oPC,sComponent1)));
AssignCommand(oPC,DelayCommand(fPause,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,1.0)));
AssignCommand(oPC,DelayCommand(fPause+0.1,PlaySound("as_cn_smithmet2")));
AssignCommand(oPC,DelayCommand(fPause+1.0,ActionPlayAnimation(ANIMATION_LOOPING_TALK_PLEADING,1.0,1.0)));
AssignCommand(oPC,DelayCommand(fPause+1.1,PlaySound("as_cn_smithmet2")));
}
DelayCommand(0.2,PlaySound("as_cv_ropepully1"));
DelayCommand(3.2,PlaySound("as_cv_ropepully1"));
DelayCommand(6.2,PlaySound("as_cv_ropepully1"));
DelayCommand(9.2,PlaySound("as_cv_ropepully1"));
DestroyObject(oItem);
iClothChance = iClothChance - (iDifficulty/2);
int iSkillGain = 0;
if (Random(1000) <= iClothChance)
{
if (Random(1000) >= iClothSkill)
{
if (d10(1)+1 >= iClothChance/100) iSkillGain = 1;
}
}
else
{
DelayCommand(12.0,FloatingTextStringOnCreature(sFail,oPC,FALSE));
return;
}
// Create the item
AssignCommand(oPC,DelayCommand(12.0,CreateAnObject(sItemResRef,oPC,1)));
AssignCommand(oPC,DelayCommand(12.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE)));
//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));
}
}
// Do skill gains
if (iSkillGain ==1)
{
string sOldSkill = "";
string sOldSkill2 = "";
iClothSkill++;
sOldSkill2 = IntToString(iClothSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iClothSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iClothSkill <= 1000)
{
//DelayCommand(13.0,SetTokenPair(oPC,13,4,iClothSkill));
DelayCommand(13.0,SetPersistentInt(oPC,"iClothSkill",iClothSkill,0,"UOACraft"));
DelayCommand(13.0,SendMessageToPC(oPC,"========================================="));
DelayCommand(13.0,SendMessageToPC(oPC,"Your skill in clothmaking has gone up!"));
DelayCommand(13.0,SendMessageToPC(oPC,"Current clothmaking skill : "+ sOldSkill+"%"));
DelayCommand(13.0,SendMessageToPC(oPC,"========================================="));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(12.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;
}