Jump to content

EveryEmpireFalls

Member
  • Content Count

    8
  • Joined

  • Last visited

  • Medals

Community Reputation

0 Neutral

About EveryEmpireFalls

  • Rank
    Private
  1. EveryEmpireFalls

    Respawn Expressions Issue(s)

    We tried doing the _pylonPaths before the if/then loop as seen here: [ this ] call { params[ "_logic" ]; if (!isServer) exitWith {}; _vehs = synchronizedObjects _logic; _initPylons = { params[ "_vehicle", [ "_pylons", "none" ] ]; private "_pylonPaths"; if (_pylons isEqualType []) then { _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply { getArray (_x >> "turret") }; { _vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon") }forEach getPylonMagazines _vehicle; { _vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex] }forEach _pylons; }; }; { [ _x ] call _initPylons; }forEach _vehs; [ _vehs, _initPylons ] spawn { params[ "_vehs", "_initPylons" ]; private _respawnList = _vehs apply{ [ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ] }; while { true } do { sleep 10; private _respawnDistance = 20; private _respawnDistanceSqr = _respawnDistance ^2; { _x params[ "_veh", "_respawnPos", "_vecDirAndUp", "_pylonMags" ]; if ( !alive _veh || { _veh distanceSqr _respawnPos > _respawnDistanceSqr } ) then { private _nearPlayers = allPlayers select{ alive _x && { _x distanceSqr _veh <= _respawnDistanceSqr } }; if (count _nearPlayers > 0) then { continue; }; _veh lock true; deleteVehicleCrew _veh; private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ]; _newveh setVectorDirAndUp _vecDirAndUp; _newveh setPosATL _respawnPos; [ _newveh, _pylonMags ] spawn _initPylons; _respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ]; deleteVehicle _veh; }; } forEach _respawnlist; }; }; }; With no luck.
  2. EveryEmpireFalls

    Respawn Expressions Issue(s)

    I think I miscommunicated with you in my previous response (my bad). The "Error undefined variable in expression _pylonPaths" was thrown around here: I did edit the pylonMags -> _pylonMags, and that portion appears to work fine. We tried the https://community.bistudio.com/wiki/Arma_3:_Vehicle_Loadouts "Saving and Restoring" segment by manually hardcoding the pylon loadouts and that worked but appears to have overwritten the unlimited ammo execution. Just for clarity's sake I have copied the current code below: [ this ] call { params[ "_logic" ]; if (!isServer) exitWith {}; _vehs = synchronizedObjects _logic; _initPylons = { params[ "_vehicle", [ "_pylons", "none" ] ]; if (_pylons isEqualType []) then { private _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply { getArray (_x >> "turret") }; { _vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon") }forEach getPylonMagazines _vehicle; { _vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex] }forEach _pylons; }; }; { [ _x ] call _initPylons; }forEach _vehs; [ _vehs, _initPylons ] spawn { params[ "_vehs", "_initPylons" ]; private _respawnList = _vehs apply{ [ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ] }; while { true } do { sleep 10; private _respawnDistance = 20; private _respawnDistanceSqr = _respawnDistance ^2; { _x params[ "_veh", "_respawnPos", "_vecDirAndUp", "_pylonMags" ]; if ( !alive _veh || { _veh distanceSqr _respawnPos > _respawnDistanceSqr } ) then { private _nearPlayers = allPlayers select{ alive _x && { _x distanceSqr _veh <= _respawnDistanceSqr } }; if (count _nearPlayers > 0) then { continue; }; _veh lock true; deleteVehicleCrew _veh; private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ]; _newveh setVectorDirAndUp _vecDirAndUp; _newveh setPosATL _respawnPos; [ _newveh, _pylonMags ] spawn _initPylons; _respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ]; deleteVehicle _veh; }; } forEach _respawnlist; }; }; }; And further, here is the hardcoded version with ONLY the F/A-181's loadouts (which is less than ideal because we want it to work for multiple types of vehicles without having to manually load each): [ this ] call { params[ "_logic" ]; if (!isServer) exitWith {}; _vehs = synchronizedObjects _logic; _initPylons = { params[ "_vehicle", [ "_pylons", "none" ] ]; private _pylons = ["PylonRack_Missile_AGM_02_x1", "PylonRack_Missile_AGM_02_x1", "PylonRack_Missile_HARM_x1", "PylonRack_Missile_HARM_x1", "PylonMissile_Missile_BIM9X_x1", "PylonMissile_Missile_BIM9X_x1", "PylonMissile_Missile_AMRAAM_D_INT_x1", "PylonMissile_Missile_AMRAAM_D_INT_x1", "PylonRack_Bomb_SDB_x4", "PylonRack_Bomb_SDB_x4", "PylonMissile_1Rnd_BombCluster_01_F", "PylonMissile_1Rnd_BombCluster_01_F"]; if (_pylons isEqualType []) then { private _pylonPaths = configProperties[ configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x" ] apply { getArray (_x >> "turret") }; { _vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon") }forEach getPylonMagazines _vehicle; { _vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex] }forEach _pylons; }; }; { [ _x ] call _initPylons; }forEach _vehs; [ _vehs, _initPylons ] spawn { params[ "_vehs", "_initPylons" ]; private _respawnList = _vehs apply{ [ _x, getPosATL _x, [ vectorDir _x, vectorUp _x ], getPylonMagazines _x ] }; while { true } do { sleep 10; private _respawnDistance = 20; private _respawnDistanceSqr = _respawnDistance ^2; { _x params[ "_veh", "_respawnPos", "_vecDirAndUp", "_pylonMags" ]; if ( !alive _veh || { _veh distanceSqr _respawnPos > _respawnDistanceSqr } ) then { private _nearPlayers = allPlayers select{ alive _x && { _x distanceSqr _veh <= _respawnDistanceSqr } }; if (count _nearPlayers > 0) then { continue; }; _veh lock true; deleteVehicleCrew _veh; private _newVeh = createVehicle[ typeOf _veh, [0, 0, 100], [], 0, "NONE" ]; _newveh setVectorDirAndUp _vecDirAndUp; _newveh setPosATL _respawnPos; [ _newveh, _pylonMags ] spawn _initPylons; _respawnlist set[ _forEachIndex, [ _newveh, _respawnPos, _vecDirAndUp, _pylonMags ] ]; deleteVehicle _veh; }; } forEach _respawnlist; }; }; };
  3. EveryEmpireFalls

    Respawn Expressions Issue(s)

    Thanks for the reply, Larrow. I took your code snippet for the Vehicle Respawn unlimited ammo and placed it in the expression field of said module; it works great! However, I do not completely follow what you do with the pylons in your cleaned-up code (even with the help of a friend more experienced with Arma language than I). Additionally, it throws some errors: "Error local variable in global space" around this line. _x params[ "_veh", "_respawnPos", "_vecDirAndUp", "pylonMags" ]; pylonMags appears to be the fault here, as it is not local. We corrected the pylonMags to _pylonMags, which solved that issue. However, now it throws an "error undefined variable in expression _pylonPaths". Thanks again for your assistance.
  4. Hello! First | The basic premise of what I am attempting to do is two-fold. A) respawn existing vehicles (of different types - i.e. some jets, some helicopters, some ground vehicles), with the same custom pylons - for the jets/helis - set by the pylon/dynamic loadout editor in 3den. This part works fine thus far (see below). And B) apply unlimited ammo on a delay (i.e. it takes 45 seconds for the ammo to restore) to both the original vehicle and its respawned clone. The main trouble I am having is getting unlimited ammo to work with the new, respawned vehicles. Second | A code dump and summary of what is where: The code below is my unlimited ammo expression in the existing F/A-181 (and other vehicles). Ideally, the missiles & bombs refresh on a delay, hence the {sleep 45} segment. This part works perfectly for my purposes. this addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 45};_this select 0 setVehicleAmmo 1}}]; This code is present in the expression of a Game Logic and synced to all relevant air vehicles. It works perfectly for my purposes; no errors and functions as intended. [this] call { if (!isServer) exitWith {}; params ["_thisObject"]; _vehs = synchronizedObjects _thisObject; _initScript = { params ["_vehicle", ["_pylons", "none"]]; if (typeName _pylons == typeName []) then { private _pylonPaths = (configProperties [configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"]) apply { getArray (_x >> "turret") }; { _vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon") } forEach getPylonMagazines _vehicle; { _vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex] } forEach _pylons; }; }; { [_x] call _initScript; } forEach _vehs; [_vehs, _initScript] spawn { params ["_vehs", "_initScript"]; sleep 1; _respawnlist = []; { _respawnlist = _respawnlist + [[_x, position _x, [vectorDir _x, vectorUp _x], getPylonMagazines _x]] } forEach _vehs; while { true } do { sleep 1; { _veh = _x # 0; _respawnpos = _x # 1; _playerdistance = 200; { if (_veh distance _x < _playerdistance) then { _playerdistance = _veh distance _x }; } forEach allPlayers; if (!alive _veh || (_veh distance _respawnpos > 20 && _playerdistance > 20)) then { _vehType = typeOf _veh; [_veh, _respawnlist] spawn { params ["_veh", "_respawnlist"]; deleteVehicleCrew _veh; _veh lock true; _inSpawn = false; waitUntil { sleep 0.5; _inSpawn = false; { _respawnpos = _x # 1; if ((_veh distance _respawnpos) < 30) exitWith { _inSpawn = true; }; } forEach _respawnlist; _inSpawn || ((speed _veh == 0) && (isTouchingGround _veh)); }; if (!_inSpawn) then { sleep 30 }; deleteVehicle _veh; }; sleep 10; _newveh = _vehType createVehicle _respawnpos; _newveh setPos _respawnpos; _newveh setVectorDirAndUp (_x # 2);[_newveh, _x # 3] call _initScript; _respawnlist set [_forEachIndex, [_newveh, _respawnpos, _x # 2, _x # 3]]; }; } forEach _respawnlist; }; }; }; This is the current code present in the "System Specific - Vehicle Respawn" Module expression (not its Init). It does not work at all. params ["_newVeh", "_oldVeh"]; [_newVeh addEventHandler ["Fired", { [_newVeh select 0, getNumber (configFile/"CfgAmmo"/(_newVeh select 4)/"explosive")] spawn { if (_newVeh select 1 >= 0) then { sleep 5 }; _newVeh select 0 setVehicleAmmo 1 } }]] call BIS_fnc_initVehicle; The Vehicle Respawn Module: It throws the no errors upon mission launch and no errors upon vehicle respawn. My friends and I suspect it is not even executing properly. Here are a few screencaps of the 3den editor of the scene in question if it helps you: // Overview of the whole airfield. The Vehicle Respawn Module on the Right by the center of the airfiled is exlusively linked to ground vehicles. It respawns the vehicles fine but without the unlimited ammo. // The test F/A-181. // The Game Logic. // My two primary test subjects (Left is experimental; Right is the control). As you can see, the left F/A-181 is the primary test subject for the Vehicle Respawn Module, as it is synced to both the Vehicle Respawn and the Game Logic. The right F/A-181 (and all other air vehicles) is synced only to the Game Logic. Both jets initially spawn with the proper pylons/dynamic loadouts and unlimited ammo, as expected vis-a-vis the 3den editor settings. Both jets respawn with the proper pylons/dynamic loadouts. Neither jet respawns with unlimited ammo, currently. I feel close to solving this, but I am blind to what I am missing/adding unnecessarily. I have tried numerous other variations with even less luck. I am sure there is some redundancy between the Vehicle Respawn Module and the game logic, and I would appreciate any simplifications there. However, that is a secondary concern. Thanks for reading this far! Hopefully, you can help me and anyone else who wants to do this.
  5. EveryEmpireFalls

    Help with respawn asset script - INIT

    Removing the comma made no difference. And now it throws a syntax error.
  6. EveryEmpireFalls

    Help with respawn asset script - INIT

    Thanks for the response Harzach. Here is the new line: params [_newVeh, oldVeh]; [_newVeh addEventHandler ["Fired",{[_newVeh select 0, getNumber (configFile/"CfgAmmo"/(_newVeh select 4)/"explosive")] spawn {if (_newVeh select 1==1) then {sleep 0.5}; _newVeh select 0.5 setVehicleAmmo 1}}]] call BIS_fnc_initVehicle; It does not give any errors, however, it still does not work upon vehicle respawn. FYI I am not very experienced at coding. I have some friends who are, and they are assisting me but they're about as confused as I am.
  7. EveryEmpireFalls

    Help with respawn asset script - INIT

    Hello! I would like to piggyback off this thread, as it so happens that I have a related conundrum. First, the basic premise of what I am attempting to do is to respawn an existing vehicle with the same custom pylons set by the pylon/dynamic loadout editor in 3den, all with unlimited ammo. I know the unlimited ammo and pylons before the vehicle respawns, but not after (in whole). Second, a code dump and summary of what is where: This is the unlimited ammo expression I have in the existing F/A-181 (and other vehicles). Ideally, the missiles & bombs would refresh on a delay, hence the {sleep 45} segment. This part works perfectly for my purposes. this addEventHandler ["Fired",{[_this select 0,getNumber (configFile/"CfgAmmo"/(_this select 4)/"explosive")] spawn {if (_this select 1==1) then {sleep 45};_this select 0 setVehicleAmmo 1}}]; This code is present in the expression of a game logic and synced to all relevant vehicles. It works perfectly for my purposes. [this] call { if (!isServer) exitWith {}; params ["_thisObject"]; _vehs = synchronizedobjects _thisObject; _initScript = { params ["_vehicle", ["_pylons", "none"]]; if (typeName _pylons == typeName []) then { private _pylonPaths = (configProperties [configFile >> "CfgVehicles" >> typeOf _vehicle >> "Components" >> "TransportPylonsComponent" >> "Pylons", "isClass _x"]) apply {getArray (_x >> "turret")}; { _vehicle removeWeaponGlobal getText (configFile >> "CfgMagazines" >> _x >> "pylonWeapon") } forEach getPylonMagazines _vehicle; { _vehicle setPylonLoadout [_forEachIndex + 1, _x, true, _pylonPaths select _forEachIndex] } forEach _pylons; }; }; { [_x] call _initScript; } foreach _vehs; [_vehs, _initScript] spawn { params ["_vehs", "_initScript"]; sleep 1; _respawnlist = []; {_respawnlist = _respawnlist + [[_x, position _x, [vectorDir _x, vectorUp _x], getPylonMagazines _x]]} forEach _vehs; while {true} do { sleep 1; { _veh = _x # 0; _respawnpos = _x # 1; _playerdistance = 200; {if (_veh distance _x < _playerdistance) then {_playerdistance = _veh distance _x};} foreach allPlayers; if (!alive _veh || (_veh distance _respawnpos > 20 && _playerdistance > 20)) then { _vehType = typeOf _veh; [_veh, _respawnlist] spawn { params ["_veh", "_respawnlist"]; deleteVehicleCrew _veh; _veh lock true; _inSpawn = false; waitUntil { sleep 0.5; _inSpawn = false; { _respawnpos = _x # 1; if ((_veh distance _respawnpos) < 30) exitWith {_inSpawn = true;}; } forEach _respawnlist; _inSpawn || ((speed _veh == 0) && (isTouchingGround _veh)); }; if (!_inSpawn) then {sleep 30}; deleteVehicle _veh; }; sleep 10; _newveh = _vehType createVehicle _respawnpos; _newveh setPos _respawnpos; _newveh setVectorDirAndUp (_x # 2);[_newveh, _x # 3] call _initScript; _respawnlist set [_forEachIndex, [_newveh, _respawnpos, _x # 2, _x # 3]];};} foreach _respawnlist; }; };}; This is the current code present in the Vehicle Respawn Module System Specific expression (not its Init). It does not work at all. params [_newVeh, oldVeh]; [_newVeh, addEventHandler ["Fired",{[_newVeh, select 0, getNumber (configFile/"CfgAmmo"/(_newVeh, select 4)/"explosive")] spawn {if (_newVeh, select 1==1) then {sleep 0.5}; _newVeh, select 0.5 setVehicleAmmo 1}}]] call BIS_fnc_initVehicle; It throws the following error upon mission launch, but not upon vehicle respawn (which happened in some previous iterations of my attempts). Here is a screencap of the 3den editor of the scene in question: As you can see, the left F/A-181 is the primary test subject, as it is synced to both the Vehicle Respawn and the game logic. The right F/A-181 is synced only to the game logic. Both jets initially spawn with the proper pylons/dynamic loadouts and unlimited ammo. Both jets respawn with the proper pylons/dynamic loadouts. Neither jet respawns with unlimited ammo, currently. I feel rather close to solving this, but I am blind to what I am missing/adding unnecessarily. I am sure there is some redundancy between the Vehicle Respawn Module and the game logic, and I would appreciate any simplifications there. However, that is a secondary concern. Thanks for reading this far! Hopefully you can help me and anyone else who wants to do this.
×