Jump to content
Sign in to follow this  
Yolo Joe

Item 3D spin and hover

Recommended Posts

But where do I put all this code?! :confused: :confused:

fnc_pwrotate = {
   private ["_turntable","_holder","_time","_dir"];
   _turntable = createVehicle [
       "Land_Can_V3_F",
       _this select 0,
       [],
       0, 
       "CAN_COLLIDE"
   ];
   _turntable hideObject true;
   _holder = createVehicle [
       "WeaponHolderSimulated",
       _this select 0,
       [],
       0, 
       "CAN_COLLIDE"
   ];
   _holder addWeaponCargoGlobal [_this select 1, 1];
   _holder attachTo [_turntable, [0,-0.63,0.7]];
   _holder setVectorDirAndUp [[0,0,1],[0,-1,0]];
   _time = time + 10;
   _dir = getDir _turntable;
   waitUntil {
       _dir = _dir + (
           if (_dir > 360) then [{-360},{3}]
       );
       _turntable setDir _dir;
       time > _time
   };
   deleteVehicle _holder;
   deleteVehicle _turntable;
};

And

_null = [
   player modelToWorld [0,2,0],
   "arifle_Mk20_ACO_pointer_F"
] spawn fnc_pwrotate;

---------- Post added at 13:37 ---------- Previous post was at 12:41 ----------

Anyone familiar with Killzonekid's tutorials?

Plz send help!

Share this post


Link to post
Share on other sites

Just save this in a .sqf file called weaponrotate.sqf and put it in your mission folder:

_turntable = createVehicle [
       "Land_Can_V3_F",
       _this select 0,
       [],
       0, 
       "CAN_COLLIDE"
   ];
   _turntable hideObject true;
   _holder = createVehicle [
       "WeaponHolderSimulated",
       _this select 0,
       [],
       0, 
       "CAN_COLLIDE"
   ];
   _holder addWeaponCargoGlobal [_this select 1, 1];
   _holder attachTo [_turntable, [0,-0.63,0.7]];
   _holder setVectorDirAndUp [[0,0,1],[0,-1,0]];
   _time = time + 10;
   _dir = getDir _turntable;
   waitUntil {
       _dir = _dir + (
           if (_dir > 360) then [{-360},{3}]
       );
       _turntable setDir _dir;
       time > _time
   };
   deleteVehicle _holder;
   deleteVehicle _turntable;

then call it from a trigger or wherever you want using this:

_nul = [
   player modelToWorld [0,2,0],
   "arifle_Mk20_ACO_pointer_F"
] execVM "weaponrotate.sqf";

that's as basic as it will get ;)

Share this post


Link to post
Share on other sites

thanks! But the first time I call the script it does not show up.. :confused:

I have to call it 2 times.

Share this post


Link to post
Share on other sites

Anybody know how I can load a magazine into the rotating weapon?

I tried this, but didn't succseed :(

_mag = "30Rnd_65x39_Caseless_mag"; 
_holder = createVehicle [ "WeaponHolderSimulated", player modelToWorld [0,2,0], [], 0, "CAN_COLLIDE" ];
_holder addMagazineCargoGlobal [_mag, 1];

Share this post


Link to post
Share on other sites

I'm guessing your wondering if there is a way to do it to all items?

Share this post


Link to post
Share on other sites
Yes? How?

Well what I was thinking of is we could have a while that checks in a radius of the player for GroundWeaponHolder and then change that to a WeaponHolderSimulated and then do that spinning stuff.

Share this post


Link to post
Share on other sites

We'll, it would be neat, but I'm not God, so I don't know how to do that :P

Share this post


Link to post
Share on other sites
We'll, it would be neat, but I'm not God, so I don't know how to do that :P

Well I've started to work on it

here is how it is so far. literally a minutes worth of work.

3ditems.sqf

while {true} do {
stuff = position player nearObjects ["groundweaponholder",10];
{
	if ( isNil {_x getVariable "newholder"} ) then {
		_magazines = magazineCargo _x;
		_x setVariable ["magazines",_magazines,true];
		_weapons = weaponCargo _x;
		_x setVariable ["weapons",_weapons,true];
		_items = itemCargo _x;
		_x setVariable ["items",_items,true];
		_holder = createVehicle ["WeaponHolderSimulated", position _x, [], 0, "CAN_COLLIDE"];
		_x setVariable ["newholder",_holder,true];
	};
}forEach stuff;
sleep 2;
};

i made "stuff" global for me to easily access it in game for now.

anyway so far what it does is get all the stuff there and create the weaponholdersimulated. Now to move all the shit in it.

update

