Aschbourne_PRC8/_module/nss/s_lib_search_hrt.nss

267 lines
9.5 KiB
Plaintext
Raw Permalink Normal View History

2024-06-14 10:48:20 -04:00
void main()
{
object oBookshelf = GetNearestObjectByTag("Bookshelf",OBJECT_SELF);
int iPCSearch = GetLocalInt(oBookshelf,"PCSearch");
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC,oBookshelf);
string sPCName = GetName(oPC);
string sPlayerName = GetPCPlayerName(oPC);
string sPubCDKey = GetPCPublicCDKey(oPC);
string sFullID = sPCName + sPlayerName + sPubCDKey;
string sPCID = GetLocalString(oBookshelf,"PCID");
int iMatch = TestStringAgainstPattern(sFullID, sPCID);
int iSearchTime = GetLocalInt(oPC,"SearchTime");
int iResearch = GetLocalInt(oPC,"Research");
float fDistance = GetDistanceBetween(oPC,oBookshelf);
if (iSearchTime == 0)
{
int iTimeRoll = d20(2);
SetLocalInt(oPC,"SearchTime",iTimeRoll);
}
if (iPCSearch == 1 && iMatch && (fDistance < 4.0))
{
if (iResearch < iSearchTime)
{
int iResearch = GetLocalInt(oPC,"Research");
iResearch = iResearch+1;
SetLocalInt(oPC,"Research",iResearch);
SendMessageToPC(oPC,"OOC FEEDBACK: YOUR REQUIRED TIME IS " + IntToString(iSearchTime));
SendMessageToPC(oPC,"OOC FEEDBACK: YOUR RESEARCH TIME SO FAR IS " + IntToString(iResearch));
int iChance = d8(1);
switch (iChance)
{
case 1:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_FIREFORGET_READ,1.0,4.0));
}
break;
case 2:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_LOOK_FAR,1.0,2.0));
}
break;
case 3:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_GET_MID,1.0,3.0));
}
break;
case 4:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_SCRATCH_HEAD,1.0,1.0));
}
break;
case 5:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_FIREFORGET_PAUSE_BORED,1.0,2.0));
}
break;
case 6:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_LOOPING_PAUSE_TIRED,1.0,3.0));
}
break;
case 7:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_FIREFORGET_READ,1.0,4.0));
}
break;
case 8:
{
AssignCommand(oPC,ActionPlayAnimation(ANIMATION_FIREFORGET_READ,1.0,4.0));
}
break;
}
}
if (iResearch >= iSearchTime)
{
// A little something for the scholars . . .
if (((GetLevelByClass(CLASS_TYPE_WIZARD,oPC) != 0)||(GetLevelByClass(CLASS_TYPE_BARD,oPC) != 0)) && (GetXP(oPC) >= 0) && (GetXP(oPC) <= 1000))
{
SendMessageToPC(oPC,"You gain general knowledge by reading over the texts . . . ");
GiveXPToCreature(oPC,5);
}
// Lets see if the PC actually checks out a book . . .
if (GetIsSkillSuccessful(oPC, SKILL_SEARCH, 15))
{
string sLocalBooks = GetLocalString(oBookshelf, "LocalBooks");
string sSpecialBooks = GetLocalString(oBookshelf, "SpecialBooks");
int iChance = d20(1);
switch (iChance)
{
case 1:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book001"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 2:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book002"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 3:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book003"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 4:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book004"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 5:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book005"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 6:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book006"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 7:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book007"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 8:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sLocalBooks+"book008"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 9:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sSpecialBooks+"book001"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
case 10:
{
SendMessageToPC(oPC,"You found an interesting book!.");
CreateItemOnObject((sSpecialBooks+"book002"),oPC);
GiveXPToCreature(oPC,5);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
default: // The PC did not have much luck in finding a useful text . . .
{
SendMessageToPC(oPC,"You look through several books. Most appear to be mundane information that you already knew about. Perhaps further research will yield new information.");
GiveXPToCreature(oPC,2);
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
break;
}
}
else
{
SendMessageToPC(oPC,"No book grabs your attention well enough to check it out of the library.");
SetLocalInt(oBookshelf,"PCSearch",0);
SetLocalString(oBookshelf,"PCID","");
SetLocalInt(oPC,"Research",0);
SetLocalInt(oPC,"SearchTime",0);
}
}
}
if (iPCSearch == 1 && iMatch && (fDistance >= 4.0))
{
SendMessageToPC(oPC,"You are too far from the bookshelf to read the titles. Try staying closer to the shelf if you want to search for a book.");
}
}