Advertisement

Author Topic: Semi-automatic defensive positions  (Read 1343 times)

0 Members and 1 Guest are viewing this topic.

Offline lendrom

  • Members
  • *
Semi-automatic defensive positions
« on: 20 Mar 2008, 09:23:09 »
Introduction
I'm not sure if it's a right place to post it. It would better suit "Editing and scripting Ideas" board (there was one like that on OFPEC some time ago, wasn't it?).
Anyway I have a script which is not perfect but it suits its purpose quite good and I don't think I'll be able (because of skills and time) to develop any further but I think the idea and work done so far is worthy to be shared with the community.

The script is based on General Barron's beta script for OFP which for some unknown reason caused OFP to CTD. So AFAIK General Barron stopped working on it. But when ARMA came out I realised that the scrip works (with slight improvements) with the new game. So I started to add my little improvements (now the script is rather different than the General Barron's one) and now I don't think I'll be able to improve it any more (this really DOESN'T mean it can't be improved - I'm just not skilled enough). So I release it now so anyone can develop it further or just use it in mission in its current state.

Purpose:
Script is used to semi-automaticly force some units to efectively use a cover. In its current state it can be used to quickly prepare some defence missions.

Features:
- when the script is executed units automaticly search for suitable cover
- units know how to use the cover - they hide behind the cover and pop up from behind it to shoot

Room for improvements:
- rewrite the script to sqf
- add more general script which would automaticly decide when the units should take cover (and at which position and in which direction) and when they should leave the cover
- add suppressive fire script which would force units to search for cover and to increase the time they stay behind the cover and decrease the time for which they pop up from behind it
- add better handling of exceptions ie. which types of cover to ignore (for now there is a quite clumsy way of ruling out claseless visitor placed objects such as roads)
- better taking cover rutines for urban areas and woods
Anyone is free to copy, modify, print and burn at his fireplace those scripts. It would be nice though if he gave me some credit ;) (and to General Barron - as it is he who gave it a first try).


Some technical remarks:
Execution:
- copy contents of "init.sqs" to your mission's init.sqs
- use [<unit>, <position>, <direction>, <radius>] exec "LEH_takeCoverIt.sqs" to execute the script. Fourth parameter is optional.

Parameters:
unit - unit to take cover
position - position around which unit is to search for cover (eg. position <unit>)
direction - direction from which the cover shoud protect the unit
radius - (optional) - radius in which the unit should search for cover
Script uses some global variables (with LEH tag) initiated in "init.sqs".


Ok. Now after my too-long introduction you can try the two attached missions.
Blessed are those who have nothing to say and yet they remain silent.

Offline Wolfrug

  • Addons Depot
  • Administrator
  • *****
  • Official OFPEC Old Timer
Re: Semi-automatic defensive positions
« Reply #1 on: 20 Mar 2008, 10:10:03 »
:D Since it's not a question, and you've actually got a script attached, I think this fits better in here. /moderator hat.

Will check this out, sounds quite nice! Although yes - conversion to .sqf might be a good idea overall. Nice stuff, nice stuff...

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Semi-automatic defensive positions
« Reply #2 on: 20 Mar 2008, 10:34:46 »
As long as Lendrom wants it here to be tested and potentially submitted to the ED.

Offline lendrom

  • Members
  • *
Re: Semi-automatic defensive positions
« Reply #3 on: 20 Mar 2008, 11:19:23 »
Well, I posted it in Editing/Scripting General because I don't feel it's a finished product and I doubt if I will be able to develop it further. The intention of posting this was to show the idea, show the ilustration how do I think this could be done (and that it works to some extent) ask the scripting gurus if they think this isn't a senseless project and finally encourage someone to pick up the idea and help me with the project, or completely take it over from me.
Blessed are those who have nothing to say and yet they remain silent.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Semi-automatic defensive positions
« Reply #4 on: 20 Mar 2008, 12:33:43 »
Well, if you want to finish it, and you need our help, then this is the place  ;)

Offline lendrom

  • Members
  • *
Re: Semi-automatic defensive positions
« Reply #5 on: 28 Mar 2008, 17:19:09 »
Has anyone tried it? Does anyone have any suggestions or thoughts? Btw I had a very busy week but I tried 1.11 beta patch and I noticed that it introduces a small bug to my script (units behind cover not only strafe behind cover as intended but they move forward and then strafe and end up a long way before the cover).
Blessed are those who have nothing to say and yet they remain silent.

Offline Wolfrug

  • Addons Depot
  • Administrator
  • *****
  • Official OFPEC Old Timer
Re: Semi-automatic defensive positions
« Reply #6 on: 28 Mar 2008, 17:33:14 »
Sorry, yeah - meant to post but it kept slipping my mind :D

Tried the test missions - particularly in the second there was a rather atrocious init-lag as everything was (presumably) prepared for the groups. Definitely needs a move to .sqf, and probably needs to chop the script up into several preloaded bits that can be called for more efficient use of resources.

Other than that, it did look...well...better than if they'd just stand around and take the attack. Some walked too far, some stood too far back, some didn't seem to find anything at all. Sometimes they'd occupy the exact same space, either because they animate-walked into it or because of the script. But as mentioned, definitely an improvement over default behaviour!

But first things first : you have to make it more resource-friendly! Two squads using this can't slow down the game to a crawl. Converting to .sqf and chopping up bits that can be called is a good start. A good effort though, definitely has some potential.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline lendrom

  • Members
  • *
Re: Semi-automatic defensive positions
« Reply #7 on: 28 Mar 2008, 18:16:09 »
Thanks for your oppinion. It's good to hear you've got performance problems. This means that my PC isn't that bad :P. I just didn't notice any visible lags in demo missions. And if the lag occures I think it's because in the demo missions i executed the script for each units at the same time (ie with forEach) command which can cause a lot of lag. I think adding eg. '~(random 3)' (so the scripts wouldn't run simoutanously) command at the begining of the script would greately reduce the lag. I'll look into it later. The lag is only at the begining of the missions, right? Because I don't think the scripts' loops which run after the best cover for units is selected could cause lags.

Quote
Some walked too far, some stood too far back some didn't seem to find anything at all.
I don't think anything can be done about it as it totally depends on ARMA's pathfinding routines. And preventing the units from going into each other would require more loops which would hit the performance.
Quote
some didn't seem to find anything at all
It is possible. When a unit doesn't find a cover he'll stay at his position. I tried to prevent it but sometimes units can choose some not suitable object for cover - roads, mosquitos, bees ;) (AFAIK this shouldn't happen now).

Quote
Sometimes they'd occupy the exact same space, either because they animate-walked into it or because of the script.
What I tried to do was to prevent many units from choosing the same cover for themselves (to avoid a sitiuation in which all the group would hide behind one tree which accured in the early stage of the making of the script) and I think it works quite good. Every choosen cover is added to a global array of occupied covers and if the next unit wants to use it cover the script will know that the cover is occupied. The cover is deleted from the global array of occupied covers when a unit using it dies or leaves the script.

Quote
Other than that, it did look...well...better than if they'd just stand around and take the attack.
Well I think that's the main purpose of the script at this stage. That's why I call it semi-automatic. It's up to mission dessigner to decide on which conditions (eg at which waypoint) groups should seek for cover and on which conditions they should leave the cover but he doesn't have to choose a cover for every particular unit.
Blessed are those who have nothing to say and yet they remain silent.