Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
ryleyra

Registered:
Posts: 2,492
Reply with quote  #1 
Artemis 2.6 introduces the set_comms_button command, but only allows you to specify a sideValue, it doesn't let you set a Comms button for a specific player ship. However, I have confirmed that it is possible to change sideValue for a given ship, add a Comms button, and reset sideValue back to the original side. The same persistence of Comms messages that causes them to be retained even after the message is sent also keeps the buttons on the screen.

In other words, this works:

 

Code:

<event name="Set Intrepid Side Value">

<if_timer_finished name="Set_Side_Value"/>

<if_variable name="Set_Side_Value" value="1" comparator="NOT"/>

<set_side_value name="Intrepid" value="3"/>

<set_variable name="Set_Side_Value" value="1"/>

<set_timer name="Create_Button" seconds="10"/>

</event>

<event name="Set Intrepid Comms Buttons">

<if_timer_finished name="Create_Button"/>

<if_variable name="Create_Button" value="1" comparator="NOT"/>

<set_comms_button text="Intrepid Only" sideValue="3"/>

<set_variable name="Create_Button" value="1"/>

<set_timer name="Reset_Side_Value" seconds="10"/>

</event>

<event name="Reset Intrepid Side Value">

<if_timer_finished name="Reset_Side_Value"/>

<if_variable name="Reset_Side_Value" value="1" comparator="NOT"/>

<set_side_value name="Intrepid" value="2"/>

<set_variable name="Reset_Side_Value" value="1"/>

</event>

 

All you have to do is start a timer called "Set_Side_Value" and the button "Intrepid Only" will be added to the Comms console for Intrepid, and only Intrepid.

There are a couple of caveats. First of all, the sideValue must be set before the Comms button is added. If you try to set it in the same event, it won't work. I used a 10 second timer for test purposes, but I see no reason why a 1 second timer wouldn't work in each case. All that is required is that the sideValue be set in a separate event.

The sideValue probably DOESN'T need to be reset back to 2 in a separate event. It probably can just be set after creating the buttons. I haven't tested that, though.

You can reuse the same sideValue to set the buttons for other ships as long as you don't try to set buttons for more than one ship at the same time. You should use a higher sideValue than the number of sides. I used 3 since there was only one side, 2, if you have sides 2 and 3, you should use 4, and so on. Note that sideValues usually start with 2 for players, side 1 is the enemy side. You COULD use side 1 for a player if there were no enemies, only neutrals that are allies to use and enemies to the other side(s).

If the Comms officer exits to the Console selection menu and returns, all the Comms buttons are cleared and you will have to rebuild them. Of course, this is true of Comms buttons in general. Putting the buttons on a timer to create them is probably a good idea since it gives Comms time to log in.

Note this means it is possible to make players switch sides in a script. This brings up a lot of possibilities for story ideas. Of course, enemies can switch sides too, but I was expecting that. I have not tested for any long term effects of the side switch, but I didn't see any in my quick test.
Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 1,759
Reply with quote  #2 
Thanks, Ryley! I have experimented with changing sidevalues of players, but had not considered this creative use. I'll give it a try ASAP.
__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
ryleyra

Registered:
Posts: 2,492
Reply with quote  #3 
I honestly wasn't sure it would work, but I was really hoping it would. As I said above, I'm still not entirely sure it will work as intended and there won't be any unexpected side effects.

I never actually tested to make sure the "if_comms_button" command catches clicks on that button, but I'm pretty optimistic that it will. If I'm guessing correctly, once the button is created, the script will respond to it whatever the side value.

Likewise, you should be able to destroy the "Intrepid Only" button by using the ship's CURRENT sideValue. You don't need to change it, and it isn't going to effect any other ships because no other ship will have the "Intrepid Only" button. It will just ignore it, just as if Comms had logged on late and missed creating that button.
Dave Thaler

Registered:
Posts: 304
Reply with quote  #4 
Nice find!  I will definitely be playing around with this idea.
Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 1,759
Reply with quote  #5 
I have been working with this for a few days. It does work but there are some caveats. Let's assume
AI enemies are side_value = 1
Players are side_value = 2
We push buttons to side_value = 3

  • The change of side value does not take place immediately. You need to wait at least one program main loop cycle. That means the fastest possible way to send out a single-ship button is to have the button deployed to side_value = 3 based on a variable. The variable and side_value =3 should be set later in the program stack. The variable should be detected, the button deployed, and side_value =2 should be set earlier in the program stack.
  • Even using the above procedure, in that split second with side_value =3 friendly AI ships and bases will try to fire at the ship receiving the button.
  • If you want several ships to have buttons that do the same thing, but you want to know which ship clicked the button, you need to give the buttons different names. For example, Artemis has [ACTIVATE CLOAK] while Intrepid has [ENGAGE CLOAK].

More to come . . .

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

Registered:
Posts: 985
Reply with quote  #6 
I've been pondering on this too and how to utilise it in the TSN Sandbox. I came up with the same issues - the time it takes to set, comms buttons with the same name and allies.

My idea was to set up all ships with a 'one-shot' button at the very beginning of the script - a deployable object for example. In our mod, we have satellite-looking objects that can be set at generic meshes, and it would be this kind of thing that we use. You could also have other one-shot functions set up for specific missions. Maybe you have a button to launch a probe, or activate a scan of some sort?

For the same name issue, you could just put a number at the beginning referring to the ship number, so using your example, you'd have: '1 Activate Cloak' on Artemis and '2 Activate Cloak' on Intrepid.

__________________
Captain Xavier Wise TSN Raven (BC-014)
Link to TSN RP Community website
Link to TSN Sandbox
Link to Blog
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.