Aschbourne_PRC8/_module/nss/_use_rubble2.nss

194 lines
6.1 KiB
Plaintext
Raw Normal View History

2024-06-14 10:48:20 -04:00
//#include "_persist_01a"
void CheckAction(object oPC, object oSelf);
void CreateAnObject(string sResource, object oPC);
void ReplaceSelf(object oSelf, object oPC, string sPlaceable);
void ReplaceSelf2(object oSelf, string sPlaceable);
void main()
{
object oSelf=OBJECT_SELF;
object oPC=GetLastUsedBy();
object oGlass=OBJECT_INVALID;
object oTool=OBJECT_INVALID;
oGlass = GetItemPossessedBy(oPC,"ITEM_GLASSBOTTLE");
oTool = GetItemPossessedBy(oPC,"TOOL_SHOVEL");
if (oGlass==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You must have a glass bottle in order to gather this!",oPC,FALSE);
return;
}
if (oTool==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You must have a shovel in order to dig.",oPC,FALSE);
return;
}
if (GetLocalInt(oPC,"iAmDigging")!= 0) return;
if (GetLocalInt(oSelf,"iAmSetToDie")==0)SetLocalInt(oPC,"iAmDigging",99);
DelayCommand(5.0,SetLocalInt(oPC,"iAmDigging",0));
string sSelf=GetTag(oSelf);
string sResource = "";
string sSuccessString = "";
string sFailString = "";
string sOldSkill = "";
string sOldSkill2 = "";
//int iDigSkill=GetTokenPair(oPC,14,3);
int iDigSkill = GetCampaignInt("UOACraft","iDigSkill",oPC);
int iDigChance=iDigSkill;
int iSuccess=0;
int iToolBreak=GetLocalInt(oPC,"iToolWillBreak");
int iRandom = 0;
if (iDigChance < 350)
{
iDigChance = GetAbilityScore(oPC,ABILITY_STRENGTH)*5;
iDigChance = iDigChance + (GetAbilityScore(oPC,ABILITY_CONSTITUTION)*3);
iDigChance = iDigChance + (GetAbilityScore(oPC,ABILITY_DEXTERITY)*2);
iDigChance = iDigChance*3;
if (iDigChance >350) iDigChance = 350;
if (iDigSkill>iDigChance)iDigChance=iDigSkill;
}
if (sSelf == "_UOA_DIG_TAR")
{
if (iDigSkill<500)
{
FloatingTextStringOnCreature("You are unsure as to how to properly dig this substance!",oPC,FALSE);
return;
}
iDigChance=iDigChance-400;
sResource = "_uoa_bottle_tar";
sSuccessString = "You successfully gather some sticky tar.";
sFailString = "You try to dig some tar, but the tar is ruined by dirt and other contaminants.";
PlaySound ("as_cv_mineshovl1");
}
iRandom = Random(1000);
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,5.0));
if (iRandom <= iDigChance)
{
DelayCommand(5.0,FloatingTextStringOnCreature(sSuccessString,oPC,FALSE));
DestroyObject(oGlass,4.0);
iSuccess = 1;
DelayCommand(6.0,CreateAnObject(sResource,oPC));
if (Random(1000)<75)
{
SetLocalInt(oSelf,"iAmSetToDie",99);
SetLocalInt(oPC,"iAmDigging",0);
DelayCommand(3.0,FloatingTextStringOnCreature("The tar has temprarily stopped flowing!",oPC,FALSE));
DelayCommand(6.5,ReplaceSelf(oSelf,oPC,"x2_plc_hole_b"));
}
if (Random(1000)>= iDigSkill)
{
if (d10(1)+1>= iDigChance/1000)
{
if (GetLocalInt(oPC,"iSkillGain")==0)
{
if (GetLocalInt(oSelf,"iAmSetToDie")!=99)SetLocalInt(oPC,"iSkillGain",99);
DelayCommand(10.0,SetLocalInt(oPC,"iSkillGain",0));
iDigSkill++;
sOldSkill2 = IntToString(iDigSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iDigSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iDigSkill <= 1000)
{
//DelayCommand(5.5,SetTokenPair(oPC,14,3,iDigSkill));
DelayCommand(6.0,SetCampaignInt("UOACraft","iDigSkill",iDigSkill,oPC));
DelayCommand(6.0,SendMessageToPC(oPC,"=================================="));
DelayCommand(6.0,SendMessageToPC(oPC,"Your skill in digging has gone up!"));
DelayCommand(6.0,SendMessageToPC(oPC,"Current digging skill : "+ sOldSkill+"%"));
DelayCommand(6.0,SendMessageToPC(oPC,"=================================="));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(6.0,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
}
}
}
else
{
switch (d8(1))
{
case 1:{sFailString="Your progress is slow...";break;}
case 2:{sFailString="Your back is getting sore...";break;}
case 3:{sFailString="Your arms are getting tired...";break;}
case 4:{sFailString="You know there has to be some in here somewhere..";break;}
case 5:{sFailString="This is back-breaking work!";break;}
default:{break;}
}
DelayCommand(5.0,FloatingTextStringOnCreature(sFailString,oPC,FALSE));
DelayCommand(5.5,AssignCommand(oPC,CheckAction(oPC,oSelf)));
return;
}
if (iSuccess == 1)
{
iToolBreak++;
if (iToolBreak > 100)
{
DelayCommand(6.0,FloatingTextStringOnCreature("Your tool has broken while digging..",oPC,FALSE));
DestroyObject(oTool,6.0);
iToolBreak = 0;
}
}
SetLocalInt(oPC,"iToolWillBreak",iToolBreak);
}
void CheckAction(object oPC, object oSelf)
{
int iCurrentAction = GetCurrentAction(oPC);
if (iCurrentAction == ACTION_MOVETOPOINT) return;
if (iCurrentAction == ACTION_ATTACKOBJECT) return;
if (iCurrentAction == ACTION_CASTSPELL) return;
if (iCurrentAction == ACTION_REST) return;
if (iCurrentAction == ACTION_PICKUPITEM) return;
if (iCurrentAction == ACTION_SIT) return;
if (GetDistanceBetween(oPC,oSelf) >2.5) return;
AssignCommand(oPC,ActionInteractObject(oSelf));
}
void CreateAnObject(string sResource, object oPC)
{
CreateItemOnObject(sResource,oPC,1);
return;
}
void ReplaceSelf(object oSelf, object oPC, string sPlaceable)
{
object oTemp;
oTemp = CreateObject(OBJECT_TYPE_PLACEABLE,sPlaceable,GetLocation(oSelf),FALSE);
AssignCommand(oTemp,DelayCommand(600.0,ReplaceSelf2(oTemp,"depositoftar001")));
DestroyObject(oTemp,610.0);
DestroyObject(oSelf,1.0);
SetLocalInt(oPC,"iAmDigging",0);
return;
}
void ReplaceSelf2(object oSelf, string sPlaceable)
{
CreateObject(OBJECT_TYPE_PLACEABLE,sPlaceable,GetLocation(oSelf),FALSE);
return;
}