Jump to content

Scripting: Minimum to get ground units engage each other?

Recommended Posts

I'm trying to spawn some ground units and have them engage each other. With ME, that's quite easy. Pick Red side, pick unit, place. Pick Blue side, pick unit, place. Run scenario, and if the units see each other and are placed close enough, they'll engage each other. 


Now I'm trying the same from script and all I get are some units that blissfully ignore each other and enjoy the view. While that may be a nice story to tell, it's not what I was looking for. No mayhem. I need your help to change that.


Here's what I do (once for each side, I'm using "Hummer" as unitType


- I create some group data with "Hummers" as units (5 each). Minimal data table as shown in the docs.

- I spawn the units via coalition.addGroup. The units appear just like I want them, where I want them. one red group, one blue group.


No mayhem.


OK, so I task them:

- First I wait 5 seconds, then both groups receive an option ROE: weapons free. 

- Another second later, I give them the task to attack the other group.




Which brings me to the question: what am I overlooking? What is required for two units to actually attack each other? One possibility is that perhaps - due to the minimal unit data table I use for addGroup, they are perhaps unarmed? But before I deep-dive into further frustration I thought I'd better solicit some tips on how it's done correctly. 


This is how I create the ground unit data for spawning:


function createGroundUnitData(name, unitType, transportable)
		local theUnit = {}
		theUnit.type = unitType -- e.g. "LAV-25" or "Hummer"
		theUnit.transportable = {["randomTransportable"] = transportable} 
		theUnit.skill = "Average" -- always average 
		theUnit.x = 0 
		theUnit.y = 0
		theUnit.name = name
		theUnit.playerCanDrive = false
		theUnit.heading = 0
		return theUnit


I then simply add that to the group update x and y, and then spawn the group.


Too simplistic?


Thank you for any pointers!




Link to post
Share on other sites

OK, before you laugh I found out what I did wrong.


In a game about warfare I managed to pick exactly the unit that is not armed. Replace "Hummer" in the type with "AAV7" and they immediately attack each other.


Thanks all!




Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...