Author Topic: Give Xp to party members within certain distance?  (Read 315 times)

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
Give Xp to party members within certain distance?
« on: April 26, 2012, 10:03:32 pm »


                How can I grant xp to all party members that are within a defined distance from creatures death?
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
Give Xp to party members within certain distance?
« Reply #1 on: April 26, 2012, 10:07:48 pm »


               I'd recommend implementing this which will allow you to do that, among many other options:
http://nwvault.ign.c....Detail&id=1179
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Give Xp to party members within certain distance?
« Reply #2 on: April 27, 2012, 10:09:37 am »


               Could do something kinda like so:


void main()
{
    float fDistance = 5.0;//distance to check
    int iXP = 500;//xp to give if within distance

    //To keep this script universal you could also set an integer variable on
    //the creature and just use that as the amount of XP to give. Example:
    //int iXP = GetLocalInt(OBJECT_SELF, "MY_DEATH_XP");
    //You could also do the same thing with the float fDistance above by setting
    //a float variable on the creature. Example:
    //float fDistance = GetLocalFloat(OBJECT_SELF, "MY_XP_DIST");

    location lDeath = GetLocation(OBJECT_SELF);
    location lMember;
    object oDeathArea = GetArea(OBJECT_SELF);
    object oKiller = GetLastKiller();
    if (GetMaster(oKiller) != OBJECT_INVALID)
    oKiller = GetMaster(oKiller);

    object oMember = GetFirstFactionMember(oKiller, TRUE);
    while (GetIsObjectValid(oMember))
    {
        //Decided to go with distance between locations because I wasn't sure
        //if the dead monster could still be considered a valid object to check.
        lMember = GetLocation(oMember);
        if (GetDistanceBetweenLocations(lDeath, lMember) <= fDistance &&
            GetArea(oMember) == oDeathArea)
        GiveXPToCreature(oMember, iXP);
        oMember = GetNextFactionMember(oKiller, TRUE);
    }
}
               
               

               


                     Modifié par GhostOfGod, 27 avril 2012 - 02:01 .
                     
                  


            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Give Xp to party members within certain distance?
« Reply #3 on: April 27, 2012, 01:33:37 pm »


               You have to be careful with GetDistanceBetweenLocations checks, from what I've seen for their returns, since they'll register as less than whatever distance selected if the creatures are in different areas.  The return might be 0 or -1, I'm not sure which, but I've had to resort to adding area checks in addition to compensate.

Edit:  Testing just now, it actually looks like it checks the comparative distance based on relative x,y, and z ignoring the area component, might allow for some interesting uses (like triangulation in any area based on points found only in a single one), but would lead to irrugularities in this scripts use without the area check added in.
               
               

               


                     Modifié par Failed.Bard, 27 avril 2012 - 12:45 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Give Xp to party members within certain distance?
« Reply #4 on: April 27, 2012, 03:06:03 pm »


               

Failed.Bard wrote...

You have to be careful with GetDistanceBetweenLocations checks, from what I've seen for their returns, since they'll register as less than whatever distance selected if the creatures are in different areas.  The return might be 0 or -1, I'm not sure which, but I've had to resort to adding area checks in addition to compensate.

Edit:  Testing just now, it actually looks like it checks the comparative distance based on relative x,y, and z ignoring the area component, might allow for some interesting uses (like triangulation in any area based on points found only in a single one), but would lead to irrugularities in this scripts use without the area check added in.


Good catch FB. According to the Lexicon it should return a -1.0000 if the locations are in different areas. I edited the script above to check the areas.