Jump to content
Sign in to follow this  
Warpo

Automatically attacking to enemy units

Recommended Posts

Hi, I sorry for my English. I'm basically a beginner at some scripts. I need to deal with this:

_Warrior = _this;

while {Alive _Warrior} do {
Hint "START";

_Enemy = nearestObjects [_Warrior, ["Man","Man"], 100] Select 1;
_man_damag = damage _Enemy;
Side _Enemy = EAST;

while {Alive _Enemy} do {
 if (_Warrior distance _Enemy > 0) then {_Warrior Move position _Enemy};
 if ({_Warrior distance _Enemy <= 4 && Alive _Enemy && Side _Enemy == EAST} count allUnits > 0) then {_man_damag = _man_damag + 0.51; _Enemy setdamage _man_damag; _Warrior playMove "AmelPercMstpSnonWnonDnon_amaterUder3"};
Sleep 6
};
Sleep 1
};


I want to unit "_Warrior" automatically searched enemy force "_Enemy" and then himself to this unit attacked. But this script so does not work.

"_Warrior" runs so to me (when I'm from him nearest, I'm West as him) I want, that he go only against other side..

A second problem, after killing one unit, he is inactive for searching other enemy unit. I need, that he constantly searched enemy force (in the 100 meters), until he is alive ..

What am I doing wrong here?

I hope you understand my problem, thanks for the advice ..:)

Edited by Warpo

Share this post


Link to post
Share on other sites

search and destroy or guard waypoints do just that, no need to go into scripting for this, learn editor first, then go script.

Share this post


Link to post
Share on other sites
search and destroy or guard waypoints do just that, no need to go into scripting for this, learn editor first, then go script.

I can well with the editor, the script also. I'm concerned about a specific solution to this script, I do not want use waypoints.

I need only to "_Enemy =" seting for side East. How to do it (Side == _Enemy EAST; does not work)? ;)

So that I want use this for next working in the script.

Edited by Warpo

Share this post


Link to post
Share on other sites

Some help...

nearestObjects returns an array (list of men in this case). The list might contain only one man...but it is still a list.

To get the nearest man from the list select the first element like this....

_man = _enemy select 0;

You also have "Man" there twice...no need for that.

You also need to understand how to use side.

There are a lot of errors in your script....not just one or two!

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

Big thanks to you..

I'm tried repair this sript. Somehow it works. Do you see a mistake there, where? Thanks..

_Warrior = _this;

while {Alive _Warrior} do {
_EnemyField = nearestObjects [_Warrior, ["Man"], 100];
_Enemy = _NepritelField Select 1;
East = side _Enemy;
_man_damag = damage _Enemy;

while {Alive _Enemy} do {
 if (_Warrior distance _Enemy > 4) then {_Warrior Move position _Enemy};
 if (_Warrior distance _Enemy <= 4 && Alive _Enemy) then {_man_damag = _man_damag + 0.51; _Enemy setdamage _man_damag; _Warrior playMove "AmelPercMstpSnonWnonDnon_amaterUder3"};
Sleep 4
};

Sleep 1
};


Or other solution this script. Runs him person created through command "createUnit". For example "CWarrior ExecVM "Attack.sqf", _Enemy not, it's complete side east.

Edited by Warpo

Share this post


Link to post
Share on other sites

Okay, I look at it.

Still, please you look for this script and repair error in him.

I need it's have functional soon as possible and not until a few days. Just quickly solution.

Thanks..

Share this post


Link to post
Share on other sites

lol, i asumed warrior was the armored vehicle not a "warrior", i checked your animation and you want a man to run around and punch all enemys...

Lol at google translate.

Lol, this was so funny i actually kindof made it for you.

// execute with:
// _null = this execVM "hunt.sqf";

_warrior = _this;
while {alive _warrior} do {
_enemyList = nearestObjects [_Warrior, ["Man"], 100];
{
	if ((side _x) == east) then {
		while {alive _x AND alive _warrior} do {
			if ((_warrior distance _x) > 2) then {
				_warrior doMove (getPos _x);
			};
			if ((_warrior distance _x) <= 3 AND alive _warrior AND alive _x) then {
				_warrior lookAt _x;
				sleep 1;
				_man_damag = getDammage _x;
				_man_damag = _man_damag + 0.51;
				_x setdamage _man_damag;
				_Warrior playMove "AmelPercMstpSnonWnonDnon_amaterUder3";
			};
			sleep 4;
		};
	};
} foreach _enemyList;
sleep 1;
};

of course not perfect, but now you have something to work with.

main issues is turning to face enemy, and timings, but you will find that out easy.

Share this post


Link to post
Share on other sites

Oh my god, now you're really pleased me. Thank you very much, you saved me a lot of time. I'm also teach something (I have previously worked only with SQS). This Script wokring perfectly.

Of course, further improve the script, it creates a protection, etc..

Yes Warrior is not armored vehicle. Exactly how to you write. :D

I helped with Google Translator, is it shit..:p

Edited by Warpo

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  

×