Author Topic: Interesting quirk with set-immobile and AI aiming (useful for tanks!)  (Read 2229 times)

0 Members and 1 Guest are viewing this topic.

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Interesting quirk with set-immobile and AI aiming (useful for tanks!)
I hit an interesting quirk while FREDding With Tanks. This is general advice for using set-immobile, but it's particularly handy when you're dealing with objects that have to be managed primarily through coordinate manipulation because the regular AI can't be trusted.

set-immobile is a great SEXP for locking something in place - an installation, a warship you need to stop RIGHT THERE, a company of tanks whose AI just doesn't quite work by normal FreeSpace standards. But it comes with a pretty funny caveat!

If you set-immobile an object with AI and the ability to move, it still thinks it's moving. So does any AI shooting at it. This means that if you, say, set-immobile a fighter that's attempting to waypoint at 100 m/s, any AI attacking it will aim for a 100 m/s lead point even though the target's dead still. And unless they're shooting from straight ahead, they'll probably miss.

One solution is to clear the ship's AI so it doesn't try to move. Sometimes, though, a quirk of the mission you're working in (like the AI bugs caused by the proximity of a massive terrain model!) can make these solutions difficult. Or you might be worried about upsetting the fragile balance of a mission by altering AI behavior in even the slightest way. Or you might want your ship to retain its current orders, whatever they are, when it goes mobile again. (we should really get a sexp that returns a ship's current orders)

If you set-object-speed 0 your target on x/y/z every frame, however, AI attacking it will correctly decide that it's worth aiming straight for center of mass, instead of going for the false leadpoint. This is a quick and dirty solution to the problem that doesn't require any messing with AI orders. And you can switch it off when you set the target mobile again.

It's a crazy corner case, but Now You Know!

Spoiler:
i'll give it three posts before someone points out a much easier workaround for this whole problem

 

Offline Fury

  • The Curmudgeon
  • 213
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
If you set-object-speed 0 your target on x/y/z every frame
Sounds like this would add significant performance penalty?

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
Don't think so, the SEXP code is really lightweight. You can hold 60 with a ton of SEXPs going off every frame.

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
Sounds like something that'd be easy to fix in the AI code.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
If it's necessary. The nice thing about immobile is that it's a very clean feature: it just skips movement, doesn't affect anything else.

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
Ugh, the AI code...

Yes, it just skips movement, and that's all it does.  "All it does" can be a good thing or a bad thing.  The original intended use of this sexp was for installations, docking hubs, and sentry guns that needed to stay put and not be affected by things like shockwaves.  But, of course, it was inevitable that someone would try to use it for otherwise mobile objects. :p

I would call this a bug and say this needs to be fixed.  I have no idea how complicated it will be though.

 

Offline Kopachris

  • 28
  • It's Pythonic
    • Steam
    • Twitter
    • HLP QuoteDB
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
The original intended use of this sexp was for installations, docking hubs, and sentry guns that needed to stay put and not be affected by things like shockwaves.  But, of course, it was inevitable that someone would try to use it for otherwise mobile objects. :p

Why should installations and sentry guns not be affected by shockwaves?
--
Yo momma's so fat when she sits on a binary tree she flattens it to a linked list in constant time.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
Sometimes you don't want them to be. Set-immobile is really useful for that. I first used it (it might even have been written for? I don't remember...) in The Blade Itself, where players could ram their warship into the Arcadia and push it around, or hook it on the Karuna's spinny bit and flip it around like a gigantic paddle of death, shredding enemy corvettes. It's pretty handy to say 'just don't move that damn thing, no matter what hits it'.

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
As I recall, it was requested by Black Wolf, who ran into problems when he had a metric dozen modular space station components all next to each other.

And in case Kopachris needs clarification, "affected by shockwaves" refers to the small nudge that every shockwave produces, not the shockwave damage.

 

Offline Kopachris

  • 28
  • It's Pythonic
    • Steam
    • Twitter
    • HLP QuoteDB
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
I'm still lost as to why anyone would want to disable that.  Seems pretty obviously unrealistic (as opposed to the subtle non-realism we get otherwise) to have an installation stay stone-still while every other ship is rocked by the shockwave.
--
Yo momma's so fat when she sits on a binary tree she flattens it to a linked list in constant time.

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
I'm still lost as to why anyone would want to disable that.

Because it allows you to do some rare and complicated stuff which would otherwise be broken if the ship moves an inch, and for which the small loss of realism is a small enough price to pay.

 

Offline Fury

  • The Curmudgeon
  • 213
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
I'm still lost as to why anyone would want to disable that.
in The Blade Itself, where players could ram their warship into the Arcadia and push it around, or hook it on the Karuna's spinny bit and flip it around like a gigantic paddle of death, shredding enemy corvettes.
Wasn't good enough a reason to you?

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
Battuta, can you Mantis this?

 

Offline Black Wolf

  • Twisted Infinities
  • Global Moderator
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
I'm still lost as to why anyone would want to disable that.  Seems pretty obviously unrealistic (as opposed to the subtle non-realism we get otherwise) to have an installation stay stone-still while every other ship is rocked by the shockwave.

I asked Goober to add it primarily for the modular construction kit. At the time, I was sill using it to make massive great big structures (I've since stopped doing that because of the performance impact and use it for other things mainly now, but the point holds). One of the consequences of that was that it stressed the crap out of FS's docking system to have a few dozen pieces all docked together. Even just sitting there it would often vibrate or do other weirdness, and if it took a bump or a shockwave, the engine just had no idea what to do. Quite often the whole structure would thrash about in crazy ways, changing orientations of individual pieces and just being generally unpleasant.

So, the solution I came up with was to have everything placed in FRED using the docking and then, at time=0 in the mission, simply jettison-cargo everything so it was just floating in space. This, however, presented other problems with shockwaves and bumps, notably that the individual pieces could move independently, making the structure susceptible to just floating apart whenever it was bumped. In part, that could be solved with high mass values, but that added additional weirdness associated with player/AI collisions and was always a nasty hack. The "Does not move" checkbox and associated immobility sexps were (and remain) the cleanest solution to the problem.

The other factor, of course, is that we have always had some crazy talented FREDders in the community, who, ever since retail, have been taking features designed for one purpose and twisting them around, reusing them in ways in which they were never intended. Just because you can't think of a reason to have it, doesn't mean it's not there, I promise you that! :)
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
For the original problem have you tried sticking everything in the same collision group? I don't know if it would solve it but it's worth a try as it would actually be cleaner than setting immobile if it did work.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
I tried it, but unfortunately it leads to tanks getting blasted down through the terrain model and stuck underneath the world, which is bad for the mission. I have some events that try to maintain the tanks in a fixed altitude range but I'd rather not trust them.

 

Offline Kopachris

  • 28
  • It's Pythonic
    • Steam
    • Twitter
    • HLP QuoteDB
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
I'm still lost as to why anyone would want to disable that.
in The Blade Itself, where players could ram their warship into the Arcadia and push it around, or hook it on the Karuna's spinny bit and flip it around like a gigantic paddle of death, shredding enemy corvettes.
Wasn't good enough a reason to you?

No, that sounds awesome.

I'm still lost as to why anyone would want to disable that.  Seems pretty obviously unrealistic (as opposed to the subtle non-realism we get otherwise) to have an installation stay stone-still while every other ship is rocked by the shockwave.

I asked Goober to add it primarily for the modular construction kit. At the time, I was sill using it to make massive great big structures (I've since stopped doing that because of the performance impact and use it for other things mainly now, but the point holds). One of the consequences of that was that it stressed the crap out of FS's docking system to have a few dozen pieces all docked together. Even just sitting there it would often vibrate or do other weirdness, and if it took a bump or a shockwave, the engine just had no idea what to do. Quite often the whole structure would thrash about in crazy ways, changing orientations of individual pieces and just being generally unpleasant.

So, the solution I came up with was to have everything placed in FRED using the docking and then, at time=0 in the mission, simply jettison-cargo everything so it was just floating in space. This, however, presented other problems with shockwaves and bumps, notably that the individual pieces could move independently, making the structure susceptible to just floating apart whenever it was bumped. In part, that could be solved with high mass values, but that added additional weirdness associated with player/AI collisions and was always a nasty hack. The "Does not move" checkbox and associated immobility sexps were (and remain) the cleanest solution to the problem.

The other factor, of course, is that we have always had some crazy talented FREDders in the community, who, ever since retail, have been taking features designed for one purpose and twisting them around, reusing them in ways in which they were never intended. Just because you can't think of a reason to have it, doesn't mean it's not there, I promise you that! :)

Okay, that's a good reason.
--
Yo momma's so fat when she sits on a binary tree she flattens it to a linked list in constant time.

  

Offline 0rph3u5

  • 211
  • Someone should label the Future: Assembly Required
    • Steam
    • Twitter
Re: Interesting quirk with set-immobile and AI aiming (useful for tanks!)
(we should really get a sexp that returns a ship's current orders)

Using a String variable as a work around

Forget I spoke, not feasable...
"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

==================

"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

"...because they are not Dragons."