submarine / boat scripts

Discussion in 'Coding' started by TheLiberalElitist, Feb 15, 2011.

  1. TheLiberalElitist

    TheLiberalElitist Member

    Messages:
    627
    Likes Received:
    4
    Trophy Points:
    0
    I've been playing around with the airboat scripts from halflife2 to see if I can test a submarine, and missile boat model I have been working on. Buoyancy and counter acting buoyancy to get the sub to dive is has me a little stuck. Does anyone have any ideas on how to accomplish something like that in source?
     
  2. blizzerd

    blizzerd Member

    Messages:
    10,552
    Likes Received:
    60
    Trophy Points:
    0
    dont think trusters

    think buoyancy increase and decrease
     
  3. Chris0132'

    Chris0132' Developer

    Messages:
    9,482
    Likes Received:
    0
    Trophy Points:
    0
    Yeah you can actually change the buoyancy of objects in source directly, think it's in the surface properties or something.
     
  4. Cloud

    Cloud Member

    Messages:
    1,379
    Likes Received:
    0
    Trophy Points:
    0
    Fun fact: A large boulder with a weight of 1000000 or so and material set to wood can act as a platform for people on the water.
     
  5. OuNin

    OuNin Member

    Messages:
    3,703
    Likes Received:
    3
    Trophy Points:
    0
    final destination
     
  6. blizzerd

    blizzerd Member

    Messages:
    10,552
    Likes Received:
    60
    Trophy Points:
    0
    do you mean in source? cus if you set a material in source it overrides the properties
     
  7. TheLiberalElitist

    TheLiberalElitist Member

    Messages:
    627
    Likes Received:
    4
    Trophy Points:
    0
    I think the initial code for the boat portion won't be all that difficult, but submerging the the sub then bringing the submarine back to the surface where it acts like the regular boats is what is racking my brain.

    What if there was some type of depth control, so when clicked the sub's mass would be increased, then when submarine rises to the surface weight is reduced so physics is restored, and the sub acts as any other ship.

    also as a counter I wanted to test some type of depth charge, which will sink slowly to the ground then explode when it hits the ground, or comes in contact with a submarine. Only the missile boats will have this capability
     
  8. blizzerd

    blizzerd Member

    Messages:
    10,552
    Likes Received:
    60
    Trophy Points:
    0
    i already explained how this should work, make it change the buoyancy

    less means it sinks, more means it comes up, find out some good max and min values then make 2 buttons add and subtract to it within the max and min values you gave (so subs cant jump up like if they are baloons)

    this is how real subs do it, they pressurise water in there ballast tanks to increase there average weight, and to go up they pump out the water to a lower density then outside so they become lighter and rise up

    edit: correction they dont compress it, they just take in water to be heavier then the water, or drive out the water with compressed air
     
    Last edited: Feb 21, 2011
  9. alucard13mmfmj

    alucard13mmfmj Member

    Messages:
    2,170
    Likes Received:
    0
    Trophy Points:
    0
    how can water be heavier than water? :P
     
  10. Demented

    Demented Member

    Messages:
    2,337
    Likes Received:
    0
    Trophy Points:
    0
    As far as I know, Source doesn't change water density with depth. Buoyancy is basically either 'this sinks' or 'this floats' (and sometimes 'this flies into the sky'). There's no in-between. Also, objects use their origin to determine if they are above/below water, rather than calculating the volume of water they displace.
     
  11. harryhoot1

    harryhoot1 Member

    Messages:
    663
    Likes Received:
    0
    Trophy Points:
    0
    I think it might be time for emp_subfight
     
  12. Empty

    Empty Member

    Messages:
    14,912
    Likes Received:
    11
    Trophy Points:
    0
    Simple solution:
    Hardcode submarines to ignore water physics and basically move in 0 gravity.
    If they exit water they gain standard gravity, preventing them from flying away.

    ???

    SUBMARINES!

    (it's highly unlikely to happen though)
     
  13. blizzerd

    blizzerd Member

    Messages:
    10,552
    Likes Received:
    60
    Trophy Points:
    0
    the sub is heavier then water, unless its ballast tanks are only filled with air
     
  14. Krazer

    Krazer Member

    Messages:
    651
    Likes Received:
    1
    Trophy Points:
    0
    Do want!
     
  15. Empty

    Empty Member

    Messages:
    14,912
    Likes Received:
    11
    Trophy Points:
    0
    Hey then it'll be in a map so it has to be easily possible to implement in code.
    Trust me I know these things. (PS I'm sodaen)
     
  16. alucard13mmfmj

    alucard13mmfmj Member

    Messages:
    2,170
    Likes Received:
    0
    Trophy Points:
    0
    how about we have some pseudo water?
    have some fake water where u reduce gravity and friction in some parts of the map.
     
  17. TheLiberalElitist

    TheLiberalElitist Member

    Messages:
    627
    Likes Received:
    4
    Trophy Points:
    0
    Atm I want to test three types of watercraft

    Submarine
    Can go undetected by radar, only missile boats would have the ability to detect it. Also the submarine would have space for five people making it a great tool to sneak a squad undetected into an enemies base. Will be equipped with two missile slots

    Destroyer
    These boats act as fast attack craft. Will have the ability to detect submarines and drop depth charges to take out submarines if necessary. The boats would be equipped with heavy artillery, for ship to ship warfare, and bombarding bases from a far distance.

    Transport/carrier
    Got the idea from emp_landing, basically a watercraft that can ferry up to two heavies and has a landing pad to heal one aircraft. Will have the capacity to carry eight players like the apc, but will not have the ability to act as a spawn.

    Already started working on the three models for both NF and BE, and two shipyard models. Just basic models, for the purpose of testing the basic shape of the craft. and if it will float upright in water and not roll or bob unnaturally.
     
    Last edited: Mar 31, 2011
  18. flasche

    flasche Member Staff Member Moderator

    Messages:
    13,299
    Likes Received:
    168
    Trophy Points:
    0
    does scaling finally work? if not theres not enough space to build maps that suport ship fights AND tank combat rendering your carrier/landing boat idea useless (duststorm is about max grid size). and turning empires into battleships - idk, kinda sucks ....
     
  19. TheLiberalElitist

    TheLiberalElitist Member

    Messages:
    627
    Likes Received:
    4
    Trophy Points:
    0
    I used to use a map with nothing but water , and hide the CV's over the map, then have a little land for testing and building purposes.

    at issue.but recently I have been having trouble getting hammer not to crash, so I have halted everything to find some way to resolve that issue
     
  20. MOOtant

    MOOtant Member

    Messages:
    4,047
    Likes Received:
    0
    Trophy Points:
    0
    Havok handles buoyancy and that stuff but Source doesn't allow maps big enough (at least without scaling) to fit submarines. I hope that everyone remembers buoyancy puzzle from Half Life 2.

    Every physics object has drag and buoyancy ratio. Every fluid brush has density property. All these properties can be changed from code. These are properties for every fluid brush:

    Code:
    struct fluidparams_t
    {
            Vector4D        surfacePlane;   // x,y,z normal, dist (plane constant) fluid surface
            Vector          currentVelocity; // velocity of the current in inches/second
            float           damping;                // damping factor for buoyancy (tweak)
            float           torqueFactor;
            float           viscosityFactor;
            void            *pGameData;
            bool            useAerodynamics;// true if this controller should calculate surface pressure
            int                     contents;
    }
    
    To find out how they work I'd have to check Havok code which I don't have (or lolol HL2 leak). To play around with that stuff you have to use C++ and be able to write at least basic things in C++. It simply wasn't exposed as entities/airboat props.
     
    Last edited: Mar 6, 2011

Share This Page