Modifié par andysks, 10 février 2014 - 09:21 .
Same tag question <<<SOLVED>>>
Débuté par
andysks
, févr. 02 2014 07:21
#1
Posté 02 février 2014 - 07:21
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?
#2
Posté 02 février 2014 - 07:27
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
Posté 02 février 2014 - 10:01
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);
}
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
Posté 04 février 2014 - 12:50
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
Posté 04 février 2014 - 08:05
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.
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
Posté 04 février 2014 - 09:00
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
Posté 05 février 2014 - 02:11
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
Posté 05 février 2014 - 04:54
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.
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
Posté 05 février 2014 - 05:18
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
Posté 10 février 2014 - 09:20
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.





Retour en haut






