Command_turret?

The place to discuss scripting and game modifications for X³: Reunion.

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

asynd
Posts: 11
Joined: Thu, 4. Jan 07, 08:26
x3

Command_turret?

Post by asynd » Thu, 4. Jan 07, 08:50

first post ^^

im new to scripting but ive been looking through alot of the popular scripts that are on this site and i use alot of them too, my question is that i would like to make a script that automaticly sets the turrent command to - > attack all enemies. for all of the players m1 & m2 ships. is it even possible? so far when ive used the command COMMAND_TURRET_PROTECT but nothing happens, when set to attack all enemy the ship just starts cruising around if it had been given the order to attack enemies, rather than setting its turrets to that command :|

ive searched this forum but i havent been able to find out if anyones asked about this before sorry if it has been asked though

fud
Posts: 9837
Joined: Wed, 25. Jan 06, 14:26
x3

Post by fud » Thu, 4. Jan 07, 13:50

You have to use the set task comamand.


set task # command !turret.protect.ship (obviously not exactly the line, but it gives you the line to look for in the SE (in general commands))


# is the number of the turret. From memory, #1 is rear, etc.

asynd
Posts: 11
Joined: Thu, 4. Jan 07, 08:26
x3

Post by asynd » Thu, 4. Jan 07, 19:42

thanks for the reply, with your bit of insight I have come up with(not sure if its right)

@ START $ship -> call script "!turret.killenemies.std" : ?0=1,
@ START $ship -> call script "!turret.killenemies.std" : ?0=2,
@ START $ship -> call script "!turret.killenemies.std" : ?0=3,
@ START $ship -> call script "!turret.killenemies.std" : ?0=4,
@ START $ship -> call script "!turret.killenemies.std" : ?0=5,
@ START $ship -> call script "!turret.killenemies.std" : ?0=6,

in the script, the ship will start attacking any enemies, but ive noticed if more than one ship is created , they will just stop attacking. and if the ship is given any other order the ship just goes back to normal :/

also is there any way to set the actual command console>turret commands>set all turret commands> to attack all enemies? with one of these scripts, since thats what i was wanting to do originally.

fud
Posts: 9837
Joined: Wed, 25. Jan 06, 14:26
x3

Post by fud » Thu, 4. Jan 07, 20:06

I can't remember it exactly off the top of my head, but I can find it quickly, if I was home. :)


If someone else doesn't jump in, I can have it posted in a couple hours.

User avatar
moggy2
Posts: 5505
Joined: Wed, 6. Nov 02, 20:31
x3ap

Post by moggy2 » Thu, 4. Jan 07, 20:32

Code: Select all

@ START $ship -> call script "!turret.killenemies.std" :
will start the script !turret.killenemies.std in the ship's autopilot. Obviously that's not going to do much, and certainly wont affect any of the turrets on the ship.

to start the script on the rear turret of a Nova:

Code: Select all

$ship -> start task 1 with script "!turret.killenemies.std" and prio 0:...
for other turrets on ships with more than 1 turret change the task number to 2, 3, 4, 5, or 6.

fud
Posts: 9837
Joined: Wed, 25. Jan 06, 14:26
x3

Post by fud » Thu, 4. Jan 07, 20:41

See? There you go. :)

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

Post by Cycrow » Thu, 4. Jan 07, 20:42

adding on from moggy

Code: Select all

$turrets = get number of turrets
while $turrets
  $ship -> start task $turrets with script "!turret.killenemies.std"
  dec $turrets
end

fud
Posts: 9837
Joined: Wed, 25. Jan 06, 14:26
x3

Post by fud » Thu, 4. Jan 07, 20:51

Quick question about that:

Can you refer to the command with a variable?


ie:

Code: Select all

$turrets = get number of turrets
$cmd == '!turret.killenemies.std' 
while $turrets 
  $ship -> start task $turrets with script $cmd 
  dec $turrets 
end 

I can only assume, not. :)

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

Post by Cycrow » Thu, 4. Jan 07, 21:04

nope, unfortuatlly you cant do that, as anything that requires you to select a script, ie the call script or start task functions, will only display the list of scripts, you cant actually select a varible, so you wont even be able to enter that.

unless u edit the xml files directly of course, but then ur prolly jsut end up curropting the script

fud
Posts: 9837
Joined: Wed, 25. Jan 06, 14:26
x3

Post by fud » Thu, 4. Jan 07, 21:08

That's what I figured. Some things are just too good to be true I guess. :)

