Jump to content
Sign in to follow this  
TomTurbo11

Make an AI sit on a bench

Recommended Posts

Hey

At the moment I'm trying to make some base-feeling at Stratis Airfield. You know, with soldiers patroling and others are talking to each other.

Also I'd like one soldier to sit on a bench [Objects (Furniture) ==> Bench].

At the moment, all I get is this

2013_07_26_00001.jpg

I'm doing it with the AI named p1, the bench named b1, and a waypoint with the follwing code:

p1 switchMove "Hub_Sitting_Chair_Rifle_A_idle1"; p1 setPos (position b1); p1 disableAI "anim";

If anyone can tell me where my fault is, or can direct me to some sort of guide (because I didn't found one) I would be more than happy :).

Regards.

EDIT:

I tried a little bit more (something about 2 hours :icon_rolleyes: ) but I managed to fix it. :yay:

Edited by Dawnthief
Solved

Share this post


Link to post
Share on other sites

How DawnThief,

Can you get the AI to sit in a chair?

edit:More for the community than me, there are a lot of topics that have a request for help. then they end with Edit: fixed and no explanation. Search does work and having a solution prevents multiple posts.

Edited by KevsnoTrev
updated to prevent the thought that I could not figure it out for myself

Share this post


Link to post
Share on other sites
How DawnThief,

Can you get the AI to sit in a chair?

Well at the moment its not perfect, but its good enough for me.

Share this post


Link to post
Share on other sites

You should post your solution to save the next guy 2 hours of trouble. :)

Share this post


Link to post
Share on other sites
You should post your solution to save the next guy 2 hours of trouble. :)

Does make sense :)

Thats what I got:

2013_07_28_00001.jpg

2013_07_28_00002.jpg

So as I said, it's sure as hell not perfect, maybe not even good, but it's good enough for me.

I placed a Camping Chair and named that b1.

Then I placed a Recon Paramedic (named p1) and put this in the Init-Field:

0 = this spawn{_this switchMove "InBaseMoves_SittingRifle2";}; this disableAI "anim"; this disableCollisionWith b1; removeBackpack p1;

The

removeBackpack p1

is just that the backpack doesn't glitches trough the chair.

btw. if anyone has a better solution or ideas for improvment, I would be glad to hear them. :)

Share this post


Link to post
Share on other sites

Thought you might like to know,

I just found this in the functions viewer.

BIS_fnc_ambientAnim

Start of the code.

/*    Author: Jiri Wainar


   Description:
   Play set of ambient animations on given unit.


   Remarks:
   * Can handle several different anims and auto-switching between them.
   * Detects nearby units with the same animation set and tries to select different animations.
   * A game logic is created on units position and animated unit is then attached to it, to prevent possible problems, like player pushing units around.
   * The unit can be snapped to a set snappoint to prevent game from repositioning the unit.
       * The snappoint is automatically detected, snap distance is 2 meters (in top-down view, ignoring vertical info).
       * To position unit vertically, move its snappoint up/down.
       * A snappoint is a (cyan colored) helper "Sign_Pointer_Cyan_F".
       * This is extremely handy if the unit needs to be placed near object(s) - like on chair near a table.


   Parameter(s):
   0: OBJECT - unit the anim & gear changes are going to be applied to
   1: STRING - animation set id, describing what the unit's action looks like.
      > "STAND"        - standing still, slightly turning to the sides. Needs a rifle!
      > "WATCH"        - standing and turning around, good for soldier on watch. Needs a rifle!
      > "GUARD"        - standing still, like on guard with hands behing the body.
      > "LISTEN_BRIEFING"  - standing still, hands behind back, recieving briefing / commands, no rifle.
      > "SIT"        - sitting on chair or bench. Needs a rifle!
      > "SIT_HIGH"     - sitting on taller objects like a table or wall, legs not touching the ground. Needs a rifle!
      > "SIT_LOW"        - sitting on the ground, with weapon.
      > "SIT_LOW_NOWPN"    - sitting on the ground, without weapon.
      > "SIT_SAD1"        - sitting on a chair, head down, looking very sad.
      > "SIT_SAD2"        - sitting on a chair, staring towards, looking very sad.
      > "KNEEL"        - kneeling, with weapon.
      > "KNEEL_MEDIC"    - kneeling while treating the wounded.
      > "PRONE_INJURED_NOWPN"    - laying wounded, back on the ground.
      > "PRONE_INJURED"    - laying wounded & still, back on the ground, no weapon.
      > "LEAN_ON_TABLE"    - standing while leaning on the table
      > "LEAN"        - standing while leaning (on wall)
      > "REPAIR_VEH_PRONE"    - repairing vehicle while laying on the ground (under the vehicle)
      > "REPAIR_VEH_KNEEL"    - repairing vehicle while kneeling (like changing a wheel)
      > "REPAIR_VEH_STAND"    - repairing/cleaning a vehicle while standing


   2: STRING - equipment level id, describing how heavily is the unit equipped.
      > "NONE"          - no goggles, headgear, vest, weapon
      > "LIGHT"          - no goggles, headgear, vest
      > "MEDIUM"         - no goggles, headgear
      > "FULL"          - full gear = no touches
      > "RANDOM" (default)    - gear is randomized according to the animation set


   Returns:
   -


   Example:
   [this,"PATROL"] call BIS_fnc_ambientAnim;
*/

