Jump to content
johnnyboy

JBOY_PainGrunt [SCRIPT Release]

Recommended Posts

This simple script will play a pain grunt sound on a unit (randomly selected from list of Arma hit/pain sound fx).

 

Credits: 

 

To use this script:

1. Put the script code below into a file in your mission directory named JBOY_PainGrunt.sqf.

2. In your init.sqf, add this line to compile the script:

JBOY_PainGrunt =  compile preprocessFileLineNumbers "JBOY_PainGrunt.sqf";

 

JBOY_PainGrunt.sqf

Spoiler

// JBOY_PainGrunt
// Purpose:         Have unit say one of the loud ingame pain grunts
// Precompile:      JBOY_PainGrunt =  compile preprocessFileLineNumbers "Scripts\JBOY_PainGrunt.sqf";
// Credits:         Bohemia Interactive, and Greenfist and Gunter Severloh for finding path to the sounds.
//                  
// Example call:   [player] call JBOY_PainGrunt;
params["_unit"];
// _n = [_unit] = spawn
// {
    // params["_unit"];
    playSound3D [selectRandom [
        "a3\sounds_f\characters\human-sfx\P07\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P08\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P09\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P10\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P11\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P12\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P13\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P14\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P15\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P16\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P17\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P18\Hit_Max_3.wss",
        "a3\sounds_f\characters\human-sfx\P04\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P05\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P06\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P07\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P08\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P09\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P10\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P11\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P12\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P13\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P14\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P15\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P16\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P17\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P18\Hit_Max_4.wss",
        "a3\sounds_f\characters\human-sfx\P04\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P05\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P06\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P07\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P08\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P09\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P10\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P11\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P12\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P13\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P14\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P15\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P16\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P17\Hit_Max_5.wss",
        "a3\sounds_f\characters\human-sfx\P18\Hit_Max_5.wss"],_unit];
//};

 

 

To test this out, run this from the console in the Editor:

_n = [] spawn
{
   while {true} do
   {
      [player] call JBOY_PainGrunt;
      sleep 1;
   };
};

Help a Brother Out!  There's only one day left to help JohnnyBoy win a steak dinner!  If you like my scripts, please subscribe and upvote my Last Tango in Tanoa mission on Steam. Its a short mission, only 30 minutes play time.   I only need a few more ratings!

 

  • Like 3
  • Thanks 2

Share this post


Link to post
Share on other sites

JBOY PainGrunt 4 REAL if you lose out on that steak dinner!  Good luck bro'....

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites

Hey JB

Sry to bump up a old tread.

But does this work on a Hosted server, if i put it inside the InitPlayerLocal.sqf or does it have to be in the initServer.sqf ?

 

Cheers Play3r

Share this post


Link to post
Share on other sites

I think it will work either way, but not sure. Try it and find out!  Good luck.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
18 hours ago, Play3r said:

Hey JB

Sry to bump up a old tread.

But does this work on a Hosted server, if i put it inside the InitPlayerLocal.sqf or does it have to be in the initServer.sqf ?

 

Cheers Play3r

 

This code uses the playSound3D  as unique command, and this command is AG EG, you could say:  run it on server only. Problem: if you refer to player, that doesn't work on dedi, and player will refer to host only in MP (server only)

Btw, InitPlayerLocal.sqf is fine. initServer.sqf is same as server only as mentioned above

and no sense on player in multiplayer, except for grunting all day long for all players.

 

Solution:

- place it in initPlayerLocal.sqf if you're not afraid to make all players always grunting...

- or, use the EH "handleDamage" if you want the player grunts when hit (initPlayerLocal.sqf also). See the code below, core coming from @johnnyboy's script:


 

ABC_gruntings = [ "a3\sounds_f\characters\human-sfx\P07\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P08\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P09\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P10\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P11\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P12\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P13\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P14\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P15\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P16\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P17\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P18\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P04\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P05\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P06\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P07\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P08\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P09\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P10\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P11\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P12\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P13\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P14\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P15\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P16\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P17\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P18\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P04\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P05\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P06\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P07\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P08\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P09\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P10\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P11\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P12\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P13\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P14\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P15\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P16\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P17\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P18\Hit_Max_5.wss"];  
  
player addEventHandler ["HandleDamage", {  
  params ["_unit", "", "_dam"]; 
  if !(_unit getVariable ["passed_EH",FALSE]) then { 
    _unit spawn { 
      params ["_unit"]; 
      _unit setVariable ["passed_EH",TRUE]; 
      private _delay = 0.1;  
      while {sleep _delay; _delay = 5 / sqrt damage _unit; !(damage _unit in [0.25,0])} do {  
        playSound3D [selectRandom ABC_gruntings,_unit, false, getPosASL _unit, 1, damage _unit max 0.7,10/ (damage _unit max 0.1)];  
      };  
      _unit setVariable ["passed_EH",FALSE];  
    }; 
  }; 
  _dam  
}];

 

  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

Thanks much Pierre!  EHs definitely are best.

Share this post


Link to post
Share on other sites
3 hours ago, pierremgi said:

 

This code uses the playSound3D  as unique command, and this command is AG EG, you could say:  run it on server only. Problem: if you refer to player, that doesn't work on dedi, and player will refer to host only in MP (server only)

Btw, InitPlayerLocal.sqf is fine. initServer.sqf is same as server only as mentioned above

and no sense on player in multiplayer, except for grunting all day long for all players.

 

Solution:

- place it in initPlayerLocal.sqf if you're not afraid to make all players always grunting...

- or, use the EH "handleDamage" if you want the player grunts when hit (initPlayerLocal.sqf also). See the code below, core coming from @johnnyboy's script:


 


ABC_gruntings = [ "a3\sounds_f\characters\human-sfx\P07\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P08\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P09\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P10\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P11\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P12\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P13\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P14\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P15\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P16\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P17\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P18\Hit_Max_3.wss", "a3\sounds_f\characters\human-sfx\P04\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P05\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P06\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P07\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P08\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P09\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P10\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P11\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P12\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P13\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P14\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P15\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P16\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P17\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P18\Hit_Max_4.wss", "a3\sounds_f\characters\human-sfx\P04\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P05\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P06\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P07\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P08\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P09\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P10\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P11\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P12\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P13\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P14\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P15\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P16\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P17\Hit_Max_5.wss", "a3\sounds_f\characters\human-sfx\P18\Hit_Max_5.wss"];  
  
player addEventHandler ["HandleDamage", {  
  params ["_unit", "", "_dam"]; 
  if !(_unit getVariable ["passed_EH",FALSE]) then { 
    _unit spawn { 
      params ["_unit"]; 
      _unit setVariable ["passed_EH",TRUE]; 
      private _delay = 0.1;  
      while {sleep _delay; _delay = 5 / sqrt damage _unit; !(damage _unit in [0.25,0])} do {  
        playSound3D [selectRandom ABC_gruntings,_unit, false, getPosASL _unit, 1, damage _unit max 0.7,10/ (damage _unit max 0.1)];  
      };  
      _unit setVariable ["passed_EH",FALSE];  
    }; 
  }; 
  _dam  
}];

 

Thanks for the help @pierre MGI and @JhonnyBoy i think it will be a good surprise to the 2 guys i play with 🙂

Pierre i do not know what the AG EG means but i guess you are right  🙂
Cheers Play3r

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

×