Aller au contenu

Photo

Same tag question <<<SOLVED>>>


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

#1
andysks

andysks
  • Members
  • 1 652 messages
Hi all. I need to ask if a script where I cal GetObjectByTag could encounter problems if the tag is duplicated. Example, I am adding some creatures to a group this way, and on the death of the group a conversation begins. For ease of the script writing, all 15 creatures of the given encounter share a tag. When half die, the convo starts though. So, I velieve that only half of them got added to the group. Is it because of the shared tag maybe? Should I use some other way?

Modifié par andysks, 10 février 2014 - 09:21 .


#2
andysks

andysks
  • Members
  • 1 652 messages
Something else that might be important. I just noticed that the way the creatures are laid out, don't aggro all at the same time. So maybe when the first wave dies the group on death fires, even if the back ones are still alive but not fighting?

#3
Dann-J

Dann-J
  • Members
  • 3 161 messages
I usually give groups of creatures with the same tag an OnSpawn script that adds them to a specific group. My particular OnSpawn script (using the include script "ginc_group") checks for a string variable on the creature and uses that as the group name. Then I use a custom OnDeath script that checks whether the entire group has been killed (another function in "ginc_group"), and does something appropriate when they're all toast (start a conversation, change the journal, etc).

Here's the simple OnSpawn script I'm currently using:

#include "ginc_group"
void main()
{
string sGroup = GetLocalString(OBJECT_SELF, "Group");
if (sGroup != "") AddToGroup(sGroup, OBJECT_SELF);
}

Modifié par DannJ, 02 février 2014 - 10:32 .


#4
andysks

andysks
  • Members
  • 1 652 messages
When I added creatures in a group when spawning them, it went flawless. Can it have a difference on placed creatures though? Doesn't harm to try spawning the ones causing the problem instead of placing them I guess.

#5
Loki_999

Loki_999
  • Members
  • 430 messages
Only difference between placed and spawned is that placed ones have fixed tags, whereas with spawns you can give them new tags as you spawn them should the need arise.

By the way, if this is for a PW, avoid having static monsters. They take up CPU and memory... not much, but each one adds to the overhead just a little.

#6
Tchos

Tchos
  • Members
  • 5 072 messages
You can have the same tag on placed creatures and add them all to a group, as long as you use a loop (or a function that uses a loop) that puts all of them into the group. For instance, if you know the number of the creatures, then you can loop the add to group function that many times, selecting the next creature with that tag each time. Or you can do it an arbitrary number of times by just continuing the loop until it reaches an OBJECT_INVALID.

#7
andysks

andysks
  • Members
  • 1 652 messages
OK, the loop is the key I guess then. It seems that without a loop it gets bugged, adding only half of them or something.

#8
Dann-J

Dann-J
  • Members
  • 3 161 messages
A while loop that iterates a count variable that uses GetNearestObjectByTag(), aborting when an invalid object is returned, would find all creatures with a given tag in a particular area. It won't work between areas though (which in my experience is usually a good thing).

I've got into the habit of adding encounter-spawned creatures into unique groups, primarily because encounter-spawned creatures lose their tags if you reload from a saved game (see here). Once they're in a group, the various functions in the ginc_group include file makes it so much easier to do things en masse.

#9
Tchos

Tchos
  • Members
  • 5 072 messages
But if you do need to get all creatures with a certain tag in all areas, then you can loop with GetObjectByTag with the nth parameter.

#10
andysks

andysks
  • Members
  • 1 652 messages
The loop did the work. I also changed the tags to something like hobgoblin_1 until _15. The loop checks for the tag until the _ + the ending. It works flawlessly. Thanks for the suggestions.