SAC Posted May 11, 2019 Posted May 11, 2019 Is there a way to disable combat AI (ideally on a single NPC, not global) via a script function? I haven't found any My problem is that I have NPCs reacting (combat alarm, I think) to spawning new NPCs around them, when my script wants them to keep busy doing... other stuff. This is happening including when tcai is off. There is this function: https://www.creationkit.com/index.php?title=StopCombatAlarm_-_Actor but I don't think it prevents combat alarm from triggering, it just stops ongoing (already triggered) alarms.
SAC Posted May 12, 2019 Author Posted May 12, 2019 In fact, what I am looking for is a way to call tdetect from script, not tcai
EgoBallistic Posted May 12, 2019 Posted May 12, 2019 Depending on how the actors are spawning, you could use factions to prevent combat. Put the first actor in a faction which is friendly to itself. Then, when you placeAtMe() the additional actors, set the abInitiallyDisabled parameter to true. Then add the new actor to the faction and then enable() them. The first actor won't "see" the new actor until you enable it, and since the new actor is already in the friendly faction, no combat will ensue. You can do the faction assignment with refaliases / refcollectionaliases so that the faction assignment will not be permanent.
SAC Posted May 12, 2019 Author Posted May 12, 2019 5 hours ago, EgoBallistic said: Then, when you placeAtMe() the additional actors, set the abInitiallyDisabled parameter to true. Aha! Never thought about abInitiallyDisabled! TYVM, sounds perfect! However, my implementation of spawning new NPCs is via a "grenade" whose "explosion" spawns (places) the NPCs, so not sure how to add this parameter. I'll need to think of spawning some intermediary object which in turn spawns the NPC and add the place NPC script to that object Which event triggers when an object is spawned into the world? I know onworkshopobjectplaced but that doesn't trigger on placeatme / placethere, just when you build the object in the workshop
EgoBallistic Posted May 12, 2019 Posted May 12, 2019 OnLoad() triggers when a reference is placed into the world. If the ref is initially disabled, the event will be sent a second time when it is enabled. So you may need to check isDisabled() in the event handler to prevent doing things twice.
SAC Posted May 12, 2019 Author Posted May 12, 2019 52 minutes ago, EgoBallistic said: OnLoad() triggers when a reference is placed into the world. If the ref is initially disabled, the event will be sent a second time when it is enabled. So you may need to check isDisabled() in the event handler to prevent doing things twice. At first tests it seems to work, I spawn a furniture which onload() spawns the NPC and adds them to the RSE pacification faction. NPCs spawn just fine, they get added to the faction and no conflicts so far. Will keep testing - TYVM indeed again! Scriptname SACSlaveMarkerFurnScript extends ObjectReference LeveledActor Property MoreSlaveLVLN Auto Faction Property RSEPacificationFaction Auto event onload() actor moreslaveref = self.placeatme(MoreSlaveLVLN, 1, false, true, false) as actor moreslaveref.addtofaction(RSEPacificationFaction) moreslaveref.enable() self.delete() endevent I am not sure what the abDeleteWhenAble = true parameter does, it seems to be true as default but I don't want my NPCs deleted, so I put it false.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.