Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!
Starflight Universal - Universal E2 mouseaimed flight
WHAT IS IT: All e2 (no gyro) mouse aimed flight for any small-medium sized ship.
HOW TO USE IT: Read the instructions at the start of the e2 and then follow the step-by-step chat instructions.
HOW TO MODIFY IT: There are variables at the top for simple modifications
FUTURE DEVELOPMENT: I want to add an easy way to remap the controls without digging into the meat of the code. Also add some more tweekable variables (like making space make the ship go up relative to its up, not the worlds).
CURRENT RELEASE: Version 1.3
It took me quite some time to finally settle on this method for mouse-aimed flight. Without an eyepod, this was the only way I could think of to make it happen. I decided to share it with everyone by making it as easy to learn to set up as possible.
VERSION CHANGES:
1.2->1.3 [list]Switched to setAngVel for aiming (yes, I did it!)
Changed turn-strength variable2 into 1 variable due to turning type change
Added a bit in the comments about how to possibly fix aim wobbles
Minor performance changes[/list]
1.1->1.2 [list]Cut interval in 1/5
Added 2 more variables to tweek turn speed if its jerky (depend son ship shape/size)
Overall reduced impact on server significantly[/list]
1.0->1.1 [list]Changed instructions to simplify (good note Kate)
Improved Ejector Code[/list]
HOW TO USE IT: Read the instructions at the start of the e2 and then follow the step-by-step chat instructions.
HOW TO MODIFY IT: There are variables at the top for simple modifications
FUTURE DEVELOPMENT: I want to add an easy way to remap the controls without digging into the meat of the code. Also add some more tweekable variables (like making space make the ship go up relative to its up, not the worlds).
CURRENT RELEASE: Version 1.3
It took me quite some time to finally settle on this method for mouse-aimed flight. Without an eyepod, this was the only way I could think of to make it happen. I decided to share it with everyone by making it as easy to learn to set up as possible.
VERSION CHANGES:
1.2->1.3 [list]Switched to setAngVel for aiming (yes, I did it!)
Changed turn-strength variable2 into 1 variable due to turning type change
Added a bit in the comments about how to possibly fix aim wobbles
Minor performance changes[/list]
1.1->1.2 [list]Cut interval in 1/5
Added 2 more variables to tweek turn speed if its jerky (depend son ship shape/size)
Overall reduced impact on server significantly[/list]
1.0->1.1 [list]Changed instructions to simplify (good note Kate)
Improved Ejector Code[/list]
@name Starflight Universal - by MrStump v1.3 @inputs [Pod Cam]:wirelink @persist Active ViewPause Speed LockChair TurnMult @persist Step1 Step2 Step3 @outputs [Ship Chair Driver]:entity @persist [ShipDest CamPos1 CamPos2]:vector interval(50) ############################################################## ############### Starflight Universal Use Guide ############### ######################### By:MrStump ######################### # # # INSTRUCTIONS FOR USE: # # 1)Spawn a 2x2 holo sphere (shell) from Miscellaneous Props # # 2)Place sphere in middle of your ship(do not weld yet) # # 3)Attach this e2 to it and follow the instructions in chat # # 4)When finished, alter variables below to fit your ship # # 5)After parenting, unfreeze all props but the sphere # # # # NOTES FOR ADV DUPING: # # 1)When duping, right click chair first, then hold shift # # and right click the ship. This is required because the # # chair is not attached to the ship in any way. # # 2)Parenting after you paste your dupe is recommended for # # best performance. # # # # CONTROLS: # # WASD for Forward/StrafeLeft/Back/StrafeRight # # Space/Alt for Up/Down (relative to world, no the ship) # # Shift for speed boost # # Scroll Wheel Up/Down toggles betwene cam positions # # # # HOW IT WORKS: # # The 2x2 holo sphere is used as a flight gyro. A spacebuild # # chair is then placed into the sphere by the e2, and moved # # around with the sphere. This unattached nature of the # # chair allows for real mouseaim flight. The sphere moves # # the ship around it like a pivot point. Make note this e2 # # does no parenting, use a seperate E2 for that. # # # # COMMON ISSUE: # # If the ship wobbles, it is because the sphere is not # # strong enough to make it point correctly. You may be able # # to fix it by redistributing/lessening weight and moving # # the sphere to your ship's center, but there is only so # # much total mass the sphere can move. In that case, use the # # gyropod (intergalactic) version of this E2. # # # ############################################################## # WARNING: May work on larger ships, but is not recommended! # ############################################################## ############################################################## ############################################################################################ ######## Editable Variables ################################################################ if(first()|dupefinished()){ Speed = 65 #Determines speed, 45 by default LockChair = 1 #Ejects non-owner from the chair. 1 is on, 0 is off. 1 by default. TurnMult = 5 #Strength of the turning code. Default is 5-8 CamPos1 = vec(80,0,0) #Default camera position, or selectable with scroll wheel up CamPos2 = vec(-600,0,60) #Secondary camera position, selectable with scrollwheel down #NOTE: CamPos1 and CamPos2 are relative to the position of the sphere } ###### END Editable Variables ############################################################### ############################################################################################ ############################################################### # Editing any following code is of course allowed, but not # # advised unless you know WTF you are doing. Its your E2 tho # ############################################################### if(dupefinished()){ Ship = entity():isWeldedTo() Chair = Pod["Entity",entity] Ship:setMass(50000) Chair:freeze() Chair:setAng(ang(0,Ship:angles():yaw(),0)) ShipDest = Ship:pos() Ship:setAlpha(0) entity():setAlpha(1) Step1 = 0 Step2 = 0 Step3 = 0 Step4 = 0 Step4 = 1 holoCreate(1, Ship:pos(), vec(1,1,1), Ship:angles()) holoModel(1, "models/hunter/misc/sphere2x2.mdl") holoMaterial(1, "phoenix_storms/stripes") holoColor(1, vec(71,30,20)) holoParent(1, Ship) } if(first()){ Ship = entity():isWeldedTo() if(Ship:model()=="models/hunter/misc/shell2x2.mdl"){ print("STEP1) Align the sphere so the red arrow points forward and the blue arrow points up then weld sphere to your ship.") holoCreate(1, Ship:toWorld(vec(60,0,0)), vec(3,3,3), Ship:toWorld(ang(90,0,0)), vec(255,0,0)) holoModel(1, "cone") holoCreate(2, Ship:toWorld(vec(0,0,60)), vec(3,3,3), Ship:toWorld(ang( 0,0,0)), vec(0,0,255)) holoModel(2, "cone") holoParent(1, entity()) holoParent(2, entity()) Ship:setMass(50000) } else{ print("SETUP ERROR: You are not attaching the E2 to the correct prop. It MUST be attachedto prop models/hunter/misc/shell2x2.mdl, which is the holo sphere found in Miscellaneous Props.") print("Delete this E2 and try again") } Step1 = 1 Step2 = 0 Step3 = 0 Step4 = 0 } if(Step1){ if(Ship:hasConstraints()>1){ print("STEP2) Spawn a chair (spacebuild Promethius Chair recommended). DO NOT WELD OR NOCOLLID ANYTHING TO/WITH CHAIR!") print("STEP3) Spawn an ADV POD CONTROLLER and CAM CONTROLLER, link both to chair.") print("STEP4) Wirelink this E2's coresponding wirelinks to Pod controller and Cam controller") holoDelete(1) holoDelete(2) Step1=0 Step2=1 } } if(Step2){ if(->Cam & ->Pod){ Chair = Pod["Entity",entity] if(Chair:model()==""){ print("ERROR: You forgot to link the Pod Controller to the chair! Do so now and then repaste this e2") Step2 = 0 } else{ print("STEP5) Use a parenting E2 to parent the rest of your ship TO THE SPHERE. That's it, you're done!") print("REMINDER: When you go to dupe your ship, you must remember to dupe both the chair and the ship together because the chair is unconnected to the ship") Step2=0 Step3=1 Chair:setAng(ang(0,Ship:angles():yaw(),0)) Chair:freeze() ShipDest = Ship:pos() Ship:setAlpha(0) entity():setAlpha(1) holoCreate(1, Ship:pos(), vec(1,1,1), Ship:angles()) holoModel(1, "models/hunter/misc/sphere2x2.mdl") holoMaterial(1, "phoenix_storms/stripes") holoColor(1, vec(71,30,20)) holoParent(1, Ship) } } } if(Step3){ Active = Pod["Active",number] ShipPos = Ship:pos() if(Active) { W = Pod["W",number] A = Pod["A",number] S = Pod["S",number] D = Pod["D",number] Space = Pod["Space",number] Shift = Pod["Shift",number] Alt = Pod["Alt",number] PrevWeapon = Pod["PrevWeapon",number] NextWeapon = Pod["NextWeapon",number] #Mouse1 = Pod["Mouse1",number] #Mouse2 = Pod["Mouse2",number] #R = Pod["R",number] #Light = Pod["Light",number] if($Active){ if(LockChair){ Driver = Chair:driver() if(Driver!=owner()){ Pod["Eject",number] = 1 } else{ ShipDest = ShipPos Chair:propNotSolid(1) Chair:propFreeze(1) Cam["Activated",number] = 1 } } else{ ShipDest = ShipPos Chair:propNotSolid(1) Chair:propFreeze(1) Cam["Activated",number] = 1 } Cam["Position",vector] = Ship:toWorld(CamPos1) Cam["Direction",vector] = Ship:forward() Cam["Parent",entity] = Ship timer("ViewPause",1500) } if(clk("ViewPause")){ViewPause=1 Ship:propFreeze(0)} DriverEye = Driver:eye() Cam["Direction",vector] = DriverEye if(W) {ShipDest += DriverEye:rotate(ang(0, 0,0))*Speed*(1+Shift*2)} if(S) {ShipDest +=-DriverEye:rotate(ang(0, 0,0))*Speed*(1+Shift*2)} if(A) {ShipDest += DriverEye:rotate(ang(0, 90,0)):setZ(0)*Speed*(1+Shift*2)} if(D) {ShipDest += DriverEye:rotate(ang(0,-90,0)):setZ(0)*Speed*(1+Shift*2)} if(Space) {ShipDest += vec(0,0, Speed)} if(Alt) {ShipDest += vec(0,0,-Speed)} if(PrevWeapon) {Cam["Position",vector] = Ship:toWorld(CamPos1)} if(NextWeapon) {Cam["Position",vector] = Ship:toWorld(CamPos2)} Vec = ShipDest - ShipPos Ship:setVel(Vec*3) if(ViewPause){ DistViewPos = Chair:toWorld(Chair:toLocalAxis(DriverEye)*5000) } else{ DistViewPos = Chair:toWorld(Chair:forward()*5000) } ANG = -Ship:heading(DistViewPos) Ship:setAngVel( shiftR(ANG:setRoll(-Ship:angles():roll()))*8 ) } elseif($Active){ Ship:propFreeze(1) Pod["Eject",number] = 0 Cam["Activated",number] = 0 Chair:propNotSolid(0) Chair:setAng(ang(0,Ship:angles():yaw(),0)) ViewPause = 0 ShipLockon = 0 } Chair:reposition(Ship:toWorld(-vec(0,0,30))) }
Comments
"I want you to show this world what it means to fear the sky."
And while its possible to fly that fast, the faster you go, the more un-recoverable it is when you DO hit something. No matter how I code it people will fuck with it to let themselves go at high speeds... just like they do with the sneaky way to make gyros go very quickly. The default speed is about fighter speed, but not unhittable or faster than things like drones.
Also, I'm fiddling with getting better op performance ATM without losing ship performance. That'll be V1.1
EDIT: Finished 1.1, but I can't lower ops without losing turning performance. So I am considering making a gyropod version of this e2. It would work the same way except use Gyropod for all maneuvering/flight. THOUGHTS?
Right, however you should look into my code that I made for the ship camera. You could remove the cam controller completely from the system, you have my permission to use any code in that as your own. I didn't intend to abase your chip or anything, I only meant to suggest that in future versions you may want to work on the initial set up more in terms of simplifying it if possible. It really looks like good work, I haven't had the chance to use it yet as I am taking a break from gmod.
As for using a gyropod with it, that is really up to you. What are the ops running at generally? If it is an issue, then maybe you might consider it.
As for the camera, I looked through the code and its some nice work, but I am trying to lowball ops as much as possible, and for that its better for me to use a cam controller. Simpler would be better for me generally, but in this case I want to just keep it as-is.
Would help opp-counts immensely.
Imagine:
targetFinderCreate(N)
targetFinder<Setting>(<PARAMS>)
targetFinderParent(N,entity())
Throw in some custom runOnTargetFinder(N) or wire to it by E2 and walla.
Not picture that with a camera pod controller or HUD controller.
It would make all in 1 E2s like this one so much faster.
"I want you to show this world what it means to fear the sky."
Well, I'm not sure what else I can add/remove from this e2. "The Wobbles" situation that happens on larger/heavier ships with a bunch of non-evenly distributed weight... well... unless I learn quats I do not believe that I can solve that issue. If you jam 100 tons of shit into the back of your plane, it'll fly shitty. SUPRISE.
Yeah, I learnt that the hard way...
Still, the gyro is a good replacement
Instead of telling them to delete the e2, delete it for them. selfDestruct()
Like I said before, see if you can automate this. Iterate through the contraption and check the type of everything against a pod controller / cam controller.
Again, selfDestruct(). This would be a good error checking for the previous step.
Try this code here. (Wrote this in here, may be too many or too little ()'s
That may or may not increase the performance.
Other than that, quaternions are the next step up.
I would automate the cam/pod controllers... but I have no way to check if a cam controller is linked to the chair... unless you know of one. With the pod I can check its Entity output... which is why I have them spawn and link the things then wirelink. I can check if the wirelinks are connected and if they are, check if the pod controller is linked... if I could check the cam's link or link via e2, I could automate this for them... this does remind me I also need to include an option to not use a cam controller. But I totally get I could do getConstraints to find if they placed a cam and pod on the ship.
As for the other code, Fuhr took the server down to work on it I think, but I'll take a good look at when its back up.
EDIT: Switched code on the dev server. Looks neater in the code but no change in ops so I just reverted to what I'm more comfortable with
"I want you to show this world what it means to fear the sky."