asynd
Posts: 11
Joined: Thu, 4. Jan 07, 08:26
x3

Post by asynd » Fri, 5. Jan 07, 05:53

thanks for the help ^^
thats exactly what i wanted to do

User avatar
Red Spot
Posts: 3461
Joined: Fri, 4. Feb 05, 13:44
x3

Post by Red Spot » Fri, 5. Jan 07, 06:13

Corrected the above code ....

Code: Select all

$turrets = get number of turrets
while $turrets > 1
  dec $turrets
  $ship -> start task $turrets with script "!turret.killenemies.std"
end


G

User avatar
moggy2
Posts: 5505
Joined: Wed, 6. Nov 02, 20:31
x3ap

Post by moggy2 » Fri, 5. Jan 07, 06:48

Cycrow's code is alright. Look where the dec is. ;)

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

Post by Cycrow » Fri, 5. Jan 07, 13:00

yeah if there is 6 turrets, then the tasks go from 1 to 6, not 0 to 5.

so what your doing, is getting the number of turrets, which would be 6, then decrementing it to 5, then running it on task 5, so you code actually does turrets 1 to 5, and misses the last turret.

by putting the dec after, the first task will be 6, which is the 6th turret, then when it gets to 0, it exits the loop before getting to the start task, so it only runnings task 1 to 6

User avatar
Red Spot
Posts: 3461
Joined: Fri, 4. Feb 05, 13:44
x3

Post by Red Spot » Fri, 5. Jan 07, 15:43

get max number of turrets ..

M2 == 7

turret ID 0 = main
1-6 = turrets


get max turrets (7)
while turret-id

start turret "7" ....



no, you guys are wrong

first decline the index than get the 1st turret ....

(in a loop with dec. its first dec. than the stuff, when using inc. first the stuff than the inc. ... now you guys are combining 2 methods ...)



G

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

Post by Cycrow » Fri, 5. Jan 07, 16:31

Red Spot wrote:(in a loop with dec. its first dec. than the stuff, when using inc. first the stuff than the inc. ... now you guys are combining 2 methods ...)
thats not actually true, dec doesn't always have to be first, it really depends what the loop is doing, the same with inc, it can be first, it can even be in the middle if you like, it just depends what the rest of the loop is doing

User avatar
Red Spot
Posts: 3461
Joined: Fri, 4. Feb 05, 13:44
x3

Post by Red Spot » Fri, 5. Jan 07, 17:07

I take it than that you still dont see the flaw in your logic ...


Whats that turret-script you start on task 7 going to do, except bug up the place ... ? with your coding/logic you will start an extra task on any ship with a turret wich never gets switched of as you basicly have no control over it (a regular player wont) and as this isnt an actual turret it may even cause it to run OOS adding even more presure to your game ..



G

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

Post by Cycrow » Fri, 5. Jan 07, 20:47

my logic was assuming that turrets returned 6, which i thought it did, but then i havn't really used the command much

asynd
Posts: 11
Joined: Thu, 4. Jan 07, 08:26
x3

Post by asynd » Wed, 10. Jan 07, 11:21

>< after acouple days of not touching the game, i started up x3 and the script isnt working like it used too :/ , the only turret that works is the front turret and i cant figure out why, even though all the commands are being used for every turrent and they are even set under the orders command.

right now i have this, but with the task# set to all the turrets too

$ship -> start task 1 with script "!turret.killenemies.std" and prio 0 : arg1= [TRUE] arg2= [TRUE] arg3= [TRUE] arg4= [TRUE] arg5= [TRUE]

ive even tried this with acouple different turret commands, only seems that the front turret wants to fire

$turrets = [THIS] -> get number of turrets
while $turrets > 1
dec $turrets =
$ship -> start task $turrets with script "turret.fighterdefense.std" and prio 0 : arg1= null arg2= null arg3= null arg4= null arg5= null


also when i commented out all the other turret ones and had it set to just work on the back or down turrets, the front turret was still the only one firing even though that command wasnt being sent to it
:?

User avatar
Red Spot
Posts: 3461
Joined: Fri, 4. Feb 05, 13:44
x3

Post by Red Spot » Wed, 10. Jan 07, 18:36

the script is almost good ...

try this (and not beause its the answer but beause it makes you see for yourself what your missing .. 8) )

start the turretscript with a "call script" command and see what arguments it uses .. (its kind of important to know what argument a script needs)



G

Post Reply

Return to “X³: Reunion - Scripts and Modding”