Jump to content
Sign in to follow this  
congo

Player alternately respawns at enemy base

Recommended Posts

Hi,

I have a persistent problem building multiplayer missions in OA, where the player respawns

at the enemy base after a respawn from the menu or after a death.

The bug will cause alternate, apparently random respawns between the friendly and enemy base respawns.

There may be a pattern; if the death of the player is caused by a chopper crash, a menu selected suicide/respawn

or similar, that player seems to respawn at the enemy base, but if the enemy kills the player unit, then he spawns

at the correct base.

I've been trying to solve this on my own for years, I've been searching the internet for answers

but cannot find any info that's related to:

"Arma 2 Operation Arrowhead CO AO spawning respawn at wrong base enemy base" etc etc .....

I've built many missions that worked ok, but this particular problem persists and I would appreciate any help.

Even if I build a simple test mission with very few elements, I get this respawn bug.

Any help greatly appreciated, thanks.

Details of scripts used as follows ...........

________________________________ this line to separate scripts for forum posting puposes ________________________________________

// Filename: description.ext

showCompass = 0;

showGPS = 0;

showWatch = 0;

onLoadMission = "Arma II CO - Proving Ground, FIGHT - by Congo";

onLoadMissionTime = 5;

disabledAI =1;

respawn = 3;

respawnDelay = 5;

// (Vehicle Respawns - I cannot get this to work, so I use another script - Congo)

// respawnVehicle = 3;

// respawnVehicleDelay = 10;

respawnDialog = 1;

// end of script

________________________________ this line to separate scripts for forum posting puposes ________________________________________

// Filename : init.sqf

// Remove Dead Script init

[20,40] execVM "cly_removedead.sqf";

// Same Weapon Respawn init

execVM "SaveWepOnRespawn.sqf";

// end of script

________________________________ this line to separate scripts for forum posting puposes ________________________________________

// Filename : SaveCustomLoadout.sqf - add to ammobox init -> this addaction ["Save Loadout","SaveCustomLoadout.sqf"];

_unit = _this select 1;

_weapons = weapons _unit;

_magazines = magazines _unit;

_backpack = unitBackpack _unit;

_backpackmagazines = getMagazineCargo _backpack;

_backpackweapons = getWeaponCargo _backpack;

savedloadout = [_weapons,_magazines,typeOf _backpack,_backpackmagazines,_backpackweapons];

hint "Current Loadout Saved !";

// end of script

________________________________ this line to separate scripts for forum posting puposes ________________________________________

// Filename: SaveWepOnRespawn.sqf - add to init.sqf -> execVM "SaveWepOnRespawn.sqf";

WaitUntil{not isNull player || isDedicated};

player addEventHandler ["Killed",{

player spawn {

_unit = _this;

private ['_magazines','_weapons','_backpack','_backpackweap','_backpackmags'];

if(isNil "savedloadout") then {

_weapons = weapons _unit;

_magazines = magazines _unit;

_backpack = typeOf unitBackpack _unit;

_backpackmags = getMagazineCargo unitBackpack _unit;

_backpackweap = getWeaponCargo unitBackpack _unit;

} else {

_weapons = savedloadout select 0;

_magazines = savedloadout select 1;

_backpack = savedloadout select 2;

_backpackmags = savedloadout select 3;

_backpackweap = savedloadout select 4;

};

WaitUntil{alive player};

removeAllWeapons player;

removeAllItems player;

removeBackpack player;

{player addMagazine _x} foreach _magazines;

{player addWeapon _x} foreach _weapons;

if (primaryWeapon player != "") then {

player selectWeapon (primaryWeapon player);

_muzzles = getArray(configFile>>"cfgWeapons" >> primaryWeapon player >> "muzzles"); // Fix for weapons with grenade launcher

player selectWeapon (_muzzles select 0);

};

if(_backpack != "") then {

player addBackpack _backpack; clearWeaponCargo (unitBackpack player); clearMagazineCargo (unitBackpack player);

for "_i" from 0 to (count (_backpackmags select 0) - 1) do {

(unitBackpack player) addMagazineCargo [(_backpackmags select 0) select _i,(_backpackmags select 1) select _i];

};

for "_i" from 0 to (count (_backpackweap select 0) - 1) do {

(unitBackpack player) addWeaponCargo [(_backpackweap select 0) select _i,(_backpackweap select 1) select _i];

};

};

};

}];

// end of script

________________________________ this line to separate scripts for forum posting puposes ________________________________________

// Filename : All_Ammo_A2CO.sqf - init -> null0 = this execVM "All_Ammo_A2CO.sqf";

_wepcount = 10;

_magcount = 30;

clearweaponcargo _this;

clearmagazinecargo _this;

_weaponsList = [];

_namelist = [];

_cfgweapons = configFile >> "cfgWeapons";

