Jump to content

Geck Scripting - From Fool to Fox


Recommended Posts

This tutorial will get you started making your first scripted mod for FNV/TTW. No prior experience of modding, scripting or programming is required. This is practical tutorial, so you will be scripting your first working mod by the end of part 2, and after that we slowly evolve into more advanced stuff. Don't expect everything you read to make sense immediately, it didn't for anyone. Just read it once, and then carry on with the examples. You can always re-read it later if need be.

 

The tutorial focuses on scripting, but touches on general mod making when required as well.

 

If you already have experience scripting/programming I highly recommend that you still start at the beginning, although you'll probably be able to skim through the middle chapters.

 

To keep things easy to follow, occasionally things have been simplified slightly.

 

This tutorial focuses an general fallout scripting, but since this is loverslab, there are optional sections on sexout included, including how to make you own sex key after part 5, and orgies later on.

 

Contents:

 

  1. Setting Up The GECK

  2. Your First Script

  3. GECK overview (references, base forms and functions and where to find them)

  4. Conditions

  5. Variables 1

  6. (Optional: SexoutEZ and creating a sex key)

 

Part 1 - Setting up the GECK

 

  1. Make sure you have the lastest version of NVSE installed, which you can get here.

  2. Download the GECK from Bethesda here and install.

  3. Download the GECK Power Up from here and install (this gives you some helpful extra features)

  4. Go to your FNV folder in windows explorer ('.../STEAM/SteamApps/Common/Fallout New Vegas'). Find this file nvse_loader.exe, right click and create shortcut. Right click on that shortcut you just made, and click 'properties'. Under 'Target' which is probably highlighted already, add  -editor at the end. So, it will look something like: "E:\STEAM\SteamApps\common\Fallout New Vegas\nvse_loader.exe" -editor

  5. Click okay. Done, you have now setup the GECK correctly, whenever you want to run it, double click this shortcut. Do not run “GECK.exe”, because this won't work for non-vanilla features.

  6. Double click the short cut to start the GECK.

 

Now you've got the GECK setup, just wait for it load (note: whenever the GECK is busy loading, do not click the mouse or press any keys, be patient and wait for it to finish. Sometimes it crashes otherwise). At the moment, there are no files loaded in the GECK, so you can't see anything interesting.

Click 'file' at the top left, then 'Data...'.

  • This will show you a list of all the .ESM and .ESP files in your data folder, with a tick box beside them, anything ticked will load when you press 'OK'.

  • There is also a button 'Set As Active File', if you want to edit an existing mod, you click this, but to create something new, you just press 'OK' with nothing set to active. NEVER set a vanilla file (eg “FalloutNV.esm”) as active.

Now, make sure “FalloutNV.esm” is selected, but nothing else. If you have DLC, they might default to selected, if so then double click them to unselect them. It should look like this:

(fig1: post-158171-0-81614100-1403782436_thumb.png),

if so then press 'OK' and wait for the GECK to load.

 

Now, the GECK top left should look like this:

(fig2: post-158171-0-82382800-1403782477_thumb.png),

if instead you see a file name, like “FalloutNV.esm”, you accidentally set an active file, so click 'file' → 'Data..' and fix that.

 

Click 'File' → 'Save', then type in a name for your mod, such as “MyFirstMod” and press enter.

 

Congratulations, you just created your first mod. Granted it does nothing at all yet, but still. If you close the GECK and then want to re-open your mod, this is when you select it from that list and click 'Set Active File', before pressing OK. This will still load any files selected in the list, but your 'active' mod will be the one that is saved to.

Link to comment

Part 2 – Your first script

 

So, you have the GECK setup and running from part 1?

 

In the object window, expand 'Miscellaneous' and click on 'Script' within that. The GECK should now look something like this:

(fig3: post-158171-0-70075800-1403782591_thumb.png).

If not, go back to the end of part 1.

 

In this section I will give a short explanation of what things are, then give you an example to try. If the explanation seems hard to understand, don't worry- just carry on and try out the example, this is the best way to understand it. You can always re-read the explanation later on.

 

