Author Topic: Gravity - with (I hope) very minor code changes.  (Read 6624 times)

0 Members and 1 Guest are viewing this topic.

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
OK. By now, everyone's seen the TI atmospheric pics. The first question everyone seems to ask is "Will there be gravity?". And so far, I've had to say no, because there really wasn't any way to do it convincingly. We messed around with stuff like invisible kinetic weapons firing at you from great distance and stuff, but nothing seemed feasible. Then last night, I was sitting around and realized I was an idiot.

Code: [Select]
when
 - true
 - Set-Ship-position
    - Alpha 1
    - Get Position X
       - Alpha 1
    - -
       - Get-position-Y
          - Alpha 1
       - 25
    - Get Position Z
       - Alpha 1
Repeat Count 9999, Interval 1


The basic pemise was that every second, the sexp would shift the player down 25 meters. And it worked. It didn't accelerate like true gravity would, but it was as well simulated gravity as we're ever likely to get without a complete physics engine overhaul. There was only one problem. It worked as well as could be expected given what I told it to do, ie. Instantaneously shift down 25m every second. In other words, it's very, very jerky and obvious.

There are two ways I can think of to fix it. One is to implement a "move-ship" sexp, that would shift the ship naturally, as opposed to just putting it in position, however, I'm assuming this isn't as easy as it would sound, or you'd have done it, and other related sexps (like "rotate-ship-facing as opposed to set-ship-facing) by now.

The other was to do something a little sneaky. The huma eye only sees something like 15 or 20 FPS - the greater the frames fer second above that, of course, the smoother the transitions look, but once you pass about 10 or 15, things start to look decent. So, I figured the easiest way top make this happen would be to decrease the allowed interval between sexps to .1 or .05, and increase the number of allowed repeats by an equivalent amount (ie to 99999, or 200000). It wouldn't break backwards compatability, since the numbers would stay thge same, the only thing I'm worried about is that V might have limited you to 1 second intervals for a reason.

I know this seems very campaign specific, and I know you guys don't like making those kinds of changes, but I know there are other missions where I could use either of these (other than the atmospheric stuff), so it's entirely possible other people will find uses for them as well. I know that's kind of thin (though true), but it's the best I could come up with on short notice. :)
« Last Edit: June 11, 2004, 01:34:42 am by 302 »
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Gravity - with (I hope) very minor code changes.
You'd also have to implement an any-ship operator in place of Alpha 1. But, that would be pretty easy from a coding point of view.
-C

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
Actually, I'm not so sure about that - I really don't know how the AI would react to this, so limiting it to the player would probably be an acceptable compromise.

I would like a "velocity" returner, so that it could be applied only once the players speed drops below, say, 20 m/s, but if neccesary I can probably fudge it with the "speed" returner (which requires the set-training-context-speed sexp as well) (and frankly is pretty crappy) and the alternating On/Off variable method I worked out (And Karajorma made work :)) for the other topic.

That said, the "any-ship" would be very useful, but I think Goober or somebody was working on it (or planning to). I posted something about it a few weeks back.

