Jump to content

Fallout New Vegas GECK & Scripting Help 101


Recommended Posts

Posted

Thank you, jaam.  : )

 

In other exciting "Please help" news...

 

Does anyone have any advice/wisdom regarding the UseWeapon function or UseWeapon package?  At least one source said that the package was unpredictable.

 

End Goal:  Create a pacifist companion that heals you if you are below a certain amount of health in battle.  The script below is currently using a bumper sword to make it obvious that the function is working since my healing gun probably isn't configured properly yet (ammo, ench, weap, spel, base, argc, argv, argh).

 

In her Object script, I have OnStartCombat, cast her combat spell on her. 

 

Code Snippet from the Effect spell:

 

 

scn HopeCompCombatEffectSCRIPT

ref rHope
int iIsPacifist

Begin ScriptEffectStart
    Set rHope to GetSelf
    Set iIsPacifist to 1
End

Begin ScriptEffectUpdate
    if (1 == Player.IsInCombat) ;Probably redundant at this point
        if (1 == iIsPacifist)
            if (.75 > Player.GetHealthPercentage)
                rHope.SetAV Strength 8        ;Set her strength to use the sword for test purposes
                rHope.SetAV Confidence 4    ;Conf and Agg set to lowest on character start
                rHope.SetAV Aggression 4
                rHope.EquipItem WeapNVBumperSword 1 0 ;Sword is in her inventory but isn't equipped by default
                rHope.RemoveFromFaction PlayerFaction ;Tried these to see if there was a faction conflict
                rHope.RemoveFromFaction TeammateFaction
                Label 1
                rHope.UseWeapon WeapNVBumperSword rHope Player 1
                if (.75 > Player.GetHealthPercentage)
                    Goto 1 ;Continue healing, or in this case attacking, if player health < 75%
                endif    
                rHope.UnequipItem WeapNVBumperSword 0 0
                rHope.AddToFaction PlayerFaction 1
                rHope.AddToFaction TeammateFaction 1  ;I realize that Str/Conf/Agg need to be reset afterwards and may need to come somewhere else in the string of IFs
            endif
        endif
    endif
End

 

 

 

What's happening is that once the player hits 75%, the game freezes.  :(

 

EDIT:  If anyone is curious, it was the Goto loop in the ScriptEffectUpdate block that made an infinite loop.  What can I say?  I had it in a Game Mode block before I created the spell and didn't think about the ScriptEffectUpdate's looping in the copy/paste.

Posted

That's correct, the bAllowMultipleMasterLoads directive can always be found the .ini. All you need to do is find it and change 0 to 1

 

Yes. I figured that out after trying to get it to work. I was working off these instructions

 

Add the following to your geckcustom.ini

bAllowMultipleMasterLoads=1

Instead of something along the lines of

 

 

Change the following in your geckcustom.ini

bAllowMultipleMasterLoads=0   to  bAllowMultipleMasterLoads=1  

Posted

Thank you, jaam.  : )

 

In other exciting "Please help" news...

 

Does anyone have any advice/wisdom regarding the UseWeapon function or UseWeapon package?  At least one source said that the package was unpredictable.

 

End Goal:  Create a pacifist companion that heals you if you are below a certain amount of health in battle.  The script below is currently using a bumper sword to make it obvious that the function is working since my healing gun probably isn't configured properly yet (ammo, ench, weap, spel, base, argc, argv, argh).

 

In her Object script, I have OnStartCombat, cast her combat spell on her. 

 

Code Snippet from the Effect spell:

 

 

scn HopeCompCombatEffectSCRIPT

ref rHope
int iIsPacifist

Begin ScriptEffectStart
    Set rHope to GetSelf
    Set iIsPacifist to 1
End

Begin ScriptEffectUpdate
    if (1 == Player.IsInCombat) ;Probably redundant at this point
        if (1 == iIsPacifist)
            if (.75 > Player.GetHealthPercentage)
                rHope.SetAV Strength 8        ;Set her strength to use the sword for test purposes
                rHope.SetAV Confidence 4    ;Conf and Agg set to lowest on character start
                rHope.SetAV Aggression 4
                rHope.EquipItem WeapNVBumperSword 1 0 ;Sword is in her inventory but isn't equipped by default
                rHope.RemoveFromFaction PlayerFaction ;Tried these to see if there was a faction conflict
                rHope.RemoveFromFaction TeammateFaction
                Label 1
                rHope.UseWeapon WeapNVBumperSword rHope Player 1
                if (.75 > Player.GetHealthPercentage)
                    Goto 1 ;Continue healing, or in this case attacking, if player health < 75%
                endif    
                rHope.UnequipItem WeapNVBumperSword 0 0
                rHope.AddToFaction PlayerFaction 1
                rHope.AddToFaction TeammateFaction 1  ;I realize that Str/Conf/Agg need to be reset afterwards and may need to come somewhere else in the string of IFs
            endif
        endif
    endif
End

 

 

 

What's happening is that once the player hits 75%, the game freezes.  :(

Move your ScriptEffectUpdate code to ScriptEffectStart or guard it with bool.

Like that, you are perpetually running the block over and over while the effect lasts.

Posted

Thank you, jaam.  : )

 

In other exciting "Please help" news...

 

Does anyone have any advice/wisdom regarding the UseWeapon function or UseWeapon package?  At least one source said that the package was unpredictable.

 

End Goal:  Create a pacifist companion that heals you if you are below a certain amount of health in battle.  The script below is currently using a bumper sword to make it obvious that the function is working since my healing gun probably isn't configured properly yet (ammo, ench, weap, spel, base, argc, argv, argh).

 

In her Object script, I have OnStartCombat, cast her combat spell on her. 

 

Code Snippet from the Effect spell:

 

 

scn HopeCompCombatEffectSCRIPT

ref rHope
int iIsPacifist

Begin ScriptEffectStart
    Set rHope to GetSelf
    Set iIsPacifist to 1
End

Begin ScriptEffectUpdate
    if (1 == Player.IsInCombat) ;Probably redundant at this point
        if (1 == iIsPacifist)
            if (.75 > Player.GetHealthPercentage)
                rHope.SetAV Strength 8        ;Set her strength to use the sword for test purposes
                rHope.SetAV Confidence 4    ;Conf and Agg set to lowest on character start
                rHope.SetAV Aggression 4
                rHope.EquipItem WeapNVBumperSword 1 0 ;Sword is in her inventory but isn't equipped by default
                rHope.RemoveFromFaction PlayerFaction ;Tried these to see if there was a faction conflict
                rHope.RemoveFromFaction TeammateFaction
                Label 1
                rHope.UseWeapon WeapNVBumperSword rHope Player 1
                if (.75 > Player.GetHealthPercentage)
                    Goto 1 ;Continue healing, or in this case attacking, if player health < 75%
                endif    
                rHope.UnequipItem WeapNVBumperSword 0 0
                rHope.AddToFaction PlayerFaction 1
                rHope.AddToFaction TeammateFaction 1  ;I realize that Str/Conf/Agg need to be reset afterwards and may need to come somewhere else in the string of IFs
            endif
        endif
    endif
End

 

 

 

What's happening is that once the player hits 75%, the game freezes.  :(

Repeating the UseWeapon too often might not be good

You may need to check rHope doesn't equal <null> on the first run of the script and that it isn't being run on an object or creature (unlikely being an effect script)

 

One of the first things I do on all my scripts is a

if rActor

<do stuff>

endif
Posted

 

That's correct, the bAllowMultipleMasterLoads directive can always be found the .ini. All you need to do is find it and change 0 to 1

 

Yes. I figured that out after trying to get it to work. I was working off these instructions

 

Add the following to your geckcustom.ini

bAllowMultipleMasterLoads=1

Instead of something along the lines of

 

 

Change the following in your geckcustom.ini

bAllowMultipleMasterLoads=0   to  bAllowMultipleMasterLoads=1  

 

Ahh oops, yeah I can see how people could take that literally, Fixed in the OP  :)

Posted

OK rant time. The dialog and scripting system must have been designed by some drunk Bethsoft programmer that stumbled into a radiation zone and his brain melted. Hence we have to deal with this crazed system today. (Maybe that same guy is now a feral ghoul wandering the depths of Bethsoft's headquarters??)

 

I've decided rather than try and wrestle with an idiotic system... I'm making NPC's ESSENTIAL. Eat that GECK! Mwahahah! :angel:

 

Yeah. I may need to take a break.....   :blush:

 

OK much better. Carry on. :cool:

Posted

Every time I run into some idiotic thing in the geck scripting language, I'm always amazed that they didn't just embed a normal language interpreter into the engine. When Oblivion was released, C# was already pretty popular, python (though much older) was gaining popularity, and plenty of old standbys were available as well, like java, perl, or even pascal, modula or haskell.

 

The fact that they did it again with Skyrim/papyrus just astonishes me, though at least papyrus is more like a real language and less like some jr. high students attempt to reinvent BASIC. ;)

 

edit: Speaking of that.. frigging BASIC! They could've just used that as well.

Posted

I would have loved just plain old C. That at least would be useable. This TES script or whatever it is has some major schizophrenia issues.

 

Really makes one wonder what (if anything) goes on in the minds of the devs when they make these behemoths. :angel:

 

The Skyrim thing scared me off almost as fast as pics of the characters. So now I've got to waste time with OO stuff when procedural would be much faster and make SENSE. And if that's not bad enough, it's slow as hell? Great. Just great.

 

AHEM... Yes. Definitely need a break!!! :blush:

Posted

This is for the companion combat script for healing the player via a healing gun if health < 75% and not attacking anything else ever.  I got the "attack the player when health < 75%" part working by removing the NPC from all factions and adding a specific her-only faction set to enemy w/ player and starting combat on the player.  So she's only got the DontTazeMeBro and AggroHeal factions when her confidence is set to fight.

 

The problem:  While primarily attacking the player, she'll occasionally fire at enemies that have wounded her.  Does anyone have an idea of how to make an NPC only attack one person and ignore other people/things are attacking them?

 

I thought about adding her to the faction of the things that are attacking the player, but that means that the things will stop attacking her, and while it's lovely in theory, it isn't realistic for other enemies to suddenly just forget about her.

 

 

Posted

The problem:  While primarily attacking the player, she'll occasionally fire at enemies that have wounded her.  Does anyone have an idea of how to make an NPC only attack one person and ignore other people/things are attacking them?

 

This is exactly what I was thinking about when I've read it. I always have seen combat such a hard behaviour to handle, overriding in some cases scripts and packages, because of the hard code beneath like aggro and faction. Now I'm not very experienced in that but the only time I wanted to make my companion ignore enemies and vice versa was setting playerfaction and not donttazemebro.

 

Anyway... as last resource... if everything will fail to work... I could think to something like a fake player attack... equip item health pistol -> groupidle attack -> cios health player

Posted

Personally for healing I think you are better off just scripting the actor to jab a syringe into the player and avoid involving combat completely as it gets wacky trying to control it as I am trying to do in Sisters of Chastity Alpha combat isn't easily controllable if it's even possible..

Posted

I thought about that, but I figured that she'd probably get in the way a lot that way/get right in the way of your shots/swings/movement.  If I can't get it working like that, I'm going to try to set the ammo script to avoid damage or healing if it hits someone/thing other than the player.

Posted

Another thing to consider is the effect scripts only apply to the person hit by the ammo if they take at least 1 point of damage, so armor may prevent healing occurring.

You have to be cruel to be kind :)

 

It would be sad to just kill the boss guy with only a few HP left and die because your medic jabs a 1HP damage syringe in you and rolls a critical hit  :)

Posted

I must say it never happened to me, my follower was spectator of the fight and never managed to get involved or hit. That + Essential + not help friends/allies and I think it should do the trick. Scripting a combat behaviour like that, something like "change the confidence - make her run away - when radius is > than 1000 then change again confidence" etc. seems something abstruse, I really wonder if this would be possible.

 

Posted

Another thing to consider is the effect scripts only apply to the person hit by the ammo if they take at least 1 point of damage....

 

Hah. Well... that explains some of my problems. Been fumbling with slavers that shoot tranquilizer darts at the player. I could never figure out why it often took 4 times the required amount of hits to get the effect to kick in. Now I know! :cool:

Posted

Can anyone explain why I would want to use spells versus a token/item w/ a script and with the potential for a GoTo loop (besides it being the less sophisticated way of doing things, I suppose)?

 

What I know:

  • If you tell a spell to Dispel (which is the proper way to do it instead of using RemoveMe), the Update block might run another extra time or few, so variables are needed to block those out from happening.
  • Duration is set in the Spell, and Update blocks are run every frame (or whatever not-seconds is).  If that's the case, how long does it actually take to get through a block at iteration?  If it's executed every frame, isn't there the possibility that it won't be finished executing the step that it's in when it checks again?

FWIW, I got the healing targeting and movement for my comp working, but it's implemented in a package, but I've heard that packages can be wonky.  Technically, I've heard that the <insert not specifically scripted GECK thing> can be wonky.  ;)

Posted

1. What's true for a spell is also true for a token's object script: it can still execute after the token's removed, so you also need control variables.

2. One frame. And yes, it's possible for one-frame scripts not to be able to execute properly, but this is mostly due to some function not having enough time to return what they need to return in time. This is especially true if you getitemcount NG's anim tokens, for instance. In spunk, I have a start hook spell that fires on sex start containing this:

set iAnim to getitemcount SexoutNGAnimCounter
if iAnim > 0
	DebugPrint "Spunk:StartHook:anim is %.0f" iAnim
else
	DebugPrint "Spunk:StartHook:anim count fail"
	return
endif

The "fail" debugprint fires around 20-30 times on my tests before it's counted all the tokens (let's say 933 of them for anim number 933) and the rest of the script can continue. Hence the "return" command, to make sure it's done first.

 

Edit: as for spells v tokens: whatever floats your boat. Tokens are more reliable for long-term stuff (Hal says spells can crap out especially on cell transitions), then again I like spells better for most short-term, fast-running scripts. 3 blocks (start/update/finish), and the actor it's cast on is the implied ref to the script ("GetSelf"), so you can use them to playidle anims, which you can't with token scripts (ref.playidle someIdleID doesn't seem to work, whereas [impliedRef] playidle someIdleID does) for instance. Beyond that, it's just a matter of preference.

Guest carywinton
Posted

I will say flat out, it *really* helps if you do not code your scripts IN the geck. Use some other text editor like vim, ultraedit, whatever.. something with code folding and smart indenting and everything else.

 

Write your scripts in that text editor, then copy/paste them into the geck. This will save you a lot of agitation.

 

I go even a step beyond that now and run a local subversion repository and keep a revision history of all the scripts as text files so when something goes wrong I can go back and run a diff to find out exactly what I changed rather than trying to remember or *shudder* trying to use fnvedit to compare them.

 

Vim and extension of Vi is for Linux based system and Ultraedit has an associated "cost" , I use Notepad++ for Windows based systems and it works pretty well. It has syntax highlighting and some other nifty features for a decent basic text editor for coding.

 

http://notepad-plus-plus.org

 

Posted

Can anyone explain why I would want to use spells versus a token/item w/ a script and with the potential for a GoTo loop (besides it being the less sophisticated way of doing things, I suppose)?

 

What I know:

  • If you tell a spell to Dispel (which is the proper way to do it instead of using RemoveMe), the Update block might run another extra time or few, so variables are needed to block those out from happening.
  • Duration is set in the Spell, and Update blocks are run every frame (or whatever not-seconds is).  If that's the case, how long does it actually take to get through a block at iteration?  If it's executed every frame, isn't there the possibility that it won't be finished executing the step that it's in when it checks again?

FWIW, I got the healing targeting and movement for my comp working, but it's implemented in a package, but I've heard that packages can be wonky.  Technically, I've heard that the <insert not specifically scripted GECK thing> can be wonky.  ;)

I use both at times, Spells take more set up creating base effects etc but script can be smaller because you don't need to set REF's but unless on the Player they can dispel if the actor isn't in the players cell or even on fast travel, wait, sleep and going through doors, this could be a good thing though at times too. Token scripts on NPC's don't forget or reset in such cases but they do pause the script if the player isn't in the cell. So you may want to do what I do in a lot of the Pregnancy scripts and run a loop that checks the Current time against last Runtime to do a loop to catch up missed time.

 

Sometimes the ScriptUpdateStart and ScriptUpdateFinish are handy too, I generally use Spells for Buffs etc that aren't important if they dispel. If I apply them from a token script I just check if they are present or not.

Posted

 

I will say flat out, it *really* helps if you do not code your scripts IN the geck. Use some other text editor like vim, ultraedit, whatever.. something with code folding and smart indenting and everything else.

 

Write your scripts in that text editor, then copy/paste them into the geck. This will save you a lot of agitation.

 

I go even a step beyond that now and run a local subversion repository and keep a revision history of all the scripts as text files so when something goes wrong I can go back and run a diff to find out exactly what I changed rather than trying to remember or *shudder* trying to use fnvedit to compare them.

 

Vim and extension of Vi is for Linux based system and Ultraedit has an associated "cost" , I use Notepad++ for Windows based systems and it works pretty well. It has syntax highlighting and some other nifty features for a decent basic text editor for coding.

 

http://notepad-plus-plus.org

 

1. Vim is available on windows as well. I used to work with a guy that used it as his editor of choice, crazy bugger.

2. Ultraedit is worth every penny, and then some. :D

Posted

Edit: as for spells v tokens: whatever floats your boat. Tokens are more reliable for long-term stuff (Hal says spells can crap out especially on cell transitions), then again I like spells better for most short-term, fast-running scripts. 3 blocks (start/update/finish), and the actor it's cast on is the implied ref to the script ("GetSelf"), so you can use them to playidle anims, which you can't with token scripts (ref.playidle someIdleID doesn't seem to work, whereas [impliedRef] playidle someIdleID does) for instance. Beyond that, it's just a matter of preference.

I also use both, but I prefer spells. The main problem I have with tokens is their 'accidental' release into the wild if something goes wrong. SexoutNG slowly switched almost entirely to spells to avoid that issue. It still has and uses some tokens, but they are no longer scripted. Thanks to jaam getting the geck conditional stuff going with NX, those tokens will eventually be retired as well and replaced with NX vars.

 

Actually I take that back. The dress/undress system is still, I believe, done with a scripted token. I can't remember why it is, just that it is. Probably just because I never got around to spellifying it.

Posted

So ... well... I feel quite in awe to ask something like this at this point, but I decided that too much time was passed and it was becoming necessary...

 

Everyone uses tokens, everyone speaks about "tokens" but... could someone define "token", please? :D

 

What I figured on my own was adding some random not playable item, not appearing in the inventory, and check its presence with a GetItemCount...

Did I figure well? If it's so, what baseID do you use to create your own "token"?

Posted

You have to buy them on E-Bay, 500 Bottlecaps each, just give me 5 minutes to get a store set up :)

 

A token is usually just a Armor or Misc item with no mesh that isn't set to any wearing slot, usually they are set to quest and unplayable so they aren't visible to the player, a token may or may not have any script running in it. Also someone may of course for example put 23 invisible SexoutPregPercToken tokens in an actors inventory to indicate they are 23% Pregnant.

 

Never hesitate to ask "dumb" questions, I got to use up all my "Dumb" answers somehow :)

