Author Topic: What is a good way to make a ship dock with many cargo in succession?  (Read 1582 times)

0 Members and 1 Guest are viewing this topic.

Offline PIe

  • 28
  • GTVA POLICE
    • freespace3.com
What is a good way to make a ship dock with many cargo in succession?
I have a transport that I want to dock with ten cargo containers, then jump out when it has docked with everything that hasn't been destroyed.  I could set up nine different events, checking whether they've been docked for the requisite amount of time, ordering the transport to undock, then in the next event, which is triggered when they are undocked, ordering it to dock with the next ship.
However, that's seems unnecessary.  I'm looking for a shorter, neater way to do this, but currently the transport, which has initial orders to dock with the first one, docks and undocks from that correctly, but then has no more orders and just sits there doing nothing.  I keep track of the how many have been docked with and how many have been destroyed, and when their sum equals 10, the transport jumps out.
Also, do I need to invalidate anything that's destroyed from the list of potential dockees?  I just realized that could be a problem.
Screenshots of the relevant events are attached.  Thanks.

[attachment stolen by Russian hackers]
[6:23 PM] PIe: why do I have the feeling that I shouldn't be able to give orders to 22nd armored hq
[6:24 PM] Axem: 22nd armored hq, i order you to get me a cup of coffee
[6:24 PM] PIe: and donuts
[6:24 PM] PIe: BECAUSE THIS IS THE GTVA POLICE
[6:25 PM] Axem: :O
[6:25 PM] Axem: am i under arrest
[6:26 PM] [`_`]/: no, just please step out of the myrmidon
[6:26 PM] [`_`]/: you have so much to fred for

[9:50 PM] Sottises: wait did you do vassago's verge?
[9:50 PM] Sottises: .. dirge?
[9:50 PM] Axem: yes
[9:50 PM] Sottises: ohh
[9:50 PM] Sottises: well I have that and JAD too
[9:50 PM] Axem: :)
[9:50 PM] Sottises: what a contrast of themes lmao
[9:50 PM] Axem: isnt it
[9:51 PM] Axem: super grimdark thriller about unknowable alien intelligence and over the top colorful action about friendship
[9:51 PM] PIe: jad is grimdark???
[9:51 PM] Axem: :skull:

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: What is a good way to make a ship dock with many cargo in succession?
I can't see anything actually wrong so the first thing I'd do if I were you would be to use the event logging options. Set them to true for all 4 events and then post the event.log on here. That will really help me figure out what is going on when the mission runs.

I wouldn't worry about not invalidating any cargo containers that have been destroyed. Simply add an event that triggers "lambda select docking target" up to 10 times if nextDockee is destroyed. This also saves you from problems if that container is destroyed while it is docked. Yes the ship will get orders to dock with a container that is destroyed but it will at worst spend a few seconds looking for a container that isn't destroyed before moving on.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: What is a good way to make a ship dock with many cargo in succession?
Karajorma is right about there being wrong with having 10 events to facilitate the chain.

While your version with the use of variables is good, maybe something else could help you:
You see you can add conditionals under the intial one (see attachment) to make the freighter skip destoryed containers.

[attachment stolen by Russian hackers]
"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

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

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"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

"...because they are not Dragons."

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: What is a good way to make a ship dock with many cargo in succession?
I think PIe is on the right track. I think there's just some minor flaw which is preventing the whole thing from working.



To be honest though, after using them in Diaspora R2, I'd do the whole thing with SEXP containers rather than variables and argument lists. Unfortunately no one else really has that option yet.  :nervous:
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline PIe

  • 28
  • GTVA POLICE
    • freespace3.com
Re: What is a good way to make a ship dock with many cargo in succession?
For some reason, I'm not getting an event.log though I'm following the wiki instructions.  I am looking in AppData.
Just to make sure, flagged events should look like this:
Code: [Select]
$Formula: ( when
   ;stuff
)
+Name: sample
+Repeat Count: 99999999
+Interval: 1
+Event Log Flags: ( "true" )
[6:23 PM] PIe: why do I have the feeling that I shouldn't be able to give orders to 22nd armored hq
[6:24 PM] Axem: 22nd armored hq, i order you to get me a cup of coffee
[6:24 PM] PIe: and donuts
[6:24 PM] PIe: BECAUSE THIS IS THE GTVA POLICE
[6:25 PM] Axem: :O
[6:25 PM] Axem: am i under arrest
[6:26 PM] [`_`]/: no, just please step out of the myrmidon
[6:26 PM] [`_`]/: you have so much to fred for

[9:50 PM] Sottises: wait did you do vassago's verge?
[9:50 PM] Sottises: .. dirge?
[9:50 PM] Axem: yes
[9:50 PM] Sottises: ohh
[9:50 PM] Sottises: well I have that and JAD too
[9:50 PM] Axem: :)
[9:50 PM] Sottises: what a contrast of themes lmao
[9:50 PM] Axem: isnt it
[9:51 PM] Axem: super grimdark thriller about unknowable alien intelligence and over the top colorful action about friendship
[9:51 PM] PIe: jad is grimdark???
[9:51 PM] Axem: :skull:

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: What is a good way to make a ship dock with many cargo in succession?
It should be appearing in %appdata%\HardLightProductions\FreeSpaceOpen\YourModName\data.

You should always get an event.log generated even if you haven't selected any events because the first thing it writes is the name of the last mission you loaded.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline PIe

  • 28
  • GTVA POLICE
    • freespace3.com
Re: What is a good way to make a ship dock with many cargo in succession?
I wasn't looking in the mod folder.

[attachment stolen by Russian hackers]
[6:23 PM] PIe: why do I have the feeling that I shouldn't be able to give orders to 22nd armored hq
[6:24 PM] Axem: 22nd armored hq, i order you to get me a cup of coffee
[6:24 PM] PIe: and donuts
[6:24 PM] PIe: BECAUSE THIS IS THE GTVA POLICE
[6:25 PM] Axem: :O
[6:25 PM] Axem: am i under arrest
[6:26 PM] [`_`]/: no, just please step out of the myrmidon
[6:26 PM] [`_`]/: you have so much to fred for

[9:50 PM] Sottises: wait did you do vassago's verge?
[9:50 PM] Sottises: .. dirge?
[9:50 PM] Axem: yes
[9:50 PM] Sottises: ohh
[9:50 PM] Sottises: well I have that and JAD too
[9:50 PM] Axem: :)
[9:50 PM] Sottises: what a contrast of themes lmao
[9:50 PM] Axem: isnt it
[9:51 PM] Axem: super grimdark thriller about unknowable alien intelligence and over the top colorful action about friendship
[9:51 PM] PIe: jad is grimdark???
[9:51 PM] Axem: :skull:

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: What is a good way to make a ship dock with many cargo in succession?
I see the problem now. The has-docked-delay SEXP returns ALWAYS TRUE not TRUE. What that means is that after the first time it evaluates to true, it will never evaluate to false again, even after you change the variable and are now dealing with a new instance of docking.

Basically this is what the every-time SEXP was meant to deal with. Changing from when to every-time should fix your problem, but you will need to change any SEXPs that check if an event using every-time has come true as they never will. 
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: What is a good way to make a ship dock with many cargo in succession?
If you are able to use post-3.8 builds, I added an is-docked sexp that will avoid this problem.  It checks the current status of the ships, rather than the mission log.

 

Offline PIe

  • 28
  • GTVA POLICE
    • freespace3.com
Re: What is a good way to make a ship dock with many cargo in succession?
If you are able to use post-3.8 builds, I added an is-docked sexp that will avoid this problem.  It checks the current status of the ships, rather than the mission log.
Unfortunately not, though I really wish I could.
I got it working; thanks a lot everyone.
Edit:  I guess I should post what works, in case anyone else has this question.
Code: [Select]
$Formula: ( every-time
   ( and
      ( has-docked-delay
         "Lambda 1"
         "@nextDockee[TC 2 1]"
         1
         @timeDocked[13]
      )
      ( = @docked[1] 1 )
      ( = @readyToDock[0] 0 )
   )
   ( modify-variable @readyToDock[0] 1 )
   ( modify-variable @docked[1] 0 )
   ( add-goal
      "Lambda 1"
      ( ai-undock 89 )
   )
   ( ship-invulnerable
      "@nextDockee[TC 2 1]"
   )
)
+Name: lambda undock trigger
+Repeat Count: 99999999
+Interval: 1

$Formula: ( every-time-argument
   ( random-multiple-of
      "VC 3 1"
      "TC 2 2"
      "VC 3 2"
      "TC 2 3"
      "VC 3 3"
      "TC 2 4"
      "TC 2 5"
      "VC 3 4"
      "VC 3 5"
   )
   ( and
      ( = @readyToDock[0] 1 )
      ( = @docked[1] 0 )
      ( has-undocked-delay
         "Lambda 1"
         "@nextDockee[TC 2 1]"
         1
         0
      )
   )
   ( modify-variable
      "@nextDockee[TC 2 1]"
      "<argument>"
   )
   ( modify-variable
      @timeDocked[13]
      ( rand-multiple 10 15 )
   )
   ( modify-variable
      @numCargoRescued[0]
      ( + @numCargoRescued[0] 1 )
   )
   ( invalidate-argument "<argument>" )
   ( clear-goals "Lambda 1" )
   ( add-goal
      "Lambda 1"
      ( ai-dock
         "@nextDockee[TC 2 1]"
         "cargo dock"
         "cargo dock"
         89
      )
   )
   ( modify-variable @readyToDock[0] 0 )
)
+Name: lambda select docking target
+Repeat Count: 99999999
+Interval: 1

$Formula: ( every-time
   ( and
      ( has-docked-delay
         "Lambda 1"
         "@nextDockee[TC 2 1]"
         1
         0
      )
      ( = @docked[1] 0 )
      ( = @readyToDock[0] 0 )
   )
   ( modify-variable @docked[1] 1 )
)
+Name: mark lambda docked
+Repeat Count: 99999999
+Interval: 1
« Last Edit: September 09, 2017, 01:09:00 am by PIe »
[6:23 PM] PIe: why do I have the feeling that I shouldn't be able to give orders to 22nd armored hq
[6:24 PM] Axem: 22nd armored hq, i order you to get me a cup of coffee
[6:24 PM] PIe: and donuts
[6:24 PM] PIe: BECAUSE THIS IS THE GTVA POLICE
[6:25 PM] Axem: :O
[6:25 PM] Axem: am i under arrest
[6:26 PM] [`_`]/: no, just please step out of the myrmidon
[6:26 PM] [`_`]/: you have so much to fred for

[9:50 PM] Sottises: wait did you do vassago's verge?
[9:50 PM] Sottises: .. dirge?
[9:50 PM] Axem: yes
[9:50 PM] Sottises: ohh
[9:50 PM] Sottises: well I have that and JAD too
[9:50 PM] Axem: :)
[9:50 PM] Sottises: what a contrast of themes lmao
[9:50 PM] Axem: isnt it
[9:51 PM] Axem: super grimdark thriller about unknowable alien intelligence and over the top colorful action about friendship
[9:51 PM] PIe: jad is grimdark???
[9:51 PM] Axem: :skull: