Creature refuses to be added to a group

#1

Hi all. I got this situation where 5 creatures are added to a group by using the function

string elf_group = "HD_ELVES";
AddNearestWithTagToGroup(elf_group, "c_hd_elf_leader", 20);

I’ve already tried passing the group name as a string parameter and not as a pre-declared string in a desperate attempt to make it work.
I also have already double checked the tag of the creature and the tag in the script.
I also deleted his blueprint, made a new one and gave the tag. Just in case it was a blueprint error.

At the end of a convo where the group is present I call this function.

void main(string sGroup)
{
	GroupGoHostile(sGroup);
}	

to which I pass HD_ELVES as a parameter. 5 creatures go hostile, the one with the tag above stays a commoner. Only thing I can think as a problem at this stage, is that he is the convo owner. However, the hostility happens on the very last node. And even if it weren’t, it shouldn’t prevent him from going hostile and breaking the convo.

Any ideas about this behavior would be much appreciated.

0 Likes

#2
void AddNearestWithTagToGroup(string sGroup, string sTag, int iMax = 20);

<- is obsolete (although it should still work)
try replacing with ->

void GroupAddNearestTag(string sGroup, string sTag, object oTarget = OBJECT_SELF, int iMax = 20, int bOverride = FALSE);
0 Likes

#3

I’ll try it thanks.

A couple of thoughts though.
1: Rest of the creatures do get added to the group using the (apparently?) obsolete function.
2: Why is it obsolete? It never failed me.
3: Shouldn’t they have deprecate it or something if it’s obsolete :smiley: ?

0 Likes

#4
  1. Bad function naming;
  2. Doesn’t work if the object is already in another group (doesn’t support the bOverride parameter).
1 Like

#5
void AddNearestWithTagToGroup(string sGroupName, string sTag, int iMax=20)
{
    OldFunctionMessage("AddNearestWithTagToGroup", "GroupAddNearestTag");
    GroupAddNearestTag(sGroupName, sTag, OBJECT_SELF, iMax);
}

// a specialized error message for phasing out old stuff
void OldFunctionMessage(string sOldFunctionName, string sNewFunctionName)
{
    string sMessage = "Function '" + sOldFunctionName + "' is obsolete and should be replaced with '" + sNewFunctionName;
    ErrorMessage(sMessage);	
}

 :^p

0 Likes

#6

That’s kinda cool. OldFunctionMessage… the things I learn today :smiley:

let’s see if that solves anything now.

0 Likes

#7

you could also try delaying the GroupGoHostile by 0.1 sec to ensure the dialog has ended

0 Likes

#8

Will do.

Also, what is the object oTarget doing there in GroupAddNearestTag?

0 Likes

#9

oTarget is the object to measure “nearest” against …

0 Likes

#10

Interesting. And I guess GroupAddTag is like GetObjectByTag, while GroupAddNearestTag is like GetNearestObjectByTag. Just the equivalent functions for groups.

Would GroupAddTag work when all tags are unique of course?

0 Likes

#11

sounds right.

but let’s back up a sec.

getnearest does not include oTarget itself

so that needs to be taken into consideration when assigning group-members

fallback on using

void GroupAddTag(string sGroup, string sTag, int iMax = 20, int bOverride = FALSE);

if the creature to add is OBJECT_SELF (ie. oTarget) in the adding script (and make sure its tag is unique across the module)

0 Likes

#12

I made it work with GroupAddTag(…). Good to know that some dozen instances in my campaign where I use the obsolete method are a ticking bomb :smile:. I won’t go into the effort to change them though. They work. I just know now for any future projects that I should look into the libraries. I just thought that obsolete methods should include the obsolete description in the method description (Like when I pick it from the script assist). And the one in question here doesn’t mention anywhere that it is problematic.

Anyway, that’s why we love the toolset. We’re a bit masochistic I guess.

0 Likes

#13

/hehe

it’s a bit of a hassle, but this should be/is written to the temp/logfile whenever the obsolete function runs:

not sure if logging needs to be set up …

(it’s probably a good idea for devs to run with full logging in place anyway)

0 Likes