OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Landdon on 04 Aug 2008, 01:37:37
-
I am working on a mission where a team must infiltrate an area. One of the things I would to use, to dispel reality is to have the OPFOR say (play a ogg sound file) when they are a set distance or less to the OPFOR AI. I would assume a trigger, but I am just starting to learn how to script, and I'm not sure how to do this in Arma. I have made the ogg sound files already, after that I'm not sure on how to proceed. If anyone has the time to provide me with an example could you please post it here. Thanks!
-
greetings,
there are many ways to do what you want. the easiest is:
define the sound(s) in the description.ext:
// Sounds
class cfgSounds
{
sounds[] = {};
class jet1
{
name = "Jet1";
sound[] = {"\sounds\JetPass.ogg", 0.5, 1.2};
titles[] = {};
};
class valk
{
name = "Valk";
sound[] = {"\sounds\Valk.ogg", 100, 1};
titles[] = {};
};
};
then make sure your sound file(s) are in your mission folder. add a trigger to the area... in the activation line put:
playsound "jet1";
but if you want to get really tricky.. i'd suggest you look at wolfrug's awesome DSAI (http://www.ofpec.com/forum/index.php?topic=30495.0)
-
Loki explained how to define sounds, but missed out the randomness and that an AI had to speak (say), rather than the sound just be played to the player (playsound: played directly without coming from a set position). Assuming you'd named your OPFOR soldier opfor1 and defined three sounds as Loki described (in the example, talk1, talk2 and talk3 classes):
opfor1 say (["talk1", "talk2", "talk3"] select (floor (random 3)));
-
:whistle:
i didn't know that.
thanks
-
Just a note...
Unless they've changed the random command from OFP to ArmA, you should be aware that the random command is local. This means, that the code Spooner posted will not work fully in multiplayer.
Don't get me wrong, the AI will still say something, problem is just that the unit will very likely say different things on different computers...
Clicky (http://community.bistudio.com/wiki/Locality_in_Multiplayer)
-
@Garcia: Yes, that was an oversight on my behalf. I read the title/question, not the forum name :whistle:
You should have linked to my MP scripting tutorial (http://www.ofpec.com/ed_depot/mptutorial/), rather than to the Biki. Would have made me look even more daft ;P There is even an example in there of how to say random things in an MP setting ::)
@Landdon:
Simplest thing to do would be to always play the same sound file. After all, how many times will players play the mission to get bored of the enemies saying the same then when you get near? Anyway, here is a solution that has everyone hearing the same thing (untested, since I'd need to set up sounds and have multiple people playing to prove it worked):
speakHandler =
{
_speaker = (_this select 1) select 0;
_sound = (_this select 1) select 1;
_speaker say _sound;
};
"speak" addPublicVariableEventHandler speakHandler;
// Call with [person, "soundName"] to make person say something for every client.
speakMP =
{
if (not isServer) exitWith {};
// Run locally (SP or MP host only)
["speak", _this] call speakHandler;
// Run on clients (MP only)
speak = _this;
publicVariable "speak";
};
[opfor1, ["talk1", "talk2", "talk3"] select (floor (random 3))] call speakMP;
-
@Garcia: Yes, that was an oversight on my behalf. I read the title/question, not the forum name :whistle:
You should have linked to my MP scripting tutorial (http://www.ofpec.com/ed_depot/mptutorial/), rather than to the Biki. Would have made me look even more daft ;P There is even an example in there of how to say random things in an MP setting ::)
There's a lot I could do to make you look daft, like adding a example that works in MP ;) But then again, wasn't really much after that :D IMO it's not too important as long as what the AI says is just for athmosphere...even if the mission is played a lot, people would probably not care if the AI said different things on each client :whistle: