This code is used in the creature ondeath events.
The high level players is helping the low level players to level up killing low level creatures example:
A player level 30 is killing ogres(level 5) to help a player level 1 to level up winning the max XP(about 4 difference of level - as you can see in the system iDN > 4).
Other bad thing is that some players is using the Epic Mummy in the Sequencer robe to level up characters lvl 11 killing level 20 creatures (and they can use the spell a lot of time giving the robe to other players after rest)
I need ideas to make the level up be dinamic.
//:://////////////////////////////////////////////////
#include "module_include"
#include "x2_inc_compon"
#include "x0_i0_spawncond"
void main()
{
object oKiller = GetLastKiller();
//============== XP Giver Script ===================
//============== Creating Variables ===============
int iQuantidade;
int iXP;
float fXPPenalt;
int iXPPenalt;
int iNewXP;
int iPenal;
int iCR = FloatToInt(GetChallengeRating(OBJECT_SELF));
int iHD;
int iDN;
object oAreaPC;
//============== Starting the count ===========================
object oArea = GetArea(oKiller);
object oObject = GetFirstObjectInArea(oArea);
int iDead = GetIsDead (oObject);
int iSameFaction = GetFactionEqual (oKiller, oObject);
while (GetIsObjectValid(oObject))
{
if ((GetIsPC(oObject)) && (iSameFaction == TRUE) && (iDead == FALSE))
{
iQuantidade = iQuantidade + 1; //iQuantidade = the amount of players in party
}
oObject = GetNextObjectInArea(oArea);
iDead = GetIsDead (oObject);
iSameFaction = GetFactionEqual (oKiller, oObject);
}
//=========== The party XP penalty ==========================
if (iQuantidade == 1) iPenal = 10;
if (iQuantidade == 2) iPenal = 20;
if (iQuantidade == 3) iPenal = 25;
if (iQuantidade == 4) iPenal = 30;
if (iQuantidade >= 5) iPenal = 60; //low XP
//========== Applying XP ====================================
oObject = GetFirstPC();
int iAmaldicoado = GetLocalInt(oObject, "amaldicoado"); // amaldicoado = cursed
while (GetIsObjectValid(oObject))
{
iHD = GetHitDice(oObject);
iDN = iCR - iHD;
iDead = GetIsDead (oObject);
iSameFaction = GetFactionEqual (oKiller, oObject);
oAreaPC = GetArea(oObject);
if ((iSameFaction == TRUE) && (iDead == FALSE) && (oAreaPC == oArea))
{
if (iDN > 4)
{
iXP = 380; // 350, 310, 290, 270, 250 //350 is the max XP
}
if (iDN == 4)
{
iXP = 330; // 300, 270, 250, 230, 210
}
if (iDN == 3)
{
iXP = 270; // 250, 220, 210, 200, 190
}
if (iDN == 2)
{
iXP = 220; // 200, 180, 170, 160, 150
}
if (iDN == 1)
{
if (iQuantidade == 4) iPenal = 32; //adjustment +02 (penalty)
if (iQuantidade == 5) iPenal = 38; //adjustment +03
iXP = 160; // 150, 130, 120, 110, 100
}
if (iDN == 0)
{
if (iQuantidade == 2) iPenal = 28; //adjustment +08
if (iQuantidade == 3) iPenal = 37; //adjustment +12
if (iQuantidade == 4) iPenal = 46; //adjustment +16
if (iQuantidade == 5) iPenal = 55; //adjustment +20
if (iQuantidade > 5) iPenal = 64; //adjustment +04
iXP = 110; // 100, 080, 070, 060, 050
}
if (iDN == -1)
{
if (iQuantidade == 4) iPenal = 34; //adjustment +04
iXP = 60; // 060, 050, 050, 040, 040
}
if (iDN == -2)
{
iXP = 40; // 040, 040, 030
}
if (iDN == -3)
{
iXP = 20; // 020, 020, 020
}
if (iDN == -4)
{
iXP = 10; // 010
}
if (iDN < -4)
{
iXP = 1; // 001
}
int iCurrentXP = GetXP(oObject);
int iXPMax = ( (iHD * 1000) + (iHD * (iHD - 1) * 500) );
if (iCurrentXP < iXPMax)
{
if (iAmaldicoado != 2) //amaldicoado = cursed
{
if (!HasSanctuary(oObject))
{
fXPPenalt = (iXP/10) * (iPenal/100.0);
iXPPenalt = FloatToInt(fXPPenalt); // conversion to integer values
iNewXP = iXP - (iXPPenalt*10);
GiveXPToCreature(oObject, iNewXP); // giving XP
}
else
{
FloatingTextStringOnCreature ("Sem XP em Santuario", oObject);
//No XP using greater sanctuary
}
}
}
if ( (iCurrentXP > (iXPMax - 1)) && (iCurrentXP < 780000))
{
FloatingTextStringOnCreature ("Level Up", oObject); //Intuitive message
//This makes the XP not accumulative
}
}
oObject = GetNextPC();
}
}