player is swimming

Post » Sat Nov 17, 2012 6:31 am

How can I tell if a player (PC) and is swimming or not?

This what I like to do

IF player is in water (aka swimming)
THEN set SeedMULT=160 //I can look the real name for this variable if you need it
ELSE set SpeedMULT = 130

I am trying to set speed based either on land vs when the player is in water / swimming

BTW, I am trouble at writing code, if anyone just write this code for me, they will get 9 hot fresh sweetrolls (or cheese) -- Their choose :biggrin:
User avatar
Miss K
 
Posts: 3458
Joined: Sat Jan 20, 2007 2:33 pm

Post » Sat Nov 17, 2012 12:31 pm

I'm only seeing a condition function for http://www.creationkit.com/IsSwimming, I don't see a Papyrus version. If you need this in code, then the only thing I see for swimming is an animation variable, so I'd take a look at this: http://www.creationkit.com/List_of_Animation_Variables.

You could try this code:

Debug.Notification("Swimstate="+GetAnimationVariableFloat("SwimDirection"))

Put this in code where ever it is you have to check and see what it shows anything useful. If it changes state when you're swimming, then great, your IF/THEN would look something like:
If GetAnimationVariableFloat("SwimDirection")) > 0  SetAV("SpeedMult",160)Else  SetAV("SpeedMULT",130)EndIf

Note: I don't know if it's a float, might need replace GetAnimationVariableFloat with:
GetAnimationVariableInt
GetAnimationVariableBool <- probably NOT a bool, but if the other two don't work, might as well try.

I'll let you do the actual testing so you can save your sweet rolls :wink:

Edit: BTW, did you do a search here on the forums already? It would be surprising if you are the first to ask about swimming.
User avatar
BlackaneseB
 
Posts: 3431
Joined: Sat Sep 23, 2006 1:21 am

Post » Sat Nov 17, 2012 6:17 am

Yeah, i try to look for it, but don't see what I am looking for

thanks for your help

All I need to do now to attached this code to the spell effect
User avatar
Shae Munro
 
Posts: 3443
Joined: Fri Feb 23, 2007 11:32 am

Post » Sat Nov 17, 2012 9:22 am

Since you are using a Magic Effect, you could use the IsSwimming conditional function there? Maybe have two different magic Effects based on if IsSwimming is True, the other for false.

Otherwise, I found this from a different thread:
and test whether PlayerREF.GetAnimationVariableInt("iState") == 63

So if the GetAnimationVariableFloat("SwimDirection")) doesn't register swimming, it looks like iState is set to 63 when swimming.
User avatar
Terry
 
Posts: 3368
Joined: Mon Jul 09, 2007 1:21 am

Post » Sat Nov 17, 2012 6:16 pm

I will also need to work with NPCs also
User avatar
lillian luna
 
Posts: 3432
Joined: Thu Aug 31, 2006 9:43 pm

Post » Sat Nov 17, 2012 11:46 am

so the code would be like

If PlayerREF.GetAnimationVariableInt("iState") == 63
SetAV("SpeedMult",

200

)
Else
SetAV("SpeedMULT",150)
EndIf
User avatar
Poetic Vice
 
Posts: 3440
Joined: Wed Oct 31, 2007 8:19 pm

Post » Sat Nov 17, 2012 7:10 am

WOW! It complies with no errors! :foodndrink:
User avatar
Sunnii Bebiieh
 
Posts: 3454
Joined: Wed Apr 11, 2007 7:57 pm

Post » Sat Nov 17, 2012 10:54 am

WOW! It complies with no errors! :foodndrink:

Yeah, but does it work :)

Remember, you'll need to change the PlayerREF if you're going to use that for an NPC.
User avatar
James Hate
 
Posts: 3531
Joined: Sun Jun 24, 2007 5:55 am

Post » Sat Nov 17, 2012 11:35 am

I can not tell for sure if it works, so I need to add a showmessage windows for debugging, unless u know a console command that let me see what value the SpeedMULT is
User avatar
FoReVeR_Me_N
 
Posts: 3556
Joined: Wed Sep 05, 2007 8:25 pm

Post » Sat Nov 17, 2012 2:03 pm

can I do a "or" on the if statement?

If PlayerREF.GetAnimationVariableInt("iState") == 63 or If NPCREF.GetAnimationVariableInt("iState") == 63
The syntax most likely be wrong, but is the logic good?
User avatar
Abi Emily
 
Posts: 3435
Joined: Wed Aug 09, 2006 7:59 am

Post » Sat Nov 17, 2012 8:32 pm

can I do a "or" on the if statement?

If PlayerREF.GetAnimationVariableInt("iState") == 63 or If NPCREF.GetAnimationVariableInt("iState") == 63
The syntax most likely be wrong, but is the logic good?
You can. The syntax is:
If PlayerREF.GetanimationVariableint("iState") == 63 || NPCREF.GetanimationVariableInt("iState") == 63
User avatar
Kelly John
 
Posts: 3413
Joined: Tue Jun 13, 2006 6:40 am

Post » Sat Nov 17, 2012 8:11 am

I can not tell for sure if it works, so I need to add a showmessage windows for debugging, unless u know a console command that let me see what value the SpeedMULT is


I was a wiki, i tried the showsvars console command and it says I don't have script attached, but it shows the spripts name. plan b -- what is the syntax of the Debug.MessageBox("variables name") to show the values of the speedmult?
http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Variables_and_Conditionals // under the "Looking at a script's variables at run time" heading

the code is attached to the magic effect in the ck, is this the right place? the spell is set to constant effect. does that makes a difference?
User avatar
Laura Mclean
 
Posts: 3471
Joined: Mon Oct 30, 2006 12:15 pm

