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

235 lines
6.6 KiB
Plaintext

void CreateAnObject(string sResource, object oPC);
void main()
{
if (GetInventoryDisturbType()!= INVENTORY_DISTURB_TYPE_ADDED)
{
if (GetLastDisturbed() == OBJECT_SELF)
{
DestroyObject(GetInventoryDisturbItem());
return;
}
return;
}
object oPC = GetLastDisturbed();
object oItem = GetInventoryDisturbItem();
// 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 mill may be destroyed.");
return;
}
// End of compatability portion.
if (GetLocalInt(OBJECT_SELF,"iAmInUse") != 0)
{
CopyItem(oItem,oPC,TRUE);
SendMessageToPC(oPC,"You must wait until the grain in the mill is done before starting another batch.");
DestroyObject(oItem);
return;
}
string sItemTag = GetTag(oItem);
string sProduct = "INVALID";
int iDifficulty = 0;
int iRandom;
int iSkillGain;
string sSuccess = "You have successfully ground the "+GetName(oItem)+" into meal.";
string sFail = "The meal is ruined by improper milling.";
if (sItemTag=="SEED_CORN")
{
sProduct = "item_meal_001";
iDifficulty = 50;
}
if (sItemTag=="SEED_WHEAT")
{
sProduct = "item_meal_002";
iDifficulty = 0;
}
if (sItemTag=="SEED_RICE")
{
sProduct = "item_meal_003";
iDifficulty = -100;
}
if (sItemTag=="SEED_OATS")
{
sProduct = "item_meal_004";
iDifficulty = -50;
}
if (sItemTag=="SEED_BARLEY")
{
sProduct = "item_meal_005";
iDifficulty = 150;
}
if (sItemTag=="SEED_SORGHUM")
{
sProduct = "item_meal_006";
iDifficulty = 0;
}
if (sItemTag=="ITEM_ACORN")
{
sProduct = "item_meal_007";
iDifficulty = 100;
}
if (sProduct=="INVALID")
{
sSuccess = "You have successfully ground the "+GetName(oItem)+" into flour.";
sFail = "The flour is ruined by improper milling.";
}
if (sItemTag=="ITEM_MEAL_001")
{
sProduct = "item_flour_001";
iDifficulty = 150;
}
if (sItemTag=="ITEM_MEAL_002")
{
sProduct = "item_flour_002";
iDifficulty = 100;
}
if (sItemTag=="ITEM_MEAL_003")
{
sProduct = "item_flour_003";
iDifficulty = 0;
}
if (sItemTag=="ITEM_MEAL_004")
{
sProduct = "item_flour_004";
iDifficulty = 50;
}
if (sItemTag=="ITEM_MEAL_005")
{
sProduct = "item_flour_005";
iDifficulty = 300;
}
if (sItemTag=="ITEM_MEAL_006")
{
sProduct = "item_flour_006";
iDifficulty = 100;
}
if (sItemTag=="ITEM_MEAL_007")
{
sProduct = "item_flour_007";
iDifficulty = 200;
}
if (sProduct=="INVALID")
{
SendMessageToPC(oPC,"You may not mill this object into any form of meal or flour!");
CopyItem(oItem,oPC,TRUE);
DestroyObject(oItem,0.1);
return;
}
int iCookSkill = GetCampaignInt("UOACraft","iCookSkill",oPC);
int iCookChance = iCookSkill;
DestroyObject(oItem,0.1);
if (iCookChance<350)
{
iCookChance = GetAbilityScore(oPC,ABILITY_WISDOM)*5;
iCookChance = iCookChance+(GetAbilityScore(oPC,ABILITY_DEXTERITY)*3);
iCookChance = iCookChance+(GetAbilityScore(oPC,ABILITY_CHARISMA)*2);
iCookChance = iCookChance*3;
if (iCookChance>350)iCookChance=350;
if (iCookSkill > iCookChance) iCookChance=iCookSkill;
}
SetLocalInt(OBJECT_SELF,"iAmInUse",99);
DelayCommand(10.0,SetLocalInt(OBJECT_SELF,"iAmInUse",0));
iCookChance = iCookChance-iDifficulty;
object oTemp = CreateObject(OBJECT_TYPE_PLACEABLE,"plc_dustplume",GetLocation(OBJECT_SELF));
DestroyObject(oTemp,9.0);
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,10.0));
PlaySound("al_cv_millwheel1");
AssignCommand(oTemp,DelayCommand(0.1,PlaySound("al_cv_fanlg1")));
AssignCommand(oPC,DelayCommand(5.0,PlaySound("as_na_x2iccrmb6")));
AssignCommand(oPC,DelayCommand(6.0,PlaySound("as_na_x2iccrmb7")));
AssignCommand(oPC,DelayCommand(7.0,PlaySound("as_na_x2iccrmb9")));
AssignCommand(oPC,DelayCommand(8.0,PlaySound("as_na_x2iccrmb7")));
AssignCommand(oPC,DelayCommand(9.0,PlaySound("as_na_x2iccrmb9")));
if (iCookChance<1)iCookChance=1;
iRandom = Random(1000)+Random(1000)+Random(800);//Adjusted difficulty downwards by a small percent to make lowlevel cooks succeed a bit more.
iRandom = iRandom/3;
if (iRandom<=iCookChance)
{
if (Random(1000) >= iCookSkill)
{
if (d10(1)+1 >= iCookChance/100) iSkillGain = 1;
}
DelayCommand(9.0,PlaySound("as_na_steamshrt2"));
AssignCommand(GetArea(oPC),DelayCommand(10.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE)));
AssignCommand(GetArea(oPC),DelayCommand(10.1,CreateAnObject(sProduct,oPC)));
}
else
{
DelayCommand(9.0,PlaySound("as_cv_woodbreak3"));
AssignCommand(GetArea(oPC),DelayCommand(10.0,FloatingTextStringOnCreature(sFail,oPC,FALSE)));
return;
}
//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 = "";
iCookSkill++;
sOldSkill2 = IntToString(iCookSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iCookSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iCookSkill <= 1000)
{
//DelayCommand(13.0,SetTokenPair(oPC,13,3,iCookSkill));
DelayCommand(14.5,SetCampaignInt("UOACraft","iCookSkill",iCookSkill,oPC));
DelayCommand(14.5,SendMessageToPC(oPC,"=================================="));
DelayCommand(14.5,SendMessageToPC(oPC,"Your skill in cooking has gone up!"));
DelayCommand(14.5,SendMessageToPC(oPC,"Current cooking skill : "+ sOldSkill+"%"));
DelayCommand(14.5,SendMessageToPC(oPC,"=================================="));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(14.4,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
}
void CreateAnObject(string sResource, object oPC)
{
CreateItemOnObject(sResource,oPC,1);
return;
}