Jump to content

Scripting - A tutorial primer


Recommended Posts

When writing complex scripts, you should first start with a basic script containing a single mission. Test that one until it does what you want, then, add to it.

When doing scripts containing several missions, TODs, you should have a script template. This template can be used to test each TOD independently and then moved over to your main script.

So for instance, say you are creating a 4 mission script. You would start with a script file called BC3K4500.SCR (the number does not matter as long as you don't use an existing one), and create a single mission in it. Test it. Once it works right, copy it to, say, BC3K9700.SCR. Then, change all the parameters in BC3K4500.SCR again, create the next one, test it, and then use cut and paste to move it into BC3K9700.SCR. You now have a script with two fully tested missions.

Carry on doing this until you have all the scripts you want, tested and working. Then, you can go in BC3K9700.SCR and check to make sure that all the scripts you pasted are correctly implemented. If you have entities that exist across missions, now you can add them in and then build+test this script.

Below is the code for a sample template script. It is pretty well commented but of course, you need to be familiar with GBS scripting, in order to make head or tail of it. You can read the GBS contents for the command descriptions, if you are just browsing. This way, you don't have to download the GBS.

The script source files are below. right-click on the file and select Save Target As

www.bc3000ad.com/gbs/bc3k9700.scr

www.bc3000ad.com/gbs/bc3k9700.des

To run them..

  1. copy them into your GBS folder

  2. run prepare bc3k9700.scr

  3. run prepare phrases bc3k9700.scr

  4. copy bc3k9700.mis, bc3k9700.dat and bc3k9700.des to your SCRIPTS folder where BC3K installed.

  5. Start a new profile and select it from the MISCON list.

We will use this template to build more complex scripts, while I work on completing the GBS command descriptions in my spare time.

Here is the source file displayed in text format.

code:


#

# SCRIPT TEST

#

#include glob_rg.scr

[dynamic]

#include glob_dyn.scr

#

[ai]

#include glob_ai.scr

#include glob_ag.scr

#

#

# Below is our control object, so, we hide and make it invincible

#

#

[dynamic]

galaxian diplomat,,ghq,probe1.3dc,satcom

[ai]

.ghq,100,100,100,100,100,100,1

start orbit blk05z^flx-11,5000,10,90,0

stop

events

!startup

cloak on this

invincible on this

autogen OFF

endevents

#

[acm]

CAMPAIGN.................SCRIPT SAMPLE

THEATRE OF OPS...........EARTH/SOL

MISSION CLASS............SCRIPT SAMPLE

.

A simple wing and multiple ID test.

.

A wing leader is ordered to patrol Mars region and RTB.

.

There is also a hostile carrier in the Mars region

.

:101,earthz,setup_tod1,begin_tod1,resolve_tod1,tod1tick,1,30,5

#

# This wing is launched in Earth region and then jumps to Marsz 5 mins

# later. The escorts have specific IDs because they were all created as

# a wing. When the leader is created (the first entry in the definition) all

# the other escorts are also created (activated).

#

# The leader will dock with GHQ if it exists (not destroyed) otherwise

# it will seek another friendly station (eg Starpath) to dock with.

#

# Note that we don't give the wingmen the same orders as the leader because

# they will follow it around anyway and protect it as necessary.

#

# This wing starts near a known reference point in the Earth region

#

# We want to be able to give commands to this wing's wingmen, so, we create

# them as a wing in which each entity has its own ID and give them starting

# orders, locations and separation distance around their leader.

#

#

[dynamic]

:wing1

terran military,,wingleader,violon.3dc,alpha_leader

terran military,,wing1,vandal.3dc,alpha1

terran military,,wing2,vandal.3dc,alpha2

::

[ai]

.wing1,100,100,100,100,100,100,0

.wingleader

start inactive near earthz^jmp-01 1500 jmp-02

stop

events 101

!go2mars

sad marsz

broadcast "ALPHA LEADER: jumping to Mars...form on my wing"

!wing_rtb2ghq

broadcast "ALPHA LEADER: returning to GALCOM HQ"

signal ack2,1

IF EXIST galcomhq THEN

dock galcomhq

ELSE

rtb

ENDIF

!begin_tod1

activate this

patrol earthz

broadcast "ALPHA LEADER: patrolling Earth region..form on my wing"

signal ack1,1

signal go2mars,5

signal wing_rtb2ghq,15

!resolve_tod1

IF EXIST galcomhq THEN

dock galcomhq

ELSE

rtb

ENDIF

endevents

#

.wing1

start inactive escort wingleader 250 3

stop

.wing2

start inactive escort wingleader 250 9

stop

#

# Can reference both wingmen in a single block. They will both execute

# the same command in sequence.

#

.wing1,wing2

events 101

!ack1

broadcast "roger that ALPHA LEADER"

!begin_tod1

activate this

endevents

#

# Only this wingman will execute this command

#

.wing1

events 101

!ack2

broadcast "ALPHA1: acknowledged ALPHA LEADER, returning to base"

!detect bc

broadcast "ALPHA1: player detected"

endevents

#

# Only this wingman will execute this command

#

.wing2

events 101

!ack2

broadcast "ALPHA2: acknowledged ALPHA LEADER, returning to base"

!detect bc

broadcast "ALPHA2: roger that ALPHA1. player detected"

endevents

#

# This carrier will launch 2 fighter escorts (type picked at random).

# It will also launch a specific type if it detects the leader of the wing

# created above. Because Starpath is not a valid target, they ignore each

# other.

#

# This wing starts near random reference point in the Mars region

#

# We don't care about giving the entities in this wing, direct commands.

# Instead, we just have the carrier launch them and let their AI determine

# their default (ESCORT) actions and anything else after that.

#

# The LAUNCH command is perfect for this sort of 'quick wing' solution. The

# only drawback is that you only have control to the main entity and not

# the entities it launches. Even though they act like wings, they are not

# treated as such.

#

#

[dynamic]

terran insurgent,,enemy_leader,megaron.3dc,HOSTILE_CONTACT

[ai]

.enemy_leader,100,100,100,100,100,100,0

start inactive in marsz

stop

events 101

!begin_tod1

activate this

patrol marsz

LAUNCH fighter,1,escort this

broadcast "Launching escorts"

!detect wing1.wingleader

broadcast "HOSTILE CONTACT: Wing Launched"

LAUNCH sfighter,1,attack wing1.wingleader

!detect wing1.wing1

broadcast "HOSTILE CONTACT: wing escort1 detected"

!detect wing1.wing2

broadcast "HOSTILE CONTACT: wing escort2 detected"

!resolve_tod1

rtb

endevents

#

# We don't want Starpath involved, so we disable it's launch and weapon systems

# We also de-classify it as a valid target for hostile entities.

#

# Its attributes are restored when the TOD is resolved (finished).

#

.starpath

events

!begin_tod1

ignore on

launches off this

weapons off this

!resolve_tod1

ignore off

launches on this

weapons on this

endevents

#

[event]

!wing_rtb2ghq

!go2mars

!ack1

!ack2

$


[This message has been edited by Supreme Cmdr (edited 01-03-2000).]

Link to comment
Share on other sites

  • 1 month later...

quote:

I be ready for the plunge and script my own missions 'tis why I be askin'

If your ready, might as well start with what is currently available. If you can get a handle on the test script, the rest will fall in place with a little experimentation.

Link to comment
Share on other sites

  • 7 months later...

I am working on an Insurgent spin on the current ACM. Basically, I am taloring the current ACM for BC3K v2.09 and combining it with the Insurgent FF mode. I have Read available GBS (Lite) documentation and perused the GBS forum and I understand 50% of the scripting techniques. Which means I knows enough to be very, very, very dangerous biggrin.gif

quote:

...Any half-baked entry level programmer, even without all the docs, can figure it out. It does not need a GUI. It is based on simple logic and all you have to know are 3 things...

1. The game galaxy layout

2. The syntax of the commands and what they do

3. The logic flow of the environment and being certain to take into account that AI entities, that you don't script, are guaranteed to screw up the logic flow of your script if you don't know what you are doing.

Very True - I figured it out somewhat and I am not a programmer, I figured out WTF .ghq is all about cool.gif

Question:

When using START in the [ai] block, what does this mean:

start 120000 near earthz^jmp-01 1500 jmp-02

I get errors when running parse - GBS TOC

  • 6.0 START/STOP 'nav' commands

    - @date|time|inactive

How is 120000 translated? I understand all but that portion.

Has this thread been locked down? I tried to create a new topic and received access denied, yet I can post/create in other Forum areas

I realize that crunch time cometh but I gots to ask (though I sorta know what the answer will be) - any chance on getting a sneak peak or any more of the GBS Manual (pg 50 and beyond) or at least Section 6.0 thru section 7.1?

This is a serious project for me and not a frivolous endeavour. I have already created an ACM where the player starts a game as an Insurgent and eceives a mission. One forum member has playtested it already.

TTFN

BTW - from what little I know and understand about GBS, a GUI interface is an exercise in futility IMO.

[This message has been edited by Gallion (edited 10-03-2000).]

Link to comment
Share on other sites

quote:

This is a serious project for me and not a frivolous endeavour. I have already created an ACM where the player starts a game as an Insurgent and eceives a mission. One forum member has playtested it already.

Yeah I did! wink.gif Whom else but ole Insurgent One would get first crack at it. So far, so very good Pirate! Let me know when you get more done. I'll give it a go unless the SC has tasked me with a Higer Priority Mission! biggrin.gif

------------------

Insurgent One, Rattler

ICV Necromancer, Spectre HQ (Antis)

Commander-In-Chief,

Insurgency

Official Tester,Battlecruiser Series

[email protected]

ICQ 12894104

Link to comment
Share on other sites

quote:

When using START in the [ai] block, what does this mean:

start 120000 near earthz^jmp-01 1500 jmp-02


I think it means starting whatever near earthz^jmp-01 at 120000 units(kilo, miles, whatever).

It's been awhile since I played around with GBS. I had a little program half working on reading the script into my own data struct, I was going to use it so I could change the script using a GUI, then I thought what the hell, it's much easier when you just open the script and edit it.

I remember there is also bunch of stuff you can tweek with, like missles, shields, stuff like that. Also, you could create you own regions or build your own objects and point models to them.

BTW, after looking at the script above I'm probably wrong about the 12000. It seems the 1500 behind earth^jmp1 is the unit. The only person that knows for sure is Derek.

[This message has been edited by SpacePhish (edited 10-03-2000).]

Link to comment
Share on other sites

I have uploaded my original design docs for the GBS. This is what I was using to finalize the gbs.txt document, but didn't finish it. Some of the items in this file (e.g. classes, messages etc) are no longer accessible from GBS but are built into AILOG (the game's AI kernel) which is why I was doing a new file that reflects the released GBS.

Anyway, in the original docs, you will find a lot more info that in the gbs.txt file. But, you will have to figure out, on you own, whats obsolete, implemented etc. For BCM I will sit down and do proper docs if I decide to release GBS II to the public.

Anyway, for your particular problem, go to line 1532 for the START syntax definition and to line 2314 for the time definition.

GBS Design Docs

[This message has been edited by Supreme Cmdr (edited 10-03-2000).]

Link to comment
Share on other sites

SpacePhish:

start 120000 near earthz^jmp-01 1500 jmp-02

Translates to:

START 120000[ms] NEAR earthz^jmp-01 1500 (Distance From) jmp-02. Using an azimuth from earthz^jmp-01 TO jmp-02.

IOW nothing will happen unto 120000 milliseconds after START of mission/scenario.

SC:

Thanks! biggrin.gif Me questions and prayers are answered! cool.gifbiggrin.gif As to whether or not to include GBSII in BCM release, I suggest that you strongly consider including GBSII either when BCM goes GOLD or shortly there after. Documentation is a bugger I realize but required. No need to dumb-down documentation if you keep same standard that was used to publish initial GBS(I) text.

The reason I suggest to include GBSII with BCM is replayability. BCM play will be predominately M/P in nature once a player masters BCM's aspects and whatnot in single player mode (IOW learns how BCM works, etc.). Many other games support M/P but only towards the deathmatch mode (Klingon Academy for example) without any player generated campaign or script support/capability (Klingon Academy is a fine example of this). Many good to great S/P games fail in the M/P arena because of this IMO. Those games that do support player M/P scripting or modification (UT, QA, etc.) tend to be more successful in both the marketplace and after intial hype wears-off. IOW the game is no longer boring.

