Jump to content

Can't get AI infantry to move, attack, etc.!


Recommended Posts

I'm a total newbie to coding triggers for TOW2, but I'm having some fun (and success) creating a scenario for the El Guettar map I posted on the repository recently.

Thanks to Webwing's tutorial videos and the docs that came with the game, I've been able to script the initial bombardment and smoke barrage, two waves of preparatory Stuka attacks, a working belt of U.S. minefields, and the appearance of the German forces as reinforcements on one corner of the map.

By lifting some code from the Faid Pass original scenario, I've gotten my German tanks to make a pretty convincing attack along an array. Now I want some Panzergrenadiers on foot to move with the tanks to support them and fight along the way.

I've gotten my Panzergrenadier group to appear on the map, right behind the wedge of tanks, but I've tried 3 or 4 different ways to code their movement/attack, and nothing seems to budge them. They just stand there, while the tanks race off.

Any suggestions? I understand the simple movement or attack triggers, but I know I probably need all sorts of If..Then lines to make sure the trigger doesn't crash the game when a soldier gets killed or routs before the destination is reached.

Link to comment
Share on other sites

BS, need more info to help you out chap. Please show the code you are using & describe groups, rects etc etc.

I assume that your infantry units are all in the same group & that after after introducing them you are commanding them to attack a rect either predefined or created by using the CreateRectByObject command. The code might look like this:-

ReinforcementLand ( Group , "Group_Infantry" )

RunCommand ( GROUP , "Group_Infantry" , STORM , RECT , "final objective" )

or

RunCommand ( GROUP , "Group_Infantry" , ATTACK , RECT , "final objective" )

Hope this helps, post your code if you get stuck

Link to comment
Share on other sites

Thanks for the coding help, friends.

My scenario is coming along great now...

Maybe someone can suggest how to do this:

I have the AI German infantry mounted in Sdkfz 251 halftracks. But I want to write some trigger code that detects when the halftrack gets within engagement range of enemy infantry, and has the German infantry then dismount to attack them.

I was thinking of something like this inside my basic Sdkfz attack trigger (where the variable @unit = the sdkfz ):

LABEL dismount

set @dist = ( UNIT , @unit , RECT , //define here us infantry ok, with good morale, OK weapon, etc// )

if ( @dist < 301 ) then

Delay ( 1000 )

RunCommand ( OUT_CREW , UNIT , @unit , PASSENGER )

Else

Delay ( 1000 )

goto dismount

ENDIF

If that worked, then I'd have to figure out a way to make the newly dismounted German infantry do something - otherwise I'm afraid they'd just stand there.

Ideas?

I looked all through the canned scenarios, and none of them seem to have any code that dismounts infantry when certain conditions are met. Maybe this can't be done?

Link to comment
Share on other sites

I don't remember if DIST work with RECT or only with POINT.

It is probably much easy to work with a point.

I wonder if the vehicule need to stop before dismount infantry ?

Don't forget setworkarmy.

Use delay 3000 instead of 1000

Then, once dismounted, the infantry will be in defend mode.

If you want them to be in line, you must use formation and send them to a point (runcommand move).

Link to comment
Share on other sites

Here's a script I used in blunted spear. It takes a squad: group 4: loads them in a truck: unit 81,

Then truck, which is also known as: group 7, moves to point 3 and dismounts all at 20m or less.

Then squad: group 4, lines up and storms the rec infront of them.

Note the syntax, and especially note some commands respond to the unit identifier and other commands work with the group identifier.

SetWorkArmy ( Army , 2 )

RunCommand ( Group , "Group4" , In_Crew , Unit , 81 )

Delay ( 12000 )

RunCommand ( Group , "Group7" , MOVE , POINT , "Point_3" )

LABEL Begin

Set @dist = Distance ( UNIT , 81 , POINT , "Point_3" )

if ( @dist < 20 ) Then

RunCommand ( UNIT , 81 , OUT_CREW , ALL )

Delay ( 10000 )

RunCommand ( GROUP , "Group4" , STORM , RECT , "Rect_3" )

Else

Delay ( 6000 )

SetGroupFormation ( "Group4" , LINETANKHUMAN )

Delay ( 2000 )

RunCommand ( GROUP , "Group4" , STORM , RECT , "Rect_3" )

Delay ( 1000 )

goto Begin

ENDIF

 

Halt

Link to comment
Share on other sites

......should also mention the bit of code above takes into account "what if" the truck is hit before the dismount command. Hence the "Else" command tells the squad that survive the truck being blowed up to line up and storm a rec.

As long as the troops are mounted the else command cannot be executed by the squad.

Link to comment
Share on other sites

×
×
  • Create New...