Jump to content
Sign in to follow this  
thefluffyraisin

Dialog based on kill

Recommended Posts

Hello everyone! So I'm currently making a mission in Arma 3 (obviously lol) and I was wondering if there was a way to have one of my team members yell out a line of dialogue of they kill a target. For example, if team member one kills an enemy ai, they have their own unique dialog that pops up. Same for 3 and 4, depending on which person kills the enemy. I already have the dialog recorded and all that, I was just wondering how one would apply it in this case. Thanks a lot!

Share this post


Link to post
Share on other sites

A killed EH on all applicable units.

Share this post


Link to post
Share on other sites
A killed EH on all applicable units.

Okay, so I'd need to use an Event Handler, but how exactly would I go about applying that to a unit?

Share this post


Link to post
Share on other sites

So lets say I have 4 units. I have unit1, unit2, unit3, and unit4, Now each of these units have a specific line that they will say if each of them kills an enemy, as written in a script. Now, how would I word an event handler in an enemy unit so that depending on which unit out of units 1-4 killed the enemy, the script would activate. In other words, if unit1 (player) kills the enemy, I don't want unit one to say unit 2's line, and so forth. How do you specify which unit will activate the event handler. (By the way I'm using the "killed" even handler.) Thanks a lot.

Share this post


Link to post
Share on other sites
The event handler tells you who the killer was.

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed

Okay, I've already seen these posts, and everyone keeps sending me the links to the wiki which isn't helping me. I understand what the "killed" event handler is, I need an example (what I stated above) of what that code would look like. I don't know how to activate the EventHandler based off of the killer of the unit.

Share this post


Link to post
Share on other sites

This is an example of what sample code looks like. You will need to expand what is in the braces {} to your needs

Put this in the init line of the unit that needs to die.

this addEventHandler ["killed",{hint format ["%1 is the killer", _this select 1]}];

Bingo - eventHandler attached.

Edit: You'll need to read up on say3D and CfgSounds to register your dialogue as a sample you can play with say3D/playsound. (or you could use kbTell, but I haven't ever used it).

https://community.bistudio.com/wiki/say3D

https://community.bistudio.com/wiki/Description.ext#cfgSounds

https://community.bistudio.com/wiki/playSound3D

There are lots of topics already on this forum covering that in detail so do a search and it will help you register your sounds and play them back

Edited by Das Attorney

Share this post


Link to post
Share on other sites
This is an example of what sample code looks like. You will need to expand what is in the braces {} to your needs

Put this in the init line of the unit that needs to die.

this addEventHandler ["killed",{hint format ["%1 is the killer", _this select 1]}];

Bingo - eventHandler attached.

Edit: You'll need to read up on say3D and CfgSounds to register your dialogue as a sample you can play with say3D/playsound. (or you could use kbTell, but I haven't ever used it).

https://community.bistudio.com/wiki/say3D

https://community.bistudio.com/wiki/Description.ext#cfgSounds

https://community.bistudio.com/wiki/playSound3D

There are lots of topics already on this forum covering that in detail so do a search and it will help you register your sounds and play them back

Thank you! That really helped, but now I have one final barrier. When unit1 completes the eventhandler, I need to delete the other eventhandler. It's a little confusing to explain, but here's the code I'm trying to use.

_specter = test1 addEventHandler ["killed", {_this execVM "specterKill1.sqf"}, "_this select 0"]; _specter = if {"killed" , 0} then test1 removeEventHandler ["killed" , 1]; _jester = test1 addEventHandler ["killed", {_this execVM "jesterKill1.sqf"}, "_this select 1"];

What I'm trying to state is that if specter kills the enemy, then jesters event handler needs to be removed. I need to do this because if specter kills the enemy, he says his line as needed, but then jester says his line which shouldn't happen. Vice versa.

By the way I probably should have stated that the code I just posted doesn't work because I don't really know how to use the "if" command.

Edited by THeFluffyRaisin

Share this post


Link to post
Share on other sites

Ok I think I get you. Sounds like you need to have a choice based on killer?

If so, do a switch/do or call/exitWith

_killer = _this select 1;

call {
if (_killer == specter) exitWith {
	// play sample A
};
if (_killer == jester) exitWith {
	// play sample B
};
};

You only attach the EH to the enemy and they can only die once (unless you're Bond lol) so the code will select the correct sample for the killer.

Share this post


Link to post
Share on other sites

See I get really confused with things like this... Am I placing that code into the unit's init, or am I placing it in an sqf file? I really don't know what to put and where to put it. (By the way I really really appreciate your help! I'm sorry I'm so inexperienced with this sort of thing. You'd think that after 3 years of playing ArmA I would have a decent understanding of its code...)

Share this post


Link to post
Share on other sites

No worries, everyone's got to start somewhere. :)

To get this to run, place the following code in a file in the root of your mission. Call the file init.sqf (make sure the suffix is .sqf and not .sqf.txt which is a common mistake).

Make sure your units specter and jester are named as such in the editor.

func_callout = {
_killer = _this select 1;
call {
    if (_killer == specter) exitWith {
        // play sample A
        specter say3D "mySample"
    };
    if (_killer == jester) exitWith {
        // play sample B
        jester say3D "mySample2"
    };
};
};

On every unit that opposes you in the mission, put this in their init line:

this addEventHandler ["killed",{_this call func_callout}];

And lastly you will have to define the sounds "mySample" and "mySample2" in your description.ext file (make one if you do not have one, placed in root of mission folder again). See that link I posted earlier for CfgSounds.

That should do it.

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  

×