EDIT - Yep http://www.hard-light.net/forums/index.php/topic,23543.0.html
« Last Edit: June 11, 2004, 02:11:33 am by 302 »
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Gravity - with (I hope) very minor code changes.
Could you do it with a get-current-speed sexp?
-C

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
Is there a get-current-speed-sexp? (I'm using a fairly elderly version of FREDOpen - need to update)

Oh, and yes. Assuming it works the same as get-position-X or whatever, then it'd be ideal.
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Lightspeed

  • Light Years Ahead
  • 212
Gravity - with (I hope) very minor code changes.
Best would be to automise all that and put it in a FRED setting, so you wont have to fiddle with the SEXPs anytime, but FRED does all the work for you.
Modern man is the missing link between ape and human being.

 

Offline aldo_14

  • Gunnery Control
  • 213
Gravity - with (I hope) very minor code changes.
someone told me Darkage got a gravity effect using a constantly fired bomb with a huge blast radius and very large negative shockwave.

NB:  I was working on an atmospheric mod till recently, but dumped it because of the whole gravity thing (specifically, the debris).

 

Offline Lightspeed

  • Light Years Ahead
  • 212
Gravity - with (I hope) very minor code changes.
BlackWolf:

I just had an idea. It should be possible to have the drop-down distance increased over time if it used another variable.

You could change the gravitation drop down according to the speed of your vessel, and according to its Y position.

I.e. get-y-position gives you the Y-location of the ship. You could make a multiplyer from that that goes into the Place ship thingy.

This would allow you to use acelerated gravity - it's fake of course, but a much better fake (as gravity would seemingly get stronger the lower youre flying).

You'll of course have to do a lot of tweaking and such to get it working properly.
Modern man is the missing link between ape and human being.

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Gravity - with (I hope) very minor code changes.
Quote
Originally posted by Black Wolf
Is there a get-current-speed-sexp? (I'm using a fairly elderly version of FREDOpen - need to update)

Oh, and yes. Assuming it works the same as get-position-X or whatever, then it'd be ideal.


I don't think so, but since the HUD displays that exact information already it should be easy to add a SEXP like that.
-C

 
Gravity - with (I hope) very minor code changes.
Would this conflict with AI? Like, say, youd have capships slowly drifting down to crash into the ground? Or am I just spouting drivel?
Carpe Diem Poste Crastinus

"When life gives you lemons...
Blind people with them..."

"Yah, dude, penises rock." Turambar

FUKOOOOV!

 
Gravity - with (I hope) very minor code changes.
From what I'm reading here it will only affect ships you tell it to affect...this could be interesting, especially if one wanted to simulate the crashing of a capital ship after its antigrav generators fail...or whatnot. :) I know Star Trek ships have antigrav, so this would work nicely for THAT :)

 

Offline HotSnoJ

  • Knossos Online!
  • 29
    • http://josherickson.org
Gravity - with (I hope) very minor code changes.
OMG!! This shoud be news ppl!! Printed on the front of ever newspaper in the world, and plastered all over the front page of HLP!!
I have big plans, now if only I could see them through.

LiberCapacitas duo quiasemper
------------------------------
Nav buoy - They mark things

 
Gravity - with (I hope) very minor code changes.
mmm...this is indeed a breakthrough. With this you could create "turbulence effects" in nebula clouds, as well. Just um, like, randomize it a bit (or something) voila.

 

Offline HotSnoJ

  • Knossos Online!
  • 29
    • http://josherickson.org
Gravity - with (I hope) very minor code changes.
Yay, me again. Though this is more of a question to the coders.

If we know the mission 'world's' X, Y, and Z coordinates, why couldn't something like this be coded into the engine long ago? [/idiot talk]


Go Black Wolf! YOU.ARE.AWESOME.!
I have big plans, now if only I could see them through.

LiberCapacitas duo quiasemper
------------------------------
Nav buoy - They mark things

 

Offline Setekh

  • Jar of Clay
  • 215
    • Hard Light Productions
Gravity - with (I hope) very minor code changes.
HotSnoJ, just a word of advice - add a link into your news post when you put it up. :) Other than that, cool job, I approved it for ya. :nod:

And BW, sweet use of what's already there. I love it. :nod::yes:
- Eddie Kent Woo, Setekh, Steak (of Steaks), AWACS. Seriously, just pick one.
HARD LIGHT PRODUCTIONS, now V3.0. Bringing Modders Together since January 2001.
THE HARD LIGHT ARRAY. Always makes you say wow.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Gravity - with (I hope) very minor code changes.
This is nice. :D

I'm glad to see people coming up with new uses for the extra SEXPs in FRED. As people get more and more familiar with them we're going to see more and more formerly impossible things done in campaigns :D

Plus it shows Goober that his SEXPing work is valued and encourages him to do more :D
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Gravity - with (I hope) very minor code changes.
What happens when you dock to a support ship?

Edit: NM
« Last Edit: June 14, 2004, 05:37:36 pm by 374 »
-C

 

Offline LtNarol

  • Biased Banshee
  • 211
    • http://www.3dap.com/hlp/hosted/the158th
Gravity - with (I hope) very minor code changes.
w00t!  Now all we need is a tank AI and roll limitations :D

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Gravity - with (I hope) very minor code changes.
This is news? :nervous:

Quote
Originally posted by Lightspeed
BlackWolf:

I just had an idea. It should be possible to have the drop-down distance increased over time if it used another variable.

You could change the gravitation drop down according to the speed of your vessel, and according to its Y position.

 


This is interesting, but it doesn't really simulate the way gravity works in the distances we'd be talking about (ie. between 0 and, say, 10000 m on average ASL). If we set it up this way, stoppping a few meters above sea level would see you slam into the ground at some ridiculous speed... but there might be a way to adapt it so that you do fall a variable defined distance based onthe time since the fall started - if we could get FRED to trigger a flag every time the evnt statrs, but not when it repeats - that might be a bit more challenging...

Quote
Originally posted by aldo_14
NB: I was working on an atmospheric mod till recently, but dumped it because of the whole gravity thing (specifically, the debris).


Yeah, we thought about this. Chances are we'll just be using a lot of ship vaporize sexps to eliminate the debris, or just not putting debris on the atmospheric-only pofs we use.

Quote
Originally posted by HotSnoJ
If we know the mission 'world's' X, Y, and Z coordinates, why couldn't something like this be coded into the engine long ago? [/idiot talk]


Presumably because until recently the infrastructure for atmospheric flight wasn't available. The decent stuff's only really come along with the advent of skyboxes and HTL, allowing the higher poly models we need (Though, for the record, the reason TIs atmospheric stuff takes place over water was originally so we could get it working without HTL). Also, the get position sexps are SCP additions, and as Karajorma's touched on, a lot of the new sexps haven't been exploited to their full potential as yet.

Quote
Originally posted by LtNarol
w00t! Now all we need is a tank AI and roll limitations


Read your public forum whydonchya? :p VA sorted this one (roll limitations) out awhile back. We're using it for boats, but it'll apply just as well to your stuff.
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline Solatar

  • 211
Gravity - with (I hope) very minor code changes.
It might be tedious to do for every ship, but for major ships in a battle, after they are destroyed you could no-warp-effect in a damaged model and have it's first orders be to plumit toward the ground. When it hits you add a nice explosion. That way if you have any capital ships or whatnot in the area, they don't just disappear.