Anyway, me ramble is complete now. Thanks again SC fer the documentation and to Rattler for your kind words of encouragement. I need to study some before diving back into my project.

More news when fit to print.

TTFN

[This message has been edited by Gallion (edited 10-04-2000).]

Link to comment
Share on other sites

I strongly agree with Gallion. BCM mod support would just be so cool! I certainly would try my hands at MODing. In the past year I think I've learned a few things about programming(3D graphic etc...), I'm dying to wet my feet by joining a MOD team. BCM seems like the perfect place! smile.gif

We will have to wait and see. The wait is killing me tho...

GBSII!!!!!Baby!!!

I have FAITH in Derek and 3000ad!

[This message has been edited by SpacePhish (edited 10-05-2000).]

Link to comment
Share on other sites

I did DO something with GBS. I just didn't post any of it. If you think I'm tripping then forget it... smile.gif

I played around with Scripting, made a few scripts, like placing space-stations, making new regions stuff like that... I had to abandon it because of school. I get the feeling that you think I know nothing about GBS, I don't, but I'm trying my best. (It's also been awhile since I touched scripting, but I had it down, for real.)

By no mean take this post offensively. smile.gif

[This message has been edited by SpacePhish (edited 10-05-2000).]

Link to comment
Share on other sites

uhm, right Phish. I find it very hard to believe that you created new regions - because not only do you need a very high knowledge of the GBS, you also need to know how to use TED in order to do that.

And since you didn't even know the format for the START command, I won't say that you have a high level understanding of GBS, would you?

Of course, I remember your notion that GBS could be wrapped around a GUI. Of course, as usual, I was right...and that was abandoned quite quickly.

tut, tut, tut wink.gif

Link to comment
Share on other sites

Okay. I will go hang out in the corner now smile.gif I knew what the [start] 12000 thingy was, I swear! I forgot. As to regions I did make it. I did something like (remember this was a LONG time ago, from a guy who can't remember worth a damn) converting the region file into text file with the utility that camed with GBS, then altered the data manually.

I'm NOT trying to be an ass, m.fact I don't know what I'm trying to accomplish here. Whatever you decision may be it's all good . I'm will head over to the air-lock ASAP.

If you do decide to release GBSII...

Perfect chance to make me look like a fool smile.gif

Link to comment
Share on other sites

quote:


converting the region file into text file with the utility that camed with GBS, then altered the data manually.

heh, yeah right. That should do it.

better quit while you're ahead wink.gif

quote:


Perfect chance to make me look like a fool


LOL!, you mean I haven't done that already? biggrin.gif

Link to comment
Share on other sites

hehehehe, no comment biggrin.gif

Project going well, even with one minor dyslexsic (sp?) episode. Failed to change one character after a copy/paste (ya, I am lazy but what is tech for if not used). Had two mission resolve at sametime. Talk about attention to detail cool.gif easy to find and fix. And yes kids, this is covered in the docs, just remember to check, check, and recheck ye scripts before prepare parse is run. I caught a couple of other minor event errors fixing my first one.

Hell of a way to learn though, baptism by fire eek.gif

Sorry fer the buggy files Rattler, I got overzealous some biggrin.gif

TTFN

Link to comment
Share on other sites

baptism by fire. LOL!!!

Gallion, if you need help, just post (make sure you post the script fragment too, if needed) and if I see it, I'll pitch in.

And since you're going to be on the Beta test team, the more people I have who know at least a little about GBS (besides my guys who already do, the better.

Link to comment
Share on other sites

Hmm, I might have to start dabbling one of these days too.. of course, the best I could do would most likely be making an inter-galactic ATV that does nothing more than ram asteroids repeatedly... if even that.

Actually, the farthest I'd probably get is opening up a pre-made script, staring at it for 30 minutes, and finishing up with a gutteral "Duuuuhhhhhhh....."

smile.gif

------------------

Cmdr. Parias

ICV-Galatae, Awaiting final assignment

Balor Fleet

ICQ 1293359

Staff member at HardNews

Link to comment
Share on other sites

Gallion's convinced me! I'm breaking out the file and the doc's this weekend and going to contribute where I can! wink.gif

Gallion, please send revised files email again. Ye fergot to include attachment! cool.gif

------------------

Insurgent One, Rattler

ICV Necromancer, Spectre HQ (Antis)

Commander-In-Chief,

Insurgency

Official Tester,Battlecruiser Series

[email protected]

ICQ 12894104

Link to comment
Share on other sites

  • 3 months later...

I,m trying to write a script with a group of 9 capital ships (mainly transports) and fighter escort which traverse from Earth to Grammula to resupply a space station. With such a large distance to travel the convoy will need to be resupplied with weapons fuel spares to prevent ships RTB when they are damaged or run out of stores.

The way to proceed and keep it simple would from what I ve read (scripting docs 07.04.98 4.2 Classes, Wings and Units) be to use a Wing containing a carrier wing, cruiser wing, transport wing and fighter wing(s) with the BC flying along side as escort, this would make the script far simpler to write and keep track of.

I ve seen from the SC script how build wings but what is the syntax to produce a collection of wings with multiple unit types within it (Exploration,supply and Evac units)

------------------

Link to comment
Share on other sites

Did I miss a download cut-off or something, SC? The links in your original post seem broken. The *.scr file is located in the main bc3kscript-source.zip downloadable, but I can't find the *.des file (nor remember what it's for -- time to read the docs again...) On the other hand, the gbs-ddocs.zip link is okay.

Link to comment
Share on other sites

Help In the script I'm writing the convoy is to travel a very long distance 24 regions patrol each region 5-10 mins then set off to the next (no short mission where commanders can use the docking loop hole forrepairs and r&r)

Following is a much simplified version of the convoy script.

problem the convoy just flies about earthz for awhile then returns to base.

tried various variations of patrol and patrolz no solution

what am I doing wrong?

.

:101,earthz,setup_tod1m1,begin_tod1m1,resolve_tod1m1,tod1m1tick,5,240,15

#

[dynamic]

:Transport

terran,military,5,con1,scarier.3dc,Arkroyal,Mark Stryker

terran,military,5,con2,sentry.3dc,Cumberland

terran,military,5,con3,sentry.3dc,Shropshire

terran,Explorer,5,con4,Generis.3dc,Ardent

terran,scientist,5,con5,Jenstar.3dc,Brazen

terran,trader,5,con6,Canlon.3dc,Codrington

terran,paramedic,5,con7,Lrt10.3dc,Duncan RN

terran,worker,5,con8,Lrt10.3dc,Encounter

terran,Commercial,5,con9,Lrt10.3dc,Fearless

terran,Colonist,5,con10,Lrt10.3dc,Garland

[AI]

.Transport,100,100,100,100,100,100,0

start inactive in earthz

stop

events 101

!begin_tod1m1

signal convoystart,5

broadcast TO "The Convoy Will Depart In Five Mins"

!convoystart

activate this

!detect bc

Patrol

Patrolz this lv103z

!arrived lv103z

IF EXIST cygni THEN

broadcast "arrived"

dock cygni,30

ELSE

RTB

ENDIF

!RESOLVE_tod1m1

broadcast "well done"

acm_off,military

endevents

#

[event]

#

# --tod1m1

!convoystart

$

Link to comment
Share on other sites

Try This:

events 101

!begin_tod1m1

signal convoystart,5

broadcast TO "The Convoy Will Depart In Five Mins"

!convoystart

activate this

!detect bc

Patrol

Patrolz this lv103z

quote:

Change to:

Patrol lv103z

!arrived lv103z

IF EXIST cygni THEN

broadcast "arrived"

dock cygni,30

ELSE

RTB

ENDIF

!RESOLVE_tod1m1

broadcast "well done"

acm_off,military

endevents

TTFN

------------------

Commander Gallion

GCV Graf Spee, Starbase Cerberus

Wing Leader - Wraith Fleet/Corsair Wing

"Run Silent, Run Deep"

Corsair Cove

Official Tester, Battlecruiser Series

Leader, Team 1

[This message has been edited by Gallion (edited 02-08-2001).]

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...