Help needed spawning LOTS of ships and giving them commands

The place to discuss scripting and game modifications for X²: The Threat.

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

marklaverty
Posts: 270
Joined: Mon, 23. Feb 04, 15:03
x2

Help needed spawning LOTS of ships and giving them commands

Post by marklaverty »

Hi,

I'm working an a package that will cause a MASSIVE spawning of Xenon ships (2 carriers, 6 m2's and about 50 fighters). It's to give people with nice shiny new m1's and m2's something to worry about!

It'll be a little mini mission with a reward for helping defeat the enemy fleet etc.

I can spawn the ships ok, but then I want to give them different scripts to run.

I want to set up some pretty advanced behaviour (formations of enemy fighters, bombing runs by enemy fighters against player ships, propper CAP patrols, enemy m5's doing missile defence of enemy capital ships)

a simple example would be .....

I want 2 of the m2's to protect each m1. Then I want to the m1's to each run a custom patrol script. Then the remaining m2's also need to be given seperate patrol commands.

If I use a seperate script to spwan each ship, I can just set $ship as the return variable from the create ship commnad, then use '$ship -> call script xxx.xxx.xxx' to make it do what I want.

With about 60-70 ships being spawned that's ALOT of seperate scripts. though and surely there must be a better way of doing it????

Is there any way to say ...

create ship X
add default items to ship X
Make ship X run this script/start this command
create ship y
add default items to ship y
Make ship y run this script/start this command
Etc etc etc......

I don't think this works with a normal script call as I think :? even if you use '$ship -> call script xxx.xxx.xxx' the called script must run and return before the rest of the script it was called from is executed.

This means ship X would be created, default items added to it, then it would run say a patrol script for example. But ship Y wouldn't be created untill ship X had finnished running that script.

I may be being a complete muppet :roll: , and if I am please tell me!! But if not and someone can help it would be much appreciated.
For everything you ever wanted to know about X2,
and more......

[ external image ]
User avatar
Kailric
Posts: 985
Joined: Sun, 7. Dec 03, 05:15
x3

Post by Kailric »

Yes there is..I am prepareing some combat simulator scripts now...will post them for you and maybe you can use them as an example.
"Try not. Do or do not, there is no try."-Yoda

"[Its] time for the human race to enter the solar system"-Dan Quayle
User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV »

Code: Select all

$m3p = 0
034|while $m3p < 30
035|  $cm3p =  create ship: type=Unknown Enemy Ship owner=Khaak addto=$carrier x=$anull y=$anull z=$anull
036|  $cm4p =  create ship: type=Unknown Enemy Ship owner=Khaak addto=$carrier x=$anull y=$anull z=$anull
037|  $cm3p -> add default items to ship
038|  $cm4p -> add default items to ship
039|  = $cm3p -> install 80 units of Cargo bay extension
040|  = $cm4p -> install 80 units of Cargo bay extension
041|  = $cm3p -> install 30 units of Unknown Object
042|  = $cm4p -> install 30 units of Unknown Object
043|  $cm3p -> set homebase to $carrier
044|  $cm4p -> set homebase to $carrier
045|  $cm3p -> set fire missile probability to 100
046|  $cm4p -> set fire missile probability to 100
047|  START $cm3p -> command COMMAND_PROTECT : arg1=$carrier, arg2=$anull, arg3=$anull, arg4=null
048|  START $cm4p -> command COMMAND_PROTECT : arg1=$carrier, arg2=$anull, arg3=$anull, arg4=null
049|  inc $m3p = 
050|end
do you mean like this?

which creates 30 + 30 khaak ships all set to protect

once they have been created though you cannot change the command for each ship
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses
User avatar
JustHere4Coffee
Posts: 1075
Joined: Wed, 6. Nov 02, 20:31
x2

Post by JustHere4Coffee »

as stated above, use START, not call... then it'll run as a seperate concurrent process

however if you want them to protect AND patrol seperately... um... can you set their homebase as the carrier, even though they can't dock? that'll give the carrier the power of veto over their patrolling
User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV »

One word of caution there.


In my experience with this setting a ship to a homebase which it cant land on may cause problems, keep your eye on it if you do this.

If the ship defaults to it's global behavior it may try to land and CTD :)

disclaimer :- although LV has written many combat scripts most are done whilst under the infuence of beer and spaceweed meaning i could easily be wrong :)

Also i have the great pleasure :( of running a pretty low end system, 1.53g cpu gf4 piece o crap )

make sure when spawing many ships you take into account the lag factor.
marklaverty
Posts: 270
Joined: Mon, 23. Feb 04, 15:03
x2

Post by marklaverty »

Yes there is..I am prepareing some combat simulator scripts now...will post them for you and maybe you can use them as an example.
Would LOVE to have a look :wink:

do you mean like this?

which creates 30 + 30 khaak ships all set to protect

once they have been created though you cannot change the command for each ship
very similar..... am not doing it with a loop though.

Want to first create an m1, then get it to run a patrol scritp. then create 2 m2's and assign them to protect the m1 thats just been created.

then create the next m1 and get it to run a patrol script, before creating 2 more m2's and assigning them to protect it.

would then create 2 more m2's and make them run a patrol script.

then create the fighters and set up the formations etc.
as stated above, use START, not call... then it'll run as a seperate concurrent process

however if you want them to protect AND patrol seperately... um... can you set their homebase as the carrier, even though they can't dock? that'll give the carrier the power of veto over their patrolling
Sounds like the 'start' prefix on the script call would do it.

If I'm reading this right....

that would start the called script as a completely seperate process, leaving the origional script to continue processing creating the rest of the ships, and starting further scripts using the 'start' prefix on these ships as it goes?

Not going to be doing patrol and protect, just one or the other.


In my experience with this setting a ship to a homebase which it cant land on may cause problems, keep your eye on it if you do this.
Have had exactly this same problem before, drove me nuts :lol:

Also i have the great pleasure of running a pretty low end system, 1.53g cpu gf4 piece o crap )

Thats ok, just get your DIY modders toolkit out and give it a bit of 'life'

my system...

AMD Athlon XP 2500+ (barton) @ 2.6ghz on 2.25v
512mb generic ram at DDR440 speeds
Radeon 9600 256mb non-pro at near XT speeds....

http://jccorpportal.jamescowper.co.uk/m ... system.jpg

Muuhahahahahahhaahhahahahahaa :fg: :fg: :fg:
For everything you ever wanted to know about X2,
and more......

[ external image ]
User avatar
LV
Sith Lord
Posts: 8255
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by LV »

marklaverty wrote:my system...

AMD Athlon XP 2500+ (barton) @ 2.6ghz on 2.25v
512mb generic ram at DDR440 speeds
Radeon 9600 256mb non-pro at near XT speeds....


Muuhahahahahahhaahhahahahahaa :fg: :fg: :fg:


If your going to brag about your system at least get one first ;)
marklaverty wrote: Thats ok, just get your DIY modders toolkit out and give it a bit of 'life'
The Empire has one little problem.

Mrs Vader has a contract which states "Every £ spent on LV's PC shall also be spent by Mrs V"

Therefore any part added is double money and it tears my black heart apart watching her spend my cash :cry:

Don't laugh it could be you.

I was drunk and the little fella took control. I'm sure she used a fekin mind trick on me :o


Moral of this ramble.



Women are Eeeeevilll
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses
marklaverty
Posts: 270
Joined: Mon, 23. Feb 04, 15:03
x2

Post by marklaverty »

uh oh....... the evil partner/accountant combo move...... nasty...

not alot you can do about that one..... :cry:


If your going to brag about your system at least get one first
How do you mean :?:

I have one...? I might have destroyed 3 processors, 1 dimm module, and a mobo screwing with it seeing how far I could push it.... but it's there under my desk... :D
For everything you ever wanted to know about X2,
and more......

[ external image ]

Return to “X²: The Threat - Scripts and Modding”