Gravity Hull Designator - a true Localized Physics mod

CURRENT REVISION
Revision 27: Fixed the underwater system in gm13.
Revision 26: Ported to Gmod 13, some infinite map fixes, physghosts also should work now.
Revision 25: Fixed smartsnap in infinite maps (partially), fixed spawning initially without weapons.
Revision 24: Fixed hulls from erroring when broken. Added the map used for Map Repeater – uncomment the second line in lua/autorun/gravityhull_init.lua in order to enable it.
Revision 23: Stopped maprepeat from loading, it was breaking spacebuild even in unaffected maps.
Revision 22: SUBMARINES YEAHHHHH
• added the prealpha maprepeat code-- don’t use it yet though.
• fixed players in hulls being invisible underwater.
• fixed players in hulls having incorrect lighting (sort of).
• stopped the water warp effect from being visible when in a hull.
• increased the minimum distance for water fog while in a hull.

if you’re updating from an early revision, I recommend scrolling down and looking at r12, r17, and r20, they’re awesome.

Well, here it is, a thread for my localized physics mod, currently in BETA. It was announced a four hours back in waywo by a friend, who posted it for me due to my lack of a facepunch account. Obviously I have one now and I decided to just go ahead and make a thread for it. A lot of people say it has the potential to change gmod forever, and I agree if only because that’s what it’s designed to do. Most of what it does is explained in the videos, so I’ll refrain from babbling and just let you see for yourself. NOTE: In video 1, it says the transitions are problematic. They are not anymore, as you can see in video 3. These were recorded with a couple days inbetween so things have changed for each video.

VIDEO ONE IS OLD. Most of the bugs mentioned in the video have been fixed by now, including velocity. The third video was made today so it gives a much better idea of the state the mod is in, but I posted the old video anyway since it explains what the mod does and how it works, and those two things have not changed. I’ll probably make a new all-in-one video when the beta is released.

[media]http://www.youtube.com/watch?v=56j7jaEtDTc&feature=related[/media]
[media]http://www.youtube.com/watch?v=xn4bDLPY69Q

What defines the hull?
The interior of the hull is defined as the set of locations where there is a floor under you, and if the point’s elevation from the floor exceeds the vertical protrusion factor, it also requires at least one non-floor (a wall or ceiling).

What this ISN’T:
NOT a module, the mod is made entirely with lua and has no dependencies.
NOT a reimplementation of source physics, it’s a complex illusion that involves a room in the middle of nowhere.
NOT a wall walking mod, though it can be used on something and then rotated 90 degrees so that down is now the wall.
NOT a spherical planet mod. “Down” inside the ship is defined as the orientation gravity was pulling when the tool was first used. Spawn a dumpster, shoot it, flip it upside-down, and you’re on the ceiling.
NOT a way to stick to things. Again, down is only one direction internally and you cannot walk around the inside of a ring unless you make it out of multiple hulls, each with their own down. This might be made easier in the future.
NOT a map entity. I might make a map entity later on that allows the effect to be present, but for now it’s just something you build with.
NOT a collision engine. This mod uses nothing more than source’s built-in havok implementation, but it sure fools it a lot. Many shortcomings of havok are avoided by making it think something different is happening.

What this mod IS:
a localized physics environment for any contraption, essentially behaving as if each hull was its own map.
a tool that anyone can use on any set of welded props that has a clear interior and exterior.
• the first and only complete spazz protection for ships. Since the ghost doesn’t move, entities inside cannot be thrown through the wall.
NOTE: In the future there will be a slider to control how much entities are thrown around by motion, but it will be applied in a backwards manner (negative velocity to the props, not positive velocity to the ghost) to avoid wallclipping, so even a 0% dampener will still stop spazz deaths even though it will throw things around just as much as before.
a separate area with its own sense of “down.” Gravity’s internal direction is defined when you first designate your hull, and does not change relative to the ship’s rotation.
a stabilizer for pretty much any vehicle you can think of. Boats are especially interesting with the tool applied, because you actually rock back and forth in the water.
linked with the outside world as seamlessly as possible-- the physgun behaves properly for the most part, and you can toolgun entities on the outside while you’re inside a hull, as well as press buttons/get in chairs.
an override of many built-in functions such as GetPos, so there is a chance that your favorite mod might work with it already without any changes.
a very convincing illusion. You’re not actually in your ship, but it sure looks like you are. For this reason a lot of things (manhack lights for example) might render in the wrong place. But hey, a video game is just an illusion too, so who cares.
a simple change brought on by extremely non-simple code, that can revolutionize almost everything else that’s already possible with the simple addition of walking in a moving object and gravity being affected by rotation.

