Author Topic: XP and Gold only for party members in area  (Read 431 times)

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
XP and Gold only for party members in area
« on: January 05, 2012, 10:34:07 am »


               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?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
XP and Gold only for party members in area
« Reply #1 on: January 05, 2012, 01:51:02 pm »


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

               
            

Legacy_Badwater

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
XP and Gold only for party members in area
« Reply #2 on: January 05, 2012, 09:20:58 pm »


               Thanks FB, works like a charm.