Posted
The main problem I have with tokens is their 'accidental' release into the wild if something goes wrong.

 

Figure of speech, or some other character randomly getting the token even though they shouldn't have?

Posted

You have to buy them on E-Bay, 500 Bottlecaps each, just give me 5 minutes to get a store set up :)

 

A token is usually just a Armor or Misc item with no mesh that isn't set to any wearing slot, usually they are set to quest and unplayable so they aren't visible to the player, a token may or may not have any script running in it. Also someone may of course for example put 23 invisible SexoutPregPercToken tokens in an actors inventory to indicate they are 23% Pregnant.

 

Never hesitate to ask "dumb" questions, I got to use up all my "Dumb" answers somehow :)

 

So in some ways, good or bad, I think I figured what was a token...

 

Now the second question then...

 

When I was doing my tries in pair animations, I create a M animation and a F animation.

Then, to trigger them, since I wasn't sure of what I was doing I tried two different approaches.

One was a simple playidle, the other one was additem (a fake item, so I suppose I should call it "tokenM" and "tokenF"), the M animation had GetItemCount tokenM as condition while the F animation had the GetItemCount tokenF.

Both cases had the same effect, with a big difference. Adding the token I had a lot of delay with consequence big de-sync between the two animations. Well, I was wondering why this should happen, aren't both cases supposed to run in the same way, in the same frame? Keep in mind I did a lot of tries, so it wasn't a casualty (as the common de-sync of big animations, it really seems a casualty for me).

 

TL;DR: is there somewhere a list that tells me if using some function is faster/slower than another one? the only thing I found in Beth guide is sin,cos etc. are slow functions, and I noticed it... but yes, I've never found anything else about other functions.

 

PS: Hal, I need tokens and I'm full of caps... where's your shop? ...

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...