Jump to content
Sign in to follow this  
chotaire

Automatically syncing First Aid modules to any spawned unit

Recommended Posts

Hi all,

I've got a question. Is it possible to sync the First aid modules to all units ingame when they get spawned, even for units spawned by the SOM module?

Thanks for your help.

---------- Post added at 11:49 PM ---------- Previous post was at 11:15 PM ----------

This also implies both friendly and hostile units spawned by the ACM module.

Share this post


Link to post
Share on other sites

Hey guys, I know this is the first time that I'm posting to this forum. I've been reading and following up on this forum for quite a long time already, this is just the first time I need help and since there have been 83 views already, I might not be the only one. Hopefully someone has an idea or is interested to lead me into the right direction. I wish it was possible that First Aid could be globally synced to the map but obviously I can't, that's a real pity because these First Aid modules are really nice. Since I like a lot to create maps that spawn units dynamically, I'd love to get a hint. Anyone?

Share this post


Link to post
Share on other sites

honestly I haven't tried to dynamically the 1st aid. I have been trying to synch the arty dynamically w/o much luck. Hopefully someone can fingure out if it is possible.

BTW, just because people don't answer your questions, doesn't mean they don't WANT to. Some questions we just haven't found the answer for yet. Hopefully synching the modules will be possible somehow.

Share this post


Link to post
Share on other sites

I don't know the answer to this either but I've always wondered. I swear I've seen enemy AI use First Aid and what not in some missions. I'm not sure if it's possible for respawning but I'm curious to find out.

Share this post


Link to post
Share on other sites

Speaking of first aid and AI, do you have to do something for them to drag or carry wounded personell?

Share this post


Link to post
Share on other sites

Yes, that is interesting aswell. I've never seen AI doing this on their own, dragging or carrying people that is.

Regarding linking the AI modules to all units/groups on map, I've been trying something like this without much success, testing to autosync to the player, if it had worked I would've thought of trying this with all existing units and loop it. However I just couldn't get it to work at all:

FAcenter = createCenter sideLogic;

FAgroup = createGroup FAcenter;

faais = FAgroup createUnit ["AlternativeInjurySimulation", [0, 0, 0], [], 0, ""];

fabc = FAgroup createUnit ["BattleFieldClearance", [0, 0, 0], [], 0, ""];

faais synchronizeObjectsAdd [player];

fabc synchronizeObjectsAdd [player];

Now when shooting people in my group, I see that there is no AIS/BC in effect. Last but not least, I found something on the BIS wiki that might mean it is generally not possible to loop this?

Quote: You can also spawn an ACM by script (createUnit). You will then have to also script its synchronization to a unit (synchronizeObjectsAdd). This needs to be done within 0.5 seconds from the start of the mission, because after that synchronizations are processed and set in stone.

Maybe I've led some clever guys into the right direction and we can get some progress, that would be really cool.

Edited by chotaire

Share this post


Link to post
Share on other sites

Check FA.sqf (decompile modules.pbo), remove the sync part, keep the 'call RE' part, don't forget to place a function module on your map & adapt the Call RE line.

use a 'call bis_fnc_variablespaceadd' if needed in order to add an init condition to the spawned unit (Call a function that trigger the FA script) or set the init at first via setVariable.

Edited by Benny.

Share this post


Link to post
Share on other sites

Have someone tried syncing the FA-modules to the ACM-module?

Share this post


Link to post
Share on other sites

I highly doubt that syncing FA & ACM Module will result in anything good.

Share this post


Link to post
Share on other sites

When you create the Module it will only sync objects that are in that modules init.

so for example I was using high command modules in my script:

"HighCommand" createUnit [[0,0,0], _USMCHCGroup ,"USMC_ASL_HC = this;this SetVariable ['addAllGroups',false];this setVariable ['ChainOfCommand', false];this synchronizeObjectsAdd [unitUSMC_1Plt_ASL];"];

So essentially your script needs to be:

FAcenter = createCenter sideLogic;

FAgroup = createGroup FAcenter;

faais = FAgroup createUnit ["AlternativeInjurySimulation", [0, 0, 0], [], 0,"this synchronizeObjectsAdd [player];"];

fabc = FAgroup createUnit ["BattleFieldClearance", [0, 0, 0], [], 0, "this synchronizeObjectsAdd [player];"];

