Author Topic: RewardPartyXP in same area only  (Read 315 times)

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
RewardPartyXP in same area only
« on: November 21, 2013, 06:07:21 am »


               I want to use RewardPartyXP and RewardPartyGP to allow party play, but I want the restrictions to be that if you want the experience/gold from someone else's kill, you need to be in the same area.

I can't exactly get it to work this way though. This is what I've been trying in my nw_i0_tool file (bold are the changes):

void RewardPartyXP(int XP, object oTarget,int bAllParty=TRUE)
{
    // * for each party member
    // * cycle through them and
    // * and give them the appropriate reward
    // * HACK FOR NOW
    if (bAllParty == TRUE)
    {
        object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
        object oArea = GetArea(oTarget);
        object oPArea = GetArea(oPartyMember);


        while (GetIsObjectValid(oPartyMember) == TRUE)
        {
            if(oPArea == oArea){
                GiveXPToCreature(oPartyMember, XP);
                }


            oPartyMember = GetNextFactionMember(oTarget, TRUE);
            oPArea = GetArea(oPartyMember);
        }
    }
    else
    {
     GiveXPToCreature(oTarget, XP);
    }
}

How do I go about doing this the right way?
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
RewardPartyXP in same area only
« Reply #1 on: November 21, 2013, 07:02:39 am »


               Use this code -- comments should explain what is happening:

void RewardPartyXP(int XP, object oPC, int bAllParty=TRUE)
{
    // Make sure we're meant to give it to the whole party
    if (bAllParty)
    {
        // Find the area of the party member who is the target
        object oArea = GetArea(oPC);

        // Get the first object in our loop
        object oPartyMember = GetFirstFactionMember(oPC, TRUE);
        while (GetIsObjectValid(oPartyMember) == TRUE)
        {
            // If the areas match...
            if(oArea == GetArea(oPartyMember))
            {
                // Give the XP
                GiveXPToCreature(oPartyMember, XP);
            }

            // Get the next party member
            oPartyMember = GetNextFactionMember(oPC, TRUE);
        }
    }
    // Otherwise we just give the XP to the original PC
    else
    {
        GiveXPToCreature(oPC, XP);
    }
}

               
               

               


                     Modifié par MagicalMaster, 21 novembre 2013 - 07:03 .
                     
                  


            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
RewardPartyXP in same area only
« Reply #2 on: November 21, 2013, 08:10:47 am »


               Thanks a ton Magical, works perfect!