Aller au contenu

Photo

Check party for restrictions and then do this?


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

#1
Xeneize

Xeneize
  • Members
  • 133 messages

Hello again!

 

As stated in the title, I am trying to make a script so it will run on the death of a certain creature and then it will check a party(member by member) if they have a certain journal entry AND give them a quest item.

 

So far where I am failing is at the bit where I tell the script to check the party, and not base its effects on the result of checking only one person that has the journal entry. My goal is to make sure the item is given to only those that have the journal entry in the party.

 

Any help with this is appreciated in advance :)



#2
kevL

kevL
  • Members
  • 4 061 messages

something like this

 

void main()
{
    object oSlayer = GetLastKiller();

    object oFM = GetFirstFactionMember(oSlayer, FALSE);
    while (GetIsObjectValid(oFM))
    {
        if (GetAssociateType(oFM) == ASSOCIATE_TYPE_NONE
            && GetJournalEntry("journal_entry", oFM) == 100)
        {
            CreateItemOnObject("tag_of_item", oFM);
        }

        oFM = GetNextFactionMember(oSlayer, FALSE);
    }
}


#3
Xeneize

Xeneize
  • Members
  • 133 messages

Will that actually effect the people that are currently in the area, or the entire party, including the party members that are not in the same area?

 

In good english I am trying to have it check all the party, but only effect those that are within the area of the dead creature and to NOT effect the party members that might not be in the same area.



#4
kevL

kevL
  • Members
  • 4 061 messages

take two

 

void main()
{
    object oSlayer = GetLastKiller();

    object oFM = GetFirstFactionMember(oSlayer, FALSE);
    while (GetIsObjectValid(oFM))
    {
        if (GetArea(oFM) == GetArea(oSlayer)
            && GetAssociateType(oFM) == ASSOCIATE_TYPE_NONE
            && GetJournalEntry("journal_entry", oFM) == 100)
        {
            CreateItemOnObject("tag_of_item", oFM);
        }

        oFM = GetNextFactionMember(oSlayer, FALSE);
    }
}


#5
Tchos

Tchos
  • Members
  • 5 054 messages