FAQ
Q: My contraption isn’t working, it says it was designated but it isn’t!
A: Does it have walls or a ceiling? If not, you need to increase the Vertical Protrusion Factor.

Q: Does this work with spheres?
A: Not in the way you’re asking.

Q: Does this work with <<SUBJECT ADDON HERE>>
A: Maybe; depends on what the addon does. There may or may not be conflicts and there’s a decent chance it won’t work inside the hull, but lots of mods do. It’s a matter of overriding the right things and I plan to fix as many of these as I can.

Q: I just want to fly a spaceship, I don’t want people running around climbing walls like spiderman.
A: They can’t. The only way you can walk on a wall is by making a “ship” and rotating it so that its floor is on the wall (or designating the wall with hit surface defines floor checked)-- it’s not just a “climb wherever you want” deal.

DOWNLOAD
As of the 6th, the mod has been released publicly as a beta. It’s quite buggy still and there are a lot of features left to implement, but for the most part it works and is stable. You can download the mod from the googlecode SVN repository at http://gravityhull.googlecode.com/svn/trunk/ - see http://wiki.garrysmod.com/?title=Svn for information about using SVN if you don’t already know.

Want to give me a little push?
Modding is a labor of love, but it doesn’t make any money, and neither does anything else I do. Therein lies the problem with my projects-- I have to set them aside at lower priorities than things that could potentially provide an income. I have no income at this time so looking for a job and working with my indie group to start off with some steam games is my top priority, and oftentimes I’ll go for long stretches without working. Donations are an excellent excuse to get back to work on the mod for a week or so, so if you want to give me a push either to encourage me or to prod me back to work, I have a paypal account and my days are made when I see “notification of donation recieved” in my email inbox! I care a lot about my project, and donations make me care even more, and give me something to show for the work that I put into something other than my indie group’s game engine.
http://i.imgur.com/Vvp0w.png
I also have a bitcoin wallet: 13SC8WFS8ukDTU3UVNCicmo7Cw1x1QqVT6 – if you donate btc and want me to know who you are, leave a PM with your wallet address so I know who to credit.

Currently, my todo list looks something like this:
TODO
• Optimize the constraint-enabled in/out scanner to reduce lag.
• Add the ability for the effect to be (adv)duplicated, including objects welded to the inside of the ship.
• Fix the hull within a hull within a hull from sending you to limbo
• Work on making major mods work flawlessly with the mod, especially wire and spacebuild.
• Implement a dampening percentage slider so that values below 100% will allow some inertia through.
• Implement a dampening threshold slider so that only velocity changes above the value will obey the above.
• Recode the physgun beam in lua so that it renders.
• Add a stencil system so you can have the classic “cloaked ship with a doorway” effect, plus total exclusion of water effects in a hull.

–SERVERS RUNNING THE MOD–
StonedPot is running a** 28-slot sandbox **server here, located in France: 188.165.193.84:27012
Bletotum is running a **16-slot sandbox **server here: 69.197.189.12:27015
Goluch is running a few **SpaceTownRP **servers at this domain: spacetownrp.com:27021 - 27024
TheForge Faction Spacewar is a 16-slot SB2 server also running the mod, at theforge.hopto.org
Pantho is is also running a **sandbox **server here, located in the UK: 204.62.12.106:27215
Mogz **Sandbox **Server runs it too: 89.145.94.221:27035
Ratboy14 is also hosting a **sandbox **server here called SmallTime Build: 67.85.152.155:27015
xxXandyXxx’s **RP **server runs it as well: 85.234.138.162:27015
HellBoy_UK is running three servers with it too:

  • 89.238.160.45:27017 - 12 slot UK spacebuild
  • 89.238.160.14:27016 - 12 slot UK** naval warfare build**
  • 69.197.189.186:27015 - 12 slot US **spacebuild **
    BamfColeTrain is running a 10 slot sandbox server on the east coast US hosted by Nuclear Fallout: flux.game.nfoservers.com:27015
    SaCleo’s **Sandbox **with Stargate, CAP, and Wire: 109.169.52.103:27015
    MattJeanes’s 16-slot sandbox: 89.238.160.229:27015
    Crimson Gaming’s **Sanbox **Server: 81.19.209.169:27018
    Game-Hunters 64-slot, SB3 + Addons( LS3, RT3 …) ,SBEP; 88.190.25.80:27017
    Game-Hunters 64-slot sandbox w/ wire, etc: 88.190.25.80:27015
    BlackMac is hosting an SB3 with CAP,SBEP,Stargate,LS3, etc: 109.169.29.181:27015
    DavidGiga1993 runs a server as well. The IP changes but it’s listed here: http://steamcommunity.com/groups/davidgiga1993

(there are definitely others and I will add them as I find their IP’s and get permission from the owners.)

SPECIAL THANKS TO:
• Cerberus Studios, a mod team that I am apart of, working towards being an indie game company, both for beta testing support and allowing me to take breaks from my game engine work to work on this. Keep us in mind if you ever see a Cerberus game on steam, it means I worked on it!
• Lavacano for providing the original alpha server, which served well for pre-facepunch releases. Though the server was overwhelmed as soon as it was announced here, it played a valuable part in the making of the mod.
• Divran for always nagging me to finish it and always being there to help with algorithm design-- and he split shipdef.lua into a bunch of files for me.
• The Wiremod forums and team for providing the original home for my Attempting the Impossible project, out of which this mod stems.
• Valve for obvious reasons, Garry for said obvious reasons and additionally for the FP highlight.
• The SBEP modellers for imagining a world without prop spazz and describing it in model form, which is perfect now that such a world exists.
• The spacebuild/sbep teams in general for making such a perfect purpose for a walk-around spaceship.
• Everybody that posted in this thread, whether it be with a bug report, encouragement, a video, or discussion; it’s been helpful.
• The donators for giving me another excuse to work on the mod, and brightening my day whenever I see paypal notifications :smiley:

CHANGELOG
Revision 21 fixed the rocket launcher and improved velocity support so that ship velocity is added/subtracted during transitions.
Revision 20:
• added FireBullets support, fixing most SWEPs
• fixed ghosted explosives from infinitely exploding
• fixed a stack overflow when welding a contraption to the inside of a hull
• fixed transitions between ships taking too long to reset
• added a player gravity slider (will work on props later on)
• added a Help button to explain how to use the tool
• added a GravHull.RegisterHull(ent,protrusion,gravity) function for developers (YOU WILL NEED TO CALL GravHull.UpdateHull(ent) AFTERWARDS)
Revision 19 fixed stack overflow when welding an object to the inside of a ship
Revision 18 fixed easy weld and keep upright causing an error
Revision 17 added/fixed:
• New Tool Handler

  • most tools work both inside and outside the ship now, including many wiremod ones
  • physghosts can be constrained, colored, etc, redirecting to the actual entity
  • ship prop modifications can be applied from the inside (i.e. color, material)
  • should fix most trace-related errors including the WAC helicopter bug
    • Fixed entities spawning hundreds of physghosts by accident
    • Fixed physghosts permanently setting a prop’s mass to 4768
    • Added client console command ‘ghd_fixcamera’ which, if run enough times, should fix the camera bug whenever it occurs
    • Fixed open sbep doors in a hull being closed on the inside
    Revision 16 re-fixed buttons and chairs
    Revision 15 fixed sbep lifts and hopefully spacebuild and stargate.
    Revision 14 fixed the AddCSLuaFile bug.
    Revision 13 fixed the floor checkbox designating hulls with extremely wrong angles, various lag/crash problems involving the new hull scanner, stopped the tool from designating something that’s already designated, and fixed a bug with physghosts where a prop would disappear if you held a prop, put it in the ship, then walked in yourself without letting go.
    Revision 12, added/fixed:
    • New Hull Scanner
  • ignores no collides
  • builds a hull out of welded/nailed props
  • adds anything constrained without a weld (ropes, hydraulics) to the “moving parts” list for permanent physghosting, allowing hydraulic doors to function with collision
  • two constrained hulls will also add each other as permanent physghosts
    • SBEP Door Support
  • uses SetNotSolid, so props will remain in the ship until they exit the door
    • Vertical Protusion Factor Slider (0 to 300)
  • sets the maximum distance from the floor for an entity to be inside the ship without a ceiling or walls
    • Hit Surface Defines Floor checkbox
  • if checked, gravity will be perpendicular to the normal of your tool’s hit trace
  • in laymen’s terms, shoot the surface you want to walk on.
    • Stopped rotating objects in a ship from pressing Use
    • Applied Divran’s file splits and loader
    • Cleaned up the code a bit and moved the globals into a table called GravHull
    Revision 11 fixed the chair teleport issue.
    Revision 10 re-fixed physghosts, added explosion effects to gas cans, and stops physboxes from crashing
    Revision 9 fixes vehicles, the invisible toolgun, no collide (sort of), and hopefully player respawning in ships
    Revision 8 should fix the thruster crash (the ship was absorbing itself) and stargates, and the following hooks for easier mod integration:
    • EnterShip(ent,ship,ghost,oldpos,oldang)
    • ExitShip(ent,ship,ghost,oldpos,oldang)
    • ValidHull(ent) – return false to disallow ent from being considered part of the hull geometry
    • OnCreatePhysghost(ship,ent,physghost) – used for custom extra steps in the setup of physghosts (the objects you’re actually dragging when you drag physgun something outside from inside a ship)
    • AllowGhostSpot(pos) – return false if pos should not be used to spawn ghost ships (i.e. underwater, though this is disabled by default)
    Revision 7 should fix Smartsnap and possibly certain aim-based E2’s
    Revision 6 should fix the GetPhysicsAttacker crash
    Revision 5 fixed:
    • Chairs/Buttons not working when welded to a ship
    • Sharpeye compatibility (and hopefully other view mods too, if you had the camera bug this should fix it permanently (EDIT: or not))
    • Physghosts (they were nonfunctional due to a typo)
    Revision 4 fixed entities not ghosting properly
    Revision 3 fixed the in/out algorithm giving unexpected results