for "_i" from 0 to (count _cfgweapons)-1 do {

_weapon = _cfgweapons select _i;

if (isClass _weapon) then {

_wCName = configName(_weapon);

_wDName = getText(configFile >> "cfgWeapons" >> _wCName >> "displayName");

_wModel = getText(configFile >> "cfgWeapons" >> _wCName >> "model");

_wType = getNumber(configFile >> "cfgWeapons" >> _wCName >> "type");

_wscope = getNumber(configFile >> "cfgWeapons" >> _wCName >> "scope");

_wPic = getText(configFile >> "cfgWeapons" >> _wCName >> "picture");

_wDesc = getText(configFile >> "cfgWeapons" >> _wCName >> "Library" >> "libTextDesc");

_isFake = false;

_wHits=0;

_mags=[];

_muzzles = getArray(configfile >> "cfgWeapons" >> _wCName >> "muzzles");

if ((_muzzles select 0)=="this") then {

_muzzles=[_wCName];

_mags = getArray(configfile >> "cfgWeapons" >> _wCName >> "magazines");

} else {

{

_muzzle=_x;

_mags = getArray(configfile >> "cfgWeapons" >> _wCName >> _muzzle >> "magazines");

}forEach _muzzles;

};

{

_ammo = getText(configfile >> "cfgMagazines" >> _x >> "ammo");

_hit = getNumber(configfile >> "cfgAmmo" >> _ammo >> "hit");

_wHits = _wHits + _hit;

}forEach _mags;

if ((_wCName!="") && (_wDName!="") && (_wModel!="") && (_wPic!="")) then {

if !(_wDName in _namelist) then {

_weaponsList = _weaponsList + [[_wCName,_wDName,_wPic,_wDesc]];

_namelist = _namelist + [_wDName];

};

};

};

if (_i % 10==0) then {

hintsilent format["Loading Weapons List... (%1)",count _weaponsList];

sleep .0001;

};

};

hint "";

_namelist=nil;

_magazinesList = [];

_namelist = [];

_cfgmagazines = configFile >> "cfgmagazines";

for "_i" from 0 to (count _cfgmagazines)-1 do {

_magazine = _cfgmagazines select _i;

if (isClass _magazine) then {

_mCName = configName(_magazine);

_mDName = getText(configFile >> "cfgmagazines" >> _mCName >> "displayName");

_mModel = getText(configFile >> "cfgmagazines" >> _mCName >> "model");

_mType = getNumber(configFile >> "cfgmagazines" >> _mCName >> "type");

_mscope = getNumber(configFile >> "cfgmagazines" >> _mCName >> "scope");

_mPic = getText(configFile >> "cfgmagazines" >> _mCName >> "picture");

_mDesc = getText(configFile >> "cfgmagazines" >> _mCName >> "Library" >> "libTextDesc");

if ((_mCName!="") && (_mDName!="") && (_mModel!="")) then {

if !(_mDName in _namelist) then {

_magazinesList = _magazinesList + [[_mCName,_mDName,_mPic,_mDesc]];

_namelist = _namelist + [_mDName];

};

};

};

if (_i % 10==0) then {

hintsilent format["Loading magazines List... (%1)",count _magazinesList];

sleep .0001;

};

};

hint "";

_namelist=nil;

while {alive _this} do

{

clearweaponcargo _this;

clearmagazinecargo _this;

for "_i" from 0 to (count _weaponsList)-1 do {

_weapon = _weaponsList select _i;

_this addweaponcargo [_weapon select 0,_wepcount];

};

for "_i" from 0 to (count _magazinesList)-1 do {

_magazine = _magazinesList select _i;

_this addmagazinecargo [_magazine select 0,_magcount];

};

// Refill timing in seconds: (20mins)

sleep 1200;

};

// end of script

________________________________ this line to separate scripts for forum posting puposes ________________________________________

// Filename = cly_removedead.sqf - Just put [60,120] execVM "cly_removedead.sqf" in your "init.sqf" script

if (!isServer) exitWith {};

_oa=isClass (configFile/"CfgPatches"/"CA_E");

_manwait=_this select 0;

_vehiclewait=if (count _this>1) then {_this select 1} else {_manwait};

CLY_removedeadpending=[];

CLY_dontremovedead=[];

//Spawnable script

_removedead={

_unit=_this select 0;

_wait=_this select 1;

sleep _wait;

if (_unit in CLY_dontremovedead) exitWith {

CLY_removedeadpending=CLY_removedeadpending-[_unit];

};

waitUntil {isNull flag _unit};

if (getPosATL _unit select 2<1.5 and _unit isKindOf "Man" and isClass (configFile/"CfgPatches"/"CA_E")) then {

hideBody _unit;

sleep 10;

};

CLY_removedeadpending=CLY_removedeadpending-[_unit];

deleteVehicle _unit;

};

//OA loop

