Jump to content

Scripting Syntax question again for Devs


Oudy

Recommended Posts

I thought that I would have my mission finished, but like a fool, I added one more section that for some reason won't work.

</font><blockquote>code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">//continues attack on hill if Russian Troops are still present

Label Check_RTroops_Hill

SetWorkArmy ( ARMY , 2 )

Set @num_MainAttack_1_exist1 = GetNUnits ( GROUP , @@MainAttack_1 , ALL )

Set @num_MainAttack_2_exist1 = GetNUnits ( GROUP , @@MainAttack_2 , ALL )

Set @num_AC_exist1 = GetNUnits ( GROUP , @Recon1 , ARMOREDCAR , OK_ENGINE , OK_WEAPON )

Delay ( 1000 )

ADD ( @num_MainAttack_1_exist1 , @num_MainAttack_2_exist1 )

SetWorkArmy ( ARMY , 1 )

Set @num_Runits = GetNUnitsInArea ( Army , 1 , HUMAN , "Right" , NO_PANIC )

Set @num_RArt = GetNUnitsInArea ( Army , 1 , ARTILLERY , "Right" , NOT_EMPTY )

If ( @num_Runits > 4 OR @num_RArt > 0 ) then

Delay ( 100 )

if ( @num_MainAttack_1_exist1 < 5 AND @num_AC_exist1 = 0 ) then

Delay ( 100 )

goto Attack_Town

endif

Delay ( 5000 )

goto Check_RTroops_Hill

endif

//once hill is secure, Recon units attack town

Label Attack_Town</pre>

Link to comment
Share on other sites

Can't see any obvious errors, so here are some debugging tips:

1) Test in isolation. Make up a map with just this routine in it. Make it so there are cases of always enough, maybe enough and never enough for each of the conditionals. See which work and which don't.

2) Have messages output to the console. ie "checking for units on hill", "checking for enough force", "no units on hill attacking town", "not enough force attacking town". This will flag the logic path to you.

3) Output variables to the console after their respective steps to make sure you are getting the results you believe you are. I've forgotten the syntax for this and am out of spare time, so I'm not much help here.

4) If the isolation cases work, test with the full program. If it works in isolation and not insertted, oh dear, oh dear.

Hope it helps some.

Link to comment
Share on other sites

Very good suggestions PFMM. I generally will try to test it in isolation, but I was rushing to finish and didn't take the time. I guess I will now.

My only question is how do you output variables to the console? I don't see any way to do it with the code we have available. Back to the mines.

Oudy

Link to comment
Share on other sites

I finally figured out the problem (that's what I get for trying to write code at 2:00a.m.

Ironically, this code works. What I had mistakenly done with the previous version is had the SetWorkArmy ( ARMY , 2 ) before the label, so after looping through once, the army was still set to Army 1 and it jumped out of the loop.

I'm about to upload the mission.

Thanks for all of the advice.

Oudy

Link to comment
Share on other sites

×
×
  • Create New...