Home   Help Search Login Register  

Author Topic: (Accepted) Basic script for trenchfights  (Read 8973 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
(Accepted) Basic script for trenchfights
« on: 15 Jul 2007, 21:44:34 »
First off all, this script requires an addon.
This script, written in oldskool sqs, make AI units stay put behind the sandbags and pop-up once a while (optional)

Check the demomission on Rahmadi and let me know what you think...

In the zip:
- demomision
- Sandbagfix1.1 addon by Raedor
- Readme in txt and pdf format
 

« Last Edit: 06 Sep 2007, 19:53:30 by hoz »
Search or search or search before you ask.

Offline Blanco

  • Former Staff
  • ****
Re: Basic script for trenchfights
« Reply #1 on: 19 Jul 2007, 20:23:31 »
Updated 1.1*


Added:

- AI groups support static weapons. (optional) When a gunner got killed another unit will take his place.

For more information, read the readme in txt or pdf.

In the zip:
- A new demomision
- Sandbagfix1.1 addon by Raedor
- Readme in txt and pdf format

Can somebody test this in MP coop please?

*edit* There were some problems with missing addons. It's fixed now. link updated
« Last Edit: 06 Sep 2007, 19:54:24 by hoz »
Search or search or search before you ask.

Offline sharkattack

  • Former Staff
  • ****
Re: Basic script for trenchfights
« Reply #2 on: 23 Jul 2007, 20:36:11 »
Quote
Can somebody test this in MP coop please?

will make a short  demo ... im  sure  cheetah  wouldnt  mind  testing  how it  handles   next time  we  get  together for a game !
"HOLY SARDINE" - see Shark-Attack meet his match

Offline ZapBrannigan

  • Members
  • *
Re: Basic script for trenchfights
« Reply #3 on: 28 Jul 2007, 04:40:02 »
If the script fails after a save game why not just put disableAI"move" in the #loop in popup.sqs, then it will be continualy applied.

Offline Blanco

  • Former Staff
  • ****
Re: Basic script for trenchfights
« Reply #4 on: 28 Jul 2007, 08:52:44 »
I didn't try that, might work.
Tried it and it doesn't work when I place the disableAI move commands in the loop of the popup script.

I tried another solution to nail the savegame bug in an updated version
I add dostop , disableAI "move" and enableattack false. An AI-leader can only give targetorders so everybody stays put even when you save or load the mission.
When you're in command you are able to enable moving by changing the selected unit(s) behavior to anything else then "combat" (thx to mandoble for the tip). Mounted units will dismount when they are in the same group.
Works fine, but it seems my script is getting slow. The condition to check the units behavior is in the popup script, it should take max 12sec before they leave the trenches, sometimes it takes minutes when they are under attack. I dunno why, but is this script lag?









 
« Last Edit: 28 Jul 2007, 09:58:02 by Blanco »
Search or search or search before you ask.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Basic script for trenchfights
« Reply #5 on: 28 Jul 2007, 10:10:36 »
I just tried this and it works pretty slick, I like it alot!.

I took the liberty of modifying the pop up script a little so that when prone, the unit will crawl sideways left or right sometimes, shifting their position a little (harder to predict where they will pop up that way).  Incorporate it if you like it.  I added comments to popup code below to clearly mark the new lines.  I also added a condition to exit the popup script if the unit is the player.

Code: [Select]
private ["_man"]

_man = _this select 0

;;; BEGIN ADDED CODE
;;; initialize _last_move variable
_last_move = "None"
;;; END ADDED CODE
#loop
;;; CHANGED FOLLOWING LINE, ADDED "or _man == player" CONDITION
?! alive _man or _man == player: exit
_man setUnitPos "down"

;;; BEGIN ADDED CODE
;;; next five lines will have shooter shift position left or right sometimes.
~1
_rand = ROUND (random 4)
?_rand == 0 && !(_last_move == "L"): _man playmove "AmovPpneMrunSlowWrflDl"; _last_move = "L"
?_rand == 1 && !(_last_move == "R"): _man playmove "AmovPpneMrunSlowWrflDr"; _last_move = "R"
?_rand > 1: _last_move == "None"
;;; END ADDED CODE

~5 + random 8
_man setUnitPos "middle"
~5 + random 8
goto "loop"


To take this further, you could test whether the unit's current weapon is rifle or pistol, and then play the correct corresponding move for crawling left/right (right now its hardcoded to rifle crawl).

It would also be really cool to integrate this with second's suppression script, where the time prone is increased the more suppressed the units are.  Might not be too hard to add a global variable in his his script (per group running the popup scripts) that carries the suppression level per group.  The  popup script would then check the global suppression level for their group, and adjust the time prone accordingly.

To speed the popup script up, converting it to a compiled function might help.  Especially because the script is being run by multiple units.

Anyways, good idea dude!
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Blanco

  • Former Staff
  • ****
Re: Basic script for trenchfights
« Reply #6 on: 28 Jul 2007, 10:24:38 »
Very nice, I tried it and it looks very good.  I had the same thing in mind but with the rolling animaitions, but I didn't try it yet. Maybe I can use them both.

 
Search or search or search before you ask.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Basic script for trenchfights
« Reply #7 on: 28 Jul 2007, 23:35:38 »
Rolling would be cool.  Especially for guys on the sides of the cover.  Roll out shoot.  Roll back hide.  Repeat.

I also tried it with two side-crawls in a row, so they pop up further away from center position.  But then you get them bumping into their neighbors, so you have think more about how far apart you space the defenders.  You will likely have that issue with the roll too.  So Parameter driving that with the script would make it more flexible.  Mission Designer can pass one parameter for a group that has its units close to each other, so you only crawl once left/right.  Pass a different parameter if they are more widely spaced, so they can roll or crawl twice.  Pass another parameter for guys on sides of cover,who will roll out---shoot--roll back.  The bigger the mix of possiblities, the more natural it will look.

I've been toying with these ideas for awhile, as I am working on group movement script that directs units to fixed positions in buildings or anywhere.  Once in position, it would be nice to integrate your script, with a few more options.  Popup is good for low walls and some windows.  But sidestepping would also be good for windows, pillars, wall corners, vehicle corners, etc.   Step out, shoot, step back.  Sidestepping looked really good in that video by sin329 linked on the ofpec home page.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Blanco

  • Former Staff
  • ****
Re: Basic script for trenchfights
« Reply #8 on: 29 Jul 2007, 03:04:20 »
I tried the rolling but I have a problem.
Animation names are "amovppnemstpsraswrfldnon_amovppnemevaslowwrfldl" for a left roll and "amovppnemstpsraswrfldnon_amovppnemevaslowwrfldr" for a right roll. When I use these in my popup script, the units perform the roll but always twice. First I thought it had something to do with loop, but later in the editor I tried these on a single unit via a trigger and they still do a double roll. I don't understand why this happens, it makes no sense.



Search or search or search before you ask.

Offline ZapBrannigan

  • Members
  • *
Re: Basic script for trenchfights
« Reply #9 on: 30 Jul 2007, 03:24:38 »
It has to do with the config in the animations im sure, if you de-PBO them and look at the config you will see the awnser.
I used to do configs for OFP animations. I dont know if arma is the same and it was along time ago that I last looked at one but maybe I can help.

also, in your demo mission, I cant find how you are executing the trench scripts, there is no trigger that I can find with []exec anything. And there is no init in the mission file. how are you running them?


Offline Blanco

  • Former Staff
  • ****
Re: Basic script for trenchfights
« Reply #10 on: 30 Jul 2007, 07:06:00 »
There are three parameters. (last two of them are optional)

1- name of the group
2- pop-up ability (true or false)
3- Third parameter is a nested array.

First element in the array is the name of the static weapon the group must support (when the gunner got killed, the closest unit in the group will take his place)
Second element is the name of the trigger that covers the units that must support the static weapon. Positions of the units are fixed anyway.

You can run the script in an init, trigger, script. In the demo I start the script in the groupleader init. I don't define a group name, I use group this.
If you want to run it in a script, trigger,... whatever you have to define and use the groupname.

Examples:
Quote
[group this, true] exec "trenches\outpost.sqs"

In this case the script starts in the init of a groupleader, because groupname is not defined. The group will pop-up once a while (default) but they won't support any static weapon.
Quote
[mygrp, false] exec "trenches\outpost.sqs"


Name of the group is mygrp and they will kneel all the time and no weapon support.

Quote
[wgrp3, true,[MGbunker,MGbunkertrig]] exec "trenches\outpost.sqs" 

Name of the group is Wgrp3, they pop-up and they support a static weapon named MGbunker. There also a trigger named MGbunkertrig covering all the unit that should support the weapon. You don't have to cover all the units in the group, units outside the triggerarea don't support static weapons.

When you place a group behind the trenches, just put them in the desired position/direction, but don't forget to set "none" in the special dropdown menu in the units init. (for each unit).

Can this be done via scripting btw? I know you can when you create units, but I'm not sure you can when you place the units on the map...

 
 

It's in the readme btw :)

« Last Edit: 30 Jul 2007, 07:23:26 by Blanco »
Search or search or search before you ask.

Offline ZapBrannigan

  • Members
  • *
Re: Basic script for trenchfights
« Reply #11 on: 30 Jul 2007, 18:29:26 »
Quote
In the demo I start the script in the groupleader init.

I see. I was expecting it to be started in a trigger. Have you ever tried starting it in a trigger, because that could maybe fix the save game bug. Possibly. You probably have already tried it.  Because If in a trigger the script wont be executed until .5 seconds or later after the game starts(which is the time a trigger takes I think).
« Last Edit: 30 Jul 2007, 18:31:49 by ZapBrannigan »

Offline subroc

  • Members
  • *
Re: Basic script for trenchfights
« Reply #12 on: 06 Aug 2007, 21:25:54 »

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
Re: (Accepted) Basic script for trenchfights
« Reply #13 on: 28 Dec 2008, 15:05:45 »
Hello blanco, hello everybody
sorry for digging up this thread but I need to know how to fix my current problem with this script. The scripts are working fine and I'm using the script for a lot of my defending missions, but there is 1 thing I would like to mention.
1.) My main problem lies in a kind of listing of following string messages

