Author Topic: XP Giver - Hard Leveling  (Read 1443 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« on: July 09, 2014, 01:16:57 am »


               

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();
    }
}


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #1 on: July 09, 2014, 05:46:15 pm »


               


 


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)


 




 


Your first example is an instance of grinding (getting unlimited XP from repetition) and there is no true fix for it unless you somehow cap or abandon the grinding level system that is common to servers.  One way would be to store the number of kills of different types of creatures and to no longer grant XP reward for having killed more than the capped amount.


 


Your second example is easily fixed (if sequencing is the only problem) simply delete the variable that sequencers use whenever an item is unacquired by a PC.


               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #2 on: July 09, 2014, 11:23:18 pm »


               

not understand   ':huh:'



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #3 on: July 10, 2014, 01:45:02 am »


               

To remove sequencer spells you are just deleting variables produced by x2_s3_sequencer


 


object oItem = GetModuleItemLost();

int i;


for (i = 1; i <= 3; i++)

        {

            DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER" + IntToString(i));

        }

        DeleteLocalInt(oItem, "X2_L_NUMTRIGGERS");



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #4 on: July 10, 2014, 06:59:19 pm »


               

I got your idea


 


1example: This is a valid solution, but does not make things the way we want because this way we are applying limit to the XP.


2example: This is fine!


 


what is this "for (i = 1; i <= 3; i++)" you used?



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #5 on: July 10, 2014, 07:04:28 pm »


               


what is this "for (i = 1; i <= 3; i++)" you used?




just a little more rafined method of coding


 


you can replace it by this:


 


DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER1");


DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER2");


DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER3");


               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #6 on: July 11, 2014, 10:31:58 pm »


               

Like just ADD this to my OnItemLost code and done?


 


DeleteLocalInt(GetModuleItemLost(), "X2_L_SPELLTRIGGER1");


DeleteLocalInt(GetModuleItemLost(), "X2_L_SPELLTRIGGER2");


DeleteLocalInt(GetModuleItemLost(), "X2_L_SPELLTRIGGER3");



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #7 on: July 12, 2014, 01:25:55 am »


               

Shadooow && Whizard


 


Dont we need to check if oItem = Sequencer Robe to delete these variables?



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #8 on: July 12, 2014, 01:51:05 am »


               

not because if its not sequencer the code wont have any effect ':rolleyes:'


 


ultimate answer:


 


add either:



int i;

for (i = 1; i <= 3; i++)
        {
            DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER" + IntToString(i));
        }
        DeleteLocalInt(oItem, "X2_L_NUMTRIGGERS");

or



DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER1");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER2");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER3");
DeleteLocalInt(oItem, "X2_L_NUMTRIGGERS");

this code, whatever you prefer the functionality is the same, into your OnUnAcquire event, compile and thats it



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #9 on: July 12, 2014, 02:09:32 am »


               

I would like to give a message to the player informing that he losts your spell in Sequencer robe... just like this?


 


sItem = GetResRef(oItem)


 


if(sItem = "resrefSequencer")


{


DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER1");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER2");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER3");
DeleteLocalInt(oItem, "X2_L_NUMTRIGGERS");


SendMessageToPC(oPC, "[ITEM] The item " + GetName(oItem) + " lost the enchantment.");


}


 


//EDITED SendMessageToPC(string, object) to SendMessageToPC(object, string)



               
               

               


                     Modifié par WhiteTiger, 12 juillet 2014 - 03:52 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #10 on: July 12, 2014, 02:41:57 am »


               


I would like to give a message to the player informing that he losts your spell in Sequencer robe... just like this?


 


sItem = GetResRef(oItem)


 


if(sItem = "resrefSequencer")


{


DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER1");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER2");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER3");
DeleteLocalInt(oItem, "X2_L_NUMTRIGGERS");


SendMessageToPC("Sequencer Robe: The slot was cleaned!", oPC);


}




I see. Good idea. This will work but there is more sequences so maybe it would be easier to do this:




if(GetLocalInt(oItem, "X2_L_NUMTRIGGERS") > 0)

{

DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER1");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER2");
DeleteLocalInt(oItem, "X2_L_SPELLTRIGGER3");
DeleteLocalInt(oItem, "X2_L_NUMTRIGGERS");

SendMessageToPC("Sequencer Robe: The slot was cleaned!", oPC);

}

               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #11 on: July 16, 2014, 12:40:22 am »


               

//edit 


thank you shadooow & wizard 


//end edit


 


I continues having troubles with the XP gain by repetition (example): the high-level gets 1 XP by killing the ogre and the other lower-level receive 200 XP for being in the party.



               
               

               


                     Modifié par WhiteTiger, 16 juillet 2014 - 03:24 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #12 on: July 16, 2014, 02:09:17 am »


               

First you must determine the killers hit dice (or hit dice of killers master in case of associate)


 


int iHDkiller = GetHitDice(oKiller);


 


then after this code:


 


    if (iDN < -4)

    {

    iXP = 1; // 001

    }


 


do something like this:


int lvldiff =  abs(iHD-iHDkiller); //difference between levels of killer and party member receiving xp


 if(lvldiff > 4)


 {


 iXP = 1;//if difference more than 4, then he gains only 1 xp


 }


               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #13 on: July 16, 2014, 02:52:07 am »


               

Good idea! I have done, shadooow. thank you



WRONG CODE


               
               

               


                     Modifié par WhiteTiger, 17 juillet 2014 - 06:56 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
XP Giver - Hard Leveling
« Reply #14 on: July 16, 2014, 02:57:05 am »


               

Another option is to loop through the party members (by faction) and find the one with the highest HD.  Then award XP to each as if they all had that HD.