Aschbourne_PRC8/_module/nss/_craft_gemcutter.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

322 lines
14 KiB
Plaintext

//#include "_persist_01a"
void CreateAnObject(string sResource, object oPC, int iStackSize);
void main()
{
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
string sItemTag = GetTag(oItem);
string sItemResRef = GetResRef(oItem);
string sSuccess = "";
if (GetInventoryDisturbType() != INVENTORY_DISTURB_TYPE_ADDED) 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 (GetStringLeft(sItemTag,13)!="GEM_POLISHED_")
{
CopyItem(oItem,oPC,TRUE);
FloatingTextStringOnCreature("This is not a polished gem...",oPC,FALSE);
DestroyObject(oItem);
return;
}
if (GetLocalInt(OBJECT_SELF,"iAmInUse")!=0)
{
CopyItem(oItem,oPC,TRUE);
FloatingTextStringOnCreature("You must first finish cutting the current gem before starting another.",oPC,FALSE);
DestroyObject(oItem);
return;
}
if (GetLocalInt(oPC,"iAmDigging")!=0)
{
CopyItem(oItem,oPC,TRUE);
FloatingTextStringOnCreature("You may only use one gemcutting station at a time!",oPC,FALSE);
DestroyObject(oItem);
return;
}
//int iGemSkill = GetTokenPair(oPC,13,7);
int iGemSkill = GetCampaignInt("UOACraft","iGemSkill",oPC);
int iGemChance = iGemSkill;
if (iGemSkill <350)
{
iGemChance = GetAbilityScore(oPC,ABILITY_DEXTERITY)*5;
iGemChance = iGemChance + (GetAbilityScore(oPC,ABILITY_WISDOM)*3);
iGemChance = iGemChance + (GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*2);
iGemChance = iGemChance *3;
if (iGemChance>350)iGemChance = 350;
if (iGemSkill>iGemChance) iGemChance = iGemSkill;
}
int iPenalty = 0;
if (sItemTag=="GEM_POLISHED_AZURITE") iPenalty=10;
if (sItemTag=="GEM_POLISHED_BANDEDAGATE") iPenalty=20;
if (sItemTag=="GEM_POLISHED_BLUEQUARTZ") iPenalty=30;
if (sItemTag=="GEM_POLISHED_EYEAGATE") iPenalty=40;
if (sItemTag=="GEM_POLISHED_HEMATITE") iPenalty=50;
if (sItemTag=="GEM_POLISHED_LAPISLAZULI") iPenalty=60;
if (sItemTag=="GEM_POLISHED_MALACHITE") iPenalty=70;
if (sItemTag=="GEM_POLISHED_MOSSAGATE") iPenalty=80;
if (sItemTag=="GEM_POLISHED_OBSIDIAN") iPenalty=90;
if (sItemTag=="GEM_POLISHED_RHODOCHROSITE") iPenalty=10;
if (sItemTag=="GEM_POLISHED_TIGEREYE") iPenalty=110;
if (sItemTag=="GEM_POLISHED_TURQUOISE") iPenalty=120;
//
if (sItemTag=="GEM_POLISHED_BLOODSTONE") iPenalty=130;
if (sItemTag=="GEM_POLISHED_CARNELIAN") iPenalty=140;
if (sItemTag=="GEM_POLISHED_CHALCENDONY") iPenalty=150;
if (sItemTag=="GEM_POLISHED_CHRYSOPRASE") iPenalty=160;
if (sItemTag=="GEM_POLISHED_CITRINE") iPenalty=170;
if (sItemTag=="GEM_POLISHED_JASPER") iPenalty=180;
if (sItemTag=="GEM_POLISHED_MOONSTONE") iPenalty=190;
if (sItemTag=="GEM_POLISHED_ONYX") iPenalty=200;
if (sItemTag=="GEM_POLISHED_ROCKCRYSTAL") iPenalty=210;
if (sItemTag=="GEM_POLISHED_SARDONYX") iPenalty=220;
if (sItemTag=="GEM_POLISHED_SMOKYQUARTZ") iPenalty=230;
if (sItemTag=="GEM_POLISHED_STARROSEQUARTZ") iPenalty=240;
if (sItemTag=="GEM_POLISHED_ZIRCON") iPenalty=250;
//
if (sItemTag=="GEM_POLISHED_AMBER") iPenalty=260;
if (sItemTag=="GEM_POLISHED_ALEXANDRITE") iPenalty=270;
if (sItemTag=="GEM_POLISHED_AMETHYST") iPenalty=280;
if (sItemTag=="GEM_POLISHED_CHRYSOBERYL") iPenalty=290;
if (sItemTag=="GEM_POLISHED_CORAL") iPenalty=300;
if (sItemTag=="GEM_POLISHED_GARNET_RED") iPenalty=310;
if (sItemTag=="GEM_POLISHED_JADE") iPenalty=320;
if (sItemTag=="GEM_POLISHED_JET") iPenalty=330;
if (sItemTag=="GEM_POLISHED_WHITEPEARL") iPenalty=340;
if (sItemTag=="GEM_POLISHED_REDSPINEL") iPenalty=350;
if (sItemTag=="GEM_POLISHED_TOURMALINE") iPenalty=360;
//
if (sItemTag=="GEM_POLISHED_AQUAMARINE") iPenalty=370;
if (sItemTag=="GEM_POLISHED_GARNET_VIOLET") iPenalty=380;
if (sItemTag=="GEM_POLISHED_BLACKPEARL") iPenalty=390;
if (sItemTag=="GEM_POLISHED_PERIDOT") iPenalty=400;
if (sItemTag=="GEM_POLISHED_BLUESPINEL") iPenalty=410;
if (sItemTag=="GEM_POLISHED_TOPAZ") iPenalty=420;
//
if (sItemTag=="GEM_POLISHED_BLACKOPAL") iPenalty=430;
if (sItemTag=="GEM_POLISHED_EMERALD") iPenalty=440;
if (sItemTag=="GEM_POLISHED_FIREOPAL") iPenalty=450;
if (sItemTag=="GEM_POLISHED_OPAL") iPenalty=460;
if (sItemTag=="GEM_POLISHED_ORIENTALAMETHYST") iPenalty=470;
if (sItemTag=="GEM_POLISHED_ORIENTALTOPAZ") iPenalty=480;
if (sItemTag=="GEM_POLISHED_SAPPHIRE") iPenalty=490;
if (sItemTag=="GEM_POLISHED_STARRUBY") iPenalty=500;
if (sItemTag=="GEM_POLISHED_STARSAPPHIRE") iPenalty=510;
//
if (sItemTag=="GEM_POLISHED_BLACKSAPPHIRE") iPenalty=520;
if (sItemTag=="GEM_POLISHED_DIAMOND") iPenalty=530;
if (sItemTag=="GEM_POLISHED_JACINTH") iPenalty=540;
if (sItemTag=="GEM_POLISHED_ORIENTALEMERALD") iPenalty=550;
if (sItemTag=="GEM_POLISHED_RUBY") iPenalty=560;
iGemChance = iGemChance - iPenalty;
if (iGemChance<1)
{
FloatingTextStringOnCreature("You do not have the skill needed to work with this gem.",oPC,FALSE);
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
return;
}
SetLocalInt(OBJECT_SELF,"iAmInUse",99);
DelayCommand(15.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0));
SetLocalInt(oPC,"iAmDigging",99);
DelayCommand(15.1,SetLocalInt(oPC,"iAmDigging",0));
AssignCommand(oPC,DelayCommand(0.1,ActionPlayAnimation(ANIMATION_LOOPING_TALK_PLEADING,1.0,3.0)));
AssignCommand(oPC,DelayCommand(3.1,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,3.0)));
AssignCommand(oPC,DelayCommand(6.1,ActionPlayAnimation(ANIMATION_LOOPING_TALK_PLEADING,1.0,3.0)));
AssignCommand(oPC,DelayCommand(9.1,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,3.0)));
AssignCommand(oPC,DelayCommand(12.1,ActionPlayAnimation(ANIMATION_LOOPING_TALK_PLEADING,1.0,3.0)));
// This snippet of code is cut-n-paste direct from ATS
// Reason for this is because I had no clue how to assign an increase
// in the z-axis of the location of the anvil for sparks to display.
// After reading through this code, it is obvious that vEffecrPos.z
// is the line which assigns this. Due to my own ignorance in this issue
// I have decided to leave this snippet of code intact with this credit to
// the original ATS script coders, whomever they may have been.
// The only modification to this code is locAnvil was changed to locBath.
location locBath = GetLocation(OBJECT_SELF);
vector vEffectPos = GetPositionFromLocation(locBath);
vEffectPos.z += 1.5;
location locEffect = Location( GetAreaFromLocation(locBath), vEffectPos,GetFacingFromLocation(locBath) );
ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect);
ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_WHITE), locEffect);
DelayCommand(0.1,PlaySound("as_cv_chiseling1"));
DelayCommand(2.9,PlaySound("as_cv_chiseling3"));
DelayCommand(8.8,PlaySound("as_cv_chiseling3"));
DelayCommand(0.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(1.2,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(2.1,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(2.8,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(3.2,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(3.8,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(4.1,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(4.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(5.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(6.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(6.5,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(7.2,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(7.9,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(8.4,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(9.2,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(9.7,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(10.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(10.9,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(11.4,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(12.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(12.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(13.1,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(13.7,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(14.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(14.7,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(15.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(16.1,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
DelayCommand(16.7,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY),locEffect));
//Adding a check for a null resref due to dividing a stack
if (sItemResRef =="")
{
oItem = GetItemPossessedBy(OBJECT_SELF,sItemTag);
sItemResRef = GetStringRight(sItemTag,GetStringLength(sItemTag)-13)+"002";
}
int iStackGems = GetNumStackedItems(oItem)-1;
if (iStackGems>0) DelayCommand(1.0,CreateAnObject(sItemResRef,oPC,iStackGems));
SendMessageToPC(oPC,sItemResRef);
int iSuccess = 0;
if (Random(1000)<=iGemChance) iSuccess++;
if (Random(1000)<=iGemChance) iSuccess++;
if (Random(1000)<=iGemChance) iSuccess++;
string sGemResRef = GetStringLeft(sItemResRef,GetStringLength(sItemResRef)-1);
string sPowderResRef = sGemResRef+"5";
switch (iSuccess)
{
case 0:
{
DelayCommand(16.0,FloatingTextStringOnCreature("the gem is completely ruined by your attempt to cut it.",oPC,FALSE));
DestroyObject(oItem);
return;
break;
}
case 1:
{
DelayCommand(16.0,FloatingTextStringOnCreature("You barely manage to cut the gem, produing a poor quality cut gem.",oPC,FALSE));
sGemResRef = sGemResRef+"4";
break;
}
case 3:
{
DelayCommand(16.0,FloatingTextStringOnCreature("With an expert hand you produce the highest quality cut gem.",oPC,FALSE));
sGemResRef = GetStringLeft(sItemResRef,GetStringLength(sItemResRef)-3);
break;
}
default:
{
DelayCommand(16.0,FloatingTextStringOnCreature("You successfully cut the gem, produing an average quality cut gem.",oPC,FALSE));
sGemResRef = sGemResRef+"3";
break;
}
}
if (Random(1000)<=iGemChance)
{
DelayCommand(17.0,FloatingTextStringOnCreature("You carefully gather the fine powder that is left over.",oPC,FALSE));
DelayCommand(16.5,CreateAnObject(sPowderResRef,oPC,1));
}
DelayCommand(17.1,CreateAnObject(sGemResRef,oPC,1));
int iSkillGain = 0;
if (iSuccess>0)
{
if (Random(1000) >= iGemSkill)
{
if (d10(1)+1 >= iGemChance/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 = "";
iGemSkill++;
sOldSkill2 = IntToString(iGemSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iGemSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iGemSkill <= 1000)
{
//DelayCommand(17.0,SetTokenPair(oPC,13,7,iGemSkill));
DelayCommand(17.0,SetCampaignInt("UOACraft","iGemSkill",iGemSkill,oPC));
DelayCommand(17.0,SendMessageToPC(oPC,"======================================"));
DelayCommand(17.0,SendMessageToPC(oPC,"Your skill in gem cutting has gone up!"));
DelayCommand(17.0,SendMessageToPC(oPC,"Current gem cutting skill : "+ sOldSkill+"%"));
DelayCommand(17.0,SendMessageToPC(oPC,"======================================"));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(16.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
DestroyObject(oItem);
}
void CreateAnObject(string sResource, object oPC, int iStackSize)
{
CreateItemOnObject(sResource,oPC,iStackSize);
return;
}