generated from Jaysyn/ModuleTemplate
Initial Commit
Initial Commit.
This commit is contained in:
307
_module/nss/jw_exp_functions.nss
Normal file
307
_module/nss/jw_exp_functions.nss
Normal file
@@ -0,0 +1,307 @@
|
||||
// returns TRUE if the PC qualifies for a multiclass penalty, FALSE if not
|
||||
int Multipen(object oPC);
|
||||
// Returns a float which can be more than 1 if the mob is higher level than the party, and less than
|
||||
// 1 if it is lower level than the party. nDifference should be the difference between party level
|
||||
// and mob CR
|
||||
float getmodifier (int nDifference);
|
||||
// Function to allow us to control xp distribution,
|
||||
// Does not give them xp if they have turned XP off
|
||||
void JWGiveXP(int nXP, object oPlayer);
|
||||
// Sets whether this player can gain xp
|
||||
// if nOnOff is TRUE then xp is turned off
|
||||
// if nOnOff is FALSE then xp is turned back on
|
||||
void SetXPOnOff(object oPlayer, int nOnOff=TRUE);
|
||||
// Gets whether this player has turned xp off
|
||||
// returns TRUE if XP is off
|
||||
int GetXPOnOff(object oPlayer);
|
||||
|
||||
#include "prc_inc_racial"
|
||||
|
||||
void SetXPOnOff(object oPlayer, int nOnOff=TRUE)
|
||||
{
|
||||
object oBox=GetItemPossessedBy(oPlayer,"jw_crafting_gem");
|
||||
SetLocalInt(oBox,"XPOFF",nOnOff);
|
||||
}
|
||||
|
||||
int GetXPOnOff(object oPlayer)
|
||||
{
|
||||
object oBox=GetItemPossessedBy(oPlayer,"jw_crafting_gem");
|
||||
return GetLocalInt(oBox,"XPOFF");
|
||||
}
|
||||
|
||||
int Multipen(object oPC)
|
||||
{
|
||||
|
||||
|
||||
int nClass1=GetClassByPosition(1,oPC);
|
||||
int nClass2=GetClassByPosition(2,oPC);
|
||||
int nClass3=GetClassByPosition(3,oPC);
|
||||
|
||||
if ((nClass1==CLASS_TYPE_ARCANE_ARCHER)||(nClass1==CLASS_TYPE_ASSASSIN)|| (nClass1==CLASS_TYPE_BLACKGUARD)||(nClass1==CLASS_TYPE_HARPER)||(nClass1==CLASS_TYPE_SHADOWDANCER)||(nClass1==CLASS_TYPE_ANIMAL)||(nClass1==CLASS_TYPE_DIVINECHAMPION)||(nClass1==CLASS_TYPE_DRAGONDISCIPLE)||(nClass1==CLASS_TYPE_DWARVENDEFENDER)||(nClass1==CLASS_TYPE_PALEMASTER)||(nClass1==CLASS_TYPE_SHIFTER)||(nClass1==CLASS_TYPE_WEAPON_MASTER))
|
||||
{
|
||||
nClass1=CLASS_TYPE_INVALID;
|
||||
}
|
||||
|
||||
if ((nClass2==CLASS_TYPE_ARCANE_ARCHER)||(nClass2==CLASS_TYPE_ASSASSIN)|| (nClass2==CLASS_TYPE_BLACKGUARD)||(nClass2==CLASS_TYPE_HARPER)||(nClass2==CLASS_TYPE_SHADOWDANCER)||(nClass2==CLASS_TYPE_ANIMAL)||(nClass2==CLASS_TYPE_DIVINECHAMPION)||(nClass2==CLASS_TYPE_DRAGONDISCIPLE)||(nClass2==CLASS_TYPE_DWARVENDEFENDER)||(nClass2==CLASS_TYPE_PALEMASTER)||(nClass2==CLASS_TYPE_SHIFTER)||(nClass2==CLASS_TYPE_WEAPON_MASTER))
|
||||
{
|
||||
nClass2=CLASS_TYPE_INVALID;
|
||||
}
|
||||
|
||||
if ((nClass3==CLASS_TYPE_ARCANE_ARCHER)||(nClass3==CLASS_TYPE_ASSASSIN)|| (nClass3==CLASS_TYPE_BLACKGUARD)||(nClass3==CLASS_TYPE_HARPER)||(nClass3==CLASS_TYPE_SHADOWDANCER)||(nClass3==CLASS_TYPE_ANIMAL)||(nClass3==CLASS_TYPE_DIVINECHAMPION)||(nClass3==CLASS_TYPE_DRAGONDISCIPLE)||(nClass3==CLASS_TYPE_DWARVENDEFENDER)||(nClass3==CLASS_TYPE_PALEMASTER)||(nClass3==CLASS_TYPE_SHIFTER)||(nClass3==CLASS_TYPE_WEAPON_MASTER))
|
||||
{
|
||||
nClass3=CLASS_TYPE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int nLevel1=GetLevelByClass(nClass1,oPC);
|
||||
int nLevel2=GetLevelByClass(nClass2,oPC);
|
||||
int nLevel3=GetLevelByClass(nClass3,oPC);
|
||||
|
||||
int nRace=MyPRCGetRacialType(oPC);
|
||||
|
||||
int nFavoured;
|
||||
|
||||
// favoured == 99 means any
|
||||
|
||||
int nProblem1=0;
|
||||
int nProblem2=0;
|
||||
int nProblem3=0;
|
||||
|
||||
|
||||
|
||||
int nPenalty=0;
|
||||
|
||||
if (nRace==RACIAL_TYPE_DWARF) //RACIAL_TYPE_DWARF
|
||||
{nFavoured=CLASS_TYPE_FIGHTER;}
|
||||
|
||||
if (nRace==RACIAL_TYPE_ELF) //RACIAL_TYPE_elf
|
||||
{nFavoured=CLASS_TYPE_WIZARD;}
|
||||
|
||||
if (nRace== RACIAL_TYPE_GNOME) //RACIAL_TYPE_gnome
|
||||
{nFavoured=CLASS_TYPE_WIZARD;}
|
||||
|
||||
if (nRace==RACIAL_TYPE_HALFLING) //RACIAL_TYPE_halfling
|
||||
{nFavoured=CLASS_TYPE_ROGUE;}
|
||||
|
||||
if (nRace== RACIAL_TYPE_HALFELF) //RACIAL_TYPE_halfelf
|
||||
{nFavoured=99;}
|
||||
|
||||
if (nRace== RACIAL_TYPE_HALFORC) //RACIAL_TYPE_halforc
|
||||
{nFavoured=CLASS_TYPE_BARBARIAN;}
|
||||
|
||||
if (nRace== RACIAL_TYPE_HUMAN) //RACIAL_TYPE_human
|
||||
{nFavoured=99;}
|
||||
|
||||
if (nRace== RACIAL_TYPE_ANIMAL) //RACIAL_TYPE_animal
|
||||
{nFavoured=99;}
|
||||
|
||||
|
||||
|
||||
|
||||
/// first of all, check to see if the classes are roughly equal
|
||||
int nEqual=0;
|
||||
// as long as nEqual==0, they are roughly level.
|
||||
|
||||
|
||||
if ((nClass1!=CLASS_TYPE_INVALID)&&(nClass2!=CLASS_TYPE_INVALID))
|
||||
{
|
||||
if ((nLevel1-nLevel2>1)||(nLevel2-nLevel1>1)) //the difference between class 1 and 2 is more than 1
|
||||
|
||||
{
|
||||
nEqual=1;
|
||||
nProblem1=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((nClass1!=CLASS_TYPE_INVALID)&&(nClass3!=CLASS_TYPE_INVALID))
|
||||
{
|
||||
if ((nLevel1-nLevel3>1)||(nLevel3-nLevel1>1)) //the difference between class 1 and 3 is more than 1
|
||||
|
||||
{
|
||||
nEqual=1;
|
||||
nProblem2=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((nClass2!=CLASS_TYPE_INVALID)&&(nClass3!=CLASS_TYPE_INVALID))
|
||||
{
|
||||
if ((nLevel2-nLevel3>1)||(nLevel3-nLevel2>1)) //the difference between class 1 and 2 is more than 1
|
||||
|
||||
{
|
||||
nEqual=1;
|
||||
nProblem3=1;
|
||||
}
|
||||
}
|
||||
// if there is no problem here, return zero
|
||||
if (nEqual==0)
|
||||
{
|
||||
return nPenalty;
|
||||
}
|
||||
|
||||
// classes are unequal but are any of the unequal classes favoured?
|
||||
// do humans and half elves first
|
||||
if (nFavoured==99)
|
||||
{
|
||||
if ((nProblem1==1)&&(nProblem2==1)&&(nProblem3==1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// now do everyone else
|
||||
|
||||
if (nProblem1==1)
|
||||
{
|
||||
if ((nClass1!=nFavoured)&&(nClass2!=nFavoured))
|
||||
{
|
||||
nPenalty=1;
|
||||
}
|
||||
}
|
||||
|
||||
if (nProblem2==1)
|
||||
{
|
||||
if ((nClass1!=nFavoured)&&(nClass3!=nFavoured))
|
||||
{
|
||||
nPenalty=1;
|
||||
}
|
||||
}
|
||||
|
||||
if (nProblem3==1)
|
||||
{
|
||||
if ((nClass2!=nFavoured)&&(nClass3!=nFavoured))
|
||||
{
|
||||
nPenalty=1;
|
||||
}
|
||||
}
|
||||
|
||||
return nPenalty;
|
||||
|
||||
}
|
||||
|
||||
|
||||
float getmodifier (int nDifference)
|
||||
|
||||
{
|
||||
|
||||
// works out the modified for xp, based on the difference between the player or average party level and
|
||||
// the cr of the mob.
|
||||
|
||||
float fModifier;
|
||||
|
||||
if (nDifference <= -7)
|
||||
{
|
||||
fModifier=3.2;
|
||||
}
|
||||
|
||||
if (nDifference == -6)
|
||||
{
|
||||
fModifier=2.8;
|
||||
}
|
||||
|
||||
if (nDifference == -5)
|
||||
{
|
||||
fModifier=2.4;
|
||||
}
|
||||
|
||||
if (nDifference == -4)
|
||||
{
|
||||
fModifier=2.0;
|
||||
}
|
||||
|
||||
if (nDifference == -3)
|
||||
{
|
||||
fModifier=1.6;
|
||||
}
|
||||
|
||||
if (nDifference == -2)
|
||||
{
|
||||
fModifier=1.4;
|
||||
}
|
||||
|
||||
if (nDifference == -1)
|
||||
{
|
||||
fModifier=1.2;
|
||||
}
|
||||
|
||||
|
||||
if (nDifference == 0)
|
||||
{
|
||||
fModifier=1.0;
|
||||
}
|
||||
|
||||
if (nDifference == 1)
|
||||
{
|
||||
fModifier=0.9;
|
||||
}
|
||||
|
||||
if (nDifference == 2)
|
||||
{
|
||||
fModifier=0.8;
|
||||
}
|
||||
|
||||
if (nDifference == 3)
|
||||
{
|
||||
fModifier=0.7;
|
||||
}
|
||||
|
||||
if (nDifference == 4)
|
||||
{
|
||||
fModifier=0.6;
|
||||
}
|
||||
|
||||
if (nDifference == 5)
|
||||
{
|
||||
fModifier=0.5;
|
||||
}
|
||||
|
||||
if (nDifference == 6)
|
||||
{
|
||||
fModifier=0.4;
|
||||
}
|
||||
|
||||
if (nDifference == 7)
|
||||
{
|
||||
fModifier=0.3;
|
||||
}
|
||||
|
||||
if (nDifference == 8)
|
||||
{
|
||||
fModifier=0.2;
|
||||
}
|
||||
|
||||
if (nDifference == 9)
|
||||
{
|
||||
fModifier=0.1;
|
||||
}
|
||||
|
||||
if (nDifference >= 10)
|
||||
{
|
||||
fModifier=0.05;
|
||||
}
|
||||
|
||||
return fModifier;
|
||||
}
|
||||
|
||||
void JWGiveXP(int nXP, object oPlayer)
|
||||
{
|
||||
if (GetXPOnOff(oPlayer)==TRUE)
|
||||
{
|
||||
SendMessageToPC(oPlayer,"You have turned experience gain off");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
GiveXPToCreature(oPlayer,nXP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user