Initial Upload
Initial Upload
This commit is contained in:
141
_module/nss/tracking.nss
Normal file
141
_module/nss/tracking.nss
Normal file
@@ -0,0 +1,141 @@
|
||||
//:://////////////////////////////////////////////
|
||||
//:: Locke's Smart Tracker
|
||||
//:: Big thanks to Barvas and The Order of the Hidden!
|
||||
//:: http://www.orderofthehidden.org/
|
||||
//:: http://stormtemplar.project404.org
|
||||
//:://////////////////////////////////////////////
|
||||
|
||||
#include "prc_inc_racial"
|
||||
|
||||
object oTracks = OBJECT_SELF;
|
||||
void CleanTracks()
|
||||
{
|
||||
DeleteLocalInt(oTracks, "nGroupSize");
|
||||
DeleteLocalInt(oTracks, "creaturetimehour");
|
||||
DeleteLocalInt(oTracks, "creaturetimeday");
|
||||
DeleteLocalInt(oTracks, "creaturesize");
|
||||
DeleteLocalString(oTracks, "sLastCreature");
|
||||
DeleteLocalString(oTracks, "sCreaturesSoFar");
|
||||
}
|
||||
void main()
|
||||
{
|
||||
DelayCommand(300.0, CleanTracks());
|
||||
//Check who walks through
|
||||
object oUsed = GetEnteringObject();
|
||||
|
||||
//Check if it is a PC
|
||||
int PCCheck = GetIsPC(oUsed);
|
||||
int iSize;
|
||||
int iRace;
|
||||
string sRace;
|
||||
//If the entering object isn't a PC, store variables
|
||||
if (PCCheck == FALSE || GetIsDMPossessed(oUsed) == TRUE)
|
||||
{
|
||||
int iGroupSize = GetLocalInt(oTracks, "nGroupSize");
|
||||
//clear variables in case it's used twice
|
||||
DeleteLocalInt(oTracks, "creaturetimehour");
|
||||
DeleteLocalInt(oTracks, "creaturetimeday");
|
||||
//Get the time
|
||||
int iHour = GetTimeHour();
|
||||
int iDay = GetCalendarDay();
|
||||
|
||||
//Get the creature info
|
||||
iSize = GetCreatureSize(oUsed);
|
||||
int iRace = MyPRCGetRacialType(oUsed);
|
||||
string sData;
|
||||
//Store the info
|
||||
SetLocalInt(oTracks, "nGroupSize", iGroupSize + 1);
|
||||
SetLocalInt(oTracks, "sLastCreature", iRace);
|
||||
SetLocalInt(oTracks, "sCreaturesSoFar", iRace);
|
||||
SetLocalInt(oTracks, "creaturetimehour", iHour);
|
||||
SetLocalInt(oTracks, "creaturetimeday", iDay);
|
||||
SetLocalInt(oTracks, "creaturesize", iSize);
|
||||
int CreatureRace = GetLocalInt(oTracks, "sLastCreature");
|
||||
string sRace;
|
||||
switch(CreatureRace)
|
||||
{
|
||||
case RACIAL_TYPE_DWARF: sData="Dwarf"; break;
|
||||
case RACIAL_TYPE_ELF: sData = "Elf"; break;
|
||||
case RACIAL_TYPE_GNOME: sData = "Gnome"; break;
|
||||
case RACIAL_TYPE_HALFELF: sData = "Half-elf"; break;
|
||||
case RACIAL_TYPE_HALFLING: sData = "Halfling"; break;
|
||||
case RACIAL_TYPE_HALFORC: sData = "Half-Orc"; break;
|
||||
case RACIAL_TYPE_HUMAN: sData="Human"; break;
|
||||
default: sData = GetName(oUsed); break;
|
||||
}
|
||||
string sCurrentCreature = sData;
|
||||
string sLastCreature = GetLocalString(oTracks, "sLastCreature");
|
||||
string sCreaturesSoFar = GetLocalString(oTracks, "sCreaturesSoFar");
|
||||
if (sLastCreature == "") //No creatures logged yet
|
||||
SetLocalString(oTracks, "sLastCreature", sCurrentCreature);
|
||||
else if (sCreaturesSoFar == "") //Only one creature so far
|
||||
{
|
||||
SetLocalString(oTracks, "sCreaturesSoFar", "a " + sLastCreature);
|
||||
SetLocalString(oTracks, "sLastCreature", sCurrentCreature);
|
||||
}
|
||||
else //more than one creature has gone by.
|
||||
{
|
||||
SetLocalString(oTracks, "sCreaturesSoFar", sCreaturesSoFar + ", a " + sLastCreature);
|
||||
SetLocalString(oTracks, "sLastCreature", sCurrentCreature);
|
||||
}
|
||||
}
|
||||
int iGroupSize = GetLocalInt(oTracks, "nGroupSize");
|
||||
if (PCCheck == TRUE)
|
||||
{
|
||||
//Get the PC's spot skill
|
||||
int iSpot = GetSkillRank(SKILL_SPOT, oUsed);
|
||||
//Check classes. Ranger, druid, or barbarian are auto-succeed
|
||||
//I'm using 15 as the spot rank skill. It can be changed, of course
|
||||
if (GetLevelByClass(CLASS_TYPE_RANGER, oUsed) >= 1 || GetLevelByClass(CLASS_TYPE_DRUID, oUsed) >= 1
|
||||
|| GetLevelByClass(CLASS_TYPE_BARBARIAN, oUsed) >= 1
|
||||
|| GetLevelByClass(CLASS_TYPE_TOTEMIST, oUsed) >= 1
|
||||
|| GetLevelByClass(CLASS_TYPE_SHAMAN, oUsed) >= 1
|
||||
|| iSpot >= 25)
|
||||
{
|
||||
//Retrieve the creature info
|
||||
int TimeHour = GetLocalInt(oTracks, "creaturetimehour");
|
||||
int TimeDay = GetLocalInt(oTracks, "creaturetimeday");
|
||||
//Convert it into strings so it can be said by the PC
|
||||
string sDay = IntToString(TimeDay);
|
||||
string sHour = IntToString(TimeHour);
|
||||
|
||||
//Say it
|
||||
string sLastCreature = GetLocalString(oTracks, "sLastCreature");
|
||||
string sCreaturesSoFar = GetLocalString(oTracks, "sCreaturesSoFar");
|
||||
if (iGroupSize == 0)
|
||||
{
|
||||
AssignCommand(oUsed, SpeakString("Looks like nothing has been around here recently."));
|
||||
}
|
||||
else
|
||||
{
|
||||
string sMessage = IntToString(iGroupSize) + " creature(s) moved through here: ";
|
||||
if (sCreaturesSoFar != "")
|
||||
sMessage = sMessage + sCreaturesSoFar + ", and a ";
|
||||
sMessage = sMessage + sLastCreature + " ";
|
||||
AssignCommand(oUsed, SpeakString(sMessage+ "today at hour " +sHour+ "."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
//If the PC fails to meet the above criteria,
|
||||
//the PC can only tell the creature size
|
||||
// if (iGroupSize == 0)
|
||||
// {
|
||||
// AssignCommand(oUsed, SpeakString("Looks like nothing has been around here recently."));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// iSize = GetLocalInt(oTracks, "creaturesize");
|
||||
// switch(iSize)
|
||||
// {
|
||||
// case 2: AssignCommand(oUsed, SpeakString("I can only make out one fresh set. Looks like a small creature went past here."));break;
|
||||
// case 3: AssignCommand(oUsed, SpeakString("I can only make out one fresh set. Looks like a medium creature went past here."));;break;
|
||||
// case 4: AssignCommand(oUsed, SpeakString("I can only make out one fresh set. Looks like a large creature went past here."));;break;
|
||||
// case 5: AssignCommand(oUsed, SpeakString("I can only make out one fresh set. Looks like a gigantic creature went past here."));; break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user