Jump to content
Sign in to follow this  
buddhabang

Counter Attack AI

Recommended Posts

Hi guys, just wanted to find out a way to spawn East AIs after a target has been cleaned up, for counter attacks. So wanted to see if i could pick your brains please.

I've tried doing: "SoldierWB" createUnit [position player, group player] but doesn't work. Thanks in advance.

Share this post


Link to post
Share on other sites

If you don't mind me asking, what's with recent mindset that everything must be spawned during a mission. Unless you're using 1000s of units, IMO it's simpler (and more immersive than spawning units) to just place them somewhere (like a nearby town or camp) and use waypoints.

One of these days I should write up my opinions on good mission design. :j:

Share this post


Link to post
Share on other sites

Yeah fair enough, but i've always wanted to find out how to spawn them in the map, from a trigger let's say if Town captured then spawn couple of AIs to recapture it, if not there won't be any spawned. Thanks for taking the time to have a look.

Share this post


Link to post
Share on other sites

There are plenty of examples here on how to spawn units (and groups of units) for various purposes. If you really want to know, do a quick search and you should be able to figure it out in no time (as I said it's quite a popular trend). This is my advice as a scripter.

My advice as a mission designer would still be to just keep it simple. Part of what originally (well what I found) made OFP so great was that you had the capability to have the enemy realistically and immersively maneuver forces around the island. In other words, you don't need to use cheap tricks such as spawning units all the time in ArmA 2. Maybe it's just me, but I like to be able to see all of the "behind the scenes" stuff the enemy does, even if there's a very slim chance the player will see it.

Share this post


Link to post
Share on other sites

No you are right, i usually like to keep it simple, it's just one of those things i wanted to find out how to. But i will do a quick search and see what pops up.

I was only asking due to the fact the more AI u place, then the more likely you will get bit of lag. So only place the unit, when they were needed.

But i see where you're coming from. Cheers.

Share this post


Link to post
Share on other sites
One of these days I should write up my opinions on good mission design. :j:

Hmm that'll be an interesting thread.

Prespawned troops are good any for small-medium sized regular missions.

Dynamic spawning is only necessary for really huge battles or missions with dynamic content. However, only do dynamic spawning if you do it well.

Spawning shouldn't be noticable by the player or if noticable it shouldn't seem unrealistic.

I've been messing around with a spawnsetup for ArmA1 we're each city had some patrols moving around and if they noticed someone, an alarm rang and the remaining troops came out of their barracks. :rolleyes: They spawned infront of the doors one by one, assembled nearby until a squad was complete and then moved around to hunt the intruders.

Afterwards they would return to their baracks, despawn and their numbers we're saved.

I somehow liked that system.

If you managed to get past the guards or kill them without beeing noticed you could destroy the baracks before the enemy soldiers left them.

Well, back to topic:

"SoldierWB" is an ArmA1 classname and won't work in ArmA2.

Try "USMC_Soldier" and provide some more parameters when spawning him, like the unit-skill and rank.

Like this:

_type createUnit [_pos,_group,_init,_skill,_rank];

Edited by Tajin

Share this post


Link to post
Share on other sites

I was only asking due to the fact the more AI u place, then the more likely you will get bit of lag.

In my experience, it's not noticable (if even true at all).

Hmm that'll be an interesting thread.

The secret to good design is being lazy... :p

Share this post


Link to post
Share on other sites
If you don't mind me asking, what's with recent mindset that everything must be spawned during a mission.

I think mission-editing is way more flexible/elegant with heavy use of scripting (which includes the spawning of lots of units, instead of placing them directly in the editor).

My mission's usually have tons of empty markers, but not much units anywhere. The benefits to this strategy are numberous and if done right, there is no noticable difference for the player (placing a unit in the editor is exactly spawing, and you can even randomize it a little there, directly in the editor: placement, prob. of presence, etc. The only difference is, that editor-placed units will get spawned at the beginning of the mission. But this is in lots of cases not only very limiting, but also can be a problem cpu-consumption, etc.)

My favorite example is this: So you have placed a group of units per editor, and gave them n-waypoints, in the editor too. Move, Move, Talk, Move, Guard, or whatever. And then you realize, that after the 4th waypoint there should be another one, with different options. What now? If you've done everything in the editor, you'll end up deleting all waypoints after the 4th one, inserting a new one, and then once again setting up the waypoints after the 4th one, which you just had to delete... this is so lame.

Now, if you had created your group per script, and thus all the waypoints would be scripted too, then you could just insert a new one anywhere you like. It's so much better and faster! to script also the simplest things (unless you are not comfortable with programming that is).

So the main reasons in short:

  • Much faster, more flexible, and IMHO more reliable in the end.
  • You can reuse your code! Yeah, you can import from another mission in the editor too, but it's nowhere near as good. If you start to abstract, before you start to write a script, you will end up with a huge collection of scripts which will come in handy every now and then.
  • And last but not least: only scripting gives you the power, to make a mission not only random (which is horrible if not done well), but `intelligent`/coherent! Instead of randomly spawning units/doing anything, you can first - per script - check various circumstances, and then do, what is called for. You can adapt waypoints/placement of units, tactics of AI, etc. to the situation, and thus you can make all so much more believable! And you can't do any of this without scripting.
    Eg. Say you squad has suffered heavy losses, thus you won't be able to proceed with your mission. Failed. But wait, we could setup a script, checking for such a situation, and then evt. the HQ will send you some reinforcements. Thus, a mission can go on, thanks to a new scripted event, which otherwise would have led to an end here...
    Another example: Instead uf just placing enemies in the editor for a 3rd or 4th objective, you first check per script (once you're up to this task) how strong the players group still is. Then spawn enemies there accordingly, or you could give the player some help in form of squad bravo (assisting team) or whatever.
    IMHO this makes for far better missions, which really can play out totally different. Perhaps you can do a missions objectives all on your own, perhaps you will need assistance, etc. You won't get assistance every time you play the mission. You can script side-missions if things go too well, or too bad, and this at locations which are - per script - assured to be coherent, etc..

I could go on and on about this. Scripting is just so much more powerful than placing some grunts in the editor and giving them waypoints. And thus writing missions this way is simply sooo much more fun! And hopefully the result will be a better mission. Yeah! :D

Share this post


Link to post
Share on other sites

Some of the best singleplayer/coop-missions out there use no scripts at all.

They may not be as dynamic as scripted missions but they tend to be more detailed/immersive.

The simple advantage of having all units available at missionstart is that the player will have much more possiblities of overcoming the situation. On the example of that city that recieves reinforcements after beeing captured. The player could scout the area before attacking, he would maybe notice the camp where the reeinforcements are stationed. Mines could be placed on the road or the camp itself could be attacked first. (possibly capturing some useful equipment that can then be used to attack the city).

Sure all this can be done by scripting, but thats alot more complicated, has the possiblity of appearing unrealistic and..... Well scripting gives you power, but it also allows you to fuck everything up big time. Lets just think about bugged Evolution-versions where an city that you have to capture is completly without any opposition and can not even be captured regardless of this.

Also, if not used carefully, scripting can produce even more serverload and desync than a whole batalion of AI soldiers.

Simply put: It's all in the mix and always depends on the abilities of the missionmaker.

A mission solely made with scripting should only be done by someone who really knows what he's doing.

Share this post


Link to post
Share on other sites

Well, back to topic:

"SoldierWB" is an ArmA1 classname and won't work in ArmA2.

Try "USMC_Soldier" and provide some more parameters when spawning him, like the unit-skill and rank.

Like this:

_type createUnit [_pos,_group,_init,_skill,_rank];

Thansk would this work then:

"USMC_Soldier" createUnit [getMarkerPos "myMarker", _groupAlpha, 0.6, "corporal"]

Thanks everyone.

Share this post


Link to post
Share on other sites

Sorry, but I am going to have to disagree with most of what you said.

My favorite example is this: So you have placed a group of units per editor, and gave them n-waypoints, in the editor too. Move, Move, Talk, Move, Guard, or whatever. And then you realize, that after the 4th waypoint there should be another one, with different options. What now? If you've done everything in the editor, you'll end up deleting all waypoints after the 4th one, inserting a new one, and then once again setting up the waypoints after the 4th one, which you just had to delete... this is so lame.

First of all, I can help you there. You actually can insert waypoints in the editor between two others. In the dialog for editing a specific waypoint, there is a drop-down box where you can select the waypoint index. You can use this to reorder waypoints as well as insert new ones between existing ones.

I think mission-editing is way more flexible/elegant with heavy use of scripting

This is entirely dependent on the nature of the scripting. A lot of times heavy scripting can make things very unmanagable.

The benefits to this strategy are numberous and if done right, there is no noticable difference for the player

Sure it has it's advantages, but it doesn't replace actually placing stuff in the editor. While I won't argue that it's not possible to make it seem unnoticable to the player, doing so requires a lot more work than simply working in the editor. It's not the same as physically having the units there at all times, doing their thing. Spawning units all of the time has big disadvantages too. The biggest of such disadvantages is simply the lack of believability you get as opposed to persistant units that have been preplaced using logic. In addition, scripting is not free on computing power. If you use heavy scripting just to spawn units, that's less potential for other scripting for things that you can't do without scripting (in other words, it's a bad use of system resources).

Like I said before, OFP/ArmA are unique games because they allow us to make a huge living world where things go about their business without the player even being around. This itself has many benefits to the realism and immersiveness of your mission.

IMHO this makes for far better missions, which really can play out totally different

Well, alot of your examples aren't limited to spawning units on the fly either. My point is that you can do this just fine by placing units in the editor, using triggers and waypoints, and minimal scripting. Again, the advantage is immersion. You simply can't predict what the player is going to do, so having stuff happening all of the time regardless of what they are doing makes for better mission design IMO.

Share this post


Link to post
Share on other sites

Well i think there is no right or wrong here, it's there for people to use. I've been playing Arma for like a year and half now, and it's been in the back of my mind for quiet some time how to do this. But i agree with both of you in the way you think. I'm easy going, but i would still use it, only for counter attacks. So a hint would pop up for the player to stay put and defend, then AI will pop up in some woods nearby and attack. I'm not gonna make things overly complicated. Just simple commands, create then move for the offensive, when they died that's it, You've resisted the counter attack.

Time to go home and try it. Well 10 mins to go. :) I've done hardly any work today,....lolz

Edited by BuddhaBang

Share this post


Link to post
Share on other sites

Well, the keyword here is `adaption`. You can set up a nice situation in the editor, but once things start to evolve, you can't do much anymore. Besides, there is no substantial difference between editor-setups and scripts. It's both exactly the same, except that editor-setups are very limited compared to the possibilities of scripting (of course this freedom/power means you can fuck up everything even more, but that's no argument). Therefore a discussion editor vs. scripting is pointless.

It's about the mission-making-paradigm anyway. Do you wan't to setup a situation which the player resolves/walks through. Or do you wan't to setup a scenario on a greater scale, where things can evolve very different each time you play it? Both is fine - of course.

PS. I didn't realize that you can rearrange your waypoints in the editor! Well, that's great then!

Edited by ruebe

Share this post


Link to post
Share on other sites

Well i've got a few objectives to do, with lots of AIs already spawned in the editor. And i was aksing about this because, one of the objectives is to cripple the enemy's Armoured Division, but once some of the tanks are destroyed, you basically get the crewmen, who were out of the base "on a holiday camp", and when they returned to base, they find you've destroyed their tanks and attack you. Just a story line.

Gotta go now...Work finished. Well if i did do any work :) hehe

Share this post


Link to post
Share on other sites

Well, why not put them in some distant town and have them drive in with a truck or something. You might find this strange about me but for some reason I always find it fun to put tank crewmen in non-armored vehicles (for transport).

Share this post


Link to post
Share on other sites
Well, why not put them in some distant town and have them drive in with a truck or something. You might find this strange about me but for some reason I always find it fun to put tank crewmen in non-armored vehicles (for transport).

True that's a possibility...but at last i've just tried it and it works fine.

Quick test: Trigger Alpha:

"USMC_Soldier" createUnit [getMarkerPos "spawnPoint", groupAlpha,"loon1 = this ; this addweapon {binocular}", 0.6, "corporal"]

Thanks for your help guys.

Share this post


Link to post
Share on other sites

@ Ruebe: I don't get your example about changing/adding wavepoints. ARMA2 editor gives option of (re)ordering wavepoints!

I like the ARMA2 editing posibility's and scripting. It would be nice to get to know more details on the AI behaviour for more efficient scripting. Now it sometimes feels like reeducating babys'-with-guns. Is it my knowledge or are they actually stupid!

Still, which game give yout his option of playing around :) :) :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×