Jump to content

Scripting question


Oudy

Recommended Posts

I've been looking at the scripting for the existing campaigns and I must admit I'm more impressed than ever by the robust nature of the scripting language and at the quality of the scripting done by the programmers. The battles are much more dynamic and unpredictable than in the original battles in TOW1.

I must confess, though, that I am a bit befuddled with the use of the Halt command. According to the scripting guide, "Commands within the trigger are executed until the keyword Halt is encountered, which will stop the processing of the trigger." Therefore, the way I read it when the command Halt is processed the whole trigger is stopped. Using a Halt command at the end of a trigger makes perfect sense to me but when they come in the middle of the trigger I'm confused.

As an example, here is a snippet of code from the Faid battle in the USA campaign. It comes from the trigger [_Attack_Tank].

Label  1

SetWorkArmy ( ARMY , @army )

SET @nGer1 = GetNUnits ( UNIT , @unit , ALL , NOT_EMPTY , OK_ENGINE , AND_TANK , AND_SPG )

if ( @nGer1 = 0 ) then

goto begin

Halt

endif


SetWorkArmy ( ARMY , @army )

SET @nGer1 = GetNUnits ( UNIT , @unit , ALL , OK_ENGINE , AND_TANK , AND_SPG )

if ( @nGer1 = 0 ) then

RunCommand ( UNIT , @unit , OUT_CREW , CREW )

goto begin

Halt

endif


SetWorkArmy ( ARMY , @army )

SET @nGer_Weapon1 = GetNUnits ( UNIT , @unit , ALL , OK_WEAPON , AND_TANK , AND_SPG )

if ( @nGer_Weapon1 = 0 ) then

goto retr

Halt

endif


Delay ( 60000 )

goto 1

By my understanding the code begins by checking the number of units and if it is equal to 0 it goes to label Begin. If it is not equal to 0 it goes to the next line which is Halt. If this Halt command stops the trigger, how logically can you ever get to the next two parts of the code?

What role does the Halt command play in this piece of code? I would greatly appreciate clarification.

Oudy

Link to comment
Share on other sites

Sneaksie

Thank you for your quick response. That was what I suspected happened but wanted clarification. You must admit it is just a tad confusing.

For anyone interested in making their own battles or campaigns, it can be intimidating to try programming with triggers. The good thing is that by looking at the triggers for the existing battles and campaigns you can use a lot of existing code, rather than having to write it all from scratch. The trigger language is very powerful and allows for almost unlimited flexibility.

Oudy

Link to comment
Share on other sites

×
×
  • Create New...