while {true} do {
stuff = position player nearObjects ["groundweaponholder",10];
{
	if ( isNil {_x getVariable "newholder"} ) then {
		_magazines = magazineCargo _x;
		_x setVariable ["magazines",_magazines,true];
		_weapons = weaponCargo _x;
		_x setVariable ["weapons",_weapons,true];
		_items = itemCargo _x;
		_x setVariable ["items",_items,true];
		_holder = createVehicle ["WeaponHolderSimulated", position _x, [], 0, "CAN_COLLIDE"];
		_x setVariable ["newholder",_holder,true];

		for [{_i=0},{_i<=count (_x getVariable "magazines")},{_i=_i+1}] do {
			(_x getVariable "newholder") addMagazineCargoGlobal [(_x getVariable "magazines") select _i,1];
		};

		for [{_i=0},{_i<=count (_x getVariable "weapons")},{_i=_i+1}] do {
			(_x getVariable "newholder") addMagazineCargoGlobal [(_x getVariable "weapons") select _i,1];
		};
		for [{_i=0},{_i<=count (_x getVariable "items")},{_i=_i+1}] do {
			(_x getVariable "newholder") addMagazineCargoGlobal [(_x getVariable "items") select _i,1];
		};
		deleteVehicle _x; //this is what is so far causing the problem though I think I know a solution.
	};
}forEach stuff;
sleep 2;
};

bug to say is that your inventory is counted as a groundweaponholder so it sorta breaks your own inventory. So I can't delete the groundweaponholder.

Update 2

its done and looks pretty good tbh

I found out that there is really no reason to switch the groundweaponholder to a weaponholdersimulated

3ditems.sqf

LALA_FNC_TURN_AROUND = {
_turntable = _this select 0;
_obj = _this select 1;

waitUntil {player distance _obj < 10};

_dir = getDir _turntable;
	waitUntil {
		_dir = _dir + (
			if (_dir > 360) then [{-360},{3}]
		);
		_turntable setDir _dir;
		player distance _obj > 10
	};
[_turntable,_obj] spawn LALA_FNC_TURN_AROUND;
};

while {true} do {
stuff = position player nearObjects ["groundweaponholder",10];
[] spawn {
	{
		if ( isNil {_x getVariable "newholder"} ) then {			
			_x setVariable ["newholder",true,true];

			_turntable = createVehicle ["Land_Can_V3_F", position _x, [], 0, "CAN_COLLIDE"];
			_turntable hideObject true;
			_x attachTo [_turntable,[0,-0.63,0.7]];
			_x setVectorDirAndUp [[0,0,1],[0,-1,0]];

			_dir = getDir _turntable;
			waitUntil {
				_dir = _dir + (
					if (_dir > 360) then [{-360},{3}]
				);
				_turntable setDir _dir;
				player distance _x > 10
			};

			[_turntable,_x] spawn LALA_FNC_TURN_AROUND;
		};
	}forEach stuff;
};
};

edit

this does not affect dead bodies only stuff you drop.

and small little change

LALA_FNC_TURN_AROUND = {
_turntable = _this select 0;
_obj = _this select 1;

waitUntil {player distance _obj < 10};

_dir = getDir _turntable;
	waitUntil {
		_dir = _dir + (
			if (_dir > 360) then [{-360},{3}]
		);
		_turntable setDir _dir;
		player distance _obj > 10
	};
[_turntable,_obj] spawn LALA_FNC_TURN_AROUND;
};

while {true} do {
_stuff = position player nearObjects ["groundweaponholder",10];
[_stuff] spawn {
_stuff = _this select 0;
	{
		if ( isNil {_x getVariable "newholder"} ) then {			
			_x setVariable ["newholder",true,true];

			_turntable = createVehicle ["Land_Can_V3_F", position _x, [], 0, "CAN_COLLIDE"];
			_turntable hideObject true;
			_x attachTo [_turntable,[0,-0.63,0.7]];
			_x setVectorDirAndUp [[0,0,1],[0,-1,0]];

			_dir = getDir _turntable;
			waitUntil {
				_dir = _dir + (
					if (_dir > 360) then [{-360},{3}]
				);
				_turntable setDir _dir;
				player distance _x > 10
			};

			[_turntable,_x] spawn LALA_FNC_TURN_AROUND;
		};
	}forEach _stuff;
};
};

Edited by Lala14

Share this post


Link to post
Share on other sites

So this would replace my weaponrotate.sqf?

Edited by Chillroy

Share this post


Link to post
Share on other sites

yea call it whatever and then to execute it do

null = [] execVM "3ditems.sqf";

or what ever you want to call it. Also one thing that I want to add is this only works on dropped items.

Share this post


Link to post
Share on other sites