while {_oa} do {

sleep 1;

{

if (isNil {_x getVariable "CLY_removedead"}) then {

if !(_x in CLY_dontremovedead or _x in CLY_removedeadpending) then {

_wait=if (_x isKindOf "Man") then {_manwait} else {_vehiclewait};

if (_wait>0 and vehicle _x==_x) then {

[_x,_wait] spawn _removedead;

CLY_removedeadpending set [count CLY_removedeadpending,_x];

};

};

} else {

if (_x getVariable "CLY_removedead" and vehicle _x==_x) then {

CLY_removedeadpending set [count CLY_removedeadpending,_x];

[_x,0] spawn _removedead;

_x setVariable ["CLY_removedead",nil];

} else {

CLY_dontremovedead set [count CLY_dontremovedead,_x];

_x setVariable ["CLY_removedead",nil];

};

};

} forEach allDead;

};

//A2 loop

_pendingunits=[];

while {!_oa} do {

_units=allUnits;

_deadunits=[];

sleep 1;

{

if !(_x in allUnits) then {

_deadunits set [count _deadunits,_x];

CLY_removedeadpending set [count CLY_removedeadpending,_x];

};

} forEach _units;

{

if (isNil {_x getVariable "CLY_removedead"}) then {

if (_manwait>0) then {

if (vehicle _x==_x) then {

[_x,_manwait] spawn _removedead;

} else {

_pendingunits set [count _pendingunits,_x];

};

};

} else {

if (_x getVariable "CLY_removedead") then {

if (vehicle _x==_x) then {

[_x,0] spawn _removedead;

} else {

_pendingunits set [count _pendingunits,_x];

};

};

};

} forEach _deadunits;

{

if (vehicle _x==_x) then {

_pendingunits=_pendingunits-[_x];

[_x,_manwait] spawn _removedead;

};

} forEach _pendingunits;

};

________________________________ this line to separate scripts for forum posting puposes ________________________________________

// Filename - VehicleRespawn.sqf - Usage : (add to vehicle init) veh = [this, 900, 2700, 50, FALSE, FALSE] execVM "VehicleRespawn.sqf"

if (!isServer) exitWith {};

// Define variables

_unit = _this select 0;

_delay = if (count _this > 1) then {_this select 1} else {30};

_deserted = if (count _this > 2) then {_this select 2} else {120};

_respawns = if (count _this > 3) then {_this select 3} else {0};

_explode = if (count _this > 4) then {_this select 4} else {false};

_dynamic = if (count _this > 5) then {_this select 5} else {false};

_unitinit = if (count _this > 6) then {_this select 6} else {};

_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;

_unitname = vehicleVarName _unit;

if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};

_noend = true;

_run = true;

_rounds = 0;

if (_delay < 0) then {_delay = 0};

if (_deserted < 0) then {_deserted = 0};

if (_respawns <= 0) then {_respawns= 0; _noend = true;};

if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;

_position = getPosASL _unit;

_type = typeOf _unit;

_dead = false;

_nodelay = false;

// Start monitoring the vehicle

while {_run} do

{

sleep (2 + random 10);

if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.

if (_deserted > 0) then

{

if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then

{

_timeout = time + _deserted;

sleep 0.1;

waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};

if ({alive _x} count crew _unit > 0) then {_dead = false};

if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true};

if !(alive _unit) then {_dead = true; _nodelay = false};

};

};

// Respawn vehicle

if (_dead) then

{

if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};

if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};

if (_explode) then {_effect = "M_TOW_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};

sleep 0.1;

deleteVehicle _unit;

sleep 2;

_unit = _type createVehicle _position;

_unit setPosASL _position;

_unit setDir _dir;

if (_haveinit) then

{_unit setVehicleInit format ["%1;", _unitinit];

processInitCommands;};

if (_hasname) then

{_unit setVehicleInit format ["%1 = this; this setVehicleVarName ""%1""",_unitname];

processInitCommands;};

_dead = false;

// Check respawn amount

if !(_noend) then {_rounds = _rounds + 1};

if ((_rounds == _respawns) and !(_noend)) then {_run = false;};

};

};

// end of script

end of this forum post

Share this post


Link to post
Share on other sites

First of All, When you have a random issue with some scripts, check and define all your private variable and then test again.

Share this post


Link to post
Share on other sites
Did you put "respawn_west" and "respawn_east" markers in their rightful places?

Yes, but thank you for the reply.

I was trying to get some random spawns with extra markers like "respawn_west1 and "respawn_east1" etc, maybe I botched it up.

I'll get back here in a day or two and say whether it's sorted out, thanks.

It's happening in other missions I've made too, so I'll have to go over them again as well.

Do all the parameter's for OA's description.ext work or are some broken ? (ie. respawnVehicleDelay = 5; with a marker "respawn_vehicle_west" - seems to do nothing?)

Share this post


Link to post
Share on other sites

Ok, I fixed it. I had errors with factions/allegiances and it was messing with my respawns.

Thanks for the replys.

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  

×