staalo18 Posted February 3 Share Posted February 3 How can I track whenever the CombatTarget of an actor is changing? Something like an event OnCombatTargetChange() would be nice, but that does not exist. Any ideas welcome! Link to comment Share on other sites More sharing options...
scorrp10 Posted February 3 Share Posted February 3 Shouldn't this Actor Event work? ; Event that is triggered when this actor's combat state against the target changes ; State is as follows: ; 0 - not in combat ; 1 - in combat ; 2 - searching Event OnCombatStateChanged(Actor akTarget, int aeCombatState) EndEvent I mean, if an Actor switches to another target, would it not generate a OnCombatStateChanged(newTarget, 1) ? Link to comment Share on other sites More sharing options...
staalo18 Posted February 3 Author Share Posted February 3 Unfortunately, no. No event is triggered until the combat state changes from 1 to 0 or 2. That means that a combattarget change (without combate state changing) does not fire this event. However, I think I have a solution (implementing it right now): I will be using a ReferenceAlias "CombatTarget", which is filled with the current combat target of the actor (also tracked via a RefAlias in the same quest), and a Scene which tracks the actual CombatTarget of the actor against this ReferenceAlias via the "IsCombatTarget" condition: Phase 1 is active as long as the condition check "IsCombatTarget" of the actor against the ReferenceAlias "CombatTarget" returns true. As soon as the actor's CombatTarget changes, the condition is no longer true, and Phase 2 starts (which is active as long as the condition check returns false). In the Phase 2 script fragment the ReferenceAlias is updated to the new target. That will make the scene will return to Phase 1, until the target changes again. Phase 3 is if the actor is not in combat (sets CombatTarget Alias to None). As a result, the ReferenceAlias "CombatTarget" will always hold the up-to-date combat target of the actor. Link to comment Share on other sites More sharing options...
scorrp10 Posted February 3 Share Posted February 3 I dunno... if this is just for a specific short period in a quest... In the script attached to alias whose target you wish to track: bool TrackTargetChange = false Actor CurrentCombatTarget = None Float TargetCheckIntervalSeconds = 1.0 Function StartTargetChangeTracking() TrackTargetChange = true CurrentCombatTarget = GetRef().GetCombatTarget() RegisterForSingleUpdate(TargetCheckIntervalSeconds) EndFunction Event OnUpdate() If TrackTargetChange If GetRef().GetCombatTarget() != CurrentCombatTarget CurrentCombatTarget = GetRef().GetCombatTarget() Debug.Trace("Combat Target changed to " + CurrentCombatTarget) ; Do stuff EndIf If TrackTargetChange RegisterForSingleUpdate(TargetCheckIntervalSeconds) EndIf EndIf EndEvent I suppose the scene option will work as well. I.e. looking at a scene where Camilla shows player the way to Bleak Falls Barrow, scene completion condition is her being less than a certain distance from a marker, so while the scene is running, it must be constantly polling for that condition. Link to comment Share on other sites More sharing options...
Sphered Posted February 3 Share Posted February 3 There's a magiceffect condition you could play with. In theory you could apply that effect to a cloak ability with no damage. A script or shader or whatever else would then apply, but only as long as IsCombatTarget is true Not tested... and could well be one of those dormant conditions that do not do as they sound like they would. Basically just try it out Link to comment Share on other sites More sharing options...
Recommended Posts