Jump to content

need scripting help - swim detection to apply magic effect


sulmithgreysin

Recommended Posts

i've read the tutorials, they don't really tell me what i need to know about how to do this. i need some help because my other option is to just move on for now.

 

if someone can post a script that:

 

1) detects when the player is swimming

2) applies a magic effect then and only then

3) removes the effect when going back on land

 

i can't find anything about script spacing, why this is this way and that is that way. i do know how to make skyrim tell me "hello world!" but that just isn't useful in any way

Link to comment
Share on other sites

To your direct question: http://www.creationkit.com/IsSwimming

 

You would have to get creative on exactly when to check for that though...

 

In terms of just scripting, this may help you some, along with playing around in the CK with it: http://www.creationkit.com/Adding_Working_Scripts_to_Items

 

I'm not certain what you mean by spacing, but here are a few quick basics I wish someone would have told me the first day I was playing with the CK:

Scripts you will most often be dealing with in this incarnation of the TES series are 'attached' to things. A script can be attached to many types of forms (quests, chairs, doors, actors, misc objects, invisible triggers, etc...). For things that can be placed out in the world, they can also be attached to an objects 'Base' basically the generic type of the object you see in the object window(Whiterunguard, grindingwheel, loaddoor, DefaultTrigger), and also to the objects specific 'reference' (Every individual specific one you drag out into the world.).

 

These are where the scripts go(Either in the objects window somewhere that says 'script' or 'papyrus fragment', or under the 'scripts' tab of an object actually in the world). When a script is attached to an object, it is said to 'extend' the object, that's why the script starts with ScriptName ZOMGScript extends ObjectReference. It's extending some sort of 'object reference' there are lots of things you can 'extend', or add extra stuff to (You can 'extend' quests, spells, weapons, actors, all sorts of things, it basically just means adding to, and overriding it's default script and behavior).

 

You may have seen the blank text boxes labeled 'Fragment' or 'Papyrus fragment' on various dialog boxes in the CK. These are wonderfully convenient little spots to put a bit of code to help 'extend' the exact thing you are looking at on that page. For quest stages, the fragment says what happens when you get to that stage. For packages, the fragments are labeled begin, change activity, and end, or something like that. They do exaclty what they say, it executes that little block of script when it starts/switches activity/ends. Scenes are the same way, you can throw in little bits of scripts into scenes in half a dozen places. It's basically to save us from having to make a formal script for each tiny action when 99% of what we want is obvious (we want you to execute this few lines of code when the guard get's an arrow to the knee, etc...)

 

The *reason* it's so great to extend specific objects, is so they can be dealt with in an object oriented manner. If you know anything about any programming language made in the past 20 years, you should at least know a *little* about object oriented concepts. If all your script code is on a particular object, the game can help you out, because it knows exactly what you need based on what you're trying to control.

 

By this I mean, when the game is reading your script on a door, the game knows you're going to want to know certain things at certain times, to get stuff done. When the player clicks the door, the game will look for what you put in the 'onActivate' function in your script(don't hold me to that name, i forget if that's exactly it) When the player walks into the cell with the door, it will check and see if you have any instructions in the 'OnLoad' function. These are called events in programming, you are giving the game specific code to read when the specific event occurs.

 

Properties are similar in a few ways. sort of... by using properties, you are letting the game know what stuff you will be messing around with in this script. This is important, so the game knows what to have ready for you when the script is read. Some properties are just letting the game know you want info from somewhere else. Even if you're in a script inside a quest, you still have to let the script know what information about the quest you want to mess around with in your code. Other properties are for your use, as variables to store stuff. Often if you make something a property that isn't pointing to something else, it's because you want to be able to access the information from places outside your script.

 

To start a scene, even in the same quest, you'd have to tell the game you want to deal with the scene:

Scene property Myquestscene auto ;telling the game you want to use it.

 

Myquestscene.start() ;now you can use

To change something in your script, from another, you would also need to let the game know you wanted to have access:

MyScript property bob auto ;you want to use Myscript and call the instance of the script we're using bob...

 

bob.Myproperty = 5

 

Again, don't hold me to the exact syntax, I'm pretty sure I'm good and close, but do check the references, particularly the ones at

 

With what I just put here (ignore the second half if you know anything about object oriented programming of course), you should have what you need, what is not very well explained on the creation kit site, to get you a head start in scripting in the CK. This isn't meant, at all, to get you doing useful things. I just wanted to fill in some of the gaps I know are there.

 

Next steps, along with more playing around in the CK and checking out existing scripts and scripts attached to interesting objects around skyrim:

 

http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Events_and_Properties

http://www.creationkit.com/Scripting_Tutorial_Using_Functions

http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Variables_and_Conditionals

 

 

 

Hmm... looks like I just accidentally wrote a terrible, tiny rough draft for a tutorial in a forum post again... Somebody clean that up, make it make sense, and put it on a wiki somewhere lol

Link to comment
Share on other sites

yeah i've been over the CK page multiple times.

 

(by spacing i mean the actual script and the placement of th e words/lines in relation to the one above it. why indent, how far and what effect does it have on the script)

 

it's the equivalent of me teaching someone how to change their oil because they need to know which A/R to pick for their turbo

 

yeah it's related but no, it's not really useful.

 

i'm still not even sure WHAT water would be classified under. object or effect or what? i can't find anything related to it

when people throw all these undefined terms at you it's really just an assault on your lifespan. all i can figure is that people want you to know that THEY know, they just don't want to risk you learning everything they know.

 

none of these tutorials teaches you how to do much else but copy while learning bits and pieces of things that are rarely defined, and sometimes they're defined with words you'd need a tutorial to figure out

 

if i'm teaching you to forcefeed a F/T pinky to a neonate ophiophagus hannah, i'm just teaching you how to make a baby king cobra eat a baby mouse that was frozen and then thawed out. i can say it both ways and mean the same thing, one way is just obviously easier to comprehend for someone who doesn't know what i'm talking about yet.

 

the tutorials aren't really useful unless you already kind of know what you're doing, and i don't. i build houses for a living. i'm around people who can't figure out how to alt-tab

Edited by sulmithgreysin
Link to comment
Share on other sites

IsSwimming is a conditional statement. You wouldn't be able to use it in a script anyway.

 

It is useful to your situation though. What I would do:

1.Make a Magic Effect for whatever effect you want to apply (sounds like you already have one...so on to step 2)

2.Make an ability that uses the Magic Effect from step 1. and put the condition IsSwimming = 1 on it

3.Add that ability to the player (easiest way is through a quest script...)

 

Once added to the player, the magic effect attached to that ability should trigger when the player is swimming and will leave when the player is not swimming.

 

Making a quest script to add the ability:

1.Make a new quest.

2.Check the checkboxes for Run Once and Start Game Enabled.

3.Click over to the Quest's Script tab and add a new script that extends Quest, name it whatever you like.

4.The new script should show up in the script window now. Right Click it and click edit. Copy and paste this into it:

Spell Property YourSpell auto

Event Oninit()
RegisterForSingleUpdate(1.0)
EndEvent

Event OnUpdate()
Game.GetPlayer().AddSpell(YourSpell)
EndEvent

5.Save and Compile and exit the script editor. Make sure your script is highlighted in the window and click the Properties button next to the window. Click YourSpell, you should see a drop down list to the right. Select the ability you made then OK for the properties window then OK for the Quest window.

Edited by cscottydont
Link to comment
Share on other sites

You actually don't need two spells/abilites, only one. Instead of having an ability adding a spell with the magic effect, just have the magic effect on the ability on the first place. I'd already briefly explained it in the earlier thread.

 

First, you create the magic effect. The magic effect should be a constant type effect that targets self. It should have a script attached. The script should look like this:

 

scriptname example extends activemagiceffect

Event OnEffectStart(Actor akTarget, Actor akCaster)

akTarget.SetAV("SpeedMult", 0.5)

EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)

akTarget.SetAV("SpeedMult", 1.0)

EndEvent

 

