Jump to content

LOgic code problem


Recommended Posts

I am having a big create rect by object problem

I want a pak, once it is occupied by my brits to be approached by 2 german units. So I created a rect around the pak. The problem is when I move the pak, the units just head straight off the map.

The dismount does work but the units dont follow as the rect moves.

</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> Delay ( 1000 )

Label Hambush

CreateRectByObject ( RECT , "pak" , 50 , UNIT , 47 , Artillery , 50 , OK_WEAPON , Not_Empty )

Delay ( 1000 )

//created rect around pac called pak

Set @gun = GetNUnitsInArea ( ARMY , 1 , Artillery , "pak" , OK_WEAPON , Not_Empty )

//trigger the germans to start moving when the cannon is occupied

IF @gun > 0 THEN

Delay ( 2000 )

SetWorkArmy ( ARMY , 2 )

Delay ( 15000 )

// in 15 secs gp 14 a sdk7 and gp 17 a bmw head towards the pak

RunCommand ( GROUP , "Group14" , MOVE , RECT , "pak" )

Delay ( 1000 )

RunCommand ( GROUP , "Group17" , Attack , RECT , "pak" )

Delay ( 2000 )

ELSE

Goto Hambush

ENDIF

LABEL Begin

Set @dist = Distance ( UNIT , 68 , UNIT , 47 )

// at 200m the sdk7 dismounts soldiers to storm the pack

IF ( @dist < 200 ) Then

SetWorkArmy ( Army , 2 )

RunCommand ( UNIT , 68 , OUT_CREW , Passenger )

Delay ( 5000 )

RunCommand ( GROUP , "Group15" , Storm , RECT , "pak" )

Delay ( 5000 )

RunCommand ( Group , "Group14" , Move , Point , "Point_7" )

ELSE

// after the dismount the sdk7 peels off to point 10 and the driver gets out

Goto Begin

ENDIF

Label Road

SetWorkArmy ( Army , 2 )

Set @dst = Distance ( UNIT , 68 , POINT , "Point_7" )

If @dst < 20 Then

RunCommand ( Group , "Group14" , Move , Point , "Point_10" )

ELSE

GOTO Road

Endif

Label Dmount

SetWorkArmy ( Army , 2 )

Set @dst2 = Distance ( UNIT , 68 , POINT , "Point_10" )

If @dst2 < 20 Then

RunCommand ( UNIT , 68 , OUT_CREW , All )

ELSE

GOTO Dmount

ENDIF

Halt

</pre>

Link to comment
Share on other sites

Did some more testing and isolated whatever problem to the very first Loop. Probably thecreate rectbyobject command.

Remmed out all the other stuff and sure enough the german units make a B line for the opposite corner of the map? This occurs ontime when the pak is occupied by the brits.

But why is the unit rect not being chased? I'm pretty sure this worked before the uber.

code:

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

Label Hambush

CreateRectByObject ( RECT , "pak" , 50 , UNIT , 47 , Artillery , 50 , OK_WEAPON , Not_Empty )

Delay ( 1000 )

//created rect around pac called pak

Set @gun = GetNUnitsInArea ( ARMY , 1 , Artillery , "pak" , OK_WEAPON , Not_Empty )

//trigger the germans to start moving when the cannon is occupied

IF @gun > 0 THEN

Delay ( 2000 )

SetWorkArmy ( ARMY , 2 )

Delay ( 15000 )

// in 15 secs gp 14 a sdk7 and gp 17 a bmw head towards the pak

RunCommand ( GROUP , "Group14" , MOVE , RECT , "pak" )

Delay ( 1000 )

RunCommand ( GROUP , "Group17" , Attack , RECT , "pak" )

Delay ( 2000 )

ELSE

Goto Hambush

[ January 31, 2008, 02:15 PM: Message edited by: Nikki Mond ]

Link to comment
Share on other sites

×
×
  • Create New...