Jump to content
Sign in to follow this  
scajolly

Adding value to modelToWorld array and effecting a change

Recommended Posts

Hello,

I was hoping I could ask for some help in what is apparently not as simple a matter as I'd have liked it to be.

_veh = _this select 0;
_ta = _this select 1;
_tb = _this select 2;

while {alive _veh} do {
sleep (5 + random 5);
if ((random 100)>0.1) then {
	_tsupa = _ta modelToWorld [random 100,random 100,100];
	_tsupax = _tsupa select 1;
	gunner _veh doWatch _tsupa;
	sleep 4;
	for "_i" from 0 to 4 + (random 15) do {
		_veh action ["useweapon", _veh,_veh turretUnit [0],0];
		sleep 0.2;

	_tsupax = _tsupax + 20;
		gunner _veh doWatch _tsupa;
	};
	_veh setVehicleAmmo 1;
} else {};

This is a snippet of code where I get a position, make a unit aim at that position, and fire at that position. What I would like is that after each sleep 0.2, the position being shot at is changed. I am attempting to do this by changing the value of one of the target's dimensions, changing _tsupax, but it does not seem to do anything at all. Could anyone possibly lend a hand? I'd be frightfully thankful.

PS. The above random 100 is just a placeholder since I dragged the snipept out of a longer length of code.

To test this if you so wish, make eg. a Ural (ZSU-23), _veh; then make an invisible H, _ta. When the effect is a change of gun alignment after every shot, that's success.

Share this post


Link to post
Share on other sites

I'm a little confused, you say it does nothing.

It fires randomly at a position.

There does seem to be some code that's doing nothing.

In the snippet you did miss a }; at the end of the code.

_veh = _this select 0;
_ta = _this select 1;
//_tb = _this select 2;

while {alive _veh} do {
sleep (5 + random 5);
if ((random 100)>0.1) then {
	_tsupa = _ta modelToWorld [random 100,random 100,100];
//	_tsupax = _tsupa select 1;
	gunner _veh doWatch _tsupa;
	sleep 4;
	for "_i" from 0 to 4 + (random 15) do {
		_veh action ["useweapon", _veh,_veh turretUnit [0],0];
		sleep 0.2;

	//_tsupax = _tsupax + 20;
	//	gunner _veh doWatch _tsupa;

	};
	_veh setVehicleAmmo 1;
} else {};
};

If your trying to make the gun move while it's firing then it would be

// null=[veh,targ] execvm "Ai_fire.sqf"
_veh = _this select 0;
_ta = _this select 1;
//_tb = _this select 2;

while {alive _veh} do {
sleep (5 + random 5);
if ((random 100)>0.1) then {
	_tsupa = _ta modelToWorld [random 100,random 100,100];
//	_tsupax = _tsupa select 1;
	gunner _veh doWatch _tsupa;
	sleep 4;
	for "_i" from 0 to 4 + (random 15) do {
		_veh action ["useweapon", _veh,_veh turretUnit [0],0];
		sleep 0.2;

	//_tsupax = _tsupax + 20;
		gunner _veh doWatch [_tsupa select 0,(_tsupa select 0)+20,100];

	};
	_veh setVehicleAmmo 1;
} else {};
};

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Hello,

Yes, I did achieve the gun firing with the code as before, so that much was alright and I knew it. What didn't happen was the traverse movement.

With your script, the gun traverses but it seems the position array is being treated differently. To be precise, the gun always goes level instead of remaining upwards pointing. I'm grateful for the help so far, but I'm no further unless it can be worked out how to stop the barrel from depressing. The target being shot at does not seem to correlate with the new doWatch at all.

Share this post


Link to post
Share on other sites

I'll check again later but never seemed to happen for me it was always pointing upwards.

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  

×