The forum has been set to read-only mode. For community discussion and questions, head over to our Discord: https://discord.taleoftwowastelands.com

I'm making a trap mod.

General mod discussion and requests.
User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

I'm making a trap mod.

Post by Puppettron » Fri Feb 07, 2014 12:27 am

so, i'm working on this idea for a mod that would allow the player to set up triggered traps and such, like the perennial favorite the shotgun trap on a pressure plate trigger.


i talked to gribble and cdt and tv about this, but my brain is refusing to process information properly, so i thought i'd make a thread so i can keep things sitting in one place i can look at later.


gribble mentioned (iirc, i could be wrong about some of the details) that the best way to set the triggers would be to have them work as activators which run a script that uses GetCrosshairRef to add the next activated item -- if it passes muster as a trap (i'm assuming running a ref.isinlist flist line would work there) -- as the ref that activates when the trigger is entered.  problem being, i can't for the life of me work out how to get the script to check my next activated thing.



so far, what i've got to work on the mod is to allow players to pick up disarmed pressure plates, by disabling and markfordeleting them while adding the misc item to the player's inventory, but the misc item's using the pressure plate mesh, so it's got the static object collision properties, and i've got no real idea how to change that.  i'm reading through a bunch of tutorials on nifskope trying to sort this out but, like i said, my brain's being stubborn and all of it's in one ear and out the asshole.


so really, what i'm looking for here is some help or good example scripts or esps to look at and dissect on my own.  when finished, though, i will finally have new things to complain about in the AI ways to play the game that other people might find interesting :D


edit:  added current build to OP


edit:  newer build, with meshes folder.


edit:  new esp and meshes, has combat shotguns in it


edit: current working version.  mostly complete, still need to figure out what i'm doing with the nade bouquet misc item and i need to figure out if i can sub those nades out for other nades without having to learn blender.


You do not have the required permissions to view the files attached to this post.
perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

TrickyVein
Posts: 982
Joined: Fri Mar 29, 2013 3:04 pm

My suggestion would be to

Post by TrickyVein » Fri Feb 07, 2014 1:18 am

My suggestion would be to export something from Fallout - Meshes.bsa that is roughly the same size and shape as the pressure plate and copy it's collision block into a new .nif that will serve as your custom pressure plate. And use the NiTriStrips data from the pressure plate, of course. 


The thing is, the pressure plate and other traps also have animation sequences which may or may not still work alongside havok. IDK. There're additional editor markers inside of the .nif that tell the engine that it's a trap which may present issues.


Without working on this problem yet, it seems like you're going to want to have either (1) two .nifs, one that is a pressure plate with physics, the other which contains the editor markers and animations for the trap as it exists now or (2) devise some way of placing the trap on the ground from your inventory without being able to pick it up and move it with the grab key. 


Otherwise, if you have a pressure plate that can be moved but doesn't preserve the trap markers or animations, you would need to find a way to switch between them once the trap 'settled' into place on the ground, which sounds really messy.



User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

i can probably set the misc

Post by Puppettron » Fri Feb 07, 2014 1:35 am

i can probably set the misc item trap to use a script that removes it and places a static object there.  i've seen that done in enough mods sitting in my data file that i could make that work.  i'd just need to create new activators with different scripts to function with them, or add a ton of code to the current activators to put more menus and stuff in


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

Gribbleshnibit8
Posts: 481
Joined: Sun Nov 04, 2012 2:06 am

You should actually be able

Post by Gribbleshnibit8 » Fri Feb 07, 2014 2:50 am

You should actually be able to modify the collision data on a mesh to make it movable. In the havok data for a mesh, look for the bhkRigidBody node. In the details section in NifSkope, you'll need to change several settings:




  1. OblivionLayer - OL_CLUTTER


  2. Layer Copy - OL_CLUTTER


  3. MotionSystem -  MO_SYS_BOX


  4. SolverDeactivation - SOLVER_DEACTIVATION_LOW


  5. MotionQuality - MO_QUAL_DEBRIS


I just took those values from a weapon, so you might want to chuck on a real clutter object, but that should do it. I've not made movable objects this way, but I have updated pure static objects to be movable static with similar tweaks to the bhkRigidBody node.


 


On the topic of how to edit them, I'd go with make new versions. Editing the existing objects is just bad form in general. Though, you could do it maybe by tracking them with a perk with activation option, idk. Anyway, editing them will break two mods I know of, and probably more. For the record JIP Companions and Gopher's Trap Detection mods.


Here's a script bit that will hopefully help with detecting the traps. You'll still need something somewhere that will activate the linked trap once the trigger is hit, but that should be much easier.



if bSetTrapLink == 1 ; selected to link trap
set fTimer to fTimer - GetSecondsPassed ; run a timer to time this section out after N seconds to keep it from running forever
if (fTimer < 0)
set bSetTrapLink to 0
MessageBoxEx "You took too long setting the trap. Activate the %n and try again" rSelf
set rCrosshairRef to GetCrosshairRef
if (IsControlPressed 5) ; activate control, use IsControlPressed to detect even if changed
if (rCrosshairRef.IsInList TrapsObjectList) ; checking for == 1 is actually less efficien than just leaving it blank. Shouldn't matter, but the more you know :)
set rTrapLink to rCrosshairRef ; alternatively, you can use the trap link as the crosshair var and save a var here
MessageBoxEx "The %n is now linked to the %n" rSelf rTrapLink ; using MessageBoxEx lets us use extended format specifiers. In this case, the names of the ref objects passed in
set bSetTrapLink to 0 ; set back to 0 to disable
; set anything else in here
else
MessageBoxEx "That's not a valid trap, please activate the %n and try again" rSelf ; or replace with generic 'failed' message box, but this is more personal :)
set bSetTrapLink to 0
endif
endif
endif


User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

ok, things are making sense

Post by Puppettron » Fri Feb 07, 2014 3:17 am

ok, things are making sense now, thanks a bundle.


btw, grib, you mentioned using geometry to maybe place a trip wire across the map between points you clicked, is that anything like this:  http://geck.bethsoft.com/index.php?title=Useful_Scripts#Ground_area_mark_that_follows_the_crosshair


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

TrickyVein
Posts: 982
Joined: Fri Mar 29, 2013 3:04 pm

You can enable havok by

Post by TrickyVein » Fri Feb 07, 2014 3:01 pm

You can enable havok by changing those fields but it's a complete toss up when it comes to defining the other variables that govern the physics of the thing. That's why I suggested copying an existing collision object instead of creating one from scratch. 



User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

ok, so i tested things with

Post by Puppettron » Sun Feb 09, 2014 2:01 am

ok, so i tested things with the newer script gribble passed and here's what happened:


script would hang up, so i peppered it with print commands to see where.  script would hang up on the gbo command line.  absolutely stop there, wouldn't go any further, wouldn't let me reactivate the object, nothing.  so i tried without that line and the script would run all the way through, cycling as normal.  but it wouldn't accept that getcrosshairref pointed at an object that was on the trapsobjectlist, so i reasoned that listgetformindex was strictly checking the reference provided against the list, so it'd return a -1.  so i got creative dirty.


i added an activate choice back to the shotgun to set a ref in the quest script to getself, then had the pressure plate check the crosshairref vs the quest ref to link.  script ran all the way through, gave me the good message box when i clicked the right object and the bad one when i clicked anything else.  however, it appears my ontriggerenter block is hanging up on the activate rtraplink 1 line, cause it will only play the animation the first time i step into it and won't fire the shotgun.  so i've got to find a different way to do that.


in case you're wondering, one of the goals i have is the ability to link multiple traps to the same trigger, so the idea is to make the process adjustable without re-writing the whole thing as those options open up or make it universal in the single script so that i can click through multiple traps without having to re-write the whole thing as one gains more trap ability.


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

Gribbleshnibit8
Posts: 481
Joined: Sun Nov 04, 2012 2:06 am

I did wonder about that, and

Post by Gribbleshnibit8 » Sun Feb 09, 2014 4:03 am

I did wonder about that, and now you mention it I believe I've had those issues before. I usually try what I think will work, and work from there when it does, so you got that right!


Did you check the variables on the objects to make sure they're set? Also, looking at the page for Activate I see that there is a not on the Action Ref part that says if a calling ref does not have an action ref it will not work. So what might be happening, since it's a triggered event and not an activate, try passing in the pressure plate as an action ref with either "this" (undocumented function that is basically getSelf without the need of setting a ref var to GetSelf) or just use a getSelf variable if you have one (which is usually what I do as "this" is finicky in how it works sometimes).


To link multiple traps, just implement a version of the pressure plate linkage on a trap, so once a trap is linked to a trigger, activate it with an option to link to another trap, and run the same script/check again for the next trap and so on. Then on activate of a trap by not player it will activate it's linked one and so on down the line. In this method, as with all of this, I've left out a key thing actually where any time before you call a function, Activate especially, you should always always always check to make sure the form is valid before using it. I like to use NVSE's IsFormValid function, but checking the ref var against 0 will work just as well. I just consider IsFormValid to be a bit more obvious to others what I'm doing at that point.



User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

...i just realized i'd been

Post by Puppettron » Mon Feb 10, 2014 4:53 pm

...i just realized i'd been trying the activate line backwards this entire time.  the terrible thing is that i'd been trying to activate them through console and figured out i had to do reftobeactivated.activate reftodotheactivating, and totally didn't think to run it that way through the script.  i'm all terrible at this some weeks.  however, doing it through console wasn't working either, so i've gotta figure out what the game has against me activating things.


i should probably spawn new test pieces and try things again.  again, terrible at this some weeks.


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

User avatar
Puppettron
Gary
Posts: 1715
Joined: Sat Nov 23, 2013 10:47 pm

quick update.  i set the

Post by Puppettron » Tue Feb 11, 2014 2:08 am

quick update.  i set the activate line correctly and gave it a runthrough before my laptop died (i absent-mindedly left the damn plug cord at a friend's house) and i can report the following:


the shotgun fired.


then i CTD'd.


so i spent some time trying to rebuild the mod on my desktop from scratch so it wouldn't come packaged with all the flotsam and jetsam i'd left lying around the relevant scripts, and it looks like i'll have to just dl the version i have posted above and go from there because terrible things happened


perms:  either a full fireworks display spelling out "Puppettron Made This" anytime a user accesses my content in-game, or just give me credit somewhere.

Post Reply