Jump to content

Scripting help: attachwire/createwire (F4SE)


SAC020

Recommended Posts

I am trying to spawn a wire between two markers. This is the code I tried so far, it compiles, but nothing shows up in game. Any help / clues / pointers on how should I correct it?

 

thank you

ObjectReference InvisibleMatRef1 = furniturestage3ref.placeatme(Game.GetForm(0x000000C2), 1)
InvisibleMatRef1.setposition(InvisibleMatRef1.getpositionx(), InvisibleMatRef1.getpositiony(), InvisibleMatRef1.getpositionz()+50)
InvisibleMatRef1.addkeyword(workshopkwd)
ObjectReference InvisibleMatRef2 = furniturestage3ref.placeatme(Game.GetForm(0x000000C2), 1)
InvisibleMatRef2.setposition(InvisibleMatRef2.getpositionx(), InvisibleMatRef2.getpositiony(), InvisibleMatRef2.getpositionz()+150)
InvisibleMatRef2.addkeyword(workshopkwd)
ObjectReference wireRef = InvisibleMatRef1.CreateWire(InvisibleMatRef2, Game.GetForm(0x00021F34))
Link to comment
Share on other sites

Figured it out, with the help of F4SE team and kinggath (thank you!)

 

For future reference:

- the endpoint objects .nifs need to have connector points (check out the generator nif for reference, just copy the connector point branch to your nif)

- the endpoint objects need to be linked with a workshop reference - I have used the Sanctuary workshop bench reference

 

For example, this code spawns two objects (which have been added connector points in their nif) and spawns a rope between them

 

ObjectReference SplineStartRef = caster.placeatme(furniturestage3, 1)
SplineStartRef.addkeyword(workshopkwd)
SplineStartRef.SetLinkedRef(workshopref, workshopkwd)


ObjectReference SplineEndRef = caster.placeatme(furniturestage3, 1)
SplineEndRef.setposition(SplineEndRef.getpositionx(), SplineEndRef.getpositiony(), SplineEndRef.getpositionz()+100)
SplineEndRef.addkeyword(workshopkwd)
SplineEndRef.SetLinkedRef(workshopref, workshopkwd)

utility.wait(1)

ObjectReference wireRef = SplineStartRef.createwire(SplineEndRef, Game.GetForm(0x00021F34))
Problem is that the rope is static, it does not adjust if I move the endpoints after spawning. So, kinda fail, overall :(
Link to comment
Share on other sites

If you want them to flex like powerlines do, I'd check how those scripts work as if I'm remembering correctly those will adjust to some degree when moving the objects and you can dettach and reattach as needed. Worth a look.

Which scripts are you referring to?

Link to comment
Share on other sites

There should be some scripting that guides how those power lines are worked with in workshop mode, because they will flex, at least to some degree, so once you find those scripts, they should indicate how the game sets those up for various lengths. I don't know the names to look for, but there should be a guide, as we do have mods that extend the reach of powerlines (power lines extended I think).

 

Hope that helps.

Link to comment
Share on other sites

Then the next idea is a bit of inheritance. Something has to set those wires as a type which should be able to have descendants, which pick up those properties but can have some property changes added to them to create a new type.

 

Example though just an idea. Exact code will be different, see a good C++ book or guide for what I'm talking about.

 

Actor foo

{

properties of said actor

}

 

Class creator foo

{

Create actor foo

Sets up an item to have those foo properties

}

 

New kid = create actor(details, type foo);

 

If you want a better example I'd check on the items and companions coding as I'm betting there would be a main actor type that the others such Preston would pick up. Example main actor type, then the human actor picks that up and adds a few other properties, then you get Preston who picks that up and has a few tweaks. Items should follow a similar idea. Example Main item type would take care of being able to be bought, sold, picked up; Ammo type picks up on that adding damage properties, explosiveness, etc; then the ammo in question (like a grenade) picks that up and adds further to it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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