That 'should' fix your problem.

Edited by Wolf

Share this post


Link to post
Share on other sites
Check FA.sqf (decompile modules.pbo), remove the sync part, keep the 'call RE' part, don't forget to place a function module on your map & adapt the Call RE line.

use a 'call bis_fnc_variablespaceadd' if needed in order to add an init condition to the spawned unit (Call a function that trigger the FA script) or set the init at first via setVariable.

If I understand this right, we're ripping the First Aid functions off the module so we can do with them whatever and whenever we want. That's a good idea. However, what about units spawned by the SOM and ACM modules, how do we set their inits? Does that mean I'll have to screw around with those modules aswell or is there a way to change the init of e.g. all_units on the map? This looks very much like I'd have to code a replacement script for ACM, SOM and AIS altogether which I am sure I am not capable of. ;(

Share this post


Link to post
Share on other sites

You are not going to get units spawned by the ACM to sync with FA. I haven't seen that ACM or FA has any code to account for that. You could mod the ACM to do it or do something like trawling through allUnits on a timely schedule and try to synchronize the entire list, perhaps using a set variable to see if they are already synced. Not a really efficient solution though.

Share this post


Link to post
Share on other sites

I use this code to enable "first aid"-modules for spawned group in SP-missions:

nul=[groupname] execVM "\ca\Modules\AIS\data\scripts\IS.sqf"; 
nul=[groupname] execVM "\ca\Modules\BC\data\scripts\BC.sqf"; 
nul=[groupname,leader groupname,true] execVM  "\ca\Modules\FA\data\scripts\FA.sqf"; 

You may also need to place the modules on map.

Edited by SaOk

Share this post


Link to post
Share on other sites
i need a way to sync up spawned mortar with arty module, hopefully a simple way...

anyone know how to do this?

how are the mortars spawned? by your own script?

also if the module is already in existence then try:

arty_module_name synchronizeObjectsAdd [mortar_leader];
[mortar_leader] call BIS_ARTY_F_initVehicle;

now i'm not quite sure if this will actually work its just some function i found in the arty module a while back and thought it could help you with that issue.

=============================================

and about units spawned by som getting synched with FA or any module for that matter i would use a double array method and periodically get the list of units on the entire battlefield with the help of a trigger kind of like:

trigger and module should be named so synchronization can be done.

make the trigger detection zone very large so it will cover the entire map.

then you can create the scripts needed:

init.sqf:

unit_array = [];
scan_time = 60; //this means every 60 seconds a new scan is conducted
exec "loop.sqs";

loop.sqs:

#start
~scan_time
handle = [trigger_name,module_name] execvm "script_name.sqf"
goto "start"

script_name.sqf:

_trigger = _this select 0;
_module = _this select 1;

_unit_list = list _trigger;
_temp_array = [];

//add new and alive units to a temporary array
for [{_a = 0},{_a < (count _unit_list)},{_a = _a + 1}] do
{
       private ["_unit"];
       _unit = _unit_list select _a;
       if ((not (_unit in unit_array)) and (alive _unit) and ((leader group _unit) ==  (leader _unit))) then
       {
              _temp_array = _temp_array + [_unit];
       };
};


//check which units are the same in both arrays and skip those that are
for [{_u = 0},{_u > (count unit_array)},{_u = _u + 1}] do
{
       private ["_unit"];
       _unit = unit_array select _u;
       if (not (_unit in _temp_array)) then
       {
                _temp_array = _temp_array + [_unit];
       };
};


//add synchronization to any units within the array that aren't synched yet and remove those that aren't alive anymore
if ((count _temp_array) > 0) then
{
      _synched_obj = synchronizedobjects _module;
      private ["_unit"];
      for [{_s = 0},{_s > (count _temp_array)},{_s = _s + 1}] do
      {
             _unit = _temp_array select _s;
             if ((not (_unit in _synched_obj)) and (alive _unit)) then
             {
                   _module synchronizeObjectsAdd _unit;
             };

             if (not (alive _unit)) then
             {
                  _temp_array = _temp_array - [_unit];
                  _module synchronizeobjectsremove _unit;
             };
      };
};

//save units array
unit_array = _temp_array;

//add init code for module after this line (delete ----)
------------init code----------

(not MP Compatible as synchronization only works on the server machine)

the above should keep a list of all units on the battlefield and add synchronization to the module if they haven't already been synched before and it'll remove any dead units from the synchronization list and unit list.

i haven't tested it out myself as i just wrote this up without my script editor so if there are any forgotten () or {} or any other problems with it then i'm sorry.

i hope those blocks of code can help or at least give you guys some good and better ideas because it is quite late and can't really think clearly anymore lol.

edit:

forgot that most modules only the group leader is needed.

Edited by soccerboy

Share this post


Link to post
Share on other sites

yea mortars are spawned by my own script...on the wiki there is no good example you should add that because when i looked at the command the objects in the word threw me off...

this fnc [mortar_leader] call BIS_ARTY_F_initVehicle;

where did you get this from i dont see it in any of my fnc list, and what exactly is it doing?

---------- Post added at 09:31 AM ---------- Previous post was at 09:03 AM ----------

am i suppose to use the varname mortar_leader? or the actual name "mortar_leader"?

so in this example

_VarName="MYUNIT";

_leader1 SetVehicleVarName _VarName;

_leader1 Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName];

