Page 1 of 2

Command_turret?

Posted: Thu, 4. Jan 07, 09:50
by asynd
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

Posted: Thu, 4. Jan 07, 14:50
by fud
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.

Posted: Thu, 4. Jan 07, 20:42
by asynd
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.

Posted: Thu, 4. Jan 07, 21:06
by fud
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.

Posted: Thu, 4. Jan 07, 21:32
by moggy2

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.

Posted: Thu, 4. Jan 07, 21:41
by fud
See? There you go. :)

Posted: Thu, 4. Jan 07, 21:42
by Cycrow
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

Posted: Thu, 4. Jan 07, 21:51
by fud
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. :)

Posted: Thu, 4. Jan 07, 22:04
by Cycrow
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

Posted: Thu, 4. Jan 07, 22:08
by fud
That's what I figured. Some things are just too good to be true I guess. :)

Posted: Fri, 5. Jan 07, 06:53
by asynd
thanks for the help ^^
thats exactly what i wanted to do

Posted: Fri, 5. Jan 07, 07:13
by Red Spot
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

Posted: Fri, 5. Jan 07, 07:48
by moggy2
Cycrow's code is alright. Look where the dec is. ;)

Posted: Fri, 5. Jan 07, 14:00
by Cycrow
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

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