Hopefully it's not plot-critical that the creature is killed by someone in the player's faction, or else no one will get the journal entry.  Though very rare and unlikely (and won't happen if there are no other creatures in that area), a creature could be killed by an NPC or other creature if they're hostile to that one creature, in which case the journal would not update.  Also, I've heard that in certain rare circumstances, an area of effect spell can lose its owner.  If that's true, and if the creature dies due to the area of effect, then it will not be connected to the caster's faction, and thus should not update the journal.



#6
Xeneize

Xeneize
  • Members
  • 133 messages

I just need to make sure it gives a certain item to those party members that are grouped up together in the same area with a given journal entry, but to make sure it does not effect party members that might have snuck into the party from other areas just to get the goodies from across the planet for easy quest completion.

 

I'll give the script above a try, thanks :)



#7
Xeneize

Xeneize
  • Members
  • 133 messages

I gave this script a try and this is what happened:

 

It didn't cycle through the entire party nor gave the items to my party members, but it DID give the party leader themquest items.

 

I truly need it to check for everyone in the party and give the item to all those that have the journal entry, not just the party leader.

 

And it needs to hopefully only take into account the party members that are present in the same area, not members of the party that are in other areas.



#8
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 592 messages
I don't develop for multi-player. A couple of things come to mind though. In multi-player is everyone in the same faction? The script assumes so. Also are you sure your campaign is not set so that everyone shares the same journal?

Regards

#9
Darin

Darin
  • Members
  • 282 messages

I'd do something like this:

 

//Add to the OnDeath Script of the Creature

object oCheck = GetFirstObjectInArea(OBJECT_SELF);

while(GetIsObjectValid(oCheck))

   {

      if(GetJournalEntry("journal_entry", oCheck == 100))

         {

             CreateItemOnObject("tag_of_item", oCheck);

             oCheck = OBJECT_INVALID;

         }

      else

         oCheck = GetNextObjectInArea(OBJECT_SELF);

   }

 

 

You could do the faction/area thing, but you should probably have it stop once the item is given out (unless everyone gets the item?)



#10
Xeneize

Xeneize
  • Members
  • 133 messages

The script I'm looking for is so when a creature dies, the script fires and checks all members of the killer PC's party has a certain journal entry and if it's true, it individually gives out an item. It shouldn't work on party members that might not be in the same area either.

 

So far I am failing at telling the script to check each party member individually. It's either giving it only to the party leader or only to the one that kills the creature. It's supposed to be a quest item for groups that share effort on trying to get items, it should reward the item to parties, but only to members that have the journal entry.



#11
kevL

kevL
  • Members
  • 4 061 messages

you might have stumbled onto one of the things that bugs me about NwN2-MP. I haven't seen any way to differentiate between the Party & the entire PC-faction.

Other than that (and the fact I can't/don't test in an MP environment) i think Epic's script should work. It cycles through only objects-in-area of the deceased, it checks each object it finds in that area to see if it has journal_entry100 (or whatever ya need), and if so creates an item .....

take out the "oCheck=OBJECT_INVALID" though; since ye say all valid creatures should get the item. more like this
 

//Add to the OnDeath Script of the Creature

object oCheck = GetFirstObjectInArea(OBJECT_SELF);
while(GetIsObjectValid(oCheck))
{
    if(GetJournalEntry("journal_entry", oCheck) == 100)
    {
        CreateItemOnObject("tag_of_item", oCheck);
    }

    oCheck = GetNextObjectInArea(OBJECT_SELF);
}

to get back to my original point, if there is a separate party (or its members) in the same area, with the journal entry doing their own quest against the same creature, they get the item as well

 

 

[edit] darn parentheses



#12
4760

4760
  • Members
  • 1 207 messages

to get back to my original point, if there is a separate party (or its members) in the same area, with the journal entry doing their own quest against the same creature, they get the item as well

Which means that even members at the opposite corner of the area, not having participated to the fight, will get the reward if they've got journal entry #100.

 

So you could also try a slightly modified script, which only gives items to party members not more then 15 m far away from the killer:

//Add to the OnDeath Script of the Creature

object oSelf = OBJECT_SELF;
object oCheck = GetFirstObjectInArea(oSelf);
object oKiller = GetLastKiller();
float fDistanceMax = 15.0; // change value here to reduce or increase the radius of the valid zone
while(GetIsObjectValid(oCheck))
{
    if(GetJournalEntry("journal_entry", oCheck) == 100)
    {
		if (GetDistanceBetween(oKiller, oCheck) <= fDistanceMax) CreateItemOnObject("tag_of_item", oCheck);
    }
    oCheck = GetNextObjectInArea(oSelf);
}


#13
kevL

kevL
  • Members
  • 4 061 messages

what I'm really curious about, guys, is what does GetFactionLeader() return in MP

 

is it the guy with the crown on his icon, ala NwN, or a controlled character, ala NwN2

 

?



#14
Xeneize

Xeneize
  • Members
  • 133 messages

In terms of game distance, how do I do to know how much is a meter?



#15
Dann-J

Dann-J
  • Members
  • 3 161 messages

The toolset units are in metres. So coordinates (100,100,0) and (105,100,0) are five metres apart (roughly 16.4 feet for those countries still living in the 19th century).

 

That's why the radius constants are all in metres, even though the radius categories themselves are defined in feet, resulting in some decidely non-rounded numbers.



#16
Tchos

Tchos
  • Members
  • 5 054 messages

Within the toolset, for lack of a proper measuring stick, I sometimes lay out corpse placeables to measure distance, with the estimation that a NWN2 human is roughly 2 m tall.



#17
AGhost_7

AGhost_7
  • Members
  • 62 messages

Hopefully it's not plot-critical that the creature is killed by someone in the player's faction, or else no one will get the journal entry.  Though very rare and unlikely (and won't happen if there are no other creatures in that area), a creature could be killed by an NPC or other creature if they're hostile to that one creature, in which case the journal would not update.  Also, I've heard that in certain rare circumstances, an area of effect spell can lose its owner.  If that's true, and if the creature dies due to the area of effect, then it will not be connected to the caster's faction, and thus should not update the journal.

Never heard of that, but if you'd want to avoid such a problem from possibly arising you could do this then:

 

// Lets make it a bit reusable
void GiveItemToPCsInArea(object oArea, string sItemReff, int nJEntry = -1, string sJTag = "")
{
    object oPC = GetFirstPC();
    while(GetIsObjectValid(oPC))
    {
        if(sJTag == "" || GetJournalEntry(sJTag, oPC) == nJEntry)
        {
            CreateItemOnObject(sItemReff, oPC);
        }
        oPC = GetNextPC();
    }
}


void main()
{
    object oKiller = GetLastKiller();
    object oArea = GetArea(oKiller);
    GiveItemToPCsInArea(oArea, "item_reff", 100, "journal_tag");
}


#18
Xeneize

Xeneize
  • Members
  • 133 messages

Figured it out! Thanks very much for the help everyone :)