Jump to content

Papyrus: detecting when player is in water?


Mansh00ter

Recommended Posts

So, I searched extensively for this, but I failed to find any scripting reference which would enable the script to detect if the player is standing in water. Now theoretically I could just apply a magic effect to all the water types I wanted and then check if the player has that effect applied on them, but I was wondering if there was a cleaner way of doing this?
Link to comment
Share on other sites

Of course depends on the usage you want, if is enough to detect if the player is at certain location, create an activator and test against it.

 

Of course that would not be solution if the purpose is, for example: standing in water, does not matter how shallow, makes the player/actor a tad more vulnerable to shock effects...

Edited by nosisab
Link to comment
Share on other sites

Hmm... I have a problem. The CK allows you to select a magic effect for water types, which I assume would be for purposes of applying said effects to anything that enters that water type. BUT, whatever I try, I can't get that to happen. Anyone had any success with that sort of thing?

 

Basically, if I could get a magic effect to be applied to the player whenever they enter water, I could then test for that magic effect via Game.getPlayer().HasMagicEffect(MyEffect) and then go on from there.

 

But right now I'm not even sure if that's possible - even though the CK has that option, it's completely undocumented.

Link to comment
Share on other sites

How do horkers detect when they are in water? They sit on land but they will follow the player into the water if you aggro them. They have a moving-on-land animation and a swimming-in-the-sea animation, so how to they detect which animation to use? The transition does seem to be a bit buggy though.

 

(If you've already investigated this route then sorry, just ignore me).

Link to comment
Share on other sites

I assume they do it the same as NPC's do, they have the "can swim" flag set and the game detects if they're in deep enough water for the swimming animation to kick in. There is that "isSwimming" conditional, but that's of no use if you're trying to make a Basic Needs mod and need to detect if the player is just standing in a body of water, even if only ankle deep.

 

But I solved it. Took me whole day.

 

What you do, is check the "causes" flag for each water type, but leave the damage at 0. That turns every water in the game to "lava", which can be detected by the isInDangerousWater conditional, but won't appear any different to the player.

Now, I haven't been able to find out if you can use conditional functions directly in the Papyrus scripts, but there is a workaround.

 

You create a new Ability effect, set it to "constant" and "self". Then you create a new magic effect, which has a condition that "isInDangerousWater" must be true in order to apply and add it to your new Ability.

Then you create your script, set it to update at regular intervals (for example, every five seconds) and simply first remove the Ability you created, then immediately re-apply it. If the player is standing in any type of water, the effect will fire and you can then use scripts to detect if the player has that particular magical effect applied on them, and then do whatever you like.

 

Voila, case solved, it detects if players are even dipping their toes in water.

 

But there really should be a simpler way of doing it.

Link to comment
Share on other sites

  • 6 months later...

Hi. I am making a mod that requires a similar condition check. I would like to simply make the player move more slowly when swimming. I noticed the Magic Effect field in the WaterType object, so I created a magic effect to reduce movement speed. However, that magic effect requires a magnitude, so it requires a spell in order to be applied. I then created another magic effect which will add an ability containing the speed reduction effect.

 

My problem is that the magic effect which adds the speed reduction ability does not appear in the "Magic Effect:" drop-down available in the WaterType object editor window. Does anyone know why a certain magic effect might not be included in the list?

 

I can find the effect available in other lists, such as the effects list for magic spells. Furthermore, I created a test spell to confirm that the magic effect functions properly (which it does). I just can't find it in the list of effects available for WaterType.

Link to comment
Share on other sites

  • 1 year later...

Sorry to bump this. But, maaan!, I've been looking for something like this for more than a year!

 

Mansh00ter's method works beautifully. Thanks!

 

carstenseng1's doesn't. In carstenseng1's method, the Magic Effect needs to be attached to a Spell, an Ability in my test-case. The Spell is selected in the WaterType object. But even with the correct Spell selected, it was never applied to the player.

 

I really should have search for a solution rather than trying to work one out myself. The solution I came up (and is working but) is slower (5 seconds max) and not 100% accurate (e.g. in shallow water). It requires an invisible item (an arrow) be dropped in front of the player and for the mod to check if it is bobbing up and down by tracking its vertical position. Only arrow items (and, possibly, dead actors) have this behaviour in water.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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