LALA_FNC_TURN_AROUND = {
_turntable = _this select 0;
_obj = _this select 1;

waitUntil {player distance _obj < 10};

_dir = getDir _turntable;
	waitUntil {
		_dir = _dir + (
			if (_dir > 360) then [{-360},{3}]
		);
		_turntable setDir _dir;
		player distance _obj > 10
	};
[_turntable,_obj] spawn LALA_FNC_TURN_AROUND;
};

while {true} do {
_stuff = nearestObjects [position player, ["GroundWeaponHolder","WeaponHolderSimulated","WeaponHolder"], 10];
[_stuff] spawn {
_stuff = _this select 0;
	{
		if ( isNil {_x getVariable "newholder"} ) then {			
			_x setVariable ["newholder",true,true];

			_turntable = createVehicle ["Land_Can_V3_F", position _x, [], 0, "CAN_COLLIDE"];
			_turntable hideObject true;
			_x attachTo [_turntable,[0,-0.63,0.7]];
			_x setVectorDirAndUp [[0,0,1],[0,-1,0]];

			_dir = getDir _turntable;
			waitUntil {
				_dir = _dir + (
					if (_dir > 360) then [{-360},{3}]
				);
				_turntable setDir _dir;
				player distance _x > 10
			};

			[_turntable,_x] spawn LALA_FNC_TURN_AROUND;
		};
	}forEach _stuff;
};
};

updated, dead bodies with guns drop will spin and items placed in the editor will spin also.

Share this post


Link to post
Share on other sites

try adding a sleep so like place it here

while {true} do {
   sleep 2;
   _stuff = nearestObjects [position player, ["GroundWeaponHolder","WeaponHolderSimulated","WeaponHolder"], 10];

Share this post


Link to post
Share on other sites
try adding a sleep so like place it here

while {true} do {
   sleep 2;
   _stuff = nearestObjects [position player, ["GroundWeaponHolder","WeaponHolderSimulated","WeaponHolder"], 10];

were does this go I have 2 files 1 is the init with the execvm the second it the file im calling ... sorry im confused

edit this is already in your sqf,

while {true} do {

_stuff = nearestObjects [position player, ["GroundWeaponHolder","WeaponHolderSimulated","WeaponHolder"], 10];

[_stuff] spawn {

why would I add it somwere eles?

opps sorry I see the change in code , ill test.. thank you.

---------- Post added at 09:18 AM ---------- Previous post was at 09:02 AM ----------

ok @Lala14 in init im using

call compile preProcessFile "scripts\weaponrotate.sqf";

I see the weapon turning and can take it but (no ammo)?

did I miss something?

---------- Post added at 09:20 AM ---------- Previous post was at 09:18 AM ----------

fixed ... thanks for script.

Edited by Dr Death JM

Share this post


Link to post
Share on other sites

@DrDeathJM what did you do to add ammo? I just placed a weapon in the editor, synced it to the Show/Hide modules and to a trigger. Works great.

Share this post


Link to post
Share on other sites

call compile preProcessFile "scripts\weaponrotate.sqf";

that's all I did ... any ai I kill or player there weapons and ammo show up ... at about 15 feet or so it starts spinning ..

using a trigger would be realy cool for loot scripts and things...

I can see this script being used in multible ways ..

Share this post


Link to post
Share on other sites
call compile preProcessFile "scripts\weaponrotate.sqf";

that's all I did ... any ai I kill or player there weapons and ammo show up ... at about 15 feet or so it starts spinning ..

using a trigger would be realy cool for loot scripts and things...

I can see this script being used in multible ways ..

if you want longer range you would need to change three areas in the script

_stuff = nearestObjects [position player, ["GroundWeaponHolder","WeaponHolderSimulated","WeaponHolder"], 10]; 

so change 10 to a greater distance

and

player distance _x > 10

I would suggest changing this to what you have for above and

player distance _obj < 10

I would suggest changing this to what you have for above and

player distance _obj > 10

I would suggest changing this to what you have for above and

I could add a simple variable so instead its just 1 thing you need to change rather than 4.

Share this post


Link to post
Share on other sites
i tried this in editor, map freezes ? I cant test.

Im getting this as well... I did not understand how to fix it xD

Share this post


Link to post
Share on other sites

hmmm my ammo dosn't show up any more

did you get it working Chillroy?

I have it working but ammo dosnt show up anymore.

@Lala14

can you post how you got ammo to show up?

Edited by Dr Death JM

Share this post


Link to post
Share on other sites

@Dr Death JM

what do you mean by ammo showing up?

Share this post


Link to post
Share on other sites
@Dr Death JM

what do you mean by ammo showing up?

ammo dosnt show up with weapons (3d spinning)...

after killing ... just weapons.

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  

×