LoD_PRC8/_module/nss/partycheck.nss
Jaysyn904 94990edc60 Initial Upload
Initial Upload
2023-09-21 21:20:34 -04:00

50 lines
1.8 KiB
Plaintext

//party check: made for LOD by bf.
//... tests if 2 pc's are near each other and of the same party. and reports the results.
//I would call this either from pc death or creature death... to minimise cpu usage
// this way the pc's can be together.. as long as they are not getting any XP benefits.
//if used in npc or monster ondeath the method for calling would be.
// ExecuteScript("partycheck",GetLastKiller());
//if used in pc ondeath it method for calling would be.
// ExecuteScript("partycheck", OBJECT_SELF);
int GetXPLevel(object oPC) {
int level = FloatToInt((1+sqrt(1+4.*GetXP(oPC)/500))/2);
if (level > 20){level = 20;}
return level;
}
void main()
{
int iXP;
float fDistance;
int LevelDifference;
object oPC = GetFirstFactionMember(OBJECT_SELF);
object oAreaSelf = GetArea(OBJECT_SELF);
string sCheat;
// AssignCommand(OBJECT_SELF, ActionSpeakString("test")); //for testing
int iLevelSelf = GetXPLevel (OBJECT_SELF);
while (GetIsObjectValid(oPC))
{
if (GetArea (oPC) == oAreaSelf && oPC != OBJECT_SELF)
{
fDistance = GetDistanceBetween(OBJECT_SELF, oPC);
if (fDistance < 20.0 && fDistance > 0.0) //close enough to get xp
{
LevelDifference = GetXPLevel(oPC) - iLevelSelf;
if (LevelDifference > 4 || LevelDifference < -4)
{
string sCheat = "Level Violation " + GetName(OBJECT_SELF) + " in " + GetName(oAreaSelf);
//cheating
// SendMessageToAllDMs(sCheat);
AssignCommand(OBJECT_SELF, ActionSpeakString(sCheat)); //for testing
ActionSpeakString(sCheat); //for testing
}
}
}
oPC = GetNextFactionMember(OBJECT_SELF);
}
}