Naming Prefix: In the GECK, all the vanilla stuff is present and you want to make sure anything new that you add does not override something that exists already- unless you wanted that to happen. Therefore, always use a prefix (eg: “MyMod”) for your mod whenever you name something new you create, eg “MyModSomeScript”, or “MyModSomeItem”. You will need to type this prefix a lot, so keep it short. This also helpful for finding things in the GECK, as you can just type “MyMod” into the search bar, and it will bring up everything that is yoursand not vanilla stuff you don't care about.

 

Now, right click anywhere within the list of scripts and click 'New',

(fig 4: post-158171-0-50693700-1403782656_thumb.png).

 

Copy what you see in fig5, which is this:

(fig 5: post-158171-0-90499200-1403782677_thumb.png)

  • (Set the script type to 'quest')

  • and type:

 

------

scn MyModFirstQuestScript
 
; This is my first script
 
Begin GameMode
 
    MessageEX "I am Working!"
 
End

Now, click 'save', then close the script window: You should see no warnings. If a warning says “Do you want to save this script?” when you already did just save it, then you did not set up the GECK correctly to use NVSE- perhaps you ran 'GECK.exe' ,instead of the shortcut you created to 'nvse_loader.exe'? Go back to part 1, because you will not be able to get any further until you do.

 

Okay, so you have written your first script and it saved properly. Now I'll explain what it does, but probably you won't really understand yet. Still, read this and then carry on with the guide regardless.

 

scn MyModFirstQuestScript

= The name of this script is MyModFirstQuestScript

 

; This is my first script

= a semicolon ; means that this line is a 'comment'. A comment does nothing at all, it just lets you add notes for personal benefit when you try to remember what the script does later on.

 

Begin GameMode

= This is a block type. All the code in the line between the 'Begin' and 'End' will run every time the game is in GameMode, which means whenever a menu (eg: pipboy/options) is not up.

 

MessageEX “I am Working!”

= This means show the message “I am Working!” on the screen in game. “MessageEx” is one of many functions. “I am Working!” is the function 'parameter' or 'argument', and whatever this happens to be is the text of the message that will show.

 

End

= This is the end of the block and script.

 

 

So, this script just shows a message to the player during gameplay. Right now, that script never actually runs, because it is not associated to anything. There are many ways to run a script, but for this one we will create a 'quest'. Go to the 'quest' section of the GECK object window (see fig 6), and right click inside it and select 'new'. Now (see fig 7):

 

