jucoking Posted January 16, 2019 Share Posted January 16, 2019 Is there a function for something like PlayerRef.IsSneaking() but instead of already being in the act of sneaking, when the player *starts* to sneak? I have tried looking up "OnBeginSneak" and "BeginSneak" on the creation kit website, but have come up short. I don't want to force the player into sneaking either, I just need them to begin sneaking to activate the trigger. Thanks in advance. Link to comment Share on other sites More sharing options...
jucoking Posted January 16, 2019 Author Share Posted January 16, 2019 (edited) "OnEnterSneaking" EDIT 1: UGH, nevermind it didn't work. Papyrus is saying that it is not a function or does not exist. EDIT 2: I have seen some using "OnBeginSneak()" in other posts but this is failing to compile for me. It needs to read something like PlayerRef.OnBeginSneak(). Edited January 16, 2019 by jucoking Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 16, 2019 Share Posted January 16, 2019 Check out the scripts in my Followers As Companions mod. I don't remember off hand how I did it. But it catches when the player enters and exits sneak so that the follower can stop walking beside and start following. I want to say it was checking the animation event. Link to comment Share on other sites More sharing options...
foamyesque Posted January 16, 2019 Share Posted January 16, 2019 (edited) There's a conditional IsSneaking. Put that on a magic effect as a condition applied at the spell level, and then use the OnEffectStart() event in a script on the magic effect to call in to whatever needs to listen for the sneak starting. You can also adapt this idea to listen for a lot of other things that scripting alone doesn't give you the tools for, e.g. weather, riding, swimming, talking, etc. Edited January 16, 2019 by foamyesque Link to comment Share on other sites More sharing options...
jucoking Posted January 19, 2019 Author Share Posted January 19, 2019 There's a conditional IsSneaking. Put that on a magic effect as a condition applied at the spell level, and then use the OnEffectStart() event in a script on the magic effect to call in to whatever needs to listen for the sneak starting. You can also adapt this idea to listen for a lot of other things that scripting alone doesn't give you the tools for, e.g. weather, riding, swimming, talking, etc.Hey foamyesque, thanks for the tip. Could you provide an example of how you accomplished this and attached it to a trigger box? I've been trying to get it working for days and can't seem to get it down. Thanks. Link to comment Share on other sites More sharing options...
foamyesque Posted January 19, 2019 Share Posted January 19, 2019 There's a conditional IsSneaking. Put that on a magic effect as a condition applied at the spell level, and then use the OnEffectStart() event in a script on the magic effect to call in to whatever needs to listen for the sneak starting. You can also adapt this idea to listen for a lot of other things that scripting alone doesn't give you the tools for, e.g. weather, riding, swimming, talking, etc.Hey foamyesque, thanks for the tip. Could you provide an example of how you accomplished this and attached it to a trigger box? I've been trying to get it working for days and can't seem to get it down. Thanks. I haven't done exactly what you're after. My use of those conditions has been involved in wardrobe management and/or avoiding interrupting a talking actor. From what you're saying it sounds like you want to do something when the player first sneaks, but only within a certain defined trigger volume, correct? My first cut at this problem would be to create a quest with an empty alias on it. That alias will add a single spell to whatever fills it: an ability, with a single effect. In the Spell window, open the effect list and add the IsSneaking condition to that effect.* Add a script to your triggerbox that, when entered by the player, forces them into that alias (and removes them from it when they leave). Add a script to the magic effect so that, when it becomes active, it calls home to whatever routines you're trying to run saying that the player is sneaking. You can then process that information however you like depending on if you care about multiple activations, etc. I can provide screenshots and code of how to do it if this is unclear. None of the individual scripts should be more than a handful of lines, though. *This is distinct from adding it directly to the effect in the MagicEffect window; conditions added through the Spell window evaluate more or less continuously, and so can toggle an effect on or off as long as the spell is still active, but ones added to the MagicEffect window are checked once, when the effect is first tried to be applied, and later changes that might alter the truth value of the conditions won't impact it. Link to comment Share on other sites More sharing options...
jucoking Posted January 20, 2019 Author Share Posted January 20, 2019 There's a conditional IsSneaking. Put that on a magic effect as a condition applied at the spell level, and then use the OnEffectStart() event in a script on the magic effect to call in to whatever needs to listen for the sneak starting. You can also adapt this idea to listen for a lot of other things that scripting alone doesn't give you the tools for, e.g. weather, riding, swimming, talking, etc.Hey foamyesque, thanks for the tip. Could you provide an example of how you accomplished this and attached it to a trigger box? I've been trying to get it working for days and can't seem to get it down. Thanks. I haven't done exactly what you're after. My use of those conditions has been involved in wardrobe management and/or avoiding interrupting a talking actor. From what you're saying it sounds like you want to do something when the player first sneaks, but only within a certain defined trigger volume, correct? My first cut at this problem would be to create a quest with an empty alias on it. That alias will add a single spell to whatever fills it: an ability, with a single effect. In the Spell window, open the effect list and add the IsSneaking condition to that effect.* Add a script to your triggerbox that, when entered by the player, forces them into that alias (and removes them from it when they leave). Add a script to the magic effect so that, when it becomes active, it calls home to whatever routines you're trying to run saying that the player is sneaking. You can then process that information however you like depending on if you care about multiple activations, etc. I can provide screenshots and code of how to do it if this is unclear. None of the individual scripts should be more than a handful of lines, though. *This is distinct from adding it directly to the effect in the MagicEffect window; conditions added through the Spell window evaluate more or less continuously, and so can toggle an effect on or off as long as the spell is still active, but ones added to the MagicEffect window are checked once, when the effect is first tried to be applied, and later changes that might alter the truth value of the conditions won't impact it. I think I'm going to need some guidance on this one if you don't mind. I really appreciate your time. Link to comment Share on other sites More sharing options...
jucoking Posted March 7, 2019 Author Share Posted March 7, 2019 (edited) There's a conditional IsSneaking. Put that on a magic effect as a condition applied at the spell level, and then use the OnEffectStart() event in a script on the magic effect to call in to whatever needs to listen for the sneak starting. You can also adapt this idea to listen for a lot of other things that scripting alone doesn't give you the tools for, e.g. weather, riding, swimming, talking, etc.Hey foamyesque, thanks for the tip. Could you provide an example of how you accomplished this and attached it to a trigger box? I've been trying to get it working for days and can't seem to get it down. Thanks. I haven't done exactly what you're after. My use of those conditions has been involved in wardrobe management and/or avoiding interrupting a talking actor. From what you're saying it sounds like you want to do something when the player first sneaks, but only within a certain defined trigger volume, correct? My first cut at this problem would be to create a quest with an empty alias on it. That alias will add a single spell to whatever fills it: an ability, with a single effect. In the Spell window, open the effect list and add the IsSneaking condition to that effect.* Add a script to your triggerbox that, when entered by the player, forces them into that alias (and removes them from it when they leave). Add a script to the magic effect so that, when it becomes active, it calls home to whatever routines you're trying to run saying that the player is sneaking. You can then process that information however you like depending on if you care about multiple activations, etc. I can provide screenshots and code of how to do it if this is unclear. None of the individual scripts should be more than a handful of lines, though. *This is distinct from adding it directly to the effect in the MagicEffect window; conditions added through the Spell window evaluate more or less continuously, and so can toggle an effect on or off as long as the spell is still active, but ones added to the MagicEffect window are checked once, when the effect is first tried to be applied, and later changes that might alter the truth value of the conditions won't impact it. I think I may be on the right track to getting this to work, but my code isn't compiling. It's basically a hijacked version of an OnEnterTrigger. I'm doing something wrong with the "ForceRefTo" or the "Clear" because it says they don't exist, but they are definitely used elsewhere. Scriptname CV2_YubaSneakLinktoAlias extends ReferenceAlias {Default script that simply activates itself onTriggerEnter and onTriggerLeave} import game import debug Actor Property PlayerRef Auto Quest Property CV2_YubatoRoverKneelAlias Auto objectReference property OnlyActor auto {By default, this property is set to the player} auto State waiting Event onTriggerEnter(objectReference triggerRef) if !onlyActor CV2_YubatoRoverKneelAlias.ForceRefTo(PlayerRef) elseif (onlyActor == triggerRef) CV2_YubatoRoverKneelAlias.ForceRefTo(PlayerRef) endif endEvent Event onTriggerLeave(objectReference triggerRef) if !onlyActor CV2_YubatoRoverKneelAlias.Clear(PlayerRef) elseif (onlyActor == triggerRef) CV2_YubatoRoverKneelAlias.Clear(PlayerRef) endif endEvent endState Edited March 7, 2019 by jucoking Link to comment Share on other sites More sharing options...
foamyesque Posted March 7, 2019 Share Posted March 7, 2019 (edited) ForceRef and Clear only work on aliases. The variable name notwithstanding, you've declared it as type Quest, which is why the compile fails.EDIT:There's also no need to import Game or Debug. I rarely import anything, but it's really only worth the trouble if you're making a lot of calls to either, and even then I prefer explicit scoping, for the clarity. Edited March 7, 2019 by foamyesque Link to comment Share on other sites More sharing options...
jucoking Posted March 7, 2019 Author Share Posted March 7, 2019 ForceRef and Clear only work on aliases. The variable name notwithstanding, you've declared it as type Quest, which is why the compile fails.EDIT: There's also no need to import Game or Debug. I rarely import anything, but it's really only worth the trouble if you're making a lot of calls to either, and even then I prefer explicit scoping, for the clarity.Gotcha ;) I'm a beginner at scripting, so I'm not exactly sure what it does but like I said before, I basically copied and pasted the already existing script. I think I'm just going to leave it as-is for now because everything works fine, the player will just have to realize that they need to enter my trigger while already in a sneaking position to get it to fire. Or I can add a little message somewhere in the game giving a hint that this is how they need to do it. Once I finish the big stuff I may revisit the topic and refine the details. The mod is probably 2-3 months away from being finished. I really appreciate your time and advice. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts