[X3LU] Quick Wings 1.10

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

[X3LU] Quick Wings 1.10

Post by kaistern » Sat, 8. Nov 14, 12:13

:arrow:Background:

With the improved wing functions in LU I have found myself relying more and more on wings. However the 10-50 button clicks (count them, include the arrow keys) to give orders to a wing in the middle of a fight is not efficiant. I wanted better. Then I saw Cycrow's Wing Hotkeys. This gave me the idea. It was close to what I wanted but not quite there, and I was not sure if it would be compatible with LU. Because of this I wrote my own version for LU.

:arrow:Installation:

Download Drop the contents of the scripts folder into your addon/scripts of your game files.

:arrow:What it does:

Quick Wings adds 12 hotkeys. Eight are selection hotkeys for each wing and four are command hotkeys. When you press one of the selection hotkeys it selects the wing without changing your target, then you press one of the command hotkeys

1: Action: If you have an enemy targeted the wing will attack, if you have a non-enemy targeted the wing will protect it. If you do not have a target the wing will protect you.

2: Shield attack: Same as the Action hotkey except it preforms a shield attack against a target enemy.

3: Protect me: nuff' said.

4: Dock: If a valid dock is selected the wing will dock, if not it will return to it's homebase.

And that's all there is to it.

:arrow:Uninstall:

In case you need to uninstall Quick Wings a uninstall script is included. To uninstall run the uninstall script (qw.uninstall.xml) and then exit the game and uninstall the 14 scripts with "qw" in their names. Do not load or start a game after running the uninstall script or you will have to run it again.


ENJOY!!! And please give a shout out if you download, just so I know people are enjoying my work. Suggestions, comments, and hints appreciated!


Thank you Joubarbe and Cycrow for being my mentors in this, Litcube for.... well everything, just everything; Cycrow for his amazing guide that really helped me understand scripting, and the writers of the MSCI handbook which is invaluable.
Last edited by kaistern on Thu, 27. Nov 14, 22:51, edited 20 times in total.

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sat, 8. Nov 14, 12:14

Future Goals and Ideas:
3: I want an error message written to your player log in case of error(I don't think this will be a problem except for the dock hotkey which must either have a vaild target or a homebase).
4 :Make the scrips prettier for Joubarbe and Cycrow. (For the life of me I can get this to work :-( )
5: Add refuel command for Joubarbe. This might be hard.
6: Add ability to add/remove target from wing. ->Hector0x
7: Passive decoy mode. Not sure if this is even possible but I'll look into it. ->Hector0x
8: I want wings to respect MCLL missile ROE. This might be hard.

11/27/2014: Version 1.1
-----Betty now talks
-----Uninstall script now included (hope you never need it)
11/13/2014: Released version 1.0
Last edited by kaistern on Fri, 28. Nov 14, 12:48, edited 4 times in total.
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sat, 8. Nov 14, 13:14

In short, you need to call one of the !wing.cmd....xml scripts on a wing's ship.

Code: Select all

START [THIS] -> call script '!wing.cmd.attack.std' : .....
Good luck :)

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sat, 8. Nov 14, 13:31

Joubarbe wrote:In short, you need to call one of the !wing.cmd....xml scripts on a wing's ship.

Code: Select all

START [THIS] -> call script '!wing.cmd.attack.std' : .....
Good luck :)
Thanks! I understand how to order the attack, what I do not understand is how to make one button figure out which of 6 wings to give the order to based on a previous button click....

Senario: you have 3 wings, 2 enemy m7s, a swarm of enemy fighters, and a friendly TS to prtect
Target enemy m7: press button 1 to select blue wing, then button 11 to order the attack.
Change target to the TS: button 2 to select select red wing, button 12 to order red wing to escort:protect the TS.
Change target to the other m7, button 3 to select green wing, button 11 to launch attack.

m7s are now dead

Target TS: button 4 to select all wings, button 12 to order all wings to escort:protect the TS


I can't actually target the wing or I lose most of the functionality I want.

but I don't know how to make the wing selection buttons tell the command buttons which wing to give the order.
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sat, 8. Nov 14, 13:48

You cannot give an order to a wing directly with the command I specified on your other thread. A wing is not a ship and only ships can take orders.

If I'm not mistaken, you have to use this :

Code: Select all

get flight wing ship array: wing=$Wing
This should return an array with all the ship of the predefined wing. I guess you can do something like that :

Code: Select all

$Wing = get predefined wing: wing=[Wing.Blue]
$Wing.Ships = get flight wing ship array: wing=$Wing
$Ship = $Wing.Ships[0]
Then give the wing order to this single ship. Some tests are probably needed because I don't use these commands often.

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sat, 8. Nov 14, 14:04

ROFL joubarbe you and me are having a communication break down :D

I want ONE button the gives orders to different wings depending on your previous button click. What I need to know is how to tell the script which wing to select. What you have given me (i think if i understand correctly) will allow me to give the order to ONLY blue wing however I want that same button to be able to select one of several wings(blue, red, green, rainbow, or all of them) depending on another hotkey you pushed and issue the command. The lines you gave me (I think) will be useful in the wing selection hotkeys, but they are only half of that hotkey, I also need a way for the 6 or so wing selection hotkeys to tell the ONE action hotkey which wing to give orders to.

6 hotkeys to choose which wing does the action (wing selection hotkeys)

1 hotkey to execute the action (command hotkey)

but I don't know how to make the 6 selection hotkeys tell the 1 command hotkey which wing to select.


If you understand all of this and the communication error is on my end then I don't understand how that will communicate between the 2 kinds of hotkey
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sat, 8. Nov 14, 14:20

I may have figure it out.... more later :D
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sat, 8. Nov 14, 14:22

kaistern wrote: 6 hotkeys to choose which wing does the action (wing selection hotkeys)

1 hotkey to execute the action (command hotkey)
Then how do you set the action to execute ? How will they know what to do between Attack, Dock or Protect ?

Anyway, my code is still relevant, I think you didn't get that [Wing.Blue] can be a variable.

Code: Select all

$PredefinedWing = get global variable 'ModPrefix_SelectedWing'
$Wing = get predefined wing: wing=$PredefinedWing
The PredefinedWing could be changed when you press one of the 6 hotkeys.

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sat, 8. Nov 14, 15:14

I understood that :D

Ok I am currently trying to get 2 scripts to communicate. What I want is the first one to write a to a text file, then the second one to read the text file, and if a then write not fail, else write fail

first one is easy *I think*

Code: Select all

write to log file #1 append=1 value='a'
the second on is

Code: Select all

001 $b = read text: page=1 id=1
002 skip if $a == 'a' 
003 write to player logbook 'fail'
004
005 write to player logbook 'not fail'
and I get fail

I think the problem is in the "==" I used <RetVar/IF><Expression> from the general commands but I don't know if that is right and i could find a better on or the option "->"

(working on getting x-studio up)
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sat, 8. Nov 14, 17:12

Why the hell are you trying to do that ? :)

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 00:03

still trying to make the 2 scripts talk to each other. The current idea is if the wing select script writes something to a text file and then the command key can read it and know what to do based on that.

ie bluewing select script writes 'blue' to a text file. action key reads 'blue' from the text file and then gives the action to blue wing. press redwing select script and it writes 'red' to a textfile then action key reads red and gives the action command to red wing

the only concern I have is that when it wrtes to the text document it MUST overwrite the previous one..... and i need to find which script to use to read and write... the ones I have now are not working
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sun, 9. Nov 14, 00:13

And that's why they created.... Arguments ! :)

... and return values.

A script that you call can return a value. You can pass informations to other scripts using arguments and receive ones with return values.

Take one of my library call :

Code: Select all

$Objective.Sector = [THIS]-> call script 'lib.joubarbe.getrandomsector' : startsector=$Mission.Sector minjumps=1 maxjumps=2 owner=$Mission.Employer.Race onlyknownsectors=[FALSE] securitylevel=0
Open the script : at the end you'll see :

Code: Select all

return $Sector
That's the return value. $Objective.Sector stores this to use it in its own script.

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 02:51

I have the next two days off so I'll have to open some of your stuff up and see if I can figure out auguments lol

I tried to open up Cycrow's wing commands but didn't work, it tried it in the game, in IE, chrome, microsoft XML viewer, and then x-studio but they all gave me an error message. I ran out of time before I could explore further but I am hoping that it is something simple like I forgot to unzip it :P maybe a bad download though

I am thinking that tomorrow I am going to work on making a teaser mod to showcase the functionality of the mod. What I am thinking should be easy, but it will only work with one wing. But it will be cool to release something that shows what I am trying to do.
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 06:17

I reread through everything and
Joubarbe wrote:Anyway, my code is still relevant, I think you didn't get that [Wing.Blue] can be a variable.

Code: Select all

$PredefinedWing = get global variable 'ModPrefix_SelectedWing'
$Wing = get predefined wing: wing=$PredefinedWing
The PredefinedWing could be changed when you press one of the 6 hotkeys.
I didn't understand what a global variable was on the first pass through but I have a better understanding now and i feel like I just got hit by a clue by four...

this solves everything.....

THANKS JOUBARBE!!!!!!!!!
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 07:00

ok here is what I want to test tommorrow and if it works use it as a teaser while i finish up the rest. See if it looks correct.

This should only add one hotkey that allows you to give orders to blue wing without use of windows. It's effect changes based on your target, if it's an enemy it will attack, if it is not an enemy it will protect it, if it is anything except a ship or station the wing will instead protect your ship.

Note: I dont have access to anything but the forums right now so I'll have to modify the script being called part of the action key so that it targets the correct scripts.

First to register the hotkey...

Code: Select all

setup.qw.register
001 $key = get global variable: name='qw.baction'
002 if not $key ...
003    $key= register hotkey 'Blue wing action command' to call script qw.baction
004    set global vairiable: name='qw.baction' value=$key
005 end
and then for the command itself

Code: Select all

qw.baction
001 $target = get player tracking aim
002 $Wing = get predefined wing: wing=[Wing.Blue] 
003 $Wing.Ships = get flight wing ship array: wing=$Wing 
004 $Ship = $Wing.Ships[0]
005 If $target = ship or station and enemy 
006   $ship -> call script 'attack my target'
007
008 Else if $target = ship or station and not enemy
009   $ship -> call script 'protect my target'
010
011 Else 
012   $ship -> call script 'protect me'
013 end
and to uninstall

Code: Select all

qw.unregister
001 $key = get global variable: name= 'qw.baction'
002 if $key ...
003  unregister hotkey $key
004 set global variable: name='qw.baction value=null
005 end
if this all looks good then when I get home and after i get some rest i'll test it out, clean it up and upload it for your enjoyment :D

Hopefully if this all works i'll finish up the rest of what I want and release the entire mod later this week

(Big thanks to Joubarbe for keeping me in line ;), and to cycrow for his guide, and whoever wrote the MSCI handbook)
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 08:28

and while my brain is being productive...

this is for the actual mod not the lite version I will work on tomorrow. I think that the first one will create the hotkeys, the second one will make a flag, and the third one will read the flag and give the order to the appropriate wing

with this one I would just add more to it for each hotkey

Code: Select all

setup.qw.register 
001 $blue = get global variable: name='qw.blue' 
002 if not $blue ... 
003    $blue= register hotkey 'Select Blue wing' to call script qw.blue 
004    set global vairiable: name='wc.baction' value=$blue
005 end 

i'll need one of these for each wing

Code: Select all

qw.blue
001 set global variable: name= 'qw_flag' value='blue'
002 end
and I THINK this will bring it all together.

Code: Select all

qw.action
001 $target = get player tracking aim
002 $wing = get global variable 'qw_flag' 
003 if $wing = 'blue'
004    $Wing = get predefined wing: wing=[Wing.Blue] 
005    $Wing.Ships = get flight wing ship array: wing=$Wing 
006    $Ship = $Wing.Ships[0]
       (at this point I could add several 'else if' for each additional wing, right?)
007 end 
008 If $target = ship or station and enemy 
009   $ship -> call script 'attack my target' 
010 
011 Else if $target = ship or station and not enemy 
012   $ship -> call script 'protect my target' 
013 
014 Else 
015   $ship -> call script 'protect me' 
016 end 
I still want to add 2 more command hotkeys (one to protect me only, one to dock) but they will follow a similar format to the action hotkey
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

User avatar
Joubarbe
Posts: 4796
Joined: Tue, 31. Oct 06, 12:11
xr

Post by Joubarbe » Sun, 9. Nov 14, 09:36

1/ Use X-Studio.

2/ Don't be hasty to release something half finished. We want the full thing :)

3/ Just one thing : don't use an intermediary "blue" string in your global variable. Make it "[Wing.Blue]". Then you just have to do that :

Code: Select all

$Wing = get global variable name: 'qw_flag'
$Wing = get predefined wing: wing=$Wing
Then you don't have to do a check for every wing.

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Sun, 9. Nov 14, 09:41

Joubarbe wrote:1/ Use X-Studio.

2/ Don't be hasty to release something half finished. We want the full thing :)

3/ Just one thing : don't use an intermediary "blue" string in your global variable. Make it "[Wing.Blue]". Then you just have to do that :

Code: Select all

$Wing = get global variable name: 'qw_flag'
$Wing = get predefined wing: wing=$Wing
Then you don't have to do a check for every wing.
1) I downloaded it but I didn't get a chance to play with it before I had to leave the house :) i plan to use it though.

2)Ok ok, I think I have the final product figured out anyhow so the lite version really isn't nessary and is really just a waste of time.

3)That makes a lot of since actually.

added:oh wow that will cut out a LOT of programming :D thank you sir!
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

kaistern
Posts: 443
Joined: Mon, 30. Jun 14, 13:29
x3ap

Post by kaistern » Wed, 12. Nov 14, 00:50

Success! well sort of... I managed to order A ship from blue wing to attack my target.... which wasn't very usefull as he left his friends behind and decided to walk through 5 or 6 sectors to get to me instead of jumping.... BUT IT'S PROGRESS!!!

Code: Select all

$target = get player tracking aim
$flag = get global variable: name='qw_flag'
$Wing = get predefined wing: wing=$flag
$wing.ships = get flight wing ship array: wing=$Wing
$ship = $wing.ships[0]
skip if $ship-> exists
write to player logbook 'Error: No wing selected'
skip if $ship-> exists
return null
if $target-> is [PLAYERSHIP] a enemy
START $ship-> call script '!wing.cmd.attack.std' : WING=$Wing target=$target
else if $target-> is [PLAYERSHIP] a friend
START $ship-> call script '!wing.cmd.protect.std' : WING=$target target=[FALSE]
else
START $ship-> call script '!wing.cmd.protect.std' : argument1=[PLAYERSHIP] argument2=[FALSE]
end
return null 
I didn't get much time to work on this this weekend(yeah my weekend this week was sunday-monday) but my work week is only two days long and then I have three off. While i'm away from home I'll read more on arrays and chapter 7 of the MSCI
[ external image ]
Running LU 1.4.7 + XM-O 1.0 + Quick Wings 1.0
Rise of Phanon DiD LUV
Wrath of the Hive DiD XM-O
Try my script: Quick Wings for better wing control in LU!

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22201
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Wed, 12. Nov 14, 09:53

The main problem here is that unlike ship commands, wing commands are actually global scripts.

as you are running the command a ship, what happens is that the wing command then issues the command to that ship with overrides the existing script.

Which means once the first ship gets its command, the wing script is essentially terminated so no other ships will move.

change the $ship -> call script to $null -> call script

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”