Jump to content
brainboy

Melee animation to kill

Recommended Posts

Hello
I wrote a script to destroy an AI with animation
The problem is that when I'm close to the enemy and animation is played, the enemy does not take damage
Can you please help me?

 

private _rifle    = primaryWeapon player;
private _pistol    = handgunWeapon player;
private _weapon    = currentWeapon player;
private _anim = "Acts_Executioner_Forehand";
private _animspeed = 1.7;
private _recoverspeed = 0.7;

if (_weapon == _rifle) then {
                            _anim = "Acts_Miller_Knockout";
                            _animspeed = 1;
                            _recoverspeed = 1.3;
                        };
                        player setAnimSpeedCoef 2;
                        [player, _anim] remoteExec ["playMove", 0];
                        sleep _animspeed;
                        //{_x setdamage 1}foreach (playableUnits + switchableUnits);
                        {_x setdamage 1}foreach (switchableUnits);
                        _sound = format [" ", (floor random + 1];
                        playSound3D [_sound, player, false, getPosASL player, 3, 1, 30];
                        sleep _recoverspeed;
                        player setAnimSpeedCoef 1;
                        [player, ""] remoteExec ["switchMove", 0];


                       

Share this post


Link to post
Share on other sites
On 3/8/2019 at 4:28 PM, brainboy said:

Hello
I wrote a script to destroy an AI with animation
The problem is that when I'm close to the enemy and animation is played, the enemy does not take damage
Can you please help me?                     

 

You are not referencing the unit you want to destroy/damage.


Read up on the following commands:

playableUnits

switchableUnits

cursorObject

 

Those should get you in the right direction...

Using playableUnits or switchableUnits is not a great idea.

 

Good luck.

 

 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, Maff said:

 

You are not referencing the unit you want to destroy/damage.


Read up on the following commands:

playableUnits

switchableUnits

cursorObject

 

Those should get you in the right direction...

Using playableUnits or switchableUnits is not a great idea.

 

Good luck.

 

 

 

yes i use playableUnits or switchableUnits dosent work but idont know how to use
can you Write me?

Share this post


Link to post
Share on other sites
55 minutes ago, brainboy said:

yes i use playableUnits or switchableUnits dosent work but idont know how to use

 

Don't use either playableUnits or switchableUnits unless you want to kill all playable units depending on MP/SP.

 

 

55 minutes ago, brainboy said:

can you Write me?

 

Not right now.

 

You need to return the unit you want to inflict the damage on which would be the unit you are looking at.

Maybe experiment with cursorObject.


Also, do a search on the forums for "melee".

 

  • Like 1
  • Thanks 1

Share this post


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

 

Don't use either playableUnits or switchableUnits unless you want to kill all playable units depending on MP/SP.

 

 

 

Not right now.

 

You need to return the unit you want to inflict the damage on which would be the unit you are looking at.

Maybe experiment with cursorObject.


Also, do a search on the forums for "melee".

 

private _rifle    = primaryWeapon player;
private _pistol    = handgunWeapon player;
private _weapon    = currentWeapon player;
private _anim = "Acts_Miller_Knockout";
private _animspeed = 1.7;
private _recoverspeed = 0.7;
_target = cursorObject;

if (_weapon == _weapon) then {
                            _anim = "Acts_Miller_Knockout";
                            _animspeed = 1;
                            _recoverspeed = 1.3;
                        };
                        player setAnimSpeedCoef 2;
                        [player, _anim] remoteExec ["playMove", 0];
                        sleep _animspeed;
												
                        if ((player distance _target <= 1.5) and (alive _target) and (_target iskindof "MAN")) then {
                       
                         //_target disableAI "MOVE"; 

                         //_target disableAI "ANIM"; 

                         //_target setBehaviour "CARELESS";
                         
                         _target setDamage 1;
						
						};
						 
						 //_target say3D "";
                        //_sound = format ["", (floor random 8) + 1];
                        //playSound3D [_sound, player, false, getPosASL player, 3, 1, 30];
						//[_target, ""] remoteExec ["say3D"];
                        sleep _recoverspeed;
                        player setAnimSpeedCoef 1;
                        [player, ""] remoteExec ["switchMove", 0];
						
				

Finally, with your advice my problem is solved.
The only thing left is I want to play a sound when the target is killed.
I do not know how to write the script.
Can you help me?

Share this post


Link to post
Share on other sites
14 hours ago, brainboy said:

The only thing left is I want to play a sound when the target is killed.
I do not know how to write the script.

 

You have the code in your script already and have used it in your previous script creation.

Spoiler

[_target, "THUNK"] remoteExec ["say3D"];

 

 

I am not 100% sure if say3D will play a sound if _target is dead. You MAY need to use player.

Give it a test.

  • Thanks 1

Share this post


Link to post
Share on other sites

Hmm. Good point. I guess it depends on respawn time? Could always play it just before killing them or just use another method like playSound or something.

  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, Maff said:

 

You have the code in your script already and have used it in your previous script creation.

  Hide contents


[_target, "THUNK"] remoteExec ["say3D"];

 

 

I am not 100% sure if say3D will play a sound if _target is dead. You MAY need to use player.

Give it a test.

Yes, I used this script, but the sound does not broadcast when the enemy is killed, but when the action happens
I'm looking for a script that sounds when the enemy is killed

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

×