(fig 6: post-158171-0-99136500-1403782758_thumb.png fig 7: post-158171-0-62593100-1403782775_thumb.png)

 

  • Set the 'Quest Name' to another you want, it doesn't matter.

  • Set the 'ID' to something unique with your mod prefix, eg: “MyModFirstQuest”.

  • Set the 'Priority' to 50. Don't worry about what that means.

  • Set 'Start Game Enabled' by ticking the box, this means the quest is automatically running at the beginning of the game. Otherwise you would need to start it yourself via some script.

  • Set the 'Script Processing Delay' to default, by clicking the tick box. This means that an attached script runs once every 5 seconds. If you type in something else, it could be a different time.

  • Now click OK. (You MUST click okay now to save the quest. You can't set anything else until you do).

 

You have created your first quest, but it doesn't do anything yet. Find it in the list of quests, right click and select 'Edit' (see fig 8). Now that the quest is pre-created, we can give it the script you made earlier. Click the arrow on the side of the 'script' box (fig 9), and either scroll down or type 'mymod' to jump to the one you created.

 

(fig 8: post-158171-0-90154300-1403782807_thumb.png fig 9: post-158171-0-21050700-1403782823_thumb.png)

 

If your script does not appear in the list, then either:

  • You did not save it (check you are running the GECK properly- part 1)

  • You did not set its type to 'quest' (the default is 'object').

  • You have forgotten its name, which is whatever is after 'scn' in the script, and how it appears in the script section of the GECK.

 

Otherwise, click okay to save the edit to the quest. Then save your plugin itself, by clicking 'file' → 'save' at the top left of the GECK.

 

You have just created your first mod that actually does something, okay its boring, but make sure it actually works before we get onto exciting stuff.

 

Open your mod manager and make sure that your mod is ticked (FOMM may default to unticked), then start up Fallout New Vegas and load any game you like.

 

Now during game play, every 5 seconds a message should appear on the screen saying “I am working!”. If that happens, congratulations! Everything is working perfectly. If this message never appears, go back to the start of part 2 and try again.

Link to comment

Part 3 - GECK overview (references, base forms and functions and where to find them)

 

If you've got this far, you've got the GECK set up ready for whatever you want to throw at it and you've created a mod that actually works in game. Maybe we can't write home about our mod yet, but its still an achievement that most people never manage. Read on a little and we can open our first beer. Read this short description of GECK concepts that you probably won't understand yet, then follow the example. Don't worry, later on you will understand it, and if not.. pffftt, you'll still have a beer.

 

Base Form: A base form is something that exists in “GECK Space”. Example: “Beer”.

 

Reference: A reference is an instance of a base form in the actual game world. Example “That beer that is on top of the bar in the prospector saloon

 

Function: Just something that does something in a script.

 

Argument or Parameter: Something that decides what a function does.

 

Open the script that you created before, and add a new line just before the “MessageEx” line:

 

PlayerREF.AddItem Beer, 1

 

(see fig 10: post-158171-0-21388100-1403782993_thumb.png)

 

Save it. Try it out in game if you want- now every 5 seconds the player is given a beer.

 

So, what does this line do?

 

PlayerREF: This is a reference in the game world for the player.

 

.AddItem: This is a function which adds an item to a reference

 

Beer: This is a base form, which is the item to add. It is the 'argument' for the function

 

1: This is also an argument for the function, it is the count of items to add. Change it to 2 and the player will get 2 beers instead of 1.

 

So, you just ran a function on a reference to add a base form argument to them. It sounds complicated when you put it like that, but you just did it already and it works, so carry on.

 

 

More on the above

 

References

 

Examples: PlayerREF (The player), SunnyREF (Sunny Smiles), VFSTheKingREF (The King), CraigBooneREF (Boone). Let's find out some more:

 

(fig 11: post-158171-0-11186000-1403783037_thumb.png)

  • Click on a cell in the 'Cell View' window of the GECK and look at the list on the right hand side. Those are all references.

  • However, to use them in a script they need to have a 'Reference Editor ID' (name). Usually, these will end with 'REF' by convention. They also need to be set as 'persistent'. You can find out if it has these by right clicking on an entry and clicking 'edit' to view details. Try out this and find a few more references if you like.

 

Base Forms:

 

(fig 12: post-158171-0-70788900-1403783068_thumb.png).

Navigate to the 'Game Effects' → 'Ingestibles' section of the 'object window'. That is all the ingestible base forms in the game. Now check 'Items' → 'Ammo' or 'Weapon' or whatever. There they all are.

 

Try 'Actors' → 'NPC', that is all the NPCs in the game- NOTE: these are their base forms, not references, so you can't do much with them script wise. So, how do you make a reference? (many mods never need to to actually do this, but its easy)

  1. Go to the 'cell view' window and select any cell on the left, right click and 'view'.

  2. Wait for the GECK to load.

  3. Now you can see the cell as it appears in game inside the 'Render Window'.

  4. You can drag/drop an NPC base form from the 'object window' into the 'render window' to place one.

  5. This placed base form is now a reference.

  6. Find that reference in the right side of “cell view”, right click and 'edit'.

  7. Give it a 'Reference Editor ID' and tick 'Persistent Reference', if it is not already ticked (if it is greyed out, then it is always ticked)

  8. All done! Now you can use it in your script.

 

Let's summarize that:

 

Base Forms: You find these in the 'Object Window' of the GECK

References: You find these in the 'Render View' or the 'Cell View' of the GECK.

 

You now know exactly what a base form is, what a reference is, how to find them, and how to create a reference from a base form!

 

Functions:

 

Check out this page of the official GECK wiki: http://geck.bethsoft.com/index.php?title=Category:Functions

 

There is also more info on NVSE stuff here: http://www.gribbleshnibit.com/projects/NVSEDocs

 

So, now you know how to find references, base forms, and functions, and you know how to use them for basic scripts (you've done it already). You can do a hell of a lot now. You probably know enough to write 50% of the scripts in the vanilla game. Seriously. Take a look at these examples, you should be able to figure them out:

 

PlayerREF.PlaceAtMe WeapNV9mmPistol, 1

 

; The PlaceAtMe function, places a base form into the game world at the position of the reference, so that places 1 9mm pistol at the player.

 

PlayerREF.AddPerk BlackWidow

 

; Adds the perk base form, 'BlackWidow' to the player. Perks are under 'perk' in the GECK.

 

MessageEx "I am Working!"

 

; You already did it. This one doesn't need a reference or a base form- not all functions do. A text argument is termed a 'string' (of text characters), but don't worry about that yet.

 

SunnyREF.MoveTo PlayerREF

 

; Moves Sunny Smiles to the player. Both are references since both are in the game world already.

 

SunnyREF.Kill

 

; Kills SunnyREF, the reference for Sunny Smiles in the game world.

 

SunnyREF.StartConversation PlayerREF, GREETING

 

; Makes Sunny smiles start conversation with the playing, saying 'GREETING'. Whats 'GREETING'? Just another base form for dialogue lines. (You can find out what the name of other dialogue lines is by opening a quest and going to the 'Topics' section, that column on the left has the 'editor ID' for them- but note that not all quests have dialogue)

 

 

Add any of these lines above to your existing script and they'll work. Experiment with some different references and base forms if you like, and test it out in game.

 

 

Notes: Technically references don't actually need a name, you can use the number, and non persistent refs may also still work if they are loaded, but ignore this for now and stick to named persistent ones.

Link to comment

Part 4 – Conditions

 

So, you've got a script already that looks something like:

scn MyModFirstQuestScript
 
; This is my first script
 
Begin GameMode
 
    PlayerREF.AddItem Beer, 1
    MessageEx "I am Working!"
 
End

Maybe you added some extra things to it too in the last section; if so, check it works as expected in game before you start this next section.

 

Okay, so your script does what its supposed to, but it does it every 5 seconds, always. This section will teach you how to change that from 'always' to 'just when I want it to', with the concept of a 'condition'. First of all, lets define a couple of terms.

 

Return: The reply of a function

 

Boolean: True or False, only. It can't be both, and it can't be anything else. Think of it as a definitive “YesorNo” if you prefer.

 

Example:

 

PlayerREF.IsInInterior

 

This is a function which returns “True” if the calling reference (the player here) is in an interior, or “False” if they are not- so false if they are outdoors.

 

So, the above line is you asking the game “is the player in an interior?”, and the return is the game replying “yes” or “no”.

 

Condition: If something is True then proceed, otherwise don't.

 

The simplest condition is the 'if' block, here is an example:

if PlayerREF.IsInInterior
    MessageEx "The player is in an interior"
endif

This code will show a message in game if the player is in an interior, or do nothing otherwise.

 

  • The 'if' key word may start any line, and everything on the rest of the line is the condition.

  • Then, everything on the following lines only run if that condition is True

  • Until you use the 'endif' key word, which marks the end of the 'if' condition block

  • Or you use 'else' or 'elseif', which mark alternative script blocks.

Else: You may also include a second keyword 'else' in an 'if' statement, this is an alternative block that runs if the 'if' condition is False.

if PlayerREF.IsInInterior
    MessageEx "The Player is in an interior"
else
    MessageEx "The Player is outdoors"
endif

So, this shows one message if the player is in an interior, and another if they are outdoors. Note that the 'endif' must be at the very end.

 

Elseif: You may use this to have multiple conditions, only one of which will ever be chosen. Multiple true conditions are preferred in the order they appear.

if PlayerREF.IsInInterior
    PlayerREF.AddItem Beer, 1
elseif SunnyREF.GetDead
    PlayerREF.AddItem Vodka, 1
else
    PlayerREF.AddItem Whiskey, 1
endif

So, in the above example, if the player is indoors, they get a beer, only. If they are outdoors and sunny is dead, they instead get a vodka, only, and in any other case they instead get a whiskey, only.

 

Comparisons: In addition to using functions that return True or False, you can also make comparisons in your if statements, such as:

if PlayerREF.GetItemCount Beer < 1
    PlayerREF.AddItem Beer, 1
endif

The function GetItemCount returns the number of beers (argument) in the player's (reference) inventory. '<' means 'less than', hence this line means: “if the player has less than 1 beer in their inventory”.

 

You can also swap '<' less than for:

'>' Greater than,

'==' (two equals signs): Equal to

'!=' : Not equal to

'>=' Greater than, or equal to

'<=' Less than, or equal to

 

Okay, that is enough for now: add some conditions to your existing script and test it in game for yourself, here's an example, but use your imagination.

scn MyModFirstQuestScript
 
; This is my first script
 
Begin GameMode
 
    if PlayerREF.GetItemCount Beer < 1
        PlayerREF.AddItem Beer, 1
    endif
 
    if SunnyREF.GetDead
        MessageEx "Sunny is Dead!"
    else
        MessageEx "Sunny is Alive!"
    endif
 
    MessageEx "I am Working!"
 
End

Heres a few other functions you could try out if you like:

 

PlaySound XXX

to play game sound base form, 'XXX': http://geck.bethsoft.com/index.php?title=PlaySound

 

GetPCIsSex "Female"

returns true if the player is female

 

PlayerREF.IsWeaponOut

returns true if the player has a weapon out: http://geck.bethsoft.com/index.php?title=IsWeaponOut

 

PlayerREF.GetActorValue "Health"

returns the number of hit points the player has: http://geck.bethsoft.com/index.php?title=GetActorValue

 

PlayerREF.DamageActorValue "Health", 13

Damages the players health by 13 points. http://geck.bethsoft.com/index.php?title=DamageActorValue

 

PlayerREF.GetInCell GSProspectorSaloonInterior

returns true if the player is inside the good springs prospector saloon- you can find other cell IDs under 'Cell View' in the GECK.

 

Rand X, Y

returns a random number between X and Y, for example, try 'if Rand 0, 10 < 5' for a 50% chance.

 

 

 

If you have gotten this far then you have the technical power to write very powerful scripted mods. Just think of some condition function to test, and then some action function to run.

 

Seriously- you technically know enough to script pretty much anything now. What you learn next will just make things quicker and easier. Take a minute to think about this.

Link to comment

Part 5 – Variables 1

 

So, let's review what we've achieved so far:

 

  1. We have the GECK set up properly.
  2. We have a script that is affecting the actual game.
  3. We know at least vaguely what a base form is: something that exists in object window.
  4. We know at least vaguely what a reference is: an instance of a base form in the game world, or GECK render window and cell view..
  5. We know at least vaguely what a function is: just something that does something.
  6. We know at least vaguely what a function argument or parameter is: something that affects what a function does, and not all functions require arguments.
  7. We know what a function return is: the reply of the function, and not all functions have returns.
  8. We know at least vaguely what a condition is, something that allows dynamic script behavior, we know 'if-(elseif)-(else)-endif'

 

If you've been imaginative, then probably not everything you have attempted so far has worked yet, but this part assumes you've gotten something simple working in game using this stuff. If not, go back and reread/play around with the earlier stuff a little more.

 

You can achieve a lot with what you know already, but so far we can only check what is happening immediately in game, we can't make a script that remembers, learns and adapts- but this is easy to achieve. Let's evolve our script with some variables.

 

Variable: (if you've never programmed before): A variable is a stored value with an associated symbolic name. Whenever you see the variable name in a script, it is replaced with this stored value at run time. Kind of like algebra:

 

GECK:

int x

int y

 

let x := 5

let y := x + 2

 

Mathematics:

x = 5

y = x + 2

 

.:. y = 5 + 2

.:. y = 7

 

Easy, right?

 

There are five basic variable types:

 

int : Stores an integer, aka a whole number. Ints are always floored (rounded down) when stored, so: 5 / 2 (divided) = 2.

 

short : Identical to an integer in the GECK.

 

Float : Stores a number with a decimal point, (example 3.14). Ints are more predictable, so stick with them unless you actually need a decimal point.

 

String_Var : Stores text, “such as a message”. Put double speech marks around contents you want to store.

 

Ref : A ref var is misleadingly named, because it can point to either a reference or a base form.

 

Wait a second, what about booleans (True or False)? Just use an int if you want to store this, True = 1, and False = 0.

 

To use a variable, first you declare it at the top of your script. Example:

scn MyModFirstQuestScript
 
; This is my first script
 
; This is my variable declaration
int iCount
float fHealthPercent
string_var my_message
ref rActor
ref rItem
 
Begin GameMode
 
… whatever else you have here already

So, those lines at the top- that is your variable declaration. It must be before the 'Begin GameMode' line, so straight after the 'scn MyModFirstQuestScript'. (comments don't matter).

 

The first word of each line is the type, and the next word is the symbolic name of that particular variable, so 'int iCount' means you declared an 'int' variable named 'iCount'.

 

In the GECK, all variables initialize to 0 (nothing) before you do anything with them.

 

To make them store something else, you use the command 'let name := value', like this:

scn MyModFirstQuestScript
 
; This is my first script
 
; This is my variable declaration
int iStage
float fHealthPercent
string_var my_message
ref rActor
ref rItem
 
Begin GameMode
 
    let my_message := "I am working!"
    MessageEx $my_message
 
End

So what does this do now?

  1. We declared a string_var variable called my_message (string_var my_message)
  2. This means whenever the variable's name, 'my_message' appears in the script, it will be replaced with the variable's contents during game play.
  3. We stored some text inside the variable (let my_message := ...)
  4. We did our good ole MessageEx again, but this time the text comes via the variable, rather than directly. (MessageEx $my_message). There is a little exception for MessageEx- you need to add the '$' dollar symbol before the variable name- this won't apply elsewhere.

 

Okay then, lets (drum cymbal) store something in those other variables now, try something like this:

scn MyModFirstQuestScript
 
; This is my first script
 
; This is my variable declaration
int iStage
ref rActor
 
Begin GameMode
 
    if iStage < 1 ; * hey, variables initializes to 0, remember?
        let rActor := SunnyREF
        let iStage := 1
    elseif iStage < 2
        let rActor := VFSTheKingREF
        let iStage := 2
    else
        return ; * end script
    endif
 
    rActor.MoveTo PlayerREF
 
End

So, what does this do? The first time the script runs, it moves Sunny Smiles to the player, and the second time it runs (5 seconds later), it move The King to the player. The third and every other time after, it does nothing at all:

 

return (keyword): makes your script end immediately, rather than continuing to the real 'End'. Unlike a function, a script may not return any values.

 

What have you just done?

 

You've used a variable (iStage) instead of a function as a condition. Now your script can be even more dynamic, because she remembers the contents of her variables between runs.

 

You've used a variable (rActor) for the 'MoveTo' function instead of naming the reference you want to move directly. In this case its not very useful, but think if you had 10 actors and 10 functions to do on each? Now you can write it all with far fewer lines.

 

You can do math in your scripts if you want:

 

let fHealthPercent := PlayerREF.GetActorValue "Health" / PlayerREF.GetBaseActorValue "Health"

 

This means set the value of the float fHealthPercent to the players current hit points divided by max hit points.

 

For numbers, you can also do:

 

let x += 1

 

which means add 1 to x, the same as 'let x := x + 1'.

 

If you want to know some more fancy expressions, you can look here (yes, they're the same as Oblivion):

 

Conclusion:

 

If you're not starting to feel a little giddy with excitement at all the potential stuff that you technically know how to achieve now, re-read and play around with all this stuff for a while. Try out some more variables, functions, conditions, etc.

 

Here's the GECK function page again, if you haven't already book marked it ;). http://geck.bethsoft.com/index.php?title=Category:Functions

 

 

 

Final Comments:

 

Naming:

Always name your variables with something meaningful to remind you what the purpose of it is. When you come back to a complex script in 6 months time, you'll thank yourself. By convention, most modders start int names 'i', floats with 'f', and refs with 'r'. This is optional, but does help prevent clashes/confusion with vanilla base forms and references (and there are a lot of those). Never start a variable name with non alphabet character.

 

Set vs Let:

Pre NVSE 4, you could not use 'let .. := ..' to store values in variables, you had to use 'set .. to ..' instead. They both work more or less the same way, but 'let' is just better. You can do more stuff with it, and if you make a mistake, 'let' gives you an error in the console. 'set' will still fail just the same, but you don't get that error, so it will take you longer to figure that out. This is why you don't see 'let' used in vanilla scripts, or those of even the foxiest pre-NVSE4 mods. You have it easy :).

 

Debugging:

If you try to run a function on a ref var but you didn't let it to something appropriate first, it might crash the script. Example:

 

ref rActor

Begin GameMode

    rActor.Kill

 

rActor initializes to empty (zero), and you can't kill nothing. Or:

 

let rActor := GSSunnySmiles

rActor.Kill

 

Thats the base form for Sunny! You meant the reference: 'SunnyREF'. Same may apply to 'Player' and 'PlayerREF'.

 

Or:

 

Let rActor := WeapNV9mmPistol

rActor.Kill

 

You can't kill a weapon! (And you can't kill a base form either). This is another good reason for sensible variable naming, because why would you 'let' something named 'rActor' to a weapon anyway?

 

String_Vars and the '$' dollar symbol:

The '$' converts anything into a string (text). You can actually use it with any variable, not just string_vars for MessageEx (example: MessageEx $rActor ; will show the actors name). There is also a console version of MessageEx (PrintC)which works identically.

Link to comment

Optional Exercise: Make your own sexout sex (or something else) key.

 

This is loverslab, so probably some readers are getting pretty impatient for some smut right now. So, want to make your own sex key?

 

You already know everything you need to script a sex key mod. We will be using the mod 'SexoutEZ' to power it, and you'll be copy/pasting some code into your mod which you don't need to understand right now. Actually, this is a key point in scripting- you might never need to understand why something works, if you know how to make it work.

 

  1. Download and Install “SexoutEZ”. Forget about this mod from now on.

  2. Go into the script section of your mod in the GECK; create a new one; leave the type as default, 'object'; copy/paste this code into it, then save and close the script:

     

    scn SexoutEZ
    ; * either calls SexoutEZ or does a fade to black
    ; * args
    array_var aActors
    string_var style
    ; * local
    int iIndex
    ref rSexoutEZ
    	
    Begin Function { aActors, style }
        if eval (IsModLoaded "SexoutEZ.esp") ; * if sexout is loaded, play this animation
    	let iIndex := GetModIndex "SexoutEZ.esp"
    	let rSexoutEZ := BuildRef iIndex, 2786
            call rSexoutEZ aActors, style
        else ; * fade to black.
    	imod FadeToBlack4sISFX
        endif
    	; * side note, you don't need to sv_destruct the string_var style, because its an argument
    End

  3. Go to that quest (not its script) that you already created, and for 'Script Processing Delay', untick 'default' and type '0.1' instead, save. Your script now runs 10 times per second, instead of once per 5 seconds. Close the quest, and go back to your old script.

  4. Declare a new ref variable, called 'rTarget'.

  5. Here's a function:

    PlayerREF.GetCombatTarget

    It returns the target in your cross hairs. You can figure out how to use this function with a ref variable, right?

  6. Here's another function:

    IsKeyPressed 45

    This returns “True” if the 'X' key is pressed. You can figure out how to make that a condition (if), right?

    (I know: who the hell chose that '45' would mean the 'X' key? You can find the numbers for other keys in the link 'DirectX Scancodes' at bottom left, here.

  7. Now, copy this line into your script:

  8. call SexoutEZ (Ar_List PlayerREF, rTarget), "Doggy Style"
  9. see the text in speech marks, “Doggy style”? You can change that to whatever sex you want to start, use your imagination or check the mod page for SexoutEZ for some examples. You can swap the order of PlayerREF and rTarget too, but otherwise don't change the line. Now save the script, start up FNV, find someone and press 'X'.

  10. Or- if you don't want sexout, skip the SexoutEZ line and add some function instead, like:

    rTarget.Kill

    For an instant death key.

 

If this feels too intimidating right now, don't worry. You can always give it another try later.

 

On the other hand, if you got it all working, how about you try adding some more conditions? Maybe different sex for different genders or factions of rTarget? Or, maybe different keys for different sex styles?

Link to comment
  • 4 months later...

How do I know if NVSE is running with this? I feel like it's not running but I don't know how to check. I followed the guide, have a shortcut that has the ending of its target set to " -editor" with the GECKPoweredUp installed in the FNV folder and NVSE up to date but I honestly feel like it's not working. 

Link to comment
  • 3 weeks later...
  • 5 months later...

I am sorry to bother you, but I can not get the geck to load via nvse.  in the instructions if says to add -editor to the shortcut with properties.  when I do the I get an error that the path is not correct.  no file NVSE-loader -editor exists?  so I created a new file NVSE loader -editor.exe and it just loads the game not the geck.  

Link to comment
  • 4 months later...

Stupid question, but is there an easy way to only have a script run once? I am doing a very basic test script. Basically, whenever the player enters a room, they get a beer and a MessageEx $my_message popup. But I only want this to happen once. I want to be able to get the absolute basics right before moving on to the more complicated stuff, but I find I'm struggling already...  :blush:

Link to comment

It's just a test, so its no big deal. The room is NovacMotelRoomQueen1. But I've found this now, which answers my question.

 

EDIT: Okay, 2nd stupid question. How can I make something dependent on multiple variables? 

 

At the moment, I have this:

 

scn CKSMyModFirstQuestScript

; This is my first script

; This is my variable declaration
int iStage
string_var my_message

Begin GameMode

let my_message := "You're a fascist pig"

If PlayerREF.GetInCell NovacMotelRoomQueen1
    PlayerREF.AddItem Beer, 1     
    MessageEx $my_message
     let iStage := 1
elseif iStage == 1
     return ; * end script
endif

End

It's a very rough test script which I've made following this tutorial. But I want the script to function based on two variables, if the player is in the room, AND iStage < 1. So is there an AND function, if you want multiple variables to make a script fire? 

 

So say for example, I want MessageEx $my_message to appear, but only IF a player has entered a room, AND they have done X, AND Y has happened. Is there a way to have multiple "Ifs" one after another without having to set stages? 

 

EDIT 2: Nvm, figured it out. Didn't realise you could have a line of if, then another line below, and that it all works so long as you have the same number of endif lines at the end, like so:

 

scn CKSMyModFirstQuestScript

; This is my first script

; This is my variable declaration
int bDoOnce
string_var my_message

Begin GameMode

let my_message := "You're a fascist pig"

If PlayerREF.GetInCell NovacMotelRoomQueen1
      if bDoOnce == 0
          let bDoOnce := 1
             MessageEx $my_message
      endif
endif

End

 

Link to comment

Thats a good way of doing it, you can also evaluate 2 conditions in one line, using the 'C' style 'AND' operator: '&&' (see http://geck.bethsoft.com/index.php?title=NVSE_Expressions for more options, back in the '70s those weird symbols seemed intuitive, I hear ;))

 

if PlayerREF.GetInCell NovacMotelRoomQueen1 && bDoOnce == 0

    MessageEx $my_message

endif

 

But, your way is safer.

Link to comment

You can use a quest/object/spell to handle the sex calls, which you trigger via the dialog script, eg:

 

set SexQuest.Partner to SunnyREF

StartQuest SexQuest

 

--

 

In dialog scripts, the calling reference is implicit to the speaker, so if you talk to Sunny with a script

 

CIOS MySpell

AddItem MyItem, 1

 

Then the spell is cast on Sunny, and she gets given the item.

 

----

 

Its best to avoid declaring variables in dialog scripts, but they are usually reliable otherwise. If you don't want to use them at all, you can detect conversations using a quest with:

 

ref Actor

 

Begin MenuMode 1009

  

   let Actor := GetDialogSubject ; or maybe you want GetDialogTarget?

   ...

End

Link to comment
  • 5 years later...
On 10/9/2015 at 12:15 AM, Odessa said:

You can use a quest/object/spell to handle the sex calls, which you trigger via the dialog script, eg:

 

set SexQuest.Partner to SunnyREF

StartQuest SexQuest

 

--

 

In dialog scripts, the calling reference is implicit to the speaker, so if you talk to Sunny with a script

 

CIOS MySpell

AddItem MyItem, 1

 

Then the spell is cast on Sunny, and she gets given the item.

 

----

 

Its best to avoid declaring variables in dialog scripts, but they are usually reliable otherwise. If you don't want to use them at all, you can detect conversations using a quest with:

 

ref Actor

 

Begin MenuMode 1009

  

   let Actor := GetDialogSubject ; or maybe you want GetDialogTarget?

   ...

End

 

Can't believe I never replied to this, but thanks! Six years later, and I still find useful info in this tutorial!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use