Home   Help Search Login Register  

Author Topic: Dynamic defend script  (Read 2460 times)

0 Members and 1 Guest are viewing this topic.

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Dynamic defend script
« on: 08 Mar 2007, 08:31:22 »
Trapper gave me an idea about dynamic defend concept:

I made an assault mission: the player attack with his squad and well-placed enemy defend a village. (Well placed mean: in buildings, behind objects... etc)
But defender are static (because they are well-placed... :) ). But it could frustrate the player and it avoid the replayability...
And this problem can solved with a dynamic defend script:


1., There are a few static soldiers (commander in a bunker, sniper on the roof)
2., Rest of enemy troops (riflemen, mg gunners...) will move/run/jog under the attack.
3., Moving/dynamic soldiers are individials (not in group), but they share information about their enemy. (knownAbout/reveal)
4., The script know a lot of good defending position (markers in the field, and buildings' positions)
5., When script run, in randomly period pick up a random soldier and move it to a new (random) position.

I want try it, but I need a help:

a., How can I force a soldier to move (not setPos) into a building to a defined position, from script (not in editor)?
b., How can I defined to a script (in parameter) a building and a building position?

I will have more question, but I could start working with it...

Oh, and BTW what is your opinion about the concept?
Fix bayonet!

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Dynamic defend script
« Reply #1 on: 09 Mar 2007, 07:44:23 »
I did it!!! :D

Code: [Select]
;Dynamic Defend
;usage:
;[soldiers, fixed positions in field, houses and positions] exec "dynDef.sqs"
;example:
;[[s1,s2,s3],[posGL1,posGL2],[[houseGL1,3],[houseGL2,18]]] exec "dynDef.sqs"
;
_unitpool = _this select 0
_unitpoolsize = count _unitpool
_pospool = _this select 1
_pospoolsize = count _pospool
_housepool = _this select 2
_housepoolsize = count _housepool

#eleje
~Random 6
_unit = _unitpool select (Random _unitpoolsize)
?(Random 2 > 1): goto "hazba"
_pos = getPos (_pospool select (Random _pospoolsize))
_unit doMove _pos
goto "eleje"
#hazba
_house = _housepool select (Random _housepoolsize)
_unit doMove (nearestBuilding (_house select 0) buildingPos (_house select 1))
goto "eleje"

There is no information sharing yet. But huge fun the running defenders... ;)

I attach an example...
Fix bayonet!

Offline Blanco

  • Former Staff
  • ****
Re: Dynamic defend script
« Reply #2 on: 09 Mar 2007, 08:32:21 »
Wtf, I was doing well. I captured the dshkm without any loss, countered upcoming forces from the south, but finaly got killed by a sniper.
He hit me 2 times in the legs. I crawl to safety but curieus as I am I popped my head once and bang! (predator's soundmod is so scary)
That sniper was sitting on the roof! Now that was cool.  8)

Anyway, I had a good time playing that mission but I couldn't really examine the AI's behaviour in the heat of the battle.
For scripts I prefer a simple testmission and watch it as a spectator.

 


Search or search or search before you ask.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Dynamic defend script
« Reply #3 on: 09 Mar 2007, 11:23:46 »
Bardosy,
it seems you are not giving the unit time to reach the desired defensive positon, with Ramdom 6 you are waiting between 0 and 6 secs before changing the command to an alredy running unit (as it is also selected randomly). You may check both, if the unit is ready (unitReady unit) and if the unit is already close to a valid defensive position. If any of these, you may want to change its position or let it there defending (fighting).

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Dynamic defend script
« Reply #4 on: 09 Mar 2007, 11:48:59 »
Thanks Blanco, Mandoble!

@Mandoble:
Random 6 is not too short, but right, I will change it (Random 6)+3 avoid the 0 sec. But this script pick soldiers from a pool. Yes, you're right, is it possible to pick a soldier and move him to any position and over 1 sec script Move this same soldier to an other position, but if there is a lot of soldiers (in my sample mission: 22) in the pool, this possibility is very small.
Thanks for the suggestion about unitReady!!! I will build it!

But this script (without information sharing) just a funny thing: the loons run up and down and you have possiblility to shoot them easily.
What is the concept of information sharing??? I try to fing General Barrons Information Sharing script, but I didn't find it... Neighter in Ofpec. :(
I must collect the units to an array, witch enemy knowsAbout > 0.5 and then this loop in this array and reveal all units from this array to every soldier? Or what?
Fix bayonet!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Dynamic defend script
« Reply #5 on: 09 Mar 2007, 12:18:20 »
Another point is that you are giving moving commands once each time (and then wait n seconds), you if you have 100 defenders, you need to wait even 600 seconds hopping that defender number 100 is given a defense position. IMO you should check which positions are undefended (no deffender assigned), then move any defender still not assigned to a position to the "free" defensive position. But all at the same time, that is all running to reach their defensive positions as soon as possible. From time to time you check if any position is "free" again because the assigned defender is dead. If you still have defenders not assigned to defensive position, you move a new one to the new "free" position.

For example:

you have a big building with 20 soldiers inside. Around the building you set up 4 defensive positions. You try to cover all of them immediately with 4 men. If any is killed, the position is marked a "free" and you move a new soldier to substitute de dead one. Of course you need an array for positions, for example [position 3D, unit assigned], if unit assigned is objNull (value by default), or unit assigned is not alive, you assign a new one. You may make it a bit more complex, but much more reallistic, giving priorities to defensive positions. For example, you have 50 defensive positions but only 10 defenders. You need to move them to the positions following a priority order, if one defender is dead, and you still have an alive defender assigned to a lower priority position, you should move that defender to the higher priority position and so on.


Offline Blanco

  • Former Staff
  • ****
Re: Dynamic defend script
« Reply #6 on: 09 Mar 2007, 12:31:04 »
Quote
Moving/dynamic soldiers are individials (not in group), but they share information about their enemy. (knownAbout/reveal)

Why individuals soldiers?
We have disableAI "move" and EnableAI "move" in Arma.
Move some guys to the defensive positions and use unitname disable "move". When they have to leave the position use unitname EnableAI "move". You don't need a AI shareinfo script, they will stay in group.

I tried both commands and they work perfectly.

 
Search or search or search before you ask.