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, 09:26
x3

Command_turret?

Post by asynd » Thu, 4. Jan 07, 09: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: 6989
Joined: Wed, 25. Jan 06, 15:26
x3

Post by fud » Thu, 4. Jan 07, 14: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, 09:26
x3

Post by asynd » Thu, 4. Jan 07, 20: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: 6989
Joined: Wed, 25. Jan 06, 15:26
x3

Post by fud » Thu, 4. Jan 07, 21: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: 4588
Joined: Wed, 6. Nov 02, 21:31
x3ap

Post by moggy2 » Thu, 4. Jan 07, 21: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: 6989
Joined: Wed, 25. Jan 06, 15:26
x3

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

See? There you go. :)

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20598
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Thu, 4. Jan 07, 21: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: 6989
Joined: Wed, 25. Jan 06, 15:26
x3

Post by fud » Thu, 4. Jan 07, 21: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: 20598
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Thu, 4. Jan 07, 22: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: 6989
Joined: Wed, 25. Jan 06, 15:26
x3

Post by fud » Thu, 4. Jan 07, 22: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, 09:26
x3

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

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

User avatar
Red Spot
Posts: 3224
Joined: Fri, 4. Feb 05, 14:44
x3

Post by Red Spot » Fri, 5. Jan 07, 07: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: 4588
Joined: Wed, 6. Nov 02, 21:31
x3ap

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

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

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20598
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Fri, 5. Jan 07, 14: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: 3224
Joined: Fri, 4. Feb 05, 14:44
x3

Post by Red Spot » Fri, 5. Jan 07, 16: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

Post Reply

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