Jump to content
Sign in to follow this  
Tand3rsson

Dead soldiers

Recommended Posts

Okay, once again out of options, looking for help.

Have two major problems that I was hoping someone would be able to help me with:

1. ZERO campaign creating knowledge (yes, have looked around the forums, but just can't understand any of it).

I have an eight man squad that I want to use for my campaign. If say, sold1 dies in mission1 he cant really be alive in mission 2...

(I dont even know how to string missions together to a campaign, so maybe I'm in deep water now)

2. If a soldier in the squad gets killed, I want another one in the squad to yell (for example) "Fuck! John Doe is down! Medic!". Obiously the man saying this needs to be alive.

I have tried:

condition:

not alive sold1;

on act:

sold8 groupChat "Oh no! John Doe is down! MEDIC!";

But then sold8 might be dead aswell.

So, then tried :

condition:

not alive sold1 and alive sold8;

this would work, but then again, if sold8 has been blown to bits, noone will proclaim sold1's passing to the afterlife. And inorder to cover all possible combos of alive/dead I would have to make sooo many triggers. And it still wouldn't work since:

trigger1:

condition:

not alive sold1 and alive sold8;

trigger2:

condition:

not alive sold1 and not alive sold8;

on act:

sold2 groupChat "Oh no! John Doe is down! MEDIC!";

this would give me first sold8 proclaiming sold1 is down, and then again sold2 saying that sold1 is dead if sold8 would die.

So I'm thinking you would have to script this somehow, but my skills are way too limited.

Anyone got a clue? Cause I dont

Share this post


Link to post
Share on other sites
Anyone got a clue? Cause I dont

LOL I've got at least one for your second problem. How I would do it is with eventHandlers. Put "this addEventHandler ["killed",{_this execVM "groupMemberKilled.sqf"}]" in each initialization line (or use forEach to streamline the process if you know how). Now, in your script "groupMemberKilled.sqf,"

//find out who was killed
_killed = _this select 0;

//what was his name?
_name =  name _killed;

//get units in player's group
_peeps = units player;

//find a random person who's still alive to cry out
//this works by generating a random number between 0 and the number of _peeps, and rounding it down so that it works with select
_person = _peeps select (floor random (count _peeps));

//now they say something
_person groupChat format ["Oh no! %1 is down! MEDIC!",_name];

(I dont even know how to string missions together to a campaign, so maybe I'm in deep water now)

My suggestion would be to learn how to make a basic campaign before trying to add advanced features.

Share this post


Link to post
Share on other sites

Thanks alot for the answer!

A couple of questions though;

The "_name" refers to the dead mans identity, the one defined by setIdentity?

Would it be possible to also add the name of the man going out on the groupchat?

Like: "(name_caller) Oh no! name_killed is down! MEDIC!"

I see the name variable after medic, does that one refer to %1?

And finally, since you use a random caller, would it be possible to add a random line of text? Maybe like 5 different possible variants?

Like:

Oh no %1 is down!

FUCK! %1 is hit!!

Thanks alot for the reply!

Share this post


Link to post
Share on other sites
Thanks alot for the answer!

You're welcome. Actually, I discovered a way to make the script work even better. Replace my "_peeps = units player;" with

_peeps = [];
{if (alive _x) then {_peeps = _peeps + [_x]}} forEach units _killed;

The "units" command still sometimes returns dead people. However, the above code fills the array _peeps with only the units that are alive.

The "_name" refers to the dead mans identity, the one defined by setIdentity?

Yes.

Would it be possible to also add the name of the man going out on the groupchat?

Like: "(name_caller) Oh no! name_killed is down! MEDIC!"

Possibly. You can always do it this way:

_saythis = format ["(%1) Oh no! %2 is down! MEDIC!", name _talker, name _killed];
_talker sideChat _saythis

I see the name variable after medic, does that one refer to %1?

Yes. Read up on the format command. It is very useful and entertaining.

And finally, since you use a random caller, would it be possible to add a random line of text? Maybe like 5 different possible variants?

Like:

Oh no %1 is down!

FUCK! %1 is hit!!

Of course! :D Try to work some magic with format and switch...do:

//generate random integer between 0 and 2, inclusive
_sel = floor random 3;

//text that they say depends on result of number
_saythis = switch (_sel) do
{
case 0: {"(%1) Oh no! %2 is down! MEDIC!"};
case 1: {"(%1) Oh no %2 is down!"};
case 2: {"(%1) FUCK! %2 is hit!!"};
};

//now they say something
_talker sideChat format [_saythis,name _talker, name _killed];

Share this post


Link to post
Share on other sites

Thank you! Im at work atm, but will try this out as soon as I can, and then I'll report back:-)

And, are there any scripting guides out there that you would recommend?

And finally, must say I am really impressed with the arma community, where so many people spends time helping others! Keep up the good work!

Share this post


Link to post
Share on other sites

Okey! Tested now:

This one works like a charm:

_killed = _this select 0;

_name =  name _killed;

_peeps = [];
{if (alive _x) then {_peeps = _peeps + [_x]}} forEach units _killed;

_person = _peeps select (floor random (count _peeps));

_person groupChat format ["Oh no! %1 is down! MEDIC!",_name];

however, the more advanced one I tried to pull of, I cant seem to get to work (so obiously I'm doing something wrong):

_killed = _this select 0;

_name =  name _killed;

_peeps = [];
{if (alive _x) then {_peeps = _peeps + [_x]}} forEach units _killed;

_person = _peeps select (floor random (count _peeps));


_sel = floor random 4;

_saythis = switch (_sel) do
{
case 0: {"(%1) Oh no! %2 is down! MEDIC!"};
case 1: {"(%1) SHIT! %2 is dead!"};
case 2: {"(%1) FUCK! %2 is hit!! He's fucked up!"};
case 3: {"(%1) FUCK! %2!! MEDIC!!"};
};

_talker sideChat format [_saythis,name _talker, name _killed];

And, just to try and steal more of your time;):

1. Would it be possible to only get the unit to say first or lastname of the killed unit (while keeping full name of talker)

2. How would I go about adding sound to the second script? Ofcourse, in the best of worlds, the predecided voice of the talker says the name of the one killed in one soundclip, and then the phrase "is hit" or one of the others in a second soundclip. If this would be impossible (or very complicated), would you be able to set a playSound command only for the rest of the text (not the name of the one killed, only a "FUCK! HE IS DOWN" as a sound (or one of the 3 other possible) and the names will only be in the groupChat). like:

_talker sideChat format [_saythis,name _talker, name _killed];

_talker saySound "sound1"

am I way off wanting to add 4 or 5 different "is hit" sounds, and all possible name _killed said in the voice of the man calling it?

This would ofcourse mean 8 different sounds for each man, and then a additional 4 to 5 phrases for each man. I dont know, am I beeing inpractical?

Share this post


Link to post
Share on other sites

however, the more advanced one I tried to pull of, I cant seem to get to work (so obiously I'm doing something wrong):

That's because I didn't make the variable names consistent, because I didn't mean for you to cut-and-paste directly into your script file. Try changing _talker to _person throughout the script, or vice-versa.

1. Would it be possible to only get the unit to say first or lastname of the killed unit (while keeping full name of talker)

Probably. Unit names (like "George Pound") are strings, and I think there's some way to disassemble strings in ArmA2. I don't know it off hand, though. Maybe I'll get back to you with it.

am I way off wanting to add 4 or 5 different "is hit" sounds, and all possible name _killed said in the voice of the man calling it?

This would ofcourse mean 8 different sounds for each man, and then a additional 4 to 5 phrases for each man. I dont know, am I beeing inpractical?

That depends on how much work you're going to put into this project! :D

Honestly, when you get to that level of complexity, it might be wiser to make an addon that would modify the way the AI speaks, rather than script everything into the mission.

EDIT: I missed this part earlier:

And, are there any scripting guides out there that you would recommend?

I learned from Johan Gustaffson's scripting tutorial, but that's for OFP. That game mostly used a scripting syntax called SQS. SQS code can still be used for ArmA2, but SQF code (which is what we've been using) is preferred.

Cheetah made a good SQF Tutorial for ArmA1.

Edited by RKDmitriyev
missed reply

Share this post


Link to post
Share on other sites

Again, thanks for your help. Im going to play around with your script a bit, and hopefully learn something that way:-) and also ofc, read up on some turtorials.

Thank you so much for your patience! If I pull this campaign off, you are so getting an end credit;-)

Asfor the sounds I mentioned, I'll keep it down a bit, adding at most 5, same voice, no names,

Edited by Tand3rsson

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  

×