Author Topic: Event triggered by distance and key-pressed in sequence.  (Read 1497 times)

0 Members and 1 Guest are viewing this topic.

Event triggered by distance and key-pressed in sequence.
I'm using FRED2_Open 3.6.9 and I'm trying to create a multiplayer mission for Beyond the Red Line.

What I want to happen:
As soon as a player ship gets within 500 m of an AI ship, that player must press a key to tell the AI ship to follow that player, in essence creating a master/slave link. But if the player gets outside of 500 m, the link is broken and the player would have to get within 500 of the target and press the key again to reestablish the link (and be able to do so again and again).

What I've tried:
Since we don't have shields or energy settings in btrl, I used one of those keys in key-pressed, in this case "Home."

"Link Up"
when
.and-in-sequence
..<
...distance
....player ship
....AI ship
....500
..key-pressed
...home
.clear goals
..AI ship
.add goals
..stay-near-ship
...player ship

"Link Broken"
when
.not
..<
...distance (etc)
.clear goals
..AI ship
.add goals
..AI ship
...stay-near-ship
....player ship

Very high repeat count for both.
Note: This was done in a single player test scenario. I have not yet tried this in the multiplayer mission.

1) When I tested it, I tried pressing Home within range. That worked. "Link Broken" worked as well. However, after breaking link, I seem to only need to get within range to reestablish the link. I no longer have to press Home again. Not what I wanted.

Restarted the mission for another test. Pressed Home at the beginning while still outside of range. This time, when i got within range, the AI ship did not respond at all.

2) Next, I set the repeat count to one and replaced "when" with "every-time." This time, the only difference is I'm able to trigger the "Link Up" event even if I press Home outside of range. But as before, I only need to press Home that one time afterwich I can reestablish link just by being within range. Again, not what I want to happen.

3) Chaining a distance event with a key-pressed event didn't work the way I wanted it to either.

4) I also tried using a YES/NO string variable. I divided the Link Up event into two separate events. The first checks the distance and modifies the variable to YES (NO being the default value). The second event checks if the variable is YES and if key is pressed in sequence. Then it clears AI goals and adds the stay-near-ship goal. I added a modify-variable in "Link Broken" to change the variable back to NO. The result is exactly the same as before with one Link Up event using "when" as in (1) and "every-time" as in (2).

How should I approach this problem (if it's even possible)?

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Event triggered by distance and key-pressed in sequence.
:welcomesilver:

Basically you should make use of key-reset and/or key-reset-multiple. They both tell FreeSpace to "reset" key-pressed so that it can be activated in a second moment. When key-pressed becomes true, in fact, it remains true for the rest of the mission :)

EDIT: You can find more info about key-reset in The FAQTM, a link to it can be found in my signature :)
« Last Edit: December 26, 2007, 05:40:48 pm by Mobius »
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito

 
Re: Event triggered by distance and key-pressed in sequence.
Oh gosh, thank you! That helped. Made me feel like an idiot looking at the things I tried.

  

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Event triggered by distance and key-pressed in sequence.
No problem, I can ensure you that most FREDders wouldn't have been able to find a solution to your problem ;)

Whenever you have a problem...ask :)
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito