Jump to content

Recommended Posts

Hello, Community friends! I want to use a script and make a unit die WHEN a trigger is activated. My idea is to use an animation for the unit making him looks like wounded, lying down on the ground and after a conversation with the player, he dies. I would use the last trigger with text from that conversation, which should activate his death. What should I put in "On Activation" in the trigger? Thanks in advance. 🙂

  • Like 1

Share this post


Link to post
Share on other sites

You will have to place:

 

execVM "nameOfScript.sqf";

 

In the script you will have to find whatever animations you want via the animation viewer located in the Eden editor and then have something like:

 

NameOfUnit switchMove "NameOfAnimation";
sleep HowManySecondsTheAnimationLasts;
switchMove "";
NameOfUnit switchMove "NameOfAnimation";
sleep HowManySecondsTheAnimationLasts;
switchMove "";

 

and so on. In the end a:

 

NameOfUnit setDamage 1;

when playing an animation sometimes switchMove does not work and you need a playMove.

  • Like 3

Share this post


Link to post
Share on other sites
4 minutes ago, JohnKalo said:

You will have to place:

 


execVM "nameOfScript.sqf";

 

In the script you will have to find whatever animations you want via the animation viewer located in the Eden editor and then have something like:

 


NameOfUnit switchMove "NameOfAnimation";
sleep HowManySecondsTheAnimationLasts;
switchMove "";
NameOfUnit switchMove "NameOfAnimation";
sleep HowManySecondsTheAnimationLasts;
switchMove "";

 

and so on. In the end a:

 


NameOfUnit setDamage 1;

when playing an animation sometimes switchMove does not work and you need a playMove.

Thank you, but is this script: NameOfUnit setDamage 1, going to eliminate the AI unit when I trigger the sqf file? 🙂

Share this post


Link to post
Share on other sites
1 hour ago, black_hawk_mw2_87 said:

eliminate the AI unit

 

He will fall down and die on the ground.

  • Like 1

Share this post


Link to post
Share on other sites

Yep exactly like @major-stiffy said.

If you do not want him to die you can erase that line of code. Since you want a conversation to take place first you can use the sleep command again. That way the unit will wait for the conversation to finish and then die  :thumbsup:

  • Like 1

Share this post


Link to post
Share on other sites

All above is good but you don't have to be quite that literal with the death. The final switchmove can be a dead animation and you can remove the body with deleteVehicle when appropriate.
Being dead animation:

this switchmove "AinjPpneMstpSnonWnonDnon";
deleteVehicle _deadActor;

This prevents all kinds of other settings from interfering. Like corpse removal. Also if you're grouped to the dying unit somebody will inevitably pipe up with, "Oh, no! _x is down!". And that would ruin the vibe you're going for I think.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you very much, guys. It's time for testing. I am working on a very scripted campaign right now, so wish me good luck. xD 🙂

  • Like 1

Share this post


Link to post
Share on other sites

There is a much easier solution, guys.

1. I put the AI near an object, for example a building. In his INIT field:

0 = this spawn {waitUntil {time > 0}; _this switchMove "Acts_SittingWounded_loop"}; {this disableAI _x} forEach ["ANIM", "TARGET", "AUTOTARGET", "MOVE"];

I set his HP at 49.

This way he's wounded from the very beginning. I call him unit1.

2. I put the player and call him X.

3. I put triggers for every sentence of their conversation, depending on the needs of the scenario, so no matter how long the dialogue is, the AI dies after it. I put the texts of the conversations and change nothing in the triggers, except timer values.

In all triggers I use: player distance unit1 <X, where X is the distance in meters.

On Activation: the texts of the conversation.

I put one last trigger with a delay of several seconds after the AI's last words, where:

the condition remains the same, and

On Activation:

this switchmove "AinjPpneMstpSnonWnonDnon"; unit1 setDamage 1;

and he falls down dead. Voilla!

Sounds pretty simple, right?

P.S. You can add a dying sound on the last trigger to make this scene look more realistic.

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites
Quote

There is a much easier solution, guys.

Placing anything in the INIT field is nice but if the mission is an MP one calling such animation commands via a trigger (or even better via the iniPlayerLocal.sqf) is advised. That is because triggers work on all clients (players). Otherwise it can happen that only the host watches the animations. Yep have been there.. As for using triggers so as to show conversations I used to do that too since recently! The problem is that when many conversations are involved too many triggers exist. Hence you can again call a script via a trigger.

Nothing changes:
 

NameOfPlayer sideChat "";
sleep NumberOfSeconds;
NameOfPlayer sideChat "";
sleep NumberOfSeconds;

Best of Wishes for your campaign!

  • Like 1

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

×