Jump to content

Recommended Posts

45C40A993C8D2122D15DF7261BA574B10D259A63

 

 

Download:

MIL_SleepingAI - Dropbox/Armaholic

Demo SP Mission - Dropbox

 

Description:

Uses beds and other user-defined objects to have AI start a mission sleeping on them.
AI can then be left asleep or woken up on command.

 

Features:

- SP/MP

- Predefined support for:

    - Vanilla sleeping bags.

    - Vanilla sleeping mats.

    - Vanilla shooting mats.

    - LoW stretchers.

    - The vanilla bed.

- Ability to define other objects as beds.

 

To use:

- Copy the folder MIL_sleepingAI to your mission folder.

- Place a sleeping bag, mat, bed or other custom object into the mission.

- Position a unit near their required bed. They must be within 5m of the object to work.

- Run this command where the unit is local before the mission starts (e.g. initServer.sqf if created on the server, or init.sqf for SP):

nul = [_units,_otherBeds] execVM "MIL_SleepingAI\initSleepingAI.sqf";

_units - array - list of objects to start asleep.
_otherBeds - array (embedded) - optional. Default - [].
                              - list of other object classnames ,their [x,y,z] offsets and direction adjustments (solution to units laying perpendicular to objects).
                              - offset and angle adjustment MUST be defined, and should be tested and adjusted for best positioning of AI.

Examples:

nul = [units group1] execVM "MIL_SleepingAI\initSleepingAI.sqf";
_otherBeds = [
	["Land_Stretcher_01_F",[0,0,0],0],      //AI will be at 0 degrees to object's "north axis"
	["Land_WoodenTable_large_F",[0,0,0],90] //AI will be at 90 degrees to object's "north axis"
];
nul = [units group1,_otherBeds] execVM "MIL_SleepingAI\initSleepingAI.sqf";

 

- To wake the AI up, run this command:

nul = [_unit,_pos,_enableMoving] spawn MIL_fnc_WakeUp;

_unit - object - name given to the sleeping unit.
_pos - string - stance that the unit is to be in, example:
              - "Up", "Middle", "Down", "NotProne" (uses either "Up" or "Middle"), "Auto" (normally the default AI setting).
              - optional. Default - "Auto"
_enableMoving - boolean - allow AI to move from bed once woken up.
                        - optional. Default - false.
                        - NOTE - to get AI moving at a later stage, use:
                               - _unit enableAI "PATH"

Examples:

nul = [unit1] spawn MIL_fnc_WakeUp; //setUnitPos "Auto" is used.
{nul = [_x,"NotProne"] spawn MIL_fnc_WakeUp;} forEach (units group1);
nul = [unit2,"Auto",true] spawn MIL_fnc_WakeUp;

 

Media:

Demo (38s):

 

 

If anyone finds any problems please let me know.

 

Thank you.

 

Change log:

Spoiler

v2.1:

Added - Option to set rotation of AI on an object to account for the possibility that an object's "north point" would mean that the AI would end up sleeping perpendicular to (across) the object (Updated "To Use" and "Examples" in OP).

Added - Shooting mats and LoW stretchers to predefined bedding (Updated "Features" in OP).

 

v2:

Re-release.

 

Edited by beno_83au
Update v2.1
  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Ahhh yes, this is an older one from back while i was still learning the different aspects of arma scripting. As coincidence would have it though, i went to use this about a week ago in a new mission and revamped the whole thing, including proper MP compatability (i don't think i understood locality enough back then). 

 

I'm at work right now but I'll look at sorting a fresh download out tonight if i don't get home too late. 

  • Like 1

Share this post


Link to post
Share on other sites

Update.

 

v2:

Rebuild of the original function.

Please see OP for info.

  • Like 3

Share this post


Link to post
Share on other sites

OI, WAKE UP! BOOM, YOU'RE DEAD. :rofl:

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites

A quick update/request. It seems (obvious now, I guess) that some objects will cause an AI to orientate themselves perpendicular to a custom (user selected) object. No doubt this is due to the object's N/S/E/W orientation not being intuitive. So if anyone comes across any of these objects before I update it, can you please let me know what object? Mainly for curiosity's sake.

Share this post


Link to post
Share on other sites

Update.

 

v2.1:

Added - Option to set rotation of AI on an object to account for the possibility that an object's "north point" would mean that the AI would end up sleeping perpendicular to (across) the object (Updated "To Use" and "Examples" in OP).

Added - Shooting mats and LoW stretchers to predefined bedding (Updated "Features" in OP).

  • Like 1

Share this post


Link to post
Share on other sites

Hey Beno

thanks for the help on making it to a AddAction for the wake up:

 

this addAction [ "<t color='#88B985' shadow='2'>Wake Up</t>", { params ["_target","_caller","_actionID","_arguments"]; nul = [_target,"Auto",true] spawn MIL_fnc_WakeUp; _target removeAction _actionID; }, nil, 6, true, true, "", {(_target distance _this) < 3} ];

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Hi Beno

i get a error in the InitSleepAi.sqf when i want to try the sleep script.

it is something i line 9 and my line 9 is like this

 

{nul = [_x,_otherBeds] call MIL_fnc_StartAsleep} forEach _sleepingUnits;

 

and in my INIT.sqf i have put this one

 

_units = ("unit1","unit2","unit3");

nul = [_units,_otherBeds] execVM "MIL_SleepingAI\initSleepingAI.sqf";

 

What have i done wrong?

 

Share this post


Link to post
Share on other sites

@Play3r

If I remember correctly, _otherBeds is only needed if you want to define other objects as beds that aren't already covered by the script, so you could either leave it out, or define it as an array with classnames of other objects. But maybe just leave it out for now. 

 

As for _units, it needs to be an array of objects. So [unit1,unit2,unit3].

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, beno_83au said:

As for _units, it needs to be an array of objects. So [unit1,unit2,unit3].

 

then i did remember wrong was sure that i needed the <"> around when it was text, 

will give it a go

 

Share this post


Link to post
Share on other sites

I still get some errors when i start up the mission..

Spoiler

4vp8cm.jpg

Spoiler

28uh4w0.jpg

Share this post


Link to post
Share on other sites

@Play3r Your init.sqf should look something like this:

 

init.sqf

_units = [unit1,unit2,unit3];
nul = [_units] execVM "MIL_SleepingAI\initSleepingAI.sqf";

OR, just:
nul = [[unit1,unit2,unit3]] execVM "MIL_SleepingAI\initSleepingAI.sqf";

Then you need to make sure your units are also named. If it still isn't working you really should post your init.sqf contents here.

Share this post


Link to post
Share on other sites

Hi beno.

 

https://www.dropbox.com/sh/hcfmdry42n1ebwd/AABI45NnRVZ6tmUWGk-gT4ZVa?dl=0

 

Here is my try mission for the SleepingAi, it is just vanilla on Tanoa

3 units (unit1,unit2,unit3)

and player

and 3 Land_Stretcher_01_olive_F 

 

can you tell me what is wrong with this setup. 

I get a error in 

initSleepingAI.sqf line 9

Something about  _X variabel and _units.

 

I have only this in my Init.sqf:

nul = [[unit1,unit2,unit3]] execVM "MIL_SleepingAI\initSleepingAI.sqf";

 

and my units have the addaction :

this addAction [ "<t color='#88B985' shadow='2'>Wake Up</t>", { params ["_target","_caller","_actionID","_arguments"]; nul = [_target,"Auto",true] spawn MIL_fnc_WakeUp; _target removeAction _actionID; }, nil, 6, true, true, "", {(_target distance _this) < 3} ];

 

Cheers Play3r

Share this post


Link to post
Share on other sites

Cool script Beno (I've never seen it before).  Now I'm off to create my next mission:  "Slumber Party"

Share this post


Link to post
Share on other sites

Ok @Play3r, I'm going to assume that at some point you've (unintentionally?) edited MIL_SleepingAI\initSleepingAI.sqf, because on your mission line 9 of that file has an incorrectly written forEach loop. It's missing the { } that should contain the loop. Just re-download the function and copy it into your mission over the one that's there (incase there's anything else I missed). I checked the dropbox and armaholic downloads and they're both correct.

Also (and an error on my part), when using addActions the condition line needs to be a string, not code which is what I had in the example I gave you. So, the unit inits should look like this:

this addAction [
	"<t color='#88B985' shadow='2'>Wake Up</t>",
	{
		params ["_target","_caller","_actionID","_arguments"];
		nul = [_target,"Auto",true] spawn MIL_fnc_WakeUp;
		_target removeAction _actionID;
	},
	nil,
	6,
	true,
	true,
	"",
	"(_target distance _this) < 3"
];

 

@johnnyboy Don't forget, ArmA 3 has no females so your creative options might be a bit one-sided. Coincidentally, both people in the photo in the OP are males, and on that night out they seemed to have made it work for them 😆 (one of them was a real creepy dude.....). 

  • Like 1
  • Thanks 1
  • Haha 3

Share this post


Link to post
Share on other sites

@beno_83au

Thank you for your help so i can make this work for me.

Yes i may have deleted the two  {} but how i do not know.

perhaps when i wanted to understand the script i can have done it. 🤔

it works like a charm now, and the AddAction works great also👍

 

@johnnyboy all it is going to be in that mission  is pillow fighting..

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites
On 5/30/2019 at 2:51 AM, beno_83au said:

Ok @Play3r, I'm going to assume that at some point you've (unintentionally?) edited MIL_SleepingAI\initSleepingAI.sqf, because on your mission line 9 of that file has an incorrectly written forEach loop. It's missing the { } that should contain the loop. Just re-download the function and copy it into your mission over the one that's there (incase there's anything else I missed). I checked the dropbox and armaholic downloads and they're both correct.

Also (and an error on my part), when using addActions the condition line needs to be a string, not code which is what I had in the example I gave you. So, the unit inits should look like this:


this addAction [
	"<t color='#88B985' shadow='2'>Wake Up</t>",
	{
		params ["_target","_caller","_actionID","_arguments"];
		nul = [_target,"Auto",true] spawn MIL_fnc_WakeUp;
		_target removeAction _actionID;
	},
	nil,
	6,
	true,
	true,
	"",
	"(_target distance _this) < 3"
];

 

@johnnyboy Don't forget, ArmA 3 has no females so your creative options might be a bit one-sided. Coincidentally, both people in the photo in the OP are males, and on that night out they seemed to have made it work for them 😆 (one of them was a real creepy dude.....). 

Hello, community!

If I am right, I can put this code inside AI's init field, while he's asleep (caused by the script) and when I go to him, I will be given the option (by scrolling up/down the mouse) to wake him up... 🙂

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

×