Home   Help Search Login Register  

Author Topic: random sound on death  (Read 2096 times)

0 Members and 1 Guest are viewing this topic.

Offline FiLL2d

  • Members
  • *
  • X.x
random sound on death
« on: 05 Sep 2005, 16:53:20 »
ok can someone read through this, this is a script a friend made for me a long time ago but some bit is deleted and the script won't work without it.

its for making a random sound from the list when the unit dies.

init.sqs
=====================
[civ1] exec "LoadScream.sqs"
[civ2] exec "LoadScream.sqs"
[civ3] exec "LoadScream.sqs"
[civ4] exec "LoadScream.sqs"
[civ5] exec "LoadScream.sqs"
[civ6] exec "LoadScream.sqs"
[civ7] exec "LoadScream.sqs"
[civ8] exec "LoadScream.sqs"
[civ9] exec "LoadScream.sqs"
[civ10] exec "LoadScream.sqs"

exit



loadscream.sqs
=====================
_unit = _this select 0
[_unit] exec "Scream.sqs"

#check
? not alive _unit : goto "restart"
~1
goto "check"

#restart
----------something is gone from here that connects to scream.sqs


scream.sqs
=====================
_unit = _this select 0
_delay = 30


#start
_score = score _unit
~0.1

#checkbody
? score _unit > _score : goto "sound"
~0.1
goto "checkbody"

#sound
sound = random 10

? sound > 9 : goto "s1"
? sound > 8 : goto "s2"
? sound > 7 : goto "s3"
? sound > 6 : goto "s4"
? sound > 5 : goto "s5"
? sound > 4 : goto "s6"
? sound > 3 : goto "s7"
? sound > 2 : goto "s8"
? sound > 1 : goto "s9"
? sound > 0 : goto "s10"

#s1
_unit say "die1"
goto "start"

#s2
_unit say "die2"
goto "start"

#s3
_unit say "die3"
goto "start"

#s4
_unit say "die4"
goto "start"

#s5
_unit say "die5"
goto "start"

#s6
_unit say "die6"
goto "start"

#s7
_unit say "die7"
goto "start"

#s8
_unit say "die8"
goto "start"

#s9
_unit say "die9"
goto "start"

#s10
_unit say "die10"
goto "start"
« Last Edit: 05 Sep 2005, 16:54:00 by FiLL2d »

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Re:random sound on death
« Reply #1 on: 05 Sep 2005, 17:12:34 »
I would change it from two scripts to one, like this:

Code: [Select]
_unit = _this select 0


#check
~0.1
?(alive _unit):goto"check"

_rnd = (random 10)

?(_rnd < 10):_soundname = "die1"
?(_rnd < 9):_soundname = "die2"
?(_rnd < 8):_soundname = "die3"
?(_rnd < 7):_soundname = "die4"
?(_rnd < 6):_soundname = "die5"
?(_rnd < 5):_soundname = "die6"
?(_rnd < 4):_soundname = "die7"
?(_rnd < 3):_soundname = "die8"
?(_rnd < 2):_soundname = "die9"
?(_rnd < 1):_soundname = "die10"
_unit say _soundname
exit

This will make whoever, whenever they die yell, however make sure you have these sound names clearified in the description.ext or the game wont be able to find them!
« Last Edit: 05 Sep 2005, 17:13:34 by RujiK »
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline FiLL2d

  • Members
  • *
  • X.x
Re:random sound on death
« Reply #2 on: 05 Sep 2005, 19:53:22 »
thx for the reply, i tried it, but still no sound

Code: [Select]
_unit = _this select 0


#check
~0.1
?(alive _unit):goto"check"

_rnd = (random 10)

?(_rnd < 10):_soundname = "s1"
?(_rnd < 9):_soundname = "s2"
?(_rnd < 8):_soundname = "s3"
?(_rnd < 7):_soundname = "s4"
?(_rnd < 6):_soundname = "s5"
?(_rnd < 5):_soundname = "s6"
?(_rnd < 4):_soundname = "s7"
?(_rnd < 3):_soundname = "s8"
?(_rnd < 2):_soundname = "s9"
?(_rnd < 1):_soundname = "s10"
_unit say _soundname
hint "done"
exit

it goes through to the hint, but no sound, they are all defined in the config

Code: [Select]
onLoadMission = "Loading";

class CfgSounds
{
   sounds[] =
      {
         s1, s2, s3, s4, s5, s6, s7, s8, s9, s10
      };
   class s1
   
   {
      name = "s1";
      sound[] = {"s1.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s2
   
   {
      name = "s2";
      sound[] = {"s2.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s3
   
   {
      name = "s3";
      sound[] = {"s3.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s4
   
   {
      name = "s4";
      sound[] = {"s4.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s5
   
   {
      name = "s5";
      sound[] = {"s5.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s6
   
   {
      name = "s6";
      sound[] = {"s6.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s7
   
   {
      name = "s7";
      sound[] = {"s7.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s8
   
   {
      name = "s8";
      sound[] = {"s8.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s9
   
   {
      name = "s9";
      sound[] = {"s9.ogg", 1, 1.0};
      titles[] = {   };
   };
   class s10
   
   {
      name = "s10";
      sound[] = {"s10.ogg", 1, 1.0};
      titles[] = {   };
   };
};

any ideas?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:random sound on death
« Reply #3 on: 05 Sep 2005, 20:35:32 »
I presume the files s1.ogg etc. are all saved in a folder called Sound that is a sub-folder of the mission folder, that the volume of the files is sufficient and that the units that are saying the sound file are alive and close by.  All of these have caused me problems in the past.

As a test try using playsound, that will test that your sound files are working okay.

Also:

hint _soundname

might be a useful test also
« Last Edit: 05 Sep 2005, 20:46:57 by THobson »

Offline FiLL2d

  • Members
  • *
  • X.x
Re:random sound on death
« Reply #4 on: 05 Sep 2005, 20:54:37 »
ive just tested it, they all work with playsound so it must be the script synax?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:random sound on death
« Reply #5 on: 05 Sep 2005, 21:47:23 »
What about:

hint _soundname
?

That will tell you if it is the script syntax.  If the hint message is what you expect then are the units too far away from you for you to hear them?
« Last Edit: 05 Sep 2005, 21:48:38 by THobson »

Offline FiLL2d

  • Members
  • *
  • X.x
Re:random sound on death
« Reply #6 on: 06 Sep 2005, 00:28:21 »
i'm not familar with that command and the forum search doesnt bring anything up? how do i use it?

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:random sound on death
« Reply #7 on: 06 Sep 2005, 02:45:12 »
as you know already, _soundname is a variable storing your sound name.

the command
Code: [Select]
hint is a popup box in the upper-left corner.

When you say
Code: [Select]
hint _soundname, a small box in the upper-left corner should pop up (with a ping sound) and have a few words of text inside.

This text should be the proper sound file name.
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:random sound on death
« Reply #8 on: 06 Sep 2005, 07:42:59 »
Thanks. Yes the use of a variable may be confusing.  You already know about hint.  You have the line:

hint "done"

Well just put

 _soundname  instead of "done"

It will report on what sound file is going to be played.

"done" and _soundname are both strings.  The only difference is one is stored as a variable and the other isn't
« Last Edit: 06 Sep 2005, 07:44:07 by THobson »

Offline FiLL2d

  • Members
  • *
  • X.x
Re:random sound on death
« Reply #9 on: 06 Sep 2005, 14:55:27 »
thanks, i tested with hint _soundname, it tells everysound thats been choosen from the list after a unit has been killled, but no sound is heard, even when i kill them at point blank range...could it be they cannot talk while dead? all my sounds work with playsound  :-\

« Last Edit: 06 Sep 2005, 14:56:08 by FiLL2d »

Offline 456820

  • Contributing Member
  • **
Re:random sound on death
« Reply #10 on: 06 Sep 2005, 15:35:52 »
the reason your getting no sound is becuase the unit is dead
dead units cannot talk or say things so you will get no sound

wth play sound it would work wicne the units not talking
oh and sideradio or whatever radio wont work if the unit is talking is dead

if i was you i would use playsound

Offline FiLL2d

  • Members
  • *
  • X.x
Re:random sound on death
« Reply #11 on: 06 Sep 2005, 17:24:37 »
_unit = _this select 0


#check
~0.1
?(alive _unit):goto"check"

_rnd = (random 10)

?(_rnd < 10):_soundname = "s1"
?(_rnd < 9):_soundname = "s2"
?(_rnd < 8):_soundname = "s3"
?(_rnd < 7):_soundname = "s4"
?(_rnd < 6):_soundname = "s5"
?(_rnd < 5):_soundname = "s6"
?(_rnd < 4):_soundname = "s7"
?(_rnd < 3):_soundname = "s8"
?(_rnd < 2):_soundname = "s9"
?(_rnd < 1):_soundname = "s10"
playsound _soundname
hint _soundname
exit

well now it works but i wanted it to play at the dead person so you can only hear it if you are close, i dont want to use varables, is there an easier way?

would it be possible to make the unit say it when he's 0.9999 damaged? that way it would be very unlikely he would ever get that damaged and not dying.
« Last Edit: 06 Sep 2005, 17:26:23 by FiLL2d »

Offline 456820

  • Contributing Member
  • **
Re:random sound on death
« Reply #12 on: 06 Sep 2005, 17:30:32 »
you could use an Event handler more specific a Hit event handler
that way it will detect when hes hit and whne he is it would load a script in it you could say
_ammount = getdammage _unit
? _ammount >= 0.9 : goto "rest of script"

then at the end i woudl recomend you kill him since he may still appear alive

theres a tut in the ed depot for event handlers i would give you a link but my interents still a bit weird

Offline FiLL2d

  • Members
  • *
  • X.x
Re:random sound on death
« Reply #13 on: 06 Sep 2005, 17:43:02 »
ok cool thx

the unit is been created in a script, how do i add event handlers in the script to a certian unit.

Offline 456820

  • Contributing Member
  • **
Re:random sound on death
« Reply #14 on: 06 Sep 2005, 17:44:53 »
well name the unit by adding _name of unit = before the create command then use
_unit addeventhandler ["Hit", {_this exec "script"}] syntac not guaranteed better check the tut for correct syntax