Jump to content
Sign in to follow this  
Cyborg11

Changing uniform

Recommended Posts

Wrote a new script :D

With this script you can change the uniform :)

Script:

/*
======================================================================================
by Cyborg11
Version: 1.02 @ 08.01.2010
Parameters: unit addAction ["Change Uniform", "uniformchange.sqf", [newunit,side]];
_unit = unit which gets the action to change the uniform
_newunit = classname of the new unit
_side = side of the new unit
Example: this addAction ["Change uniform", "uniformchange.sqf", ["GUE_Soldier_1",guerr]];
Example 2: player addAction ["Change uniform", "uniformchange.sqf", ["FR_GL",west,true]];

The new unit has the same weapons, magazines and the same name as the old unit
=======================================================================================
*/

// Variables
_unit = _this select 1;		// old unit
_action = _this select 2;	// action id 
_sideold = side _unit;		// side of old unit
_type = typeOf _unit;		// classname of old unit
_posunit = getPos _unit;	// position of the old unit
_VarName = (vehicleVarName _unit);	// Editorname of the old unit
_array = _this select 3;	// the new soldier array => ["FR_GL",west]
_newunit = _array select 0;	// classname of the new unit
_side = _array select 1;	// side of the new unit
_exit = _array select 2;	// if set to true the script will exit
_weapons = ((weapons _unit) - (items _unit));	// weapons of the old unit
_primweap = primaryWeapon _unit;	// primaryWeapon of the old unit
_magazines = magazines _unit;	// magazines of the old unit

_unit setPos [0,0,0];	// teleport the old unit to [0,0,0]
titleText ["Changing uniform ...", "BLACK FADED"];	// Black Screen
_unit removeAction _action;

// Create the new unit
_uniform = group _unit createUnit [_newunit, _posunit, [], 0, "NONE"];
setPlayable _uniform;
sleep 0.5;
If (!isnil ("_uniform")) then {selectPlayer _uniform};

// New Unit gets the sames weapons as the old unit
removeAllWeapons _uniform;
{_uniform addMagazine _x} forEach _magazines;
{_uniform addWeapon _x} forEach _weapons;

// Select the primaryWeapon	
_uniform selectWeapon _primweap;
// Fix for weapons with grenade launcher
_muzzles = getArray(configFile>>"cfgWeapons" >> _primweap >> "muzzles");
_uniform selectWeapon (_muzzles select 0);

sleep 0.2;
deleteVehicle _unit;			// delete old unit
sleep 1;
titleText [" ", "BLACK IN"];	// delete Black Screen
_uniform SetVehicleVarName _VarName;
_uniform call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName];
If (!isNil ("_exit") && _exit) exitWith{};
_uniform addAction ["Change uniform", "uniformchange.sqf", [_type,_side,true], 0, false, false, ""]; 

//hint format ["Unit: %1\nType: %2\nPosUnit: %3\nArray: %4\nNewUnit: %5\nSide: %6\nVarNameOld: %7\nVarNameNew: %8",_unit,_type,_posunit,_array,_newunit,_side,_VarName,(vehicleVarName _uniform)];

Edited by Cyborg11

Share this post


Link to post
Share on other sites

The main problem remains:

All that you scripted is assigned to the initial unit. Once the player switches to the new entity, this is gone, i.e. stays with the old unit, which gets deleted then. Try it out: Add the action to call this script to your player unit in the init.sqf. Then this action is available only for one time. The new unit won't be able to change the uniform again.

Edited by Bon

Share this post


Link to post
Share on other sites

Ok. I will change both :) The new unit has the name of the old unit :)

---------- Post added at 19:51 ---------- Previous post was at 19:05 ----------

1.01 is available now :) The new unit will use the name of the old one and you get an action to switch the uniform :D

Edited by Cyborg11

Share this post


Link to post
Share on other sites

I am sorry but I think you didn't understand me correctly. It is not only that you can't switch back to your old uniform.

Everything scripted, really everything, starting with the code in the Init.sqf to every other script loaded at missionstart, will be gone (or, better said, remain to the old entity) by switching into another unit.

Your script is a nice thing for everyone who creates missions exclusively in the editor, with no scripts involved.

Once there are scripts involved, at least some code initialized in the Init.sqf script, your uniform changing script gets incompatible to usage.

I failed this task to change player model during game already in Armed Assault.

Perhaps it is possible to workaround it (but I don't know any way). However, it requires more than just creating a switchable unit. And if you find a way, you will be my hero of the day :)

Edited by Bon

Share this post


Link to post
Share on other sites

Oh ok. Now I understand you :)

Yeah that would be a problem :(

And there is no way for that? :o

Share this post


Link to post
Share on other sites

Perhaps a processInitCommands command?

Oh, and THANK you for posting this - I've need of a similar script. If I can get it working, I'll post here. :)

Edit:

Oops, I did get it working, but didn't really change much. If someone is interested in my implementation, PM me. :)

Edited by TRexian

Share this post


Link to post
Share on other sites

great script :)

---------- Post added at 21:04 ---------- Previous post was at 20:33 ----------

but, I don't see a respawn dialog after I change uniform and die... will be digging this question...

Share this post


Link to post
Share on other sites

With script interests me. :) Is it compatible with ArmA AA ? :confused:

Share this post


Link to post
Share on other sites

Hey, just using this script with a 'resistance' type mission.

Just curious, even though it physically 'deletes' the old model off the map, I still am getting a buildup of names in my 'shacktac hud' from previous player models...?

Also, Is there a way to keep your player nick? Rather than adopting a random name?

Thanks

Share this post


Link to post
Share on other sites

