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

159 lines
4.6 KiB
Plaintext

//#include "_persist_01a"
void ItemCreate(object oPC, string sSeedResRef);
void CreatePlaceable(string sObject, location lPlace, float fDuration)
{
object oPlaceable = CreateObject(OBJECT_TYPE_PLACEABLE,sObject,lPlace,FALSE);
if (fDuration != 0.0)
DestroyObject(oPlaceable,fDuration);
}
void main()
{
object oPC = OBJECT_SELF;
string sPlantSeedTag = GetLocalString(oPC,"sItemActivated");
string sPlantResRef = "";
string sSeedResRef = "";
int iFailPlant = 0;
object oTool = OBJECT_INVALID;
object oWater = OBJECT_INVALID;
string sSuccess = "";
int iWater = GetLocalInt(oPC,"iWaterFull");
//int iFarmSkill = GetTokenPair(oPC,14,6);
int iFarmSkill = GetCampaignInt("UOACraft","iFarmSkill",oPC);
int iFarmChance = iFarmSkill;
int iSuccess = 0;
oTool = GetItemPossessedBy(oPC,"TOOL_SHOVEL");
if (GetLocalInt(oPC,"iAmInWaterField") != 99)
{
FloatingTextStringOnCreature("You must be in a water-soaked field in order to plant seeds.",oPC,FALSE);
iFailPlant = 99;
}
if (oTool == OBJECT_INVALID)
{
if (iFailPlant != 99) FloatingTextStringOnCreature("You must have a shovel in order to plant these seeds.",oPC,FALSE);
iFailPlant = 99;
}
if (iFarmChance <350)
{
iFarmChance = GetAbilityScore(oPC,ABILITY_WISDOM)*5;
iFarmChance = iFarmChance + (GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*3);
iFarmChance = iFarmChance+ (GetAbilityScore(oPC,ABILITY_CHARISMA)*2);
iFarmChance = iFarmChance *3;
if (iFarmChance > 350) iFarmChance = 350;
if (iFarmSkill > iFarmChance) iFarmChance = iFarmSkill;
}
if (sPlantSeedTag=="SEED_RICE")
{
sPlantResRef = "plant003";
sSeedResRef = "ricegrains";
sSuccess = "You plant the seed with tender care.";
}
if (sPlantSeedTag=="SEED_BAMBOO")
{
sPlantResRef = "plant007";
sSeedResRef = "bambooshoots";
sSuccess = "You plant the shoots with tender care.";
}
if (sPlantSeedTag =="SEED_SUGARCANE")
{
sPlantResRef = "plant072";
sSeedResRef = "seed_cane001";
iFarmChance = iFarmChance-200;
}
if (iFailPlant == 99)
{
CreateItemOnObject(sSeedResRef,oPC,1);
return;
}
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW,1.0,6.0));
PlaySound("as_cv_mineshovl1");
DelayCommand(3.0,PlaySound("as_na_splash2"));
int iRandom = Random(1000);
int iSkillGain = 0;
if (iRandom <= iFarmChance)
{
iSuccess = 1;
iRandom = Random(1000);
if (iRandom >= iFarmSkill)
{
if (d10(1)+1 >= iFarmChance/100) iSkillGain = 1;
}
}
if (iSuccess == 0)
{
DelayCommand(6.0,FloatingTextStringOnCreature("You are unable to make the plant grow.",oPC,FALSE));
return;
}
DelayCommand(6.0,FloatingTextStringOnCreature(sSuccess,oPC,FALSE));
if (iSkillGain ==1)
{
string sOldSkill = "";
string sOldSkill2 = "";
iFarmSkill++;
sOldSkill2 = IntToString(iFarmSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iFarmSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iFarmSkill <= 1000)
{
//DelayCommand(5.0,SetTokenPair(oPC,14,6,iFarmSkill));
DelayCommand(6.0,SetCampaignInt("UOACraft","iFarmSkill",iFarmSkill,oPC));
DelayCommand(6.0,SendMessageToPC(oPC,"==============================="));
DelayCommand(6.0,SendMessageToPC(oPC,"Your Farming skill has gone up!"));
DelayCommand(6.0,SendMessageToPC(oPC,"Current Farming skill : "+ sOldSkill+"%"));
DelayCommand(6.0,SendMessageToPC(oPC,"==============================="));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(5.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
float fPause = 1800.0 - IntToFloat(iFarmSkill);
//fPause = fPause/10.0;
object oTemp = CreateObject(OBJECT_TYPE_PLACEABLE,"temporaryplaceho",GetLocation(oPC),FALSE);
AssignCommand(oTemp,DelayCommand(fPause,CreatePlaceable(sPlantResRef,GetLocation(oTemp),0.0)));
DestroyObject(oTemp,fPause+10.0);
DelayCommand(7.0,SendMessageToPC(oPC,"Be sure to check back later to see if your plant has grown yet."));
int iToolBreak=GetLocalInt(oPC,"iToolWillBreak");
iToolBreak++;
if (iToolBreak > 100)
{
DelayCommand(2.0,FloatingTextStringOnCreature("Your shovel has broken while digging..",oPC,FALSE));
DestroyObject(oTool,2.0);
iToolBreak = 0;
}
SetLocalInt(oPC,"iToolWillBreak",iToolBreak);
}
void ItemCreate(object oPC, string sSeedResRef)
{
object oSeed = CreateItemOnObject(sSeedResRef,oPC,1);
return;
}