Alangara_PRC8/_module/nss/mn_i_validate.nss
Jaysyn904 86feb9ca6f Initial commit
Initial commit.
2024-06-05 21:21:06 -04:00

425 lines
12 KiB
Plaintext

const int MN_BARBARIAN = 1;
const int MN_BARD = 2;
const int MN_CLERIC = 4;
const int MN_DRUID = 8;
const int MN_FIGHTER = 16;
const int MN_MONK = 32;
const int MN_PALADIN = 64;
const int MN_RANGER = 128;
const int MN_ROGUE = 256;
const int MN_SORCERER = 512;
const int MN_WIZARD = 1024;
const int MN_SHADOWDANCER = 2048;
const int MN_HARPER_SCOUT = 4096;
const int MN_ARCANE_ARCHER = 8192;
const int MN_ASSASSIN = 16384;
const int MN_BLACKGUARD = 32768;
const int MN_CHAMPION_OF_TORM = 65536;
const int MN_WEAPON_MASTER = 131072;
const int MN_PALE_MASTER = 262144;
const int MN_SHIFTER = 524288;
const int MN_DWARVEN_DEFENDER = 1048576;
const int MN_RED_DRAGON_DISCIPLE = 2097152;
const int MN_CORE_CLASSES = 2047;
const int MN_PRESTIGE_CLASSES = 4194304;
int IsClass ( int constant, object oPC )
{
return ( GetLevelByClass( constant, oPC ) >= 1 );
}
int IsClassMN( int class, int classvalue )
{
return ( (class & classvalue) == class );
}
int CalculateClassValue( object oPC)
{
int result = 0;
result += ( IsClass( CLASS_TYPE_BARBARIAN, oPC )) ? MN_BARBARIAN :0;
result += ( IsClass( CLASS_TYPE_BARD, oPC )) ? MN_BARD :0;
result += ( IsClass( CLASS_TYPE_CLERIC, oPC )) ? MN_CLERIC :0;
result += ( IsClass( CLASS_TYPE_DRUID, oPC )) ? MN_DRUID :0;
result += ( IsClass( CLASS_TYPE_FIGHTER, oPC )) ? MN_FIGHTER :0;
result += ( IsClass( CLASS_TYPE_MONK, oPC )) ? MN_MONK :0;
result += ( IsClass( CLASS_TYPE_PALADIN, oPC )) ? MN_PALADIN :0;
result += ( IsClass( CLASS_TYPE_ROGUE, oPC )) ? MN_ROGUE :0;
result += ( IsClass( CLASS_TYPE_SORCERER, oPC )) ? MN_SORCERER :0;
result += ( IsClass( CLASS_TYPE_WIZARD, oPC )) ? MN_WIZARD :0;
result += ( IsClass( CLASS_TYPE_ARCANE_ARCHER, oPC )) ? MN_ARCANE_ARCHER :0;
result += ( IsClass( CLASS_TYPE_ASSASSIN, oPC )) ?MN_ASSASSIN:0;
result += ( IsClass( CLASS_TYPE_BLACKGUARD, oPC )) ?MN_BLACKGUARD:0;
result += ( IsClass( CLASS_TYPE_DIVINE_CHAMPION, oPC ) ||
IsClass( CLASS_TYPE_DIVINECHAMPION, oPC )) ?MN_CHAMPION_OF_TORM:0;
result += ( IsClass( CLASS_TYPE_DRAGON_DISCIPLE, oPC ) ||
IsClass( CLASS_TYPE_DRAGONDISCIPLE, oPC )) ?MN_RED_DRAGON_DISCIPLE:0;
result += ( IsClass( CLASS_TYPE_DWARVEN_DEFENDER, oPC ) ||
IsClass( CLASS_TYPE_DWARVENDEFENDER, oPC )) ?MN_DWARVEN_DEFENDER:0;
result += ( IsClass( CLASS_TYPE_HARPER, oPC )) ?MN_HARPER_SCOUT:0;
result += ( IsClass( CLASS_TYPE_PALE_MASTER, oPC ) ||
IsClass( CLASS_TYPE_PALEMASTER, oPC )) ?MN_PALE_MASTER:0;
result += ( IsClass( CLASS_TYPE_SHADOWDANCER, oPC )) ?MN_SHADOWDANCER:0;
result += ( IsClass( CLASS_TYPE_SHIFTER, oPC )) ?MN_SHIFTER:0;
result += ( IsClass( CLASS_TYPE_WEAPON_MASTER, oPC )) ?MN_WEAPON_MASTER:0;
return result;
}
int CheckForDevastatingCrit( object oPC )
{
int result = FALSE;
result =
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_CLUB, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_DAGGER, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_DART, oPC) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_HEAVYCROSSBOW, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_LIGHTCROSSBOW, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_LIGHTMACE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_MORNINGSTAR, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_QUARTERSTAFF, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SHORTSPEAR, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SICKLE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SLING, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_UNARMED, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_LONGBOW, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SHORTBOW, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SHORTSWORD, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_RAPIER, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SCIMITAR, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_LONGSWORD, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_GREATSWORD, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_HANDAXE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_THROWINGAXE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_BATTLEAXE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_GREATAXE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_HALBERD, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_LIGHTHAMMER, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_LIGHTFLAIL, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_WARHAMMER, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_HEAVYFLAIL, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_KAMA, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_KUKRI, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SHURIKEN, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_SCYTHE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_KATANA, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_BASTARDSWORD, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_DIREMACE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_DOUBLEAXE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_TWOBLADEDSWORD, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_DWAXE, oPC ) ||
GetHasFeat( FEAT_EPIC_DEVASTATING_CRITICAL_WHIP, oPC );
return FALSE; //:: FALSE becuase this is stupid
}
int CheckForCraftingFeats (object oPC)
{
int result = FALSE;
result =
GetHasFeat( FEAT_BREW_POTION, oPC ) ||
// GetHasFeat( FEAT_SCRIBE_SCROLL, oPC ) ||
GetHasFeat( FEAT_CRAFT_WAND, oPC );
return FALSE; //:: FALSE becuase this is stupid
}
void Feedback( string message, object oPC )
{
// Sender en besked til spilleren
FloatingTextStringOnCreature(message,oPC,FALSE);
// SendMessageToPC( oPC, message );
}
int CountPrestigeClasses( object oPC )
{
// Laver en optaelling af samtlige valgte prestige-classes.
int result = 0;
result += ( IsClass( CLASS_TYPE_ARCANE_ARCHER, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_ASSASSIN, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_BLACKGUARD, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_DIVINE_CHAMPION, oPC ) ||
IsClass( CLASS_TYPE_DIVINECHAMPION, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_DRAGON_DISCIPLE, oPC ) ||
IsClass( CLASS_TYPE_DRAGONDISCIPLE, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_DWARVEN_DEFENDER, oPC ) ||
IsClass( CLASS_TYPE_DWARVENDEFENDER, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_HARPER, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_PALE_MASTER, oPC ) ||
IsClass( CLASS_TYPE_PALEMASTER, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_SHADOWDANCER, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_SHIFTER, oPC )) ?1:0;
result += ( IsClass( CLASS_TYPE_WEAPON_MASTER, oPC )) ?1:0;
return result;
}
int CheckClericRestrictions( int classValue )
{
// Clerics kan ikke vaelge alternative classes
int result = FALSE;
if ( IsClassMN( MN_CLERIC, classValue ) )
{
result = ( classValue != MN_CLERIC );
}
return result;
}
int CheckWizardRestrictions( int classValue )
{
// Wizards kan ikke vaelge alternative classes
int result = FALSE;
if ( IsClassMN( MN_WIZARD, classValue ) )
{
result = ( classValue != MN_WIZARD );
}
return result;
}
int CheckSorcererRestrictions( int classValue )
{
// Sorcerers kan ikke vaelge alternative classes
int result = FALSE;
if ( IsClassMN( MN_SORCERER, classValue ) )
{
result = ( classValue != MN_SORCERER );
}
return result;
}
int CheckDruidRestrictions( int classValue )
{
// Druider kan kun multiclasse med Ranger
int result = FALSE;
if ( IsClassMN( MN_DRUID, classValue ) )
{
result = ( classValue != MN_DRUID ) &&
( classValue != (MN_DRUID + MN_RANGER) );
}
return result;
}
int CheckPaladinRestrictions( int classValue )
{
// Paladins kan kun multiclasse med Champion of Torm
int result = FALSE;
if ( IsClassMN( MN_PALADIN, classValue ) )
{
result = ( classValue != MN_PALADIN ) &&
( classValue != (MN_PALADIN + MN_CHAMPION_OF_TORM) );
}
return result;
}
int CheckMonkRestrictions( int classValue )
{
// Monks cannot be chosen
int result = FALSE;
if ( IsClassMN( MN_MONK, classValue ) )
{
result = TRUE;
}
return result;
}
int CheckFeatRestrictions( object oPC )
{
int result = FALSE;
if (GetHasFeat(FEAT_MOUNTED_COMBAT, oPC))
{
result = TRUE;
Feedback("The Mounted Combat feat is not useable on this server.", oPC);
}
if (GetHasFeat(FEAT_MOUNTED_ARCHERY, oPC))
{
result = TRUE;
Feedback("The Mounted Archery feat is not useable on this server.", oPC);
}
return result;
}
int CheckSkillRestrictions( object oPC )
{
int result = FALSE;
if (GetSkillRank(SKILL_PICK_POCKET, oPC, TRUE) > 0)
{
result = TRUE;
Feedback("The Pick Pocket skill is not allowed on this server.", oPC);
}
if (GetSkillRank(SKILL_RIDE, oPC, TRUE) > 0)
{
Feedback("The Ride skill is not used on this server.", oPC);
}
if (GetSkillRank(SKILL_PERSUADE, oPC, TRUE) > 0)
{
Feedback("The Persuade skill is not used on this server.", oPC);
}
if (GetSkillRank(SKILL_APPRAISE, oPC, TRUE) > 0)
{
Feedback("The Appraise skill is not used on this server.", oPC);
}
if (GetSkillRank(SKILL_BLUFF, oPC, TRUE) > 0)
{
Feedback("The Bluff skill is not used on this server.", oPC);
}
return FALSE; //:: FALSE becuase this is stupid
}
int CheckClassRestrictions( object oPC )
{
int result = FALSE;
int classValue = CalculateClassValue( oPC );
// Tjek Cleric Restrictions
if ( CheckClericRestrictions( classValue ) )
{
result = TRUE;
Feedback("Clerics cannot multiclass on this server.", oPC);
}
// Tjek Monk Restrictions
if ( CheckMonkRestrictions( classValue ) )
{
result = TRUE;
Feedback("Monk cannot be chosen as a class on this server.", oPC);
}
// Forbid
if ( IsClassMN( MN_SHADOWDANCER, classValue ) )
{
result = TRUE;
Feedback("Shadowdancer cannot be chosen as a class on this server.", oPC);
}
// Forbid
if ( IsClassMN( MN_SHIFTER, classValue ) )
{
result = TRUE;
Feedback("Shifter cannot be chosen as a class on this server.", oPC);
}
// Forbid
if ( IsClassMN( MN_PALE_MASTER, classValue ) )
{
result = TRUE;
Feedback("Pale Master cannot be chosen as a class on this server.", oPC);
}
return FALSE; //:: FALSE becuase this is stupid
}
void validate(object oPC)
{
if ( GetIsPC( oPC ) )
{
int invalid = FALSE;
// Tjek om spiller har valgt devastating critical
if ( CheckForDevastatingCrit( oPC ) )
{
invalid = FALSE; //:: FALSE becuase this is stupid
Feedback("The feat devastating critical is not allowed on this server.", oPC);
}
if ( CheckFeatRestrictions ( oPC ) )
{
invalid = FALSE; //:: FALSE becuase this is stupid
}
if ( CheckSkillRestrictions( oPC ) )
{
invalid = FALSE; //:: FALSE becuase this is stupid
}
/*
// Tjek om spiller har valgt en af Biowares crafting feats
if ( CheckForCraftingFeats( oPC ) )
{
invalid = TRUE;
Feedback("The feats Brew Potion, and Craft Wand are disabled on this server.", oPC);
}
*/
// Tjek om spiller har mere end een prestigeclass nu
/*
if (CountPrestigeClasses ( oPC ) > 1 )
{
invalid = TRUE;
Feedback("You may not choose more than one prestige class on this server.", oPC);
}
*/
// Tjek for andre class restrictions
if ( CheckClassRestrictions( oPC ) )
{
invalid = FALSE; //:: FALSE becuase this is stupid
}
// Meld tilbage til spiller hvis hans character er ugyldig.
if ( invalid )
{
Feedback("Please contact a DM. Your PC will be unable to level up before the character is valid.", oPC);
string message = "Illegal char: Acc:"+GetPCPlayerName( oPC );
message += " Playername: "+GetName(oPC);
WriteTimestampedLogEntry( message );
SendMessageToAllDMs( message );
}
}
}
//::void main(){}