Just make sure the selections are in full caps as there is a switch {} command; they must match case when used with a string.

Sample Mission - BIS_fnc_ambientAnim.pbo

Edited by KevsnoTrev

Share this post


Link to post
Share on other sites
Thought you might like to know,

This is very cool, gonna check it out, thank you very much.

Share this post


Link to post
Share on other sites
This is very cool, gonna check it out, thank you very much.

Agreed. Thank you for your help KevsnoTrev.

Share this post


Link to post
Share on other sites
* A snappoint is a (cyan colored) helper "Sign_Pointer_Cyan_F".

I cannot find this, anyone have any better luck- is there a debug mode I need to put on to make this work?

I found a couple of the guys turned around 180 from where the unit was placed in the mission, it can make placing very difficult for set scenes or 'random' occurences for pretty-ing up a mission

Also the transition would be nice to see how to do that......maybe its just call a command then a sleep then the other one.

Share this post


Link to post
Share on other sites

I'll update this post as well even though there are now two asking the same question.

To get the unit to react to gunfire etc. use BIS_fnc_ambientAnimCombat

/*    Author: Jiri Wainar


   Description:
   Play set of ambient animations on given unit AND allows the unit to leave the ambient state and engage enemy or move away.


   Remarks:
   * Function controls BIS_fnc_ambientAnim; check that function [Remarks] section for more info of how to use it.
   * Unit automatically leaves the animation loop if there is an enemy in 300m he knows about.


   Parameter(s):
   0: OBJECT - unit the anim & gear changes are going to be applied to
   1: STRING (optional, default "STAND") - animation set id, describing what the unit's action looks like.
      > "STAND"         - standing still, slightly turning to the sides. Needs a rifle!
      > "WATCH"        - standing and turning around, good for soldier on watch. Needs a rifle!
      > "GUARD"        - standing still, like on guard with hands behing the body.
      > "SIT_LOW"        - sitting on the ground, with weapon.
      > "KNEEL"        - kneeling, with weapon.
      > "LEAN"        - standing while leaning (on wall)


   2: STRING (optional, default "RANDOM") - equipment level id, describing how heavily is the unit equipped.
      > "NONE"          - no goggles, headgear, vest, weapon
      > "LIGHT"          - no goggles, headgear, vest
      > "MEDIUM"         - no goggles, headgear
      > "FULL"          - full gear = no touches
      > "RANDOM"         - gear is randomized according to the animation set


   3: CODE or STRING (optional, default {false}) - condition that if true frees the unit from the animation loop


   4: STRING (optional, default "COMBAT") - behaviour the unit should go to, when freed.


   Returns:
   -


   Example:
   [this,"STAND","FULL",{(player distance _this) < 5}] call BIS_fnc_ambientAnimCombat;
*/

Share this post


Link to post
Share on other sites

[this,"STAND","FULL",{(player distance _this) < 5}] call BIS_fnc_ambientAnimCombat;

or

[this,"STAND","FULL",] call BIS_fnc_ambientAnimCombat;

does not work for me.

Share this post


Link to post
Share on other sites

Your second example has an extra , which is gonna cause an error and we've already established that function doesn't work. :)

Share this post


Link to post
Share on other sites

I would love to continue on my mission, but every time I come back from work, there's a new update (wich is great btw). And with my shitty internet, it takes ages for the download to complete. =)

Share this post


Link to post
Share on other sites

I cannot find this, anyone have any better luck- is there a debug mode I need to put on to make this work?

I found it under: EMPTY ==> Objects (Helpers) ==> Pointer (Cyan)

It has the exact same classname as stated in the description.

And it works btw. :)

Edited by Dawnthief

Share this post


Link to post
Share on other sites

I get it now;

place the cyan marker and the unit will snap to that,

vertical alignment will be from the getpos _cyanmarker select 2 +/- heightnumber

nice catch dawnthief (feedback ticket) the function appears to be broken for the combat side, vote up the ticket.

Share this post


Link to post
Share on other sites

Thanks KevsnoTrev for posting the feedback ticket. Share it and stuff :)

Can't work on my mission without BIS_fnc_ambientAnimCombat :/

Edited by Vasilyevich

Share this post


Link to post
Share on other sites

vertical alignment will be from the getpos _cyanmarker select 2 +/- heightnumber

I use a different code for the vertical positioning, but yours may work too, idk :)

I use this for the marker

this setPos [getPos this select 0, getPos this select 1, 1.55]

Share this post


Link to post
Share on other sites

You can use

unit switchMove ""

on some animations to cancel it.

Share this post


Link to post
Share on other sites
I use a different code for the vertical positioning, but yours may work too, idk :)

I use this for the marker

this setPos [getPos this select 0, getPos this select 1, 1.55]

yeah that will work, i was just making the example that its the third in the getpos array that is the height.

I still have to find time to test this - rough work week.

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
Sign in to follow this  

×