i have created and have working a body model change for my preset loadouts (not yet released version 1.5)

it works in MP and SP editor.

The only issue i have not worked out is the respawn dialog.

It was said that i needed a eventhandler to sort this in the wiki i think, but i tried setDammage 0, nothing, i could move the body just fine with scripts, but could not switch to another body, by script as well.

None of my previous bodys were deleted even i did run the delete line on them after the switch.

So for now i can switch to a body with my choosen gear of choise and play fine on MP and SP, all triggers synched to me, and all triggers or scripts using my previous bodys name works, also initline is included.

But i cant respawn or switch to another body once im dead, any ideas?

Share this post


Link to post
Share on other sites

setvehicleinit and copypaste can work to get the data from the init of one unit to the init of another.

but as to return an init string - thats an entirely different matter which im not sure its possible right now.

Share this post


Link to post
Share on other sites

i actually got the switch back on killed eventhandler working by using setvariable and getvariable on death, then switch to the unit from the variable, otherwise i always returned any on the old unit. unsure why.

Maybe its an error in my script, but i think i removed all handledamage things on my old unit, but it still is invulnarable after i auto switch back on death.

Im pretty sure its only a stupid little detail ive missed.

Edit: maybe i need to set handledamege true on the player instead of the unit..

If anyone has info on why unit cannot be injured by bullets after switch back using selectPlayer id be very happy to be enlightened.

but as to return an init string - thats an entirely different matter which im not sure its possible right now.
yes i did not find anything to dynamically colletc init of unit either, but i just used the original init in a string in the start of the body script, manually pasted in by the script user in the init of the loadout script init.

got the idea from tophes vehicle respawn.

hint "this is my init"; _null = [this, "hint 'this is my init'"] execVM "script.sqf"

still working on getting the inits to work easy for the user with names, etc when not using this, unsure atm if its neccesary. body change and respawn is priority atm.

Then getting it to work with norrins or other revive scripts after....

Hooray for trial and error.

Share this post


Link to post
Share on other sites

Anyone know how to execute this from a script file (.sqf) rather than an addAction command?

Share this post


Link to post
Share on other sites

I had already made a script something like this, checkout my site on my sig! and look for

my example "change clothes" mission.

Share this post


Link to post
Share on other sites

ive released preset loadouts v 1.5 experimental, wich is confirmed working in SP and MP editor, still waiting for MP dedicated confirmation this weekend, it keeps , group, side, score, vehicle positions, leader etc...

check it out, its in my sig.

Share this post


Link to post
Share on other sites
ive released preset loadouts v 1.5 experimental, wich is confirmed working in SP and MP editor, still waiting for MP dedicated confirmation this weekend, it keeps , group, side, score, vehicle positions, leader etc...

check it out, its in my sig.

Hey I am loving your script, it works like a charm! Is there a way to separate just the uniform change script? I already have a script for custom loadouts, my problem is getting units to change uniform.

Share this post


Link to post
Share on other sites

Yeah, I'm actually looking for a script, very similar to DarkXess, but I want it to just change the model, not the entire loadout. For example, as an insurgent if I kill a BLUFOR unit I want the option to "steal uniform" and have the player model switch to a BLUFOR model, but keep my unit on the OPFOR side.

Not sure if this is possible though?

Share this post


Link to post
Share on other sites

quick solution is to download my preset loadouts v 1.5 and only use the init.sqf for the changebody.sqf and the scripts changebody.sqf and regular_respawn.sqf in your mission and run this script when changing body keeping weapons.

but note that it does have issues, in regards to revive scripts etc...

something like this, when using parts of my preset loadouts v 1.5

/*
execute with:
_null = [unit,newbodytype,["empty"]] execVM "scriptname.sqf";
*/

_unit = _this select 0;
_body = _this select 1;
_arr = _this select 2;

_weapons = weapons _unit;
_magazines = magazines _unit;

_newBody = [_unit,_body,_arr] call Preset_loadOuts_body;
sleep 1;
{_newBody addMagazine _x} foreach _magazines;
{_newBody addWeapon _x} foreach _weapons;

Share this post


Link to post
Share on other sites
quick solution is to download my preset loadouts v 1.5 and only use the init.sqf for the changebody.sqf and the scripts changebody.sqf and regular_respawn.sqf in your mission and run this script when changing body keeping weapons.

but note that it does have issues, in regards to revive scripts etc...

something like this, when using parts of my preset loadouts v 1.5

/*
execute with:
_null = [unit,newbodytype,["empty"]] execVM "scriptname.sqf";
*/

_unit = _this select 0;
_body = _this select 1;
_arr = _this select 2;

_weapons = weapons _unit;
_magazines = magazines _unit;

_newBody = [_unit,_body,_arr] call Preset_loadOuts_body;
sleep 1;
{_newBody addMagazine _x} foreach _magazines;
{_newBody addWeapon _x} foreach _weapons;

Thanks for the help, here is what I am using for the uniform change execution:

_null = [this,"FR_Assault_GL",["empty"]] execVM "f2f\uniform\uniformExe.sqf";

Does the array format look correct? I am noticing when the unit changes clothes, the original unit is standing right next to me after the swap. Is there something I am doing wrong?

Edited by VirusLIVED

Share this post


Link to post
Share on other sites

_null = [[],"FR_Assault_GL",["empty"]] execVM "f2f\clothes.sqf";

should be:

_null = [this,"FR_Assault_GL",["empty"]] execVM "f2f\clothes.sqf";

changebody.sqf and regular_respawn.sqf are in loadouts folder, copy that folder to your mission folder, and add the line from my init.sqf with the call compile or something changebody.sqf to your own init.sqf.

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  

×