Give Xp to party members within certain distance?
#1
Posté 26 avril 2012 - 09:03
#2
Posté 26 avril 2012 - 09:07
http://nwvault.ign.c....Detail&id=1179
#3
Posté 27 avril 2012 - 09:09
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 .
#4
Posté 27 avril 2012 - 12:33
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 .
#5
Posté 27 avril 2012 - 02:06
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.





Retour en haut







