Aschbourne_PRC8/_module/nss/_craft_gempolish.nss

324 lines
15 KiB
Plaintext
Raw Normal View History

2024-06-14 10:48:20 -04:00
//#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 = "";
string sName = GetName(oItem);
// 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,10)!="GEM_ROUGH_")
{
CopyItem(oItem,oPC,TRUE);
FloatingTextStringOnCreature("This is not a rough gemstone...",oPC,FALSE);
DestroyObject(oItem);
return;
}
if (GetLocalInt(OBJECT_SELF,"iAmInUse")!=0)
{
CopyItem(oItem,oPC,TRUE);
FloatingTextStringOnCreature("The tumbler is not yet ready for more gemstones...",oPC,FALSE);
DestroyObject(oItem);
return;
}
object oGrit1 = GetItemPossessedBy(oPC,"GRIT_COARSE");
object oGrit2 = GetItemPossessedBy(oPC,"GRIT_MEDIUM");
object oGrit3 = GetItemPossessedBy(oPC,"GRIT_FINE");
int iGrit1 = GetNumStackedItems(oGrit1)-1;
int iGrit2 = GetNumStackedItems(oGrit2)-1;
int iGrit3 = GetNumStackedItems(oGrit3)-1;
//SendMessageToPC(oPC,"Coarse Grit ResRef : "+GetResRef(oGrit1));
//SendMessageToPC(oPC,"Medium Grit ResRef : "+GetResRef(oGrit2));
//SendMessageToPC(oPC," Fine Grit ResRef : "+GetResRef(oGrit3));
//SendMessageToPC(oPC,"Coarse Grit Tag : "+GetTag(oGrit1));
//SendMessageToPC(oPC,"Medium Grit Tag : "+GetTag(oGrit2));
//SendMessageToPC(oPC," Fine Grit Tag : "+GetTag(oGrit3));
//SendMessageToPC(oPC,"Coarse Grit Stack : "+IntToString(iGrit1));
//SendMessageToPC(oPC,"Medium Grit Stack : "+IntToString(iGrit2));
//SendMessageToPC(oPC," Fine Grit Stack : "+IntToString(iGrit3));
if (oGrit1 == OBJECT_INVALID)
{
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
FloatingTextStringOnCreature("You must have some coarse polishing grit in order to begin polishing gems.",oPC,FALSE);
return;
}
if (oGrit2 == OBJECT_INVALID)
{
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
FloatingTextStringOnCreature("You must have some medium polishing grit in order to continue the gem polishing process.",oPC,FALSE);
return;
}
if (oGrit3 == OBJECT_INVALID)
{
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem);
FloatingTextStringOnCreature("You must have some fine polishing grit in order to finish the gem polishing process.",oPC,FALSE);
return;
}
//This line added June 3, 2003 and will check for a split stack,
//which has no ResRef, and find the other half of the stack that
//actually has the ResRef.
if (sItemResRef=="") sItemResRef = GetResRef(GetItemPossessedBy(oPC,GetTag(oItem)));
DestroyObject(oGrit1,0.1);
DestroyObject(oGrit2,0.2);
DestroyObject(oGrit3,0.3);
//***IMPORTANT NOTE****
//The delay for the 1st creation of 'grit001' is required in order to
//prevent an interesting bug in order of execution of creation/destruction of
//stacked items.
//Without the delay, the script runs properly 1st time through.. but behind the scenes
//you temporarily have 2 items.. a stack of 10 and a stack of 9.. total of 19
//it then destroys the stack of 10, leaving you with 9. The second time through
//however, it creates 8, giving you a stack of 10 and a stack of 7. It then
//destroys the stack of 10, leaving you with 7. Big error as you should have 8.
if (iGrit1 >0) DelayCommand(1.0,CreateAnObject("grit001",oPC,iGrit1));
if (iGrit2 >0) DelayCommand(10.1,CreateAnObject("grit002",oPC,iGrit2));
if (iGrit3 >0) DelayCommand(20.1,CreateAnObject("grit003",oPC,iGrit3));
FloatingTextStringOnCreature("You begin polishing the "+GetName(oItem)+"...",oPC,FALSE);
DelayCommand(10.0,FloatingTextStringOnCreature("You begin the second polishing cycle...",oPC,FALSE));
DelayCommand(20.0,FloatingTextStringOnCreature("You begin the third, and final, polishing cycle.",oPC,FALSE));
SetLocalInt(OBJECT_SELF,"iAmInUse",99);
DelayCommand(30.0,SetLocalInt(OBJECT_SELF,"iAmInUse",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 += 0.8;
location locEffect = Location( GetAreaFromLocation(locBath), vEffectPos,GetFacingFromLocation(locBath) );
ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SMOKE_PUFF), locEffect);
ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect);
DelayCommand(0.1,PlaySound("al_cv_millwheel"));
DelayCommand(6.0,PlaySound("al_cv_millwheel"));
DelayCommand(12.0,PlaySound("al_cv_millwheel"));
DelayCommand(18.0,PlaySound("al_cv_millwheel"));
DelayCommand(24.0,PlaySound("al_cv_millwheel"));
DelayCommand(0.2,PlaySound("al_cv_fanlg1"));
DelayCommand(6.1,PlaySound("al_cv_fanlg1"));
DelayCommand(12.1,PlaySound("al_cv_fanlg1"));
DelayCommand(18.1,PlaySound("al_cv_fanlg1"));
DelayCommand(24.1,PlaySound("al_cv_fanlg1"));
DelayCommand(0.4,PlaySound("al_mg_jacobs1"));
DelayCommand(0.4,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(0.5,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_WHITE), locEffect));
DelayCommand(1.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_BLUE_RED), locEffect));
DelayCommand(1.8,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(2.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_WHITE_BLUE), locEffect));
DelayCommand(3.3,PlaySound("al_mg_jacobs1"));
DelayCommand(3.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(4.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_WHITE), locEffect));
DelayCommand(4.8,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(5.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_WHITE_ORANGE), locEffect));
DelayCommand(6.2,PlaySound("al_mg_jacobs1"));
DelayCommand(6.2,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(7.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_PINK_ORANGE), locEffect));
DelayCommand(7.8,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(8.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_WHITE), locEffect));
DelayCommand(9.1,PlaySound("al_mg_jacobs1"));
DelayCommand(9.1,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(9.8,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_PINK_ORANGE), locEffect));
DelayCommand(10.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(11.4,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_BLUE_RED), locEffect));
DelayCommand(12.0,PlaySound("al_mg_jacobs1"));
DelayCommand(12.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(12.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(13.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_ORANGE), locEffect));
DelayCommand(14.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(14.9,PlaySound("al_mg_jacobs1"));
DelayCommand(14.9,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(15.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_PINK_ORANGE), locEffect));
DelayCommand(16.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(17.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_WHITE_ORANGE), locEffect));
DelayCommand(17.8,PlaySound("al_mg_jacobs1"));
DelayCommand(17.8,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(18.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_BLUE_RED), locEffect));
DelayCommand(19.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(20.0,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_ORANGE), locEffect));
DelayCommand(20.7,PlaySound("al_mg_jacobs1"));
DelayCommand(20.7,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(21.4,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_WHITE_BLUE), locEffect));
DelayCommand(22.2,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(22.9,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_PINK_ORANGE), locEffect));
DelayCommand(23.6,PlaySound("al_mg_jacobs1"));
DelayCommand(23.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(24.4,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_WHITE), locEffect));
DelayCommand(25.2,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(25.9,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_WHITE_BLUE), locEffect));
DelayCommand(26.5,PlaySound("al_mg_jacobs1"));
DelayCommand(26.5,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_HIT_ACID), locEffect));
DelayCommand(27.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_RED_ORANGE), locEffect));
DelayCommand(28.3,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPARKS_PARRY), locEffect));
DelayCommand(29.6,ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_COM_SPECIAL_WHITE_BLUE), locEffect));
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,8.5));
AssignCommand(oPC,DelayCommand(10.1,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,8.5)));
AssignCommand(oPC,DelayCommand(20.1,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,8.5)));
int iItem = GetNumStackedItems(oItem);
//int iPolishSkill = GetTokenPair(oPC,13,6);
int iPolishSkill = GetCampaignInt("UOACraft","iPolishSkill",oPC);
2024-06-14 10:48:20 -04:00
int iPolishChance = iPolishSkill;
if (iPolishChance <350)
{
iPolishChance = GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*4;
iPolishChance = iPolishChance+(GetAbilityScore(oPC,ABILITY_WISDOM)*4);
iPolishChance = iPolishChance+(GetAbilityScore(oPC,ABILITY_CHARISMA)*2);
iPolishChance = iPolishChance*3;
if (iPolishChance>350) iPolishChance = 350;
if (iPolishChance<iPolishSkill) iPolishChance = iPolishSkill;
}
int iSuccess = 0;
if (Random(1000)<=iPolishChance) iSuccess++;
if (Random(1000)<=iPolishChance) iSuccess++;
if (Random(1000)<=(iPolishChance-500)) iSuccess++;
string sGemResRef = GetStringLeft(sItemResRef,GetStringLength(sItemResRef)-1);
switch (iSuccess)
{
case 0:
{
DelayCommand(29.5,FloatingTextStringOnCreature("Your attempt to polish this gem fails completely. The gem is lost.",oPC,FALSE));
break;
}
case 1:
{
DelayCommand(29.5,FloatingTextStringOnCreature("You tumble the gem for too long, and it is reduced to powder..",oPC,FALSE));
DelayCommand(31.1,CreateAnObject(sGemResRef+"5",oPC,1));
break;
}
case 3:
{
DelayCommand(29.5,FloatingTextStringOnCreature("You successfully tumble the "+sName+ " and you recover some powder as well.",oPC,FALSE));
DelayCommand(29.1,CreateAnObject(sGemResRef+"2",oPC,1));
DelayCommand(31.1,CreateAnObject(sGemResRef+"5",oPC,1));
break;
}
default:
{
DelayCommand(29.5,FloatingTextStringOnCreature("You successfully tumble the "+sName+".",oPC,FALSE));
DelayCommand(31.1,CreateAnObject(sGemResRef+"2",oPC,1));
break;
}
}
int iSkillGain = 0;
if (iSuccess>0)
{
if (Random(1000) >= iPolishSkill)
{
if (d10(1)+1 >= iPolishChance/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 = "";
iPolishSkill++;
sOldSkill2 = IntToString(iPolishSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iPolishSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iPolishSkill <= 1000)
{
//DelayCommand(31.0,SetTokenPair(oPC,13,6,iPolishSkill));
DelayCommand(31.0,SetCampaignInt("UOACraft","iPolishSkill",iPolishSkill,oPC));
2024-06-14 10:48:20 -04:00
DelayCommand(31.0,SendMessageToPC(oPC,"======================================="));
DelayCommand(31.0,SendMessageToPC(oPC,"Your skill in gem polishing has gone up!"));
DelayCommand(31.0,SendMessageToPC(oPC,"Current gem polishing skill : "+ sOldSkill+"%"));
DelayCommand(31.0,SendMessageToPC(oPC,"========================================"));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(30.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
// Only process 1 gem at a time. Return the rest of the stack to the PC.
// The reason for this is due to the value of the gems a PC could make
// too much gold too fast if allowed to process stacks at a time.
if (iItem >1)
{
iItem--;
CreateItemOnObject(GetResRef(oItem),oPC,iItem);
}
DestroyObject(oItem);
}
void CreateAnObject(string sResource, object oPC, int iStackSize)
{
CreateItemOnObject(sResource,oPC,iStackSize);
return;
}