Code: [Select]
"SCALAR BOOL ARRAY STRING 0XE0FFFFEF"
Now I believe that it has definitely something to do with Raedor's Sandbagfix. I removed it from all missions mqs. since then I receive this strange string listings. I wasn't fully aware until now reading throughout this topic that the sandbagfix is neccessary in order for the script to work propperly.

Since I don't have any clue how to fix this can anybody give me some advice?
Thanks for any feedback in advance and a happy new year.
nettrucker

Offline MRO204

  • Members
  • *
  • I'm a llama!
Re: (Accepted) Basic script for trenchfights
« Reply #14 on: 05 Jan 2009, 18:52:26 »
You dont need the sandbag fix after patch 1.08 i think.  :)

Offline nettrucker

  • Members
  • *
  • Too young to die-OFP Campaign by TOY & nettrucker
Re: (Accepted) Basic script for trenchfights
« Reply #15 on: 07 Jan 2009, 16:04:40 »
Hello MRO240
Yeah I know that the sandbagfix is not needed anymore and that's why I removed it from my addon folder and from all missions.sqm. But in the topic states that the sandbagfix addon is needed to run this script propperly. As a matter of fact I get this weird string listings since I removed the sandbagfix.
Thanks anyway for your reply
regards
nettrucker :)

Offline MRO204

  • Members
  • *
  • I'm a llama!