Post » Sat Nov 17, 2012 4:43 pm

I can not tell for sure if it works, so I need to add a showmessage windows for debugging, unless u know a console command that let me see what value the SpeedMULT is

Because SpeedMult is an Actor Value, you can use the GetActorValue (or GetAV for short) console command:

Player.GetAV("SpeedMult") will give you the players SpeedMult. You can get the NPC value by clicking on the NPC, then typing: GetAV("SpeedMult")
User avatar
CArlos BArrera
 
Posts: 3470
Joined: Wed Nov 21, 2007 3:26 am

Post » Sat Nov 17, 2012 12:15 pm

from his code in, i think I found an answer to my question
http://www.gamesas.com/topic/1397811-this-has-had-me-stumped-for-2-days-help/

he uses UpdateMessage.Show ( pMagicka, gMagicka, HMagicka ) and his foot note: "The UpdateMessage.show at the end of the code appears to show all of the correct values. "
so I change the code around for to use in my code
UpdateMessage.Show ( SpeedMult, iState) it should the values of those vars right?
User avatar
SamanthaLove
 
Posts: 3565
Joined: Mon Dec 11, 2006 3:54 am

Post » Sat Nov 17, 2012 4:04 pm

cool, i owe you so many sweetrolls now, I lost count .. :blink:
User avatar
Alex Blacke
 
Posts: 3460
Joined: Sun Feb 18, 2007 10:46 pm

Post » Sat Nov 17, 2012 2:18 pm

UpdateMessage.Show ( SpeedMult, iState) it should the values of those vars right?

I'm not sure what your current code looks like, but I thought SpeedMult was the actor value? If so, no, that code would not show them. You'd need something like:
Debug.MessageBox("SpeedMult=" + playerREF.GetAV("SpeedMult"))


if you are passing in your own messagebox reference, then you would use:
UpdateMessage.Show(playerREF.GetAV("SpeedMult"),PlayerREF.GetanimationVariableint("iState")
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Sat Nov 17, 2012 7:27 am

my is not firing for some reason... I put it on a constant magic effect on self any ideas why?

in the console command (player.getav speedmult) always returns 100
here is the code -- comment out the real code and just tried to get a message box up -- it did not show, therefore the code is not firing....

   Scriptname k9WateDetection  extends activemagiceffect {This is my very first script!} Event OnActivate(ObjectReference akActionRef)    Debug.MessageBox("Hello, World!") endEvent;Scriptname k9WateDetection extends activemagiceffect;{If PlayerREF.GetAnimationVariableFloat("SwimDirection")) ||  NPCREF.GetAnimationVariableFloat("SwimDirection"));SetAV("SpeedMult",200);Debug.MessageBox("SpeedMult=" + playerREF.GetAV("SpeedMult"));Else;SetAV("SpeedMULT",150);Debug.MessageBox("SpeedMult=" + playerREF.GetAV("SpeedMult"));EndIf}
User avatar
James Baldwin
 
Posts: 3366
Joined: Tue Jun 05, 2007 11:11 am

Post » Sat Nov 17, 2012 7:12 pm

I see why not I have not code in years ... isn't debugging fun or what? :ahhh: :gun: :flamethrower: :banghead: :brokencomputer: :tes:
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Sat Nov 17, 2012 4:18 pm

Your script extends ActiveMagicEffect: those don't have OnActivate events. Perhaps you want Event OnEffectStart(Actor akTarget, Actor akCaster)?
User avatar
Harry Hearing
 
Posts: 3366
Joined: Sun Jul 22, 2007 6:19 am

Post » Sat Nov 17, 2012 7:15 pm

Your script extends ActiveMagicEffect: those don't have OnActivate events. Perhaps you want Event OnEffectStart(Actor akTarget, Actor akCaster)?

sorry, it is still not firing. Do I need to start a new char to get it to work?
User avatar
TASTY TRACY
 
Posts: 3282
Joined: Thu Jun 22, 2006 7:11 pm

Post » Sat Nov 17, 2012 7:21 pm

sorry, it is still not firing. Do I need to start a new char to get it to work?

You don't need to start a new char, but I would always load a save made prior to activating your mod. So don't test on game where you saved with your mod already active.
User avatar
Greg Cavaliere
 
Posts: 3514
Joined: Thu Nov 01, 2007 6:31 am

Post » Sat Nov 17, 2012 8:03 am

well, new game / new char is still no go.... no pop up box
User avatar
Robert
 
Posts: 3394
Joined: Sun Sep 02, 2007 5:58 am

Post » Sat Nov 17, 2012 6:41 am

So how are you applying this magic effect?
User avatar
chinadoll
 
Posts: 3401
Joined: Tue Aug 22, 2006 5:09 am

Post » Sat Nov 17, 2012 1:13 pm

well, new game / new char is still no go.... no pop up box

My guess it's not set up correctly in the CK. If you are extending the correct script type, then there's not much else to go wrong in the script. I've never had an issue where events randomly don't fire. I'm actually not sure how you are implementing what you're doing so I can't give you any tips.
User avatar
Patrick Gordon
 
Posts: 3366
Joined: Thu May 31, 2007 5:38 am

Post » Sat Nov 17, 2012 9:37 pm

open up the mod, made an effect to set the var, then make a new spell. Open up the spells details, added the code where it says too -- gave some cues
http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Hello_World

instead of an object like the tutorial says to do, I am under the spell area, it is a spell after all, not an object

if one opens up any spell, one will see a small box to add code -- that will I did for my spell, then I add my spell to the argoninan race

have any tried to have code run in a spell with a constant effect with any magic effect?
User avatar
Charlotte X
 
Posts: 3318
Joined: Thu Dec 07, 2006 2:53 am


Return to V - Skyrim