Then you should create a constant effect ability targeting self. Add the magic effect to the ability, with the condition "IsSwimming == 1". Then, when the ability's owner starts swimming, the OnEffectStart part of the script will run. When he/she/it stops swimming, the OnEffectFinish part will run.

 

EDIT: Since you seem to have problem with 'spacing', I'll tell you some really basic info about scripting.

 

Indentations don't matter. It's just there so that it's easier to read the code and figure out what's happening. Other than when declaring properties and variables, all the code needs to be inside functions or event calls. So indenting makes it easier to separate the functions/events.

 

In the script I just posted, I indented some stuff so that I know all the stuff in the non-indented lines were for starting and ending events. It doesn't really matter in such a short script, but if I had something like 300 lines per function/event, it makes it a lot easier to tell when one event ends and another begins.

 

Also, it doesn't matter which order I put the functions/events/declarations in (but the code inside the functions/events have to be in the correct order). So I could have put the OnEffectFinish before the OnEffectStart, and it wouldn't have mattered.

 

The stuff in the parentheses "(Actor akTarget, Actor akCaster)" are the parameters of the event. You could think of it as just another way of declaring your variables, except that you have to declare it in that order, those types, and you have to declare all of them, even if you don't use it (as in the case of akCaster). I could have used "(Actor IJustGotHitWithSomething, Actor IJustHitYou)" and it would have been fine. As for knowing what order, and what type, of variables go into those parentheses, you will just have to look at the CK wiki to know. I certainly don't remember all the parameters for all the events and functions.

Edited by fg109
Link to comment
Share on other sites

if i'm teaching you to forcefeed a F/T pinky to a neonate ophiophagus hannah, i'm just teaching you how to make a baby king cobra eat a baby mouse that was frozen and then thawed out. i can say it both ways and mean the same thing, one way is just obviously easier to comprehend for someone who doesn't know what i'm talking about yet.

 

lololol, couldn't couldn't have said it better myself.

 

Ya, it's the unfortunate result(for bethesda) of having to try and teach a slightly technical topic to people who are smarter than them, and 12 year olds, with the same text. It's really not possible without confusing or angering someone somewhere. so they do the responsible corporate thing. they put it up, and wash their hands of it lol. I defaulted to my frame of mind when I'm teaching my brother(when he wanted to learn C++ all of the sudden), my mom, or completely clueless clients who's computer I'm fixing that *really* wants to know, what a highly technical error on their screen means >.< like... seriously?

 

fg109's constant effect spell is kind of what I was hinting at with the isswimming, though I forgot about... using a constant effect spell :D

 

The effect would probably end up similar to the spellbreaker shield if you've ever aquired that. It adds a ward when you start blocking. There is, however, built into the engine, a like, 500ms delay before it will realize it, and sometimes it doesn't catch that the condition is not true anymore for another couple seconds. This is at least if you apply constant effects based on stuff like IsMoving, and I would assume, is swimming. I would expect it would get the job done though.

 

Don't hesitate to throw anything else up if you have trouble, who knows, someone may get some inspiration and show you a whole new, better suited solution than stuff you're looking at.

Link to comment
Share on other sites

no luck with either method above

 

cscottdont's method caused my movement speed to be super high after exiting the water (permanent change until i relogged)

 

fg109's method caused my guy to have a movement speed of 0 when i hit sprint out of the water (worked in the water, permanent change after exiting once)

 

i played around with the effect, the spell, magnitudes, the scripts, nothing helped

 

gonna keep messing around with it

Link to comment
Share on other sites

here is what i can do without any scripting at all, it seems close and working properly other than the fact that the values don't change in/out of the water until i open the magic effects screen then close it

 

with a new speedmult effect and a spell with isswimming == 1 as a conditional attached to the race of the toon i was testing, he would go into the water and nothing would change. i'd open the magic effect screen then close and the spell would register then and he'd be swimming slow

 

out of the water and he's running slow, open the magic effects screen and close it now he's back at normal walk speed

 

that's as close to working as i can get

 

anything jumping out as an issue?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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