Author Topic: AI, repeat events and creating a toggle effect  (Read 1992 times)

0 Members and 1 Guest are viewing this topic.

Offline diamondgeezer

AI, repeat events and creating a toggle effect
'Lo again peeps. So I'm having all kinds of fun with the new stuff in FREDO, but something is still beating my brain.

I'm trying to use the player_use_ai function to bodge an automatic landing for Alpha 1. Now, a simple press-a-key-and-you-land kind of scenario seems to work just fine. But I'm trying to build in an option for the player to disengage the AI and retake control... just in case he/she feels they want to fly around a bit longer admiring their handiwork, or whatever.

My initial attempt was to have one SEXP adding the use-ai command when a key was pressed, with a repeat count of 999, and another with the not-use-ai version, again repeating... in tests, this simply makes my fighter do cartwheels when I use the disengage bit.

I think repeats are not my friend here. I've just discovered the new bits like every-time and such, but not convinced they're right for me. What I really want is a toggle-type feature, where you can flip a switch on and off. Is there any way to call up the last key pressed? Or any hackey simulation of that?

Strangely, despite the huge demand for this kind of auto-landing back in the day, there doesn't seem to be a thread on this subject...

DG

 

Offline Axem

  • 211
Re: AI, repeat events and creating a toggle effect
After a few minutes of tinkering, I've made a test mission that does what you describe. I use variables and every-times to check what the player's ship should be doing when he presses the auto landing key (in my mission I used ALT-J).

everytime autoLand is 0 and the player presses ALT-J, autoLand gets set to 1.
everytime autoLand is 1, the ship goes to AI control and gets an order to fly the waypoint into the hangar. autoLand also gets set 2 right after so this won't trigger every frame.
everytime autoLand is 2 and the player presses ALT-J, the ship goes back to player control and autoLand resets to 0 so the cycle can begin anew.

Here's a link to my mission if you want to take a look.
http://www.axemspace.com/files/misc/_autolanding.fs2

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: AI, repeat events and creating a toggle effect
I'm still not entirely sure the 1 key works properly with repearing events. If you have problems try switching to something like G and see if that solves it.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline CP5670

  • Dr. Evil
  • Global Moderator
  • 212
Re: AI, repeat events and creating a toggle effect
If you're referring to the multiplayer messaging key, it works fine. I've used it that way in a couple of missions, with a pair of every-time events.

 

Offline diamondgeezer

Re: AI, repeat events and creating a toggle effect
Thanks Axem, I'll take that apart and have a look.

Had to check your profile to make sure you weren't Tiara there ;)

 

Offline Turey

  • Installer dude
  • 211
  • The diminutive form of Turambar.
    • FreeSpace Open Installer Homepage
Re: AI, repeat events and creating a toggle effect
Had to check your profile to make sure you weren't Tiara there ;)

 :wtf: You disturb me.

That's not necessarily a bad thing though.  :)
Creator of the FreeSpace Open Installer.
"Calm. The ****. Down." -Taristin
why would an SCP error be considered as news? :wtf: *smacks Cobra*It's a feature.

  

Offline diamondgeezer

Re: AI, repeat events and creating a toggle effect
Quote from: an0n
DG, you scare me with your oddness

:)

OK, so everything now seems to be more or less peachy... but I must profess my dislike of fighters and bombers entering the landing pattern at any old angle of roll. This happens with AI fighters, my own under AI control, the lot. I was wondering if there was a method of maybe rolling myself 'upright', parallel to a landing strip of known location and orientation, using the existing coordinate manipulation SEXPs or if this is a job for the lovely SCP chaps...
« Last Edit: March 08, 2007, 03:33:36 pm by diamondgeezer »