Aller au contenu

Photo

XP and Gold only for party members in area


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

#1
Badwater

Badwater
  • Members
  • 113 messages
I'm modifying a script - this script gives xp and gold to party members no matter who has the item:

#include "nw_i0_tool"
#include "X0_I0_PARTYWIDE"

void main()
{
    object oItem = GetFirstItemInInventory(GetPCSpeaker());
    while (GetIsObjectValid(oItem) == TRUE)
    {
        string sTag = GetTag(oItem);
        int sNum = GetNumStackedItems(oItem);
        if (sTag == "JS_SeaFleaCara" && GetHitDice(GetPCSpeaker()) < 20)
        {
            DestroyObject(oItem);
            GiveGoldToAll(GetPCSpeaker(), (10*sNum));
            GiveXPToAll(GetPCSpeaker(), (10*sNum));
        }
        if (sTag == "JS_SeaFleaCara" && GetHitDice(GetPCSpeaker()) >= 20)
        {
            DestroyObject(oItem);
            GiveGoldToAll(GetPCSpeaker(), (3*sNum));
            GiveXPToAll(GetPCSpeaker(), (3*sNum));
        }
        oItem = GetNextItemInInventory(GetPCSpeaker());
    }
}


My problem is that this gives party xp across the server. What's the proper scripting to award only for party members in the area the award is being given to?

#2
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
  I would do it differently, getting a count of all the items first, and then awarding the XP and gold in a lump sum at the end.  Otherwise, you have to loop through every party member and check area each time.  I would use something along this line for it:

void main()
{
 object oPC = GetPCSpeaker();
 object oArea = GetArea (oPC);
 object oTarget, oItem;
 int sNum;
 oItem = GetFirstItemInInventory (oPC);
 while (GetIsObjectValid(oItem))
    {
     if (GetTag (oItem) == "JS_SeaFleaCara")
        {
         sNum += GetNumStackedItems (oItem);
         DestroyObject(oItem);
        }
     oItem = GetNextItemInInventory (oPC);
    }
 // Adjust the count based on the level determined modifier.
 if (GetHitDice (oPC) < 20) sNum *= 10;
 else sNum *= 3;
 oTarget = GetFirstFactionMember (oPC);
 while (GetIsObjectValid(oTarget))
    {
     // Checks area to ensure only PCs in that area get the award.    
     if (GetArea (oTarget) == oArea)
        {
         GiveGoldToCreature (oTarget, sNum);
         GiveXPToCreature (oTarget, sNum);
        }
     oTarget = GetNextFactionMember (oPC);
    }
}

#3
Badwater

Badwater
  • Members
  • 113 messages
Thanks FB, works like a charm.