Jump to content
Alias001

Scripting door closing

Recommended Posts

Hey all

I'm trying to figure out how to close all the doors in a town (agia marina if it matters) but I can't seem to get things working. I found the following script which is supposed to close all the doors in a certain area that was made for operation arrowhead that I've tried to adapt:

0 = [getpos doorcloser,1000] spawn {

sleep 1;

{

private "_b";

_b = _x;

for "_i" from 0 to 7 do {

_b animate ["dvere" + str _i,1]

};

} foreach ((_this select 0) nearobjects (_this select 1))

}

I named the trigger that I'm using to execute the script 'doorcloser' and added a hint popup to the script to make sure the script itself started and it shows up ok but nothing else happens, no error but also no closed doors. I presume they've changed things since OA and the script won't work anymore (that or I'm really misunderstanding how it works). Does anyone know how to accomplish this in Arma3? It removes a little tension from building clearance if you know in advance that there's a guy in there since he didn't close the door when he went in, its like he was born in a barn!

Share this post


Link to post
Share on other sites
0 = [getpos doorcloser,1000] spawn {

sleep 1;

{

private "_b";

_b = _x;

for "_i" from 0 to 7 do {

_b animate ["door_" + str _i + "_rot",1]

};

} foreach ((_this select 0) nearobjects (_this select 1))

}

This works for me in all buildings i have tested.

Share this post


Link to post
Share on other sites
It removes a little tension from building clearance if you know in advance that there's a guy in there since he didn't close the door when he went in, its like he was born in a barn!

or he knows how to close a door, unlike someone. you have to admit you walked into that. that's just what came to mind when I read this and thought I would post it for lols. besides that VanZant has it covered.

Share this post


Link to post
Share on other sites

I tried to use this code to have all the doors closed in the area after AI move inside buildings, and it did not work. VanZant, can you elaborate on how you got it to work?

Share this post


Link to post
Share on other sites
Just put down the Door Close Module and enjoy.

I placed the module, and have it set to close doors in a 500m radius. When the mission starts, the AI move into position and the doors remain open. Am I missing something here?

**edit**

I figured it out, you need to sync a trigger with the module. Once the trigger is activated, the doors close. Thanks Kylania

Edited by EvilNate

Share this post


Link to post
Share on other sites

Is there a way to dynamically check when a door opens/closes. Obviously the AI can check if a door is closed and open it before they walk through. I just wanted to add an element where the door closes after a certain number of seconds but only for that specific door.

Share this post


Link to post
Share on other sites

I am building a stealth mission and I would like the AI to detect if a door is open and if no opfor are nearby it will throw the AI unit into alert for a short time. Is this possible? Thanks.

Share this post


Link to post
Share on other sites

I am building a stealth mission and I would like the AI to detect if a door is open and if no opfor are nearby it will throw the AI unit into alert for a short time. Is this possible? Thanks.

 

animationPhase might be useful for this.

Share this post


Link to post
Share on other sites

Seems there's also a new command nearestTerrainObjects which can find nearby house objects.

_nearHouses = nearestTerrainObjects [aiObject, ["House"], 50];

Also might poke around the Automated Doors A3 script for some hints and predetermined doors for various maps.

Share this post


Link to post
Share on other sites

Seems there's also a new command nearestTerrainObjects which can find nearby house objects.

_nearHouses = nearestTerrainObjects [aiObject, ["House"], 50];
Also might poke around the Automated Doors A3 script for some hints and predetermined doors for various maps.

Awesome. I have gotten the door module to work with a trigger in opening a door but not closing it. and there is also the issue of units detecting the state of the door. I am a beginner with scripts and init commands so I appreciate the help.

Share this post


Link to post
Share on other sites

Put down a trigger in the house you want to check with this as it's condition:

((nearestTerrainObjects [thisTrigger, ["House"], 10]) select 0) animationSourcePhase "Door_1_source" > 0

Then onAct of whatever:

hint "Door 1 is open!";

You can check multiple doors with something like this:

{((nearestTerrainObjects [thisTrigger, ["House"], 10]) select 0) animationSourcePhase _x > 0} count ["Door_1_source", "Door_2_source", "Door_3_source"] > 0

One problem I see though is that ambient snakes can open doors, so that might happen.  But that's how you check :)

 

 

Also you should apparently use the new command animateSource now instead of animate as shown above.

 

Close a door:

((nearestTerrainObjects [player, ["House"], 10]) select 0) animateSource ["Door_1_source", 0];

Share this post


Link to post
Share on other sites

So is there a way to make it so that a unit is detecting the state of the door and not a trigger? If an opfor is not noticing the door staying open, then he will carry about as normal, i need him to go into an aware state is he sees a door suspiciously open.

Share this post


Link to post
Share on other sites

I don't believe there anything in AI that would detect animation phases of objects around them.  That's why you'd use the trigger.  To "alert" AI to an open door replace the hint command in the onAct field with something using setBehaviour of the nearby AI groups.

 

Change the trigger to have the range you want detection to happen in and set it to OPFOR PRESENT then add this in the onAct:

{_x setBehaviour "COMBAT"} forEach thislist;

Share this post


Link to post
Share on other sites

Once I have a detection range trigger, is there a way to have a smaller trigger within, that will cause AI to stay in safe mode if opfor is present in close proximity to the door? I have also heard of something called event handlers. Can these be useful in any way here?

Share this post


Link to post
Share on other sites

You could change the condition to something like:

(((nearestTerrainObjects [thisTrigger, ["House"], 10]) select 0) animationSourcePhase "Door_1_source" > 0) && ({_x distance2D thisTrigger <= 50} count thisList < 1)

That should check that a door is open and there's no OPFOR within 50 meters of the trigger.

 

Here's the list of EventHandlers for ArmA3.  FiredNear seems to be the closest to a "detection" style event.

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

×