Jump to content
Sign in to follow this  
dematti

init gone when respawning?

Recommended Posts

Hi,

How can I put something in the init field for a respawned unit.

The respawn script that I have makes the soldier lose his init when he dies and respawns.

Thx

Share this post


Link to post
Share on other sites

Add this to your respawn script:

unit setVehicleInit "blah blah blah";
processInitCommands;

Share this post


Link to post
Share on other sites
Add this to your respawn script:

unit setVehicleInit "blah blah blah";
processInitCommands;

Nice, thx

Does this work for all the units in my group?

I have a respawn script that respawns the whole group...

Share this post


Link to post
Share on other sites

its norrins respawn script

AI respawn:

// AI_respawn.sqf
// © JULY 2009 - norrin

if (!isServer) exitWith {};

_unit 			= _this select 0;
_lives			= _this select 1;
_delay 			= _this select 2;
_respawn_point	= _this select 3;
_move_script	= _this select 4;
_group			= _this select 5;
_side 			= _this select 6;
_AI_unitArray	= _this select 7;
_AI_magArray	= _this select 8;
_AI_wepArray	= _this select 9; 

_unitsGroup = units (group _unit);

while {(count _unitsGroup) > 0} do
{	
_remainingUnits = [];
{if (alive _x) then {_remainingUnits = _remainingUnits + [_x]}} forEach _unitsGroup;
_unitsGroup = _remainingUnits;
sleep 1;
};
deleteGroup _group;
if (_lives == 0) exitWith {};
_lives = _lives - 1;
_wait = Time + _delay;
waitUntil {Time > _wait};
_group = createGroup _side; 

{_x createUnit [(getMarkerPos _respawn_point), _group];} forEach _AI_unitArray;
sleep 2;
hint "AI respawn";
_unitsGroup = units _group;
{_x disableAI "MOVE"} forEach _unitsGroup;

for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do
{
_guy = _unitsGroup select _loop;
removeAllWeapons _guy;
{_guy removeMagazine _x} forEach magazines _guy;
removeAllItems _guy;
{_guy addMagazine _x} forEach (_AI_magArray select _loop);
{_guy addWeapon _x}   forEach (_AI_wepArray select _loop);
_guy selectWeapon (primaryWeapon _guy);
_guy setSkill (_AI_skillArray select _loop);
sleep 0.1;
};
{_x enableAI "MOVE"} forEach _unitsGroup;
_leader = leader _group;
[_leader, _lives, _delay, _respawn_point, _move_script, _group, _side, _AI_unitArray,_AI_magArray, _AI_wepArray] execVM "AI_respawn\AI_respawn.sqf"; 	
[_leader] execVM _move_script;

if (true) exitWith {};

AI respawn.init

// AI_respawn_init.sqf
// © JULY 2009 - norrin (norrin@iinet.net.au)

if (!isServer) exitWith {};

_unit 			= _this select 0;
_lives			= _this select 1;
_delay 			= _this select 2;
_respawn_point	= _this select 3;
_move_script	= _this select 4;
_unitsGroup 	= units (group _unit);
_side 			= side _unit; 

sleep 2;

_AI_unitArray  = [];
_AI_magArray   = [];
_AI_wepArray   = [];
_AI_skillArray = [];
{_AI_unitArray = _AI_unitArray + [typeOf _x];
_AI_magArray = _AI_magArray + [(magazines _x)];
_AI_wepArray = _AI_wepArray + [(weapons _x)];
_AI_skillArray = _AI_skillArray + [skill _x]}forEach _unitsGroup;

[_unit, _lives, _delay, _respawn_point, _move_script, _group, _side, _AI_unitArray,_AI_magArray, _AI_wepArray,_AI_skillArray] execVM "AI_respawn\AI_respawn.sqf";
[_unit] execVM _move_script;

if (true)exitWith {};

Share this post


Link to post
Share on other sites

This should work. Added code highlighted in red. Change it as you need.

// AI_respawn.sqf
// © JULY 2009 - norrin

if (!isServer) exitWith {};

_unit 			= _this select 0;
_lives			= _this select 1;
_delay 			= _this select 2;
_respawn_point	= _this select 3;
_move_script	= _this select 4;
_group			= _this select 5;
_side 			= _this select 6;
_AI_unitArray	= _this select 7;
_AI_magArray	= _this select 8;
_AI_wepArray	= _this select 9; 

_unitsGroup = units (group _unit);

while {(count _unitsGroup) > 0} do
{	
_remainingUnits = [];
{if (alive _x) then {_remainingUnits = _remainingUnits + [_x]}} forEach _unitsGroup;
_unitsGroup = _remainingUnits;
sleep 1;
};
deleteGroup _group;
if (_lives == 0) exitWith {};
_lives = _lives - 1;
_wait = Time + _delay;
waitUntil {Time > _wait};
_group = createGroup _side; 

{_x createUnit [(getMarkerPos _respawn_point), _group];} forEach _AI_unitArray;
sleep 2;
hint "AI respawn";
_unitsGroup = units _group;
{_x disableAI "MOVE"} forEach _unitsGroup;

for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do
{
_guy = _unitsGroup select _loop;
removeAllWeapons _guy;
{_guy removeMagazine _x} forEach magazines _guy;
removeAllItems _guy;
{_guy addMagazine _x} forEach (_AI_magArray select _loop);
{_guy addWeapon _x}   forEach (_AI_wepArray select _loop);
_guy selectWeapon (primaryWeapon _guy);
_guy setSkill (_AI_skillArray select _loop);
[color="Red"]       _guy setVehicleInit "blah blah blah";
       processInitCommands;[/color]
sleep 0.1;
};
{_x enableAI "MOVE"} forEach _unitsGroup;
_leader = leader _group;
[_leader, _lives, _delay, _respawn_point, _move_script, _group, _side, _AI_unitArray,_AI_magArray, _AI_wepArray] execVM "AI_respawn\AI_respawn.sqf"; 	
[_leader] execVM _move_script;

if (true) exitWith {};

Never really uses Norrin's revive script before. I think that should work. We'll see eh? :D

Share this post


Link to post
Share on other sites

i'm sorry that doesn't work.

They respawn and then stand still (they dont move to their first waypoint)

I also have a vehicle respawn, added the same line there,

in that script normally soldiers respawn next to the vehicle, then board it and move to their wp's. Now they dont enter the vehicle and dont move.

Vehicle respawn script:

// AIvcl_respawn_WP.sqf
// © JULY 2009 - norrin

if (!isServer) exitWith {};

_unit 			= _this select 0;
_lives			= _this select 1;
_delay 			= _this select 2;
_respawn_point	= _this select 3;
_WP_script		= _this select 4;
_crew			= _this select 5;
_side 			= _this select 6;
_AI_unitArray	= _this select 7;
_AI_skillArray	= _this select 8; 

_type = typeOf _unit;
_group	= group _unit;
_unitsGroup = units (group _unit);
_dir = getDir _unit;

waitUntil {!alive _unit}; 

deleteGroup _group;
if (_lives == 0) exitWith {};
_lives = _lives - 1;
_wait = Time + _delay;
waitUntil {Time > _wait};
_group = createGroup _side; 

_vcl_new = _type createVehicle (getMArkerPos _respawn_point);
_vcl_new setDir _dir;
sleep 1;
{_x createUnit [(getMarkerPos _respawn_point), _group];} forEach _AI_unitArray;
sleep 2;
hint "AI respawn";
_unitsGroup = units _group;
{_x disableAI "MOVE"} forEach _unitsGroup;

for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do
{	
_guy = _unitsGroup select _loop;
_guy setSkill (_AI_skillArray select _loop);
[color="Blue"]_guy setVehicleInit "this setbehaviour "safe";this addEventHandler ["killed", {_this select 0 execVM "deleteBody.sqf"}]";[/color]
     processInitCommands;
if (_loop == 0) then {_guy moveInDriver _vcl_new};
if (_loop == 1) then {_guy moveInGunner _vcl_new};	
if (_loop == 2) then {_guy moveInCommander _vcl_new}; 

sleep 0.1;
};
{_x enableAI "MOVE"} forEach _unitsGroup;
_leader = leader _group;
[_vcl_new, _lives, _delay, _respawn_point, _WP_script, _crew, _side, _AI_unitArray,_AI_skillArray] execVM "AIvcl_respawn_WP\AIvcl_respawn_WP.sqf"; 	
[_leader] execVM _WP_script;
[_leader] setVehicleInit "this setbehaviour "safe";this addEventHandler ["killed", {_this select 0 execVM "deleteBody.sqf"}]"

if (true) exitWith {};

thanks for your help though, been trying for hours so i appreciate it:)

Share this post


Link to post
Share on other sites

Can someone tell me what I'm doing wrong here?

Share this post


Link to post
Share on other sites

Strings inside a string need to be quoted with single quote ('string') or with double double quote (""string"").

Share this post


Link to post
Share on other sites

ok, that was pretty logical.

was thinking about changing it, but I thought it wouldn't matter.

Thanks shk, another lesson learned:)

Share this post


Link to post
Share on other sites

I have run into this issue as well, and I was wondering what I am doing wrong...

Using a script from Norrin I am trying to add an init to each soldier that gets spawned as well. I understand strings inside of strings need either ' or "" but i can't seem to get it to work.

the script:

if (!isServer) exitWith {};

_unit = _this select 0;

_lives = _this select 1;

_delay = _this select 2;

_respawn_point = _this select 3;

_move_script = _this select 4;

_group = _this select 5;

_side = _this select 6;

_AI_unitArray = _this select 7;

_AI_magArray = _this select 8;

_AI_wepArray = _this select 9;

_unitsGroup = units (group _unit);

while {(count _unitsGroup) > 0} do

{

_remainingUnits = [];

{if (alive _x) then {_remainingUnits = _remainingUnits + [_x]}} forEach _unitsGroup;

_unitsGroup = _remainingUnits;

sleep 1;

};

deleteGroup _group;

if (_lives == 0) exitWith {};

_lives = _lives - 1;

_wait = Time + _delay;

waitUntil {Time > _wait};

_group = createGroup _side;

{_x createUnit [(getMarkerPos _respawn_point), _group];} forEach _AI_unitArray;

sleep 2;

//hint "AI respawn";

_unitsGroup = units _group;

{_x disableAI "MOVE"} forEach _unitsGroup;

for [{ _loop = 0 },{ _loop < count _unitsGroup},{ _loop = _loop + 1}] do

{

_guy = _unitsGroup select _loop;

removeAllWeapons _guy;

{_guy removeMagazine _x} forEach magazines _guy;

removeAllItems _guy;

{_guy addMagazine _x} forEach (_AI_magArray select _loop);

{_guy addWeapon _x} forEach (_AI_wepArray select _loop);

_guy selectWeapon (primaryWeapon _guy);

_guy setSkill (_AI_skillArray select _loop);

sleep 0.1;

};

{_x enableAI "MOVE"} forEach _unitsGroup;

_leader = leader _group;

[_leader, _lives, _delay, _respawn_point, _move_script, _group, _side, _AI_unitArray,_AI_magArray, _AI_wepArray]

execVM "AI_respawn\AI_respawn.sqf";

[_leader] execVM _move_script;

if (true) exitWith {};

My latest attempt

_guy setVehicleInit "addEventHandler [""killed"", {_this execVM 'f_removeBody.sqf'}]"; processInitCommands;

I have tried several different things, but I'm just wondering if someone that actually knows how to script could help.

thanks in advance!

Share this post


Link to post
Share on other sites

I'm not sure how or where to apply

unit setVehicleInit "blah blah blah";
processInitCommands;

I am not using a respawn script, but instead I am simply using a respawn_west marker and the following script in the description.ext

respawn = base;

The players on my team respawn and none of their init stuff works and I don't know what to do and it's ruining everything.

Please. I really need help with this.

Edited by A-SUICIDAL

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  

×