Jump to content

Change faction / NameIncludes or CompareName


JustChill

Recommended Posts

Hey there,

 

I've two questions and I hope someone has the time to give me a response. :smile:

 

First of all, I would like to change the faction of various creatures via script (so I don't have to add the base records into my own mod), but "SetFactionRank" only accepts references, but no base records.

Even if I save a base record into a reference variable it doesn't work. :sad:

 

So is there any way to add creatures into a faction, but by using it's base record as reference?

 

 

 

Second thing are the functions NameIncludes and CompareName. Both functions are present in OBSE (which is hilarious, as they do the same), but none of them is in NVSE or JIP available. :sad:

Is there any equivalent for that command? It's very useful as for asking about a special part of a string for example.

 

 

 

 

My current solution to add creatures to respective factions is to use GetFirstRef and GetNextRef and then using GetModelPath. This works pretty well so far, but I have to compare the whole model path.

For example:

string_var strCreaModelPath
Ref CreaRef
[...]
Begin GameMode
Set CreaRef to GetFirstRef 43 1 0
 
While CreaRef != 0
Set iCompare to -2
Set strCreaModelPath to CreaRef.GetModelPath
Set iCompare to sv_compare "Creatures\Dog\Skeleton.nif", strCreaModelPath
if iCompare == 0
[... Set CreatureRef as part of a specific faction.]
Endif
Set CreaRef to GetNextRef
Loop
[...]
End

It would be much easier to use NameIncludes for searching just for "Dog", instead of the whole path, even though it already works in that case either (I don't know if NameIncludes would have more performance impact than comparing the whole string with the expected model path. But one for sure: If I have one letter wrong in the comparison string, it won't work. So using "NameIncludes" would be much, much easier).

 

However, I would prefer a function with which I easily can add new factions to a base record, without having the need of a reference, but direcly accessing the base record of said creature.

Since I could spare that whole scanning for creature references nearby the player, which has a performance impact. :sad:

Furthermore with the scanning, I've to check for special creatures by asking for the BaseObject and comparing the EditorID of the base object then, since not EVERY creature with the dog model should be added to the faction. Which is an additional impact on the performance in such a loop. :sad:

 

 

I appreciate any help. :smile:

 

Cheers

Link to comment
Share on other sites

  • 4 years later...

So I went back into this whole thing with factions...

This time my approach is to have form lists which contain the respective base forms and use SetBaseFactionRank as before.

 

 

HOWEVER, it turns out that starting a game and then loading a savegame where the player is in fron of dynamic factions seems not to be a good idea.

As upon loading these turn out hostile, even if the player has the correct perk.

 

  Reveal hidden contents

 

This function evaluates the faction. It's working normally, except when loading a game after booting the game, as said.

Funnily, when loading a game again the factions get correct.

 

But this doesn't sound like a proper solution... "Load the game once more to fix faction issues". oO

 

 

The funny thing is, the boss (Den Mother --> Nightstalker) in that cave is always correct, but the spawned ones seem to have issues with getting grouped into the correct faction initially.

While they don't when the save is loaded again.

 

 

 

 

Is it possible that the script is too heavy?

The function only get triggered upon loading, or when changing settings in MCM.

And these spawned Nightstalkers always seem to have issues realizing that they should not be hostile. Somehow they do not want to get into the faction (or out of it) easily. :/

Link to comment
Share on other sites

Alright... So interestingly, they don't load up hostile upon start when all the creatures are added into the list in

Menu Mode 4

and then added into the respective animal friend faction.

 

However, as that's the main menu it's not possible to gather variables (from a savegame) that change the faction of just some specific creatures.

 

So I assume that the change of faction is performed at a point upon loading a recently started game, where the script fails to do so.

Funnily reloading the very same save once more fixes it.

 

So one attempt would be to make the mod static (creatures are added to faction upon main menu) or to find a method to apply faction changes while loading a save, as otherwise it seems they do not get applied. :(

 

Even more weird the Nightstalkers load up as allies but then turn hostile. But having them being corrected upon reloading is even weirder. oO

Link to comment
Share on other sites

Alright... I've updated the scanning version of the mod (for the english version) at least.

Additionally, I've recorded my issues with the "advanced" version and sent the video to jazzisparis in hope he can somewhat find out what's wrong with SetBaseFactionRank. :(

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...