Aschbourne_PRC8/_module/nss/_craft_map.nss

205 lines
6.0 KiB
Plaintext
Raw Normal View History

2024-06-14 10:48:20 -04:00
void GetNextItemPossessedBy(object oPC, string sItemTag);
void CreateAnObject(string sResource, object oPC, int iStackSize);
void CreateAMap(string sResource, object oPC, int iStackSize, int iMapSkill);
void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef);
void main()
{
object oPC = OBJECT_SELF;
object oArea = GetArea(oPC);
string sAreaResRef = GetResRef(oArea);
string sAreaName = GetName(oArea);
int iMapSkill = GetCampaignInt("UOACraft","iMapSkill",oPC);
int iMapChance = iMapSkill;
string sComponent1 = "";
string sComponent2 = "";
string sComponent3 = "";
string sComponent1Name = "";
string sComponent2Name = "";
string sComponent3Name = "";
string sComponentResRef = "";
int iComponent1 = 0;
int iComponent2 = 0;
int iComponent3 = 0;
int iComponent1Stackable = 0;
int iComponent2Stackable = 0;
int iComponent3Stackable = 0;
int iStackSize = 0;
int iFailStackable = 0;
string sItemResRef = "";
string sFailResRef = "";
if (iMapChance <350)
{
iMapChance = GetAbilityScore(oPC,ABILITY_INTELLIGENCE)*5;
iMapChance = iMapChance +(GetAbilityScore(oPC,ABILITY_WISDOM)*3);
iMapChance = iMapChance +(GetAbilityScore(oPC,ABILITY_DEXTERITY)*2);
iMapChance = iMapChance * 3;
if (iMapChance >350) iMapChance = 350;
if (iMapSkill > iMapChance) iMapChance = iMapSkill;
}
object oInk = GetItemPossessedBy(oPC,"ink_mapmaker");
if (oInk==OBJECT_INVALID)
{
FloatingTextStringOnCreature("You must have cartographers ink in order to draw a map!",oPC,FALSE);
CreateItemOnObject("papr_blank_silk",oPC,1);
return;
}
int iInk = GetNumStackedItems(oInk);
if (iInk>1)
{
iInk--;
SetItemStackSize(oInk,iInk);
}
else
{
DestroyObject(oInk);
}
if (Random(1000) > iMapChance)
{
DelayCommand(6.0,FloatingTextStringOnCreature("You fail to chart the locale properly, resulting in a useless map.",oPC,FALSE));
DelayCommand(6.1,CreateAnObject("inscribedmap001",oPC,1));
return;
}
DelayCommand(6.5,CreateAMap("inscribedmap",oPC,1,iMapChance));
int iSkillGain=0;
if (Random(1000)>=iMapSkill)
{
if (d10(1)+1 >= iMapChance/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 = "";
iMapSkill++;
sOldSkill2 = IntToString(iMapSkill);
sOldSkill = "."+GetStringRight(sOldSkill2,1);
if (iMapSkill > 9)
{
sOldSkill = GetStringLeft(sOldSkill2,GetStringLength(sOldSkill2)-1)+sOldSkill;
}
else
{
sOldSkill = "0"+sOldSkill;
}
if (iMapSkill <= 1000)
{
//DelayCommand(6.0,SetTokenPair(oPC,14,12,iAlchemySkill));
DelayCommand(6.0,SetCampaignInt("UOACraft","iMapSkill",iMapSkill,oPC));
DelayCommand(6.1,SendMessageToPC(oPC,"======================================"));
DelayCommand(6.2,SendMessageToPC(oPC,"Your skill in cartography has gone up!"));
DelayCommand(6.3,SendMessageToPC(oPC,"Current cartography skill : "+ sOldSkill+"%"));
DelayCommand(6.4,SendMessageToPC(oPC,"======================================"));
if (GetLocalInt(GetModule(),"_UOACraft_XP")!=0) DelayCommand(5.9,GiveXPToCreature(oPC,GetLocalInt(GetModule(),"_UOACraft_XP")));
}
}
//sResRef = "inscribedmap"
/*
papr_blank_silk
ink_mapmaker
string sMapAreaTag = GetLocalString(oMap,"sMapAreaTag");
string sMapAreaName = GetLocalString(oMap,"sMapAreaName");
float fMapUsedX = GetLocalFloat(oMap,"fMapPositionX");
float fMapUsedY = GetLocalFloat(oMap,"fMapPositionY");
float fMapUsedZ = GetLocalFloat(oMap,"fMapPositionZ");
float fMapOrientation = GetFacing(oPC);
object oMapArea = GetObjectByTag(sMapAreaTag);
//May need to filter out all non-area object types in case of
//tag-related issues.. i.e. area tag matching a sword item tag.
vector vMap = Vector(fMapUsedX,fMapUsedY,fMapUsedZ);
int iMapSkill = GetLocalInt(oMap,"iMapUsedSkill");
location lPC = Location(oMapArea,vMap,fMapOrientation);
*/
}
void CreateAnObject(string sResource, object oPC, int iStackSize)
{
CreateItemOnObject(sResource,oPC,iStackSize);
return;
}
void GetNextItemPossessedBy(object oPC, string sItemTag)
{
object oTemp = GetItemPossessedBy(oPC,sItemTag);
DestroyObject(oTemp);
return;
}
void GetNextStackedItem(object oPC, string sItemTag, int iCount, int iMode, string sStackResRef)
{
object oTemp = GetItemPossessedBy(oPC,sItemTag);
int iStackCount = GetNumStackedItems(oTemp);
int iTemp = iCount - iStackCount;
iStackCount = iStackCount-iCount;
DestroyObject(oTemp);
if (iStackCount > 0)
{
SendMessageToPC(oPC,"You should get back "+IntToString(iStackCount));
DelayCommand(1.0,CreateAnObject(sStackResRef,oPC,iStackCount));
}
// this next line *should* recursively call this function if the number of
// stacked items does not meet the required number of items to be destroyed.
if (iTemp > 0) DelayCommand(1.0,GetNextStackedItem(oPC,sItemTag,iTemp, iMode, sStackResRef));
return;
}
void CreateAMap(string sResource, object oPC, int iStackSize, int iMapSkill)
{
object oArea = GetArea(oPC);
string sAreaTag = GetTag(oArea);
string sAreaName = GetName(oArea);
vector vPC = GetPosition(oPC);
float fMapX = vPC.x;
float fMapY = vPC.y;
float fMapZ = vPC.z;
object oMap = CreateItemOnObject(sResource,oPC,iStackSize);
SetLocalString(oMap,"sMapAreaTag",sAreaTag);
SetLocalString(oMap,"sMapAreaName",sAreaName);
SetLocalFloat(oMap,"fMapPositionX",fMapX);
SetLocalFloat(oMap,"fMapPositionY",fMapY);
SetLocalFloat(oMap,"fMapPositionZ",fMapZ);
SetLocalInt(oMap,"iMapUsedSkill",iMapSkill);
return;
}