SadSun Posted January 15, 2015 Posted January 15, 2015 I've been working on a mod that uses a cloak to pick out detection events. This has worked in so far as it can tell me if the subject being hit has detected the player. But I also want to do things when the player is not detected. I'm adding an offset animation when the player is detected, and trying to remove it when the player is no longer detected. The problem with using a cloak is that you either have to apply the animation over every time a player is hit. Or, you add a global variable and use it as a trigger to stop the apply event and only allow a remove event. (if global == 2 apply animation and make global = 1, if global == 1 remove animation and make global = 2. This could probably also be done using States) This adds a problem while the global is in the removal state. The .IsDetectedBy argument fires if only one character is not detecting the player. So, if you have 10 npcs and one of them caught in the cloak isn't detecting the player; the animation will be removed, only to be applied again on the next instance of the cloak. I would like to keep the player using the cover animation if they are detected without armor. (This would however exclude while in a fight or swimming, just want to eliminate the shuffling of the arms) The following code is applied with an OnUpdate() .AddSpell/.RemoveSpell event. Event OnEffectStart(Actor akTarget, Actor akCaster) Armor allOthersArmor = akTarget.GetWornForm(0x00000004) as Armor if allOthersArmor == None if akTarget.IsSneaking() RegisterForAnimationEvent(akTarget, "cover_sneak") Debug.SendAnimationEvent(akTarget, "cover_sneak") else RegisterForAnimationEvent(akTarget, "cover_walk") Debug.SendAnimationEvent(akTarget, "cover_walk") endif else RegisterForAnimationEvent(akTarget, "OffsetStop") Debug.SendAnimationEvent(akTarget, "OffsetStop") endif Bool dovaDetected = Game.GetPlayer().IsDetectedBy(akTarget) as Bool Armor dovaArmor = Game.GetPlayer().GetWornForm(0x00000004) as Armor int dovaCoverState = _DetectedValue.GetValue() as int if dovaCoverState == 1 if (dovaDetected == True && dovaArmor == None) if Game.GetPlayer().IsSneaking() RegisterForAnimationEvent(Game.GetPlayer(), "cover_sneak") Debug.SendAnimationEvent(Game.GetPlayer(), "cover_sneak") _DetectedValue.SetValue(2) else RegisterForAnimationEvent(Game.GetPlayer(), "cover_walk") Debug.SendAnimationEvent(Game.GetPlayer(), "cover_walk") _DetectedValue.SetValue(2) endif endif endif EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) Bool dovaDetected = Game.GetPlayer().IsDetectedBy(akTarget) as Bool Armor dovaArmor = Game.GetPlayer().GetWornForm(0x00000004) as Armor int dovaCoverState = _DetectedValue.GetValue() as int if (dovaCoverState == 2 && dovaDetected != True) RegisterForAnimationEvent(Game.GetPlayer(), "OffsetStop") Debug.SendAnimationEvent(Game.GetPlayer(), "OffsetStop") _DetectedValue.SetValue(1) elseif (dovaCoverState == 2 && dovaArmor != None) RegisterForAnimationEvent(Game.GetPlayer(), "OffsetStop") Debug.SendAnimationEvent(Game.GetPlayer(), "OffsetStop") _DetectedValue.SetValue(1) endif EndEvent What I really need is a check on the player for detection (as in a "Bool dovaDetection = Game.GetPlayer().IsDetected() as bool") rather than a .IsDetectedBy as you have to specify the detector. Can I just Run a GetDetected condition on the PlayerRef in the quest alias' tab to get whether the player is detected instead of the above code? How would that work? This is day 15 of modding skyrim for me so I'm still quite fresh in the scripting department. My main question is. Ideas? lolz ;P
Content Consumer Posted January 15, 2015 Posted January 15, 2015 Well, bear with me here, I don't actually know anything about Skyrim scripting so I'm just sort of thinking aloud. EDIT: Never mind, I think I misunderstood how "isDetectedBy" works, what I just wrote is crap. So how about this instead? 1. Detect and make a list of all actors in the current cell 2. Iterate through the list, run IsDetectedBy on each of them 3. If any actors turn up a value of true (meaning yes, the player is detected), use the animation for being detected 4. If all of the actors turn up a value of false (meaning no, the player is not detected), use the animation for being undetected The only thing I see that may be a bit off in your code is the fact that you are doing an if/else/else and I'm not sure how that would work. Is if/else if/else what you're looking for?
SadSun Posted January 15, 2015 Author Posted January 15, 2015 Well, bear with me here, I don't actually know anything about Skyrim scripting so I'm just sort of thinking aloud. EDIT: Never mind, I think I misunderstood how "isDetectedBy" works, what I just wrote is crap. So how about this instead? 1. Detect and make a list of all actors in the current cell 2. Iterate through the list, run IsDetectedBy on each of them 3. If any actors turn up a value of true (meaning yes, the player is detected), use the animation for being detected 4. If all of the actors turn up a value of false (meaning no, the player is not detected), use the animation for being undetected The only thing I see that may be a bit off in your code is the fact that you are doing an if/else/else and I'm not sure how that would work. Is if/else if/else what you're looking for? There isn't an else, else in the code. If you look closely there is an endif between. I didn't space it correctly, but it's there. I will correct this.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.