2024-06-14 10:48:20 -04:00
|
|
|
//#include "_persist_01a"
|
|
|
|
|
|
|
|
void CreateAnObject(string sResource, object oPC, int iStackSize);
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
int iUseMode = 0;
|
|
|
|
if (GetInventoryDisturbType()!= INVENTORY_DISTURB_TYPE_ADDED)
|
|
|
|
{
|
|
|
|
iUseMode = 99;
|
|
|
|
if (GetLastDisturbed() == OBJECT_SELF)
|
|
|
|
{
|
|
|
|
DestroyObject(GetInventoryDisturbItem());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object oPC = GetLastDisturbed();
|
|
|
|
object oItem = GetInventoryDisturbItem();
|
|
|
|
string sItemTag = GetTag(oItem);
|
|
|
|
object oTemp = OBJECT_INVALID;
|
|
|
|
object oSelf = OBJECT_SELF;
|
|
|
|
|
|
|
|
if (iUseMode == 0)
|
|
|
|
{
|
|
|
|
// 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,4)!= "DYE_")
|
|
|
|
{
|
|
|
|
CopyItem(oItem,oPC,TRUE);
|
|
|
|
DestroyObject(oItem);
|
|
|
|
FloatingTextStringOnCreature("You can only dye cloth by placing dyes into this dyetub.",oPC,FALSE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string sTag = GetTag(oItem);
|
|
|
|
|
|
|
|
if (GetStringLeft(GetResRef(oItem),10)=="flagswitch")
|
|
|
|
{
|
|
|
|
if (sTag == "USE_CLOTH_NORMAL") SetLocalInt(oPC,"iUseThisCloth",0);
|
|
|
|
if (sTag == "USE_CLOTH_WOOL") SetLocalInt(oPC,"iUseThisCloth",1);
|
|
|
|
if (sTag == "USE_CLOTH_SILK") SetLocalInt(oPC,"iUseThisCloth",2);
|
|
|
|
string sClothMessage = "Switching cloth types. Now set to "+GetStringLowerCase(GetName(oItem))+".";
|
|
|
|
FloatingTextStringOnCreature(sClothMessage,oPC,FALSE);
|
|
|
|
DestroyObject(oItem);
|
|
|
|
AssignCommand(oPC,DoPlaceableObjectAction(oSelf,PLACEABLE_ACTION_USE));
|
|
|
|
AssignCommand(oPC,DelayCommand(1.0,DoPlaceableObjectAction(oSelf,PLACEABLE_ACTION_USE)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetLocalInt(oSelf,"iAmInUse")!=0)
|
|
|
|
{
|
|
|
|
FloatingTextStringOnCreature("Only one bolt of cloth may be dyed at a time.",oPC,FALSE);
|
|
|
|
CopyItem(oItem,oPC,TRUE);
|
|
|
|
DestroyObject(oItem);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int iClothType = GetLocalInt(oPC,"iUseThisCloth");
|
|
|
|
string sClothTag = "ITEM_CLOTH_NORMAL";
|
|
|
|
if (iClothType==1) sClothTag = "ITEM_CLOTH_WOOL";
|
|
|
|
if (iClothType==2) sClothTag = "ITEM_CLOTH_SILK";
|
|
|
|
if (iClothType>2) iClothType=0;
|
|
|
|
if (iClothType<0) iClothType = 0;
|
|
|
|
|
|
|
|
object oCloth = GetItemPossessedBy(oPC,sClothTag);
|
|
|
|
|
|
|
|
if (oCloth == OBJECT_INVALID)
|
|
|
|
{
|
|
|
|
FloatingTextStringOnCreature("You do not have the selected cloth type to work with..",oPC,FALSE);
|
|
|
|
CopyItem(oItem,oPC,TRUE);
|
|
|
|
DestroyObject(oItem);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int iDye = 0;
|
|
|
|
|
|
|
|
if (sItemTag=="DYE_AQUA") iDye = 1;
|
|
|
|
if (sItemTag=="DYE_BLACK") iDye = 2;
|
|
|
|
if (sItemTag=="DYE_BLUE") iDye = 3;
|
|
|
|
if (sItemTag=="DYE_YELLOW") iDye = 4;
|
|
|
|
if (sItemTag=="DYE_GREEN") iDye = 5;
|
|
|
|
if (sItemTag=="DYE_BROWN") iDye = 6;
|
|
|
|
if (sItemTag=="DYE_GOLD") iDye = 7;
|
|
|
|
if (sItemTag=="DYE_BRONZE") iDye = 8;
|
|
|
|
if (sItemTag=="DYE_SILVER") iDye = 9;
|
|
|
|
if (sItemTag=="DYE_GREY") iDye = 10;
|
|
|
|
if (sItemTag=="DYE_PINK") iDye = 11;
|
|
|
|
if (sItemTag=="DYE_ORANGE") iDye = 12;
|
|
|
|
if (sItemTag=="DYE_TAN") iDye = 13;
|
|
|
|
if (sItemTag=="DYE_COPPER") iDye = 14;
|
|
|
|
if (sItemTag=="DYE_WHITE") iDye = 15;
|
|
|
|
if (sItemTag=="DYE_PLATINUM") iDye = 16;
|
|
|
|
if (sItemTag=="DYE_PURPLE") iDye = 17;
|
|
|
|
if (sItemTag=="DYE_CHARCOAL") iDye = 18;
|
|
|
|
if (sItemTag=="DYE_MINTGREEN") iDye = 19;
|
|
|
|
if (sItemTag=="DYE_DARKRED") iDye = 20;
|
|
|
|
if (sItemTag=="DYE_DARKGREEN") iDye = 21;
|
|
|
|
if (sItemTag=="DYE_DARKBLUE") iDye = 22;
|
|
|
|
if (sItemTag=="DYE_PEACH") iDye = 23;
|
|
|
|
if (sItemTag=="DYE_SMOKE") iDye = 24;
|
|
|
|
if (sItemTag=="DYE_FUSCHIA") iDye = 25;
|
|
|
|
if (sItemTag=="DYE_OLIVE") iDye = 26;
|
|
|
|
if (sItemTag=="DYE_YELLOWGREEN") iDye = 27;
|
|
|
|
if (sItemTag=="DYE_YELLOWGRN") iDye = 27;
|
|
|
|
if (sItemTag=="DYE_RUST") iDye = 28;
|
|
|
|
if (sItemTag=="DYE_CHROMATIC") iDye = 29;
|
|
|
|
if (sItemTag=="DYE_METALLIC") iDye = 30;
|
|
|
|
|
|
|
|
if (iDye==0)
|
|
|
|
{
|
|
|
|
FloatingTextStringOnCreature("This item is not useable in this tub..",oPC,FALSE);
|
|
|
|
CopyItem(oItem,oPC,TRUE);
|
|
|
|
DestroyObject(oItem);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
string sDyeResRef = "dye0";
|
|
|
|
if (iDye<10) sDyeResRef = sDyeResRef+"0"+IntToString(iDye);
|
|
|
|
if (iDye>9) sDyeResRef = sDyeResRef+IntToString(iDye);
|
|
|
|
|
|
|
|
//int iDyeSkill = GetTokenPair(oPC,13,12); //Cloth Dyeing Skill
|
2024-09-16 23:40:48 -04:00
|
|
|
int iDyeSkill = GetCampaignInt("UOACraft","iDyeSkill",oPC);
|
2024-06-14 10:48:20 -04:00
|
|
|
int iDyeChance = iDyeSkill;
|
|
|
|
if (iDyeChance < 350)
|
|
|
|
{
|
|
|
|
iDyeChance = GetAbilityScore(oPC,ABILITY_WISDOM)*5;
|
|
|
|
iDyeChance = iDyeChance+(GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*3);
|
|
|
|
iDyeChance = iDyeChance+(GetAbilityScore(oPC,ABILITY_DEXTERITY)*2);
|
|
|
|
iDyeChance = iDyeChance*3;
|
|
|
|
if (iDyeChance>350)iDyeChance=350;
|
|
|
|
if (iDyeSkill > iDyeChance) iDyeChance=iDyeSkill;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine Cloth-dyeing difficulty based on type of cloth and color value
|
|
|
|
int iPenalty = iDye*10;
|
|
|
|
iPenalty = iPenalty + (iClothType*200);
|
|
|
|
iDyeChance = iDyeChance - iPenalty;
|
|
|
|
if (iDyeChance <1)
|
|
|
|
{
|
|
|
|
FloatingTextStringOnCreature("You do not have the skill in cloth dyeing to dye this cloth in the selected color..",oPC,FALSE);
|
|
|
|
CopyItem(oItem,oPC,TRUE);
|
|
|
|
DestroyObject(oItem);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Ensure correct stack information for dyes is gathered, and set stack to be less by 1.
|
|
|
|
object oDye = GetItemPossessedBy(oSelf,sItemTag);
|
|
|
|
int iDyeStack = GetNumStackedItems(oDye)-1;
|
|
|
|
DestroyObject(oDye);
|
|
|
|
|
|
|
|
string sItemResRef = "dyed_cloth0";
|
|
|
|
if (iClothType==1) sItemResRef=sItemResRef+IntToString(iDye+30);
|
|
|
|
if (iClothType==2) sItemResRef=sItemResRef+IntToString(iDye+60);
|
|
|
|
if (iClothType==0)
|
|
|
|
{
|
|
|
|
if (iDye >9)sItemResRef=sItemResRef+IntToString(iDye);
|
|
|
|
if (iDye<10)sItemResRef=sItemResRef+"0"+IntToString(iDye);
|
|
|
|
}
|
|
|
|
|
|
|
|
DelayCommand(0.5,DestroyObject(oCloth));
|
|
|
|
|
|
|
|
// Do skill check for success/fail
|
|
|
|
int iSkillGain = 0;
|
|
|
|
string sSuccess = "You have successfully dyed the cloth.";
|
|
|
|
string sFail = "The cloth fails to absorb the dye evenly, resulting in ruined cloth.";
|
|
|
|
string sFailResRef = "boltofcloth004";
|
|
|
|
if (iClothType==1) sFailResRef = "boltofcloth005";
|
|
|
|
if (iClothType==2) sFailResRef = "boltofcloth006";
|
|
|
|
|
|
|
|
DelayCommand(1.0,CreateAnObject(sDyeResRef,oPC,iDyeStack));
|
|
|
|
if (Random(1000) <= iDyeChance)
|
|
|
|
{
|
|
|
|
DelayCommand(6.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE));
|
|
|
|
DelayCommand(6.0,CreateAnObject(sItemResRef,oPC,1));
|
|
|
|
if (Random(1000) >= iDyeSkill)
|
|
|
|
{
|
|
|
|
if (d10(1)+1 >= iDyeChance/100) iSkillGain = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DelayCommand(6.0,FloatingTextStringOnCreature(sFail,oPC,FALSE));
|
|
|
|
DelayCommand(6.0,CreateAnObject(sFailResRef,oPC,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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do Skill Gains
|
|
|
|
string sOldSkill = "";
|
|
|
|
string sOldSkill2 = "";
|
|
|
|
if (iSkillGain==1)
|
|
|
|
{
|
|
|
|
iDyeSkill++;
|
|
|
|
sOldSkill2 = IntToString(iDyeSkill);
|
|
|
|
sOldSkill = "."+GetStringRight(sOldSkill2,1);
|
|
|
|
if (iDyeSkill > 9)
|
|
|
|
{
|
|
|
|
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sOldSkill = "0"+sOldSkill;
|
|
|
|
}
|
|
|
|
if (iDyeSkill <= 1000)
|
|
|
|
{
|
|
|
|
//DelayCommand(13.0,SetTokenPair(oPC,13,12,iDyeSkill));
|
2024-09-16 23:40:48 -04:00
|
|
|
DelayCommand(13.0,SetCampaignInt("UOACraft","iDyeSkill",iDyeSkill,oPC));
|
2024-06-14 10:48:20 -04:00
|
|
|
DelayCommand(13.0,SendMessageToPC(oPC,"======================================="));
|
|
|
|
DelayCommand(13.0,SendMessageToPC(oPC,"Your skill in cloth dyeing has gone up!"));
|
|
|
|
DelayCommand(13.0,SendMessageToPC(oPC,"Current cloth dyeing skill : "+ sOldSkill+"%"));
|
|
|
|
DelayCommand(13.0,SendMessageToPC(oPC,"======================================="));
|
|
|
|
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(12.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetLocalInt(oSelf,"iAmInUse",99);
|
|
|
|
DelayCommand(7.0,SetLocalInt(oSelf,"iAmInUse",0));
|
|
|
|
|
|
|
|
// Assign sounds and animations
|
|
|
|
PlaySound("as_na_waterlap1");
|
|
|
|
AssignCommand(oPC,PlaySound("as_na_splash2"));
|
|
|
|
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,6.0));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CreateAnObject(string sResource, object oPC, int iStackSize)
|
|
|
|
{
|
|
|
|
CreateItemOnObject(sResource,oPC,iStackSize);
|
|
|
|
return;
|
|
|
|
}
|