Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
LawsonThompson

Registered:
Posts: 827
Reply with quote  #1 
I'm adding a feature to my GM script to detect when a player ship is docked for longer than 25 seconds or so. That seems to be a reasonable amount of time to send a nudge popup that "you can leave now!" We actually have novice crews sit for a full minute or two before asking the GM "how long does it take to fuel up?"

I might just add a manual command for the GM to send the nudge messages if I can't get this timing figured out. Does anyone have a snip that handles a "ship is docked at any station for longer than X" event?

So far I have this:

  • Start: set isDocked = 0.
  • Set a 1 second timer and reset it every time it expires.
  • For each base (4 of them), add a line to trigger if the 1 second timer expired and the ship is docked at base "X", set isDocked = 1.
  • If the 1 second timer has expired and isDocked = 1, set a 25 second timer, send messages to say "reload, please wait", and set isDocked = 2.
  • If the 25 second timer expires, set isDocked = 3 and send messages advising it's OK to leave any time.
  • Repeat the following for each base: If the 1 second timer has expired and ship is NOT docked at base "X", add 1 to the NotDockedCount.
  • If the 1 second timer expired and If NotDockedCount >= 4, then set isDocked = 0 and NotDockedCount = 0.
  • If the 1 second timer expired, reset it to 1 second.
I'm getting some odd results, like the NotDockedCount flips between 0 and 3 on a perfect 1 second "pulse", and isDocked flips between 1 and 0.



__________________
----
https://LTEBridge.com
Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 2,990
Reply with quote  #2 

If there are four bases and you are constantly counting the number of bases the players are not docked at, I think NotDockedCount = 3 will happen a lot.

I had a series of timers and variables for doing this in Havoc in the Hamak sector, but it was more complex since I wanted the players to stay docked for a longer time while the base installed a ramscoop, all the while pressuring the players to buy cigarettes and ice cream and such (lots of short timers and funny messages). If they undocked before installation was complete they would be punished with damage.

How about this:

In the Start block set DockedTimer = -1 sec (timer counting down toward negative infinity)

If DockedTimer < 0 check isDocked(base1)+isDocked(base2)+isDocked(base3)+isDocked(base4)

  • If that check = 1 then set DockedTimer = 25 sec (they just docked)

If DockedTimer > 0 check isDocked(base1)+isDocked(base2)+isDocked(base3)+isDocked(base4)

  • If that check = 0 then set a dockedTimer = -1 sec (they just undocked before timer expired)

If DockedTimer = 0 then send message "Hey boneheads, you can undock now."

  • also set dockedTimer = 20 sec (message will repeat every 20 seconds until they undock)
Of course the message only triggers at the moment the dockedTimer = exactly 0, but I *think* Artemis 2.8 timers do have that behavior. If that doesn't work you will need a more complex check for a tiny fraction above 0 seconds. You could use this concept for multiple player ships, but each will need its own timer.

I believe the timer can never reach 0 unless the players are still docked. If I am wrong you might need another isDocked check.

__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
LawsonThompson

Registered:
Posts: 827
Reply with quote  #3 
I think there's another solution, if I can read/store/compare ship values correctly. 

When docked, we expect to see:
  • energy increase up to 1000
  • damcon team member count increase
  • torpedo count increase
  • fighter count increase

So: on a 2 second timer tick while docked, check for an increase of any of those values.

If any of them increased, it's very likely you are still docked.

This gets to a "truthy" condition of "am I ready to leave yet?"

If none of them increased and energy is > 990 (allowing for the energy level bounce I see between 999 and 1000 when docked), I'd venture you're ready to leave and it's safe to pop up a message "Cleared to undock at your discretion" or such.

Not sure if this reduces the code complexity yet!


__________________
----
https://LTEBridge.com
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.