Re: (Accepted) Basic script for trenchfights
« Reply #16 on: 13 Jan 2009, 00:13:50 »
Well i just downloaded the test mission and then took out the sandbag fix from the mission.sqs there only 2 lines and it all works perfect .. no errors what so ever.  :)

Offline Dirtiej

  • Members
  • *
Re: Basic script for trenchfights
« Reply #17 on: 06 Feb 2010, 20:31:00 »
i�ts no problem to use a trigger to activate the script. in one mission i  set my outpost group to disableAI "move" and set behaviour "safe" in the initifield to get them standing still then i execute the script via a "opfor detected by blufor trigger" that way i get the units to stand on guard and not dipping behind cover until the enemy is detected

Hello subroc,

I like your idea about keeping the AI standing around until the enemy is detected, can you post the details of the Trigger you used to get the AI to start the Trench behavior?  I would like to learn how to do that and am pretty new at Triggers.

Blanco, thanks for sharing this script, its exactly what I've been looking for!  :good:



Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: (Accepted) Basic script for trenchfights
« Reply #18 on: 06 Feb 2010, 21:58:16 »
After a year or so I suspect most of the people who posted here have forgotten about this topic by now.   :cool2:


Planck
I know a little about a lot, and a lot about a little.

Offline subroc

  • Members
  • *
Re: (Accepted) Basic script for trenchfights
« Reply #19 on: 09 Feb 2010, 19:32:39 »
 belive it or not, today i actually entered this subforum by mistake (or devine intervention?  :D) instead of the a2 forum and read this post.

set up the outpost group
in the initfield of the "oupostgroup" leader write:
{_x set behaviour "safe"; _x disableai "move"} foreach units group this; mygrp = group this

set up a trigger with (enemyside) detected by (side of outpostgroup) and the size of the trigger that you want to detect in and in the activationfield of the trigger write:

[mygrp, false] exec "trenches\outpost.sqs"

Sorry if the syntax is messed up havent done any coding for a1 in a year

Offline Dirtiej

  • Members
  • *
Re: (Accepted) Basic script for trenchfights
« Reply #20 on: 10 Feb 2010, 06:03:08 »
Thanks Subroc!

You are the Man! I'll try this out right away.  :good: