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

kinda got it working by

Post by Puppettron » Thu Feb 20, 2014 11:10 am

kinda got it working by altering the script in the spawning object to spawn the tripwire, then 0 out the x and y axis angles, then setangle the whole thing 90* on the z axis and setpos it up about 11 units in the z axis.  unfortunately, that's mostly working by setting the placeatme command to ref player instead of the spawning object, and changing the distance and direction of placeatme doesn't seem to be doing anything so far, so i might need to learn trig so i can reliably place it a foot infront of the player's view.


trying to setpos the tripwire back to where the spawning object was is making it disappear, so i'm going to have to figure out where it's going with more debugging before i call that road useless.


i started playing around with the mod in play and have realized that i need to make my gun traps either easier to place or aimable, which again might require some trig.  high school was a really long time ago.


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

ok, quick update.  i've got

Post by Puppettron » Fri Feb 21, 2014 6:55 pm

ok, quick update.  i've got it working as well as i can on my other computer, which also has the scripts i'm using on it.  but, here's kinda how it works:



set rTripwire to player.placeatme APTripwire01 1 100 0;  supposedly, the numbers are # of objects, distance, and direction -- 0 = in front of


rTripwire.setangle x 0


rTripwire.setangle y 0


rTripwire.setangle z 0


set fPos to rTripwire.getpos z;  fPos is a float value, until the script hits this point, it's 0


set fPos to fPos + 11


rTripwire.setpos z fPos


 


using a similar thing, i got grenade bunches to work most of the time


 



set bTargeted to placeatreticle APTrapGrenadeBunch 1 0 1200;  that's objects 1, mindistance 0, mindistance 1200


rObject.setangle x 0;  using a ref to set the placeatreticle doesn't work well, so i had the nade bunch set rObject here in it's onload block


rObject.setangle y 0


rObject.setangle z 0


set fPosz to rObject.getpos z


set fPosz to fPosz - 50


rObject.setpos z fPosz


 


...and by "doesn't work well", i mean "will for some reason keep looping back through the top of the script forever."  seriously, if i used set rObject to place...etc., i could fill the entire room with whatever object i was placing, and it would never run through the lower part of the script.


 


as for setting up an aiming system, what i'd like to do is pop up an object to aim at, have the player move that to wherever the hell he wants, and then somehow get the guntraps to point at it when he finalizes it.  what i do know is that i can easily get the 3 coordinates of the aimpoint and the guntrap, but i don't know how to translate the difference into degrees or how to ensure that the bit that gets pointed when i do it is the bit that the shots are coming out of


 


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

i'm so flummoxed by trying to

Post by Puppettron » Sun Feb 23, 2014 12:12 am

i'm so flummoxed by trying to learn trig to do this damn bit of scripting, that i made pictures to post to facebook in an attempt to crowdsource what some people might consider "basic mathematics".  i also put them here so you can see my brain working.





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

What you're looking for is

Post by TrickyVein » Sun Feb 23, 2014 3:04 am

What you're looking for is the cosine of the segment BN over AB.


So the angle



X = cos-1(BN/AB)



Assuming a right triangle. The length of the segments are 



BN = |y(A) - y(B)|


AB = |x(A) - x(B)|



The scripting language may even allow you to input trigonometric functions, so that's just dandy. I guess you'll need to figure out some way of checking if the angle is +/- from the y direction (north). 


Since this is 3D space as you pointed out, you'll need to find two angles at minimum. One for the yaw, the other for the pitch. I guess you could find the roll as well. Use the z axis just as you are using North to find the angles in the other planes of rotation. 



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

see, i knew pictures would

Post by Puppettron » Sun Feb 23, 2014 3:27 am

see, i knew pictures would help.


oh hell, i just found GetHeadingAngle.  so now i just have to run that function to get the tilt or pitch or yaw or whatever.


also, if the cos formula you posted gives answers in 360*, then it's a simple matter of if var > 180, set var to (var - 360) to get the negative angle for right-sided angles.  i swear this all makes sense in my head.  and then re-reading setangle, it doesn't specify that i have to use +/- angles to differentiate between the different sides.


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

ok, update time.

Post by Puppettron » Mon Feb 24, 2014 11:50 pm

ok, update time.


so, getheadingangle doesn't work on objects, or maybe just my traps.  no matter, i set the traps to set their z axis to player.getangle z + player.getheadingangle <trigger>.


also, i've got the script mostly working, but now that i'm having some brain break, it occurred to me that i'm doing something wrong somewhere, because i have to keep setting the angle of x and y to angle - 90 or 90 - angle to get them right.  unless i'm mistaken, that means i'm getting the wrong angle of the triangle out of the formula.


here's the script right now, before i come back to it later:  http://pastebin.com/dj7VMkjK


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

...i should've commented that

Post by Puppettron » Tue Feb 25, 2014 12:29 am

...i should've commented that script, my bad.


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

ok, i've got a trig script

Post by Puppettron » Thu Feb 27, 2014 1:29 am

ok, i've got a trig script working.  everything i did before about 3 hours ago was overthinking the problem.  now i'm just setting to 2 angles instead of setting all 3 and having cock-eyed traps that sometimes worked right.  currently, the script works on an activate choice on the trap itself that requires the advanced perk to see, but it's solid enough right now that i can change it to anything i damn well want to later.


http://pastebin.com/TysUWiRk


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

also, if you ever find

Post by Puppettron » Thu Feb 27, 2014 2:42 am

also, if you ever find yourself trying to line up guns using a trig script sort of thing, use the laser guns at least a week before you try the shotguns, and not the other way around like i did.


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

i'll probably have to find

Post by Puppettron » Fri Feb 28, 2014 6:50 am

i'll probably have to find someone capable at making meshes soon to do stuff i want to do, as i can't seem to figure out how to swap the nades of a bouquet out.  i also included a master unlinking method that unlinks traps when you reset a trigger, but i'll have to tune that because i just realized that it just sets all traps to unlink rather than just the ones attached to the trigger.  shouldn't be terribly hard though.


also, i'm in the market for new trap ideas, since i'm mostly working with variations of existing traps.


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