Aller au contenu

Photo

RewardPartyXP in same area only


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
EzRemake

EzRemake
  • Members
  • 118 messages
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?

#2
MagicalMaster

MagicalMaster
  • Members
  • 2 000 messages
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 .


#3
EzRemake

EzRemake
  • Members
  • 118 messages
Thanks a ton Magical, works perfect!