Can’t find the “lua god” button? Perhaps it’s because the “penniless programmer” describes me better; it looks like a paypal donate button, and it means a lot more to me than a forum rating.

Wow…

Dude, this is seriously really useful. Honestly, I was waiting for something like this for a long time.

At first, I was thinking

“right ok another “will change gmod” addon, gonna be shit”

Then I watched the videos

http://luaforfood.com/dirtypics/perv.gif

It’s like entity:SetParent() on crack! :smiley:
Like I said in WAYWO - looks very nice, cant wait for a release.

Could you please try to ensure compatibility with my addon? Its very similar to SB but uses drastically different methods of doing things, so it could be easily broken by this. http://www.facepunch.com/threads/1063437-Environments

I’m pretty sure it will work out of the box with it if I override the right things. Nothing in the code is specific to spacebuild or wiremod, most of it just works because of the getpos overrides and other similar techniques that apply to everything. For instance, spacebuild’s “are you in space” function automatically worked the way it was supposed to without any effort. If any mod doesn’t work with it, I’ll fix it by adding the appropriate override/special case. Each mod will not need its own fix most of the time.

This is fucking amazing! Great job; hope it runs well performance-wise with multiple people and multiple gravitized-props.

You…
Are a God.

This is pretty amazing, keep up the good work!

Very impressive, probably the most useful thing I’ve ever seen.

it’s so beautiful

:aaa:

My god this is the best thing I’ve ever seen, really awesome job, this’ll be awesome with spacebuild :slight_smile:

Just thinking of all the possibilities… :aaaaa:

This could easily be the beginning of even better mind fuck levels in GMod.

You can have my babies.
All of them.

This tears me apart in a strange way. I’ve longed for something like this, many people have, but I simply do not play the game like I used to anymore.

This addon sorta breaks my heart in a way. It’s here, but I’m not. I mostly code with the game now, and once you start this phaze, you don’t go back to sandboxing much.

http://www.benzworld.org/forums/attachments/w126-s-se-sec-sel-sd/372761d1304174922-trek-up-north-holy-euro-motor-jaw-drop.jpg

fucken spacebuild spaceship don’t push you backwards anymore fuck yeeah

this is something I would love to have in my gamemode they I will be making