arty_module synchronizeObjectsAdd [mortar_leader];

[mortar_leader] call BIS_ARTY_F_initVehicle;

should i use _leader1 or "MYUNIT"

---------- Post added at 10:26 AM ---------- Previous post was at 09:31 AM ----------

on top of that would it be any different if i created the arty module?

arty_module synchronizeObjectsAdd [mortar_leader];

or?

"arty_module" synchronizeObjectsAdd ["mortinf1"];

arty_module being the name of the arty module

---------- Post added at 11:43 AM ---------- Previous post was at 10:26 AM ----------

yea im having trouble with this command. synchronizeObjectsAdd

Edited by {Op4}Bsilenced

Share this post


Link to post
Share on other sites
yea mortars are spawned by my own script...on the wiki there is no good example you should add that because when i looked at the command the objects in the word threw me off...

this fnc [mortar_leader] call BIS_ARTY_F_initVehicle;

where did you get this from i dont see it in any of my fnc list, and what exactly is it doing?

---------- Post added at 09:31 AM ---------- Previous post was at 09:03 AM ----------

am i suppose to use the varname mortar_leader? or the actual name "mortar_leader"?

so in this example

should i use _leader1 or "MYUNIT"

---------- Post added at 10:26 AM ---------- Previous post was at 09:31 AM ----------

on top of that would it be any different if i created the arty module?

arty_module synchronizeObjectsAdd [mortar_leader];

or?

"arty_module" synchronizeObjectsAdd ["mortinf1"];

arty_module being the name of the arty module

i got the initvehicle function out of the arty module itself. sadly half of the functions inside of the module are undocumented like adding your own ammo type which i'll be using myself someday for my own artillery project.

if i remember correctly as i can't check it at the moment is initvehicle sets a few variables for that vehicle. its one of the first things the module does after initializing itself.

mortar_leader is just an example and should be the leader of the mortar battery.

mortar_leader = leader's name

arty_module = module's name

both MYUNIT and _leader1 should work however i'm a total geek and would work with _leader1 :)

also another thing to consider is if you're spawning multiple mortars for a single battery then you would have to group them together so only the leader is synched with the arty module.

Share this post


Link to post
Share on other sites

heres the script

if (isServer) then

{

//CREATE ARTY AND FO,S

//=================================================================

_SpawnPos = toLower (_this select 0); //spawn position of group and patrol pos

//=============================================================================

//CREATE MORTAR

_Object = "2b14_82mm" createVehicle (getMarkerPos "simbala_artybase");

//_VarName="mort1";

//_Object SetVehicleVarName _VarName;

//_Object Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName];

//=====================================================================================

//CREAT MORTAR SQUAD

GroupSquad1 = CreateGroup resistance;

_leader1 = GroupSquad1 createUnit ["ACE_Ins_2_1", [(getMarkerPos _SpawnPos) select 0,(getMarkerPos _SpawnPos) select 1,0], [], 3, "FORM"];

//_unit1 = GroupSquad1 createUnit ["ACE_Ins_2_2", [(getMarkerPos _SpawnPos) select 0,(getMarkerPos _SpawnPos) select 1,0], [], 3, "FORM"];

//_unit2 = GroupSquad1 createUnit ["ACE_Ins_2_3", [(getMarkerPos _SpawnPos) select 0,(getMarkerPos _SpawnPos) select 1,0], [], 3, "FORM"];

_leader1 = leader GroupSquad1;

//===============================================

//NAME MORTAR SQUAD

_VarName = "mortinf1";

_leader1 SetVehicleVarName _VarName;

_leader1 Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName];

//MOVE MORT SQUAD INTO GUNNER SEAT

_leader1 moveInGunner _Object ;

//=================================================

//SYNCRONIZE MORTOR SQUAD WITH ARTY MODULE

arty_module_name = ["arty_module"]; //name of arty module = arty_module

mortar_leader = [_leader1];

arty_module_name synchronizeObjectsAdd [mortar_leader];

[mortar_leader] call BIS_ARTY_F_initVehicle;

//this synchronizeObjectsAdd [unitUSMC_1Plt_ASL];"];

//==========================================================================================

//create FO

};

and heres the error im getting

Error in expression <r_leader = [_leader1];

arty_module_name synchronizeObjectsAdd [mortar_leader];

[>

Error position: <synchronizeObjectsAdd [mortar_leader];

[>

Error synchronizeobjectsadd: Type Array, expected Object

maybe you can tell me what im getting worng here..

---------- Post added at 12:42 PM ---------- Previous post was at 12:34 PM ----------

i get the same error when i change this

mortar_leader = [_leader1];

to this

mortar_leader = ["mortinf1"];

Share this post


Link to post
Share on other sites
heres the script

and heres the error im getting

maybe you can tell me what im getting worng here..

---------- Post added at 12:42 PM ---------- Previous post was at 12:34 PM ----------

i get the same error when i change this

mortar_leader = [_leader1];

to this

mortar_leader = ["mortinf1"];

if (isServer) then
{

//CREATE ARTY AND FO,S
//================================================== ===============
_SpawnPos = toLower (_this select 0); //spawn position of group and patrol pos
//================================================== ===========================
//CREATE MORTAR
_Object = "2b14_82mm" createVehicle (getMarkerPos "simbala_artybase");
//_VarName="mort1";
//_Object SetVehicleVarName _VarName;
//_Object Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName];
//================================================== ===================================
//CREAT MORTAR SQUAD
GroupSquad1 = CreateGroup resistance;
_leader1 = GroupSquad1 createUnit ["ACE_Ins_2_1", [(getMarkerPos _SpawnPos) select 0,(getMarkerPos _SpawnPos) select 1,0], [], 3, "FORM"];
//_unit1 = GroupSquad1 createUnit ["ACE_Ins_2_2", [(getMarkerPos _SpawnPos) select 0,(getMarkerPos _SpawnPos) select 1,0], [], 3, "FORM"];
//_unit2 = GroupSquad1 createUnit ["ACE_Ins_2_3", [(getMarkerPos _SpawnPos) select 0,(getMarkerPos _SpawnPos) select 1,0], [], 3, "FORM"];
_leader1 = leader GroupSquad1;
//===============================================
//NAME MORTAR SQUAD
_VarName = "mortinf1";
_leader1 SetVehicleVarName _VarName;
_leader1 Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName];
//MOVE MORT SQUAD INTO GUNNER SEAT
_leader1 moveInGunner _Object ;
//=================================================
//SYNCRONIZE MORTOR SQUAD WITH ARTY MODULE
[color="SeaGreen"]_arty_module_name = arty_module; //name of arty module = arty_module
_arty_module_name synchronizeObjectsAdd [_leader1];[/color]
[_leader1] call BIS_ARTY_F_initVehicle;
//this synchronizeObjectsAdd [unitUSMC_1Plt_ASL];"];
//================================================== ========================================
//create FO

}; 

the changes are in green the problem you were running into is you defined the module and the leader as an array already so the game saw it as [[module_name]] and [[leader]] which shouldn't be. so now it should look like a single array and not an array in an array.

also the arty module name is actually an object not a string.

this should work now however i'm unable to test this atm.

if it doesn't work feel free to PM me since i think we're hijacking the OP's thread with your problems LOL :P

Share this post


Link to post
Share on other sites

no more error message thanks for your time m8, i really do appreciate it.....

wierd never ran into adding a name into an array like that....

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  

×