Jump to content

Recommended Posts

Hello guys,
I m writing a script similar to Murklors Editor based AI spawn script by trigger for Arma 2.
 
My script should be able to handle any kind of vehicle and unit and its waypoints. Mission designers could use it to place their stuff in the editor and let be deleted what they want at any time and let it spawn again at the time in mission they want to.
If the script is finished it should feature some modes.
 
Modes:
1. Trigger mode:  Stuff is deleted at mission start and is spawned by trigger. This should be the easy way for guys with less scripting knowledge. They just put a command at the init line of one unit of the group they want to be handled and it should be spawned if the specified trigger fires.
 
2. Manual mode: Mission designer takes full control and deletes the stuff he wants at a time he wants to and spawns it at another time with the use of my scripts.
 
3. Script creation mode: Mission designer first specifies the stuff to handle. Starts the mission in editor and my script is creating a spawn script and copies it to clipboard. Now mission designer can paste it to a file and use that for spawning.
 
Please tell me if u have ideas for other modes the script should feature.
 
Upto now I started with storing all information of a unit before deleting it with this script:

/*
 File fn_get_unit_info.sqf
 Title: Spawn Script Creator
 Author: Sarogahtyp
 Description: Gets all info bout one unit
 Argument: unit
 Return value: array with all info about that unit with this structure:
[
 string,			-    0 class name
 [number, number, number],	-    1 position ASL
 [number, number, number],	-    2 vector dir
 [number, number, number],	-    3 vector up
 number,			-    4 level of ability (skill)
 number,			-    5 aimingAccuracy
 number,			-    6 aimingShake
 number,			-    7 aimingSpeed
 number,			-    8 endurance
 number,			-    9 spotDistance
 number,			-   10 spotTime
 number,			-   11 courage
 number,			-   12 reloadSpeed
 number,			-   13 commanding
 number,			-   14 general
 string,			-   15 behaviour
 string,			-   16 combatMode
 number,			-   17 getFatigue
 number,			-   18 captiveNum
// string,			-  currentCommand  // no idea how to set this information.
 string,			-   19 unitPos 
 number,			-   20 damage
 array,				-   21 expectedDestination
 boolean,			-   22 leader
 string,			-   23 rank
 string,			-   24 name
 number,			-   25 rating
 boolean,			-   26 stopped
 number,			-   27 getSuppression 
 string,			-   28 assignedTeam
];
*/

if (isNil "saro_SSC_leader_array") exitWith {true};
if (count saro_SSC_leader_array == 0) exitWith {true};

params[["_unit", objNull, [objNull]]];
private _info_array = [];

if (isNull _unit) exitWith {true};

_info_array pushBack (typeOf _unit);
_info_array pushBack (getPosASL _unit);
_info_array pushBack (vectorDir _unit);
_info_array pushBack (vectorUp _unit);

_info_array pushBack skill _unit;
_info_array pushBack (_unit skill "aimingAccuracy");
_info_array pushBack (_unit skill "aimingShake");
_info_array pushBack (_unit skill "aimingSpeed");
_info_array pushBack (_unit skill "endurance");
_info_array pushBack (_unit skill "spotDistance");
_info_array pushBack (_unit skill "spotTime");
_info_array pushBack (_unit skill "courage");
_info_array pushBack (_unit skill "reloadSpeed");
_info_array pushBack (_unit skill "commanding");
_info_array pushBack (_unit skill "general");
_info_array pushBack behaviour _unit;
_info_array pushBack combatMode _unit;
_info_array pushBack getFatigue _unit;
_info_array pushBack captiveNum _unit;
// _info_array pushBack currentCommand _unit;
_info_array pushBack unitPos _unit;
_info_array pushBack damage _unit;
_info_array pushBack expectedDestination _unit;

if ((leader group _unit) != _unit) then { _info_array pushBack false; }
else { _info_array pushBack true; };

_info_array pushBack rank _unit;
_info_array pushBack name _unit;
_info_array pushBack rating _unit;
_info_array pushBack stopped _unit;
_info_array pushBack getSuppression _unit;
_info_array pushBack assignedTeam _unit;

_info_array



What I want to know about this script is if u have ideas for mor information which could be stored in the array. I want the script as resilient as possible against all modifications which could be done before unit is deleted. So any modification should be stored and reset after spawning the unit.

Actually I ve no loadout storing implemented. That will be done later. So tell me your ideas about all other informations I ve not covered yet annd could be stored for a unit.

EDIT: updated script with new element of info array.


TODO list - updated regularly


sorted by priority
 
 store and reset group informations like groups side, name and formation  - DONE
drop download link for a PRE-ALPHA version  - DONE

 store group of vehicle and add vehicle to related group (addVehicle)  -  DONE
 store and resync synced triggers  -  DONE

add whole functionality for vehicles in flight while spawning as it does not work upto now  -  DONE (not part of download, will be tomorrow)
 make objects var name working in MP like did here  -  DONE
 write function to destroy info arrays  -  DONE
 write function to unmark groups - DONE
open new topic and release ALPHA version  - WIP
add option to index single units and vecs to mark function
implement option to pass custom code for execution after spawning (like EHs)
 store and reset units trait
 store and reset units hitparts
 store and reset vehicles hitparts
 store an reset vehicles loadout
 get killed EH for group leaders works to ensure group handling works after leader died

add option to mark function to update know triggers (if someone creates triggers during mission)

add options array to save function to switch storing of specific info on/off
relase BETA version
write the whole thing for copying the spawn script to clipboard for use in mission designers own sqf
release FINAL version



@foxhound
I appreciate your work very much but this link is not a public release. Its just a PRE-ALPHA drop for the readers of this topic only:

Sarogahtyps Spawn Script Creator 0.2 - PRE-ALPHA

Description:


I dropped a working mission file and I would be happy if some of u guys would test the SSC script.
Its a 2D editor mission but I think it can be converted easily.

the mission has some synced waypoints and 2 synced triggers. both triggers can be activated by setting triggerswitch variable true with debug console.


the scripts function implementation is done with function library in description.ext
everything a mission designer should do with SSC is done in the init lines of one group member for each group which should be handled and in initServer.sqf

howto setup the stuff in ur own mission:

1. use saroSSC_mark in init lines (or wherever u want) to mark the groups
2. use saroSSC_save wherever u like to save all stuff related to the marked groups
3. use saroSSC_delete wherever u like to delete all marked groups
4. use saroSSC_spawn wherever u like to spawn all the prior saved stuff
5. watch it working

scripts can be found here:
functions\sarogahtyp_SSC

each script which is thought for use by mission designer has a header with an example of usage.

the main things u should understand when u use SSC:

1. u can pass an index to each function. the index decides which set of groups will be manipulated by the function.
2. Only the groups u marked with the same index can interact each other by syncing there waypoints, let em get in vehicles and so on
3. u only need to use the mark function with one single unit or vehicle of each group.

Edited by sarogahtyp
  • Like 3

Share this post


Link to post
Share on other sites

Do not forget to store groups names otherwise the waypoints and other stuff related to group will fail.

Basically i think instead of removing, deinitialize/initialize would be better solution.

  • Like 1

Share this post


Link to post
Share on other sites

Do not forget to store groups names otherwise the waypoints and other stuff related to group will fail.

Basically i think instead of removing, deinitialize/initialize would be better solution.

I ll do that groups and waypoint stuff at a later point. now i m thinking about the stuff of one single unit only.

Could u explain ur idea with deinitialize/initialize a bit more. I dont understand what you mean with it.

Share this post


Link to post
Share on other sites

Here are some functions that i have created for some of my project.

fnc_deinitialize = {
//[group] spawn fnc_deinitialize;
    params ["_group"];
    
    {
        _x hideObjectGlobal true;
        _x enableSimulationGlobal false;
        _x disableAI "ANIM";
        _x disableAI "FSM";
        _x disableAI "MOVE";
        _x disableAI "TEAMSWITCH";
        _x disableAI "CHECKVISIBLE";
        _x disableAI "SUPPRESSION";
        _x disableAI "AIMINGERROR";
        _x disableAI "TARGET";
        _x disableAI "AUTOTARGET";
        _x setBehaviour "CARELESS";
        _x disableConversation true;
    } forEach units _group;
     
};
fnc_initialize = {
// [thisList] spawn fnc_initialize;
	params ["_list", "_eunits", "_egroups", "_cunits", "_cgroups", "_fegroups", "_fcgroups", "_eucount", "_cucount"];
	
	_eunits = [];
	_egroups =[];
	_cunits = [];
	_cgroups = [];
	_fegroups= [];
	_fcgroups= [];
	
	{
		if (alive _x && _x isKindOf "Man" && side _x == EAST) then {
		
			_eunits pushback _x;
			_egroups pushback (group _x);
		};
		
		if (alive _x && _x isKindOf "Man" && side _x == Civilian) then {
		
			_cunits pushback _x;
			_cgroups pushback (group _x);
		
		};
	} forEach _list;
	
	sleep 1;
	
	_eucount = count _eunits;
	_cucount = count _cunits;
	
		
		{		
			sleep 0.2;
			_x enableSimulationGlobal true;
			sleep 0.2;
			_x enableAI "ANIM";
			_x enableAI "FSM"; 
			_x enableAI "MOVE";
			_x enableAI "TEAMSWITCH";
			_x enableAI "CHECKVISIBLE";
			_x enableAI "SUPPRESSION";
			_x enableAI "AIMINGERROR";
			_x enableAI "TARGET";
			_x enableAI "AUTOTARGET";
			_x setBehaviour "SAFE";
			_x disableConversation false;
			_x addPrimaryWeaponItem "acc_flashlight";
			_x enableGunLights "AUTO";				
			_x hideObjectGlobal false;
			_eucount = _eucount -1;
					
		} forEach _eunits;
		
		{		
			sleep 0.2;
			_x enableSimulationGlobal true;
			sleep 0.2;
			_x enableAI "ANIM";
			_x enableAI "FSM"; 
			_x enableAI "MOVE";
			_x enableAI "TEAMSWITCH";
			_x enableAI "CHECKVISIBLE";
			_x enableAI "SUPPRESSION";
			_x enableAI "AIMINGERROR";
			_x enableAI "TARGET";
			_x enableAI "AUTOTARGET";
			_x setBehaviour "SAFE";
			_x disableConversation false;			
			_x hideObjectGlobal false;
			_cucount = _cucount -1;
					
		} forEach _cunits;
		
	waitUntil {sleep 5; _eucount isEqualTo 0 && _cucount isEqualTo 0};
			
{
	_fegroups pushBackUnique _x;
} forEach _egroups;

{
	_fcgroups pushBackUnique _x;
} forEach _cgroups;


};
  • Like 1

Share this post


Link to post
Share on other sites

okay, understood now. but why should that be better than spawning units at the time they r needed?

EDIT: U could say the advantage is that I ve not to cover waypoints, loadout and group things with the script. But that is work I want to do... The question is what is better for servers performance. and I think it should be spawning at needed time.

Edited by sarogahtyp

Share this post


Link to post
Share on other sites

I would say both methods would balance out (mostly), either way not spawned or hidden with all background proccesses ceased, the performance would be relatively similar I would think.

As far as waypoints go, I have a couple functions that may be of interest to you (save/add waypoints), I would post them, but it's extremely late, and they need a little sprucing up for the public eye :). Let me know if they interest you and I'll try and post them tomorrow. The current setup that I have for them just saves all the basic waypoint info, but there is a lot of possible info that could be saved and re-added for waypoints, and my functions are self-explainitory enough to be able to insert any additions you so desire.

  • Like 1

Share this post


Link to post
Share on other sites

I would say both methods would balance out (mostly), either way not spawned or hidden with all background proccesses ceased, the performance would be relatively similar I would think.

As far as waypoints go, I have a couple functions that may be of interest to you (save/add waypoints), I would post them, but it's extremely late, and they need a little sprucing up for the public eye :). Let me know if they interest you and I'll try and post them tomorrow. The current setup that I have for them just saves all the basic waypoint info, but there is a lot of possible info that could be saved and re-added for waypoints, and my functions are self-explainitory enough to be able to insert any additions you so desire.

 

I appreciate all info u ll give me :-) plz post what u have.

Share this post


Link to post
Share on other sites

Also make sure when you spawn  units back that you use some delay tricks to avoid large lag caused by multiple creations at once.

This is giving players a clue that ais spawn nearby.

  • Like 1

Share this post


Link to post
Share on other sites

This sounds great! looking forward to trying it out... Good point by davidoss regarding some type of delay or spacing, it's one big issue I have with eos and lagging badly every time a zone is activated.

Share this post


Link to post
Share on other sites

I appreciate all info u ll give me :-) plz post what u have.

Well, I completely blanked on doing this and just now remembered :P, here they are implementation should be simple enough (I hope), there are probably a few things overlooked because when I made this script I was really only looking at a single unit not an actual group of units, but I'm sure changes for handling that are simple enough as well. Further expansion, as I stated earlier, should be easy enough with the current layout (I do recommend not reordering the four waypoint properties that I've already got covered. There may also be a need to clean up any empty groups as to not reach the group cap, but again, I leave that for your experimentation :).

/* //////////////////////////////////////////////
Function Author: J.Shock
			   
Function: addWaypoints
Parameters: Waypoint information compiled from saveWaypoints function
Return: Array- [new group of unit,number of waypoints added back]

Example Call: [this,this getVariable "JSHK_savedWaypointArray"] call JSHK_fnc_addWaypoints;

*///////////////////////////////////////////////
JSHK_fnc_addWaypoints =
{
	params ["_WPinfo"];
	private ["_count","_unit","_newGrp"];

	_unit = (_WPinfo select 0);
	_newGrp = createGroup (side _unit);
	_count = count _WPinfo;

	for "_i" from 1 to (_count - 1) step 1 do
	{
		_tempWP = _newGrp addWaypoint [((_WPinfo select _i) select (_i - 1)),0];
		_tempWP setWaypointBehaviour ((_WPinfo select _i) select (_i - 1));
		_tempWP setWaypointSpeed ((_WPinfo select _i) select (_i - 1));
		_tempWP setWaypointType ((_WPinfo select _i) select (_i - 1));
	};

	[_unit] joinSilent _newGrp;

	[_newGrp,count waypoints _newGrp];
};

/* //////////////////////////////////////////////
Function Author: J.Shock
			   
Function: saveWaypoints
Parameters: Array- [[the unit,all waypoints of the unit],current waypoint of group]
Return: Array- [the unit,waypoint,waypoint,waypoint....]

Example Call: [[this,waypoints this], currentWaypoint this] JSHK_fnc_saveWaypoints;
*///////////////////////////////////////////////
JSHK_fnc_saveWaypoints =
{
	params ["_WPs","_current"];
	private ["_WParr"];
	
	_WPs params ["_unit","_waypoints"];
	_WParr = [_unit];
	{
		_tempArr = [];
		_tempArr pushBack (waypointPosition _x);
		_tempArr pushBack (waypointBehaviour _x);
		_tempArr pushBack (waypointSpeed _x);
		_tempArr pushBack (waypointType _x);
		_WParr pushBack _tempArr;
		false
	} count _waypoints;

	_WParr;//could easily add a setVariable on the unit here, to easily access in addWaypoints as well
};

Obviously the order in which you save them, you must add them back in that order, hopefully self-explanatory, let me know of any questions.

  • Like 1

Share this post


Link to post
Share on other sites

Progress bar:

 

Upto now I can delete and spawn waypoints, units and vehicles of specified groups with most informations available. After having some problems with syncing waypoints it works also now.

Now after the core of the project is working, Ill create the "interface" for the mission designer.

Upto now I ve a function which needs to be called in the init line of one member (unit or vehicle) of every group that should be deleted. This function does not collect any information but it marks the group leaders for later use with the scripts.

 

example init lines:

[this, 0] call saroSSC_fnc_mark;

the second parameter is an index to differentiate if you want delete and spawn different sets of groups at different times in ur mission.

so if u have 6 different groups where 2 groups should be deleted together at mission start and the other 4 groups later in the mission then u can use that index for it.

now u have marked the different sets of groups and u can save, delete and spawn em as follows:

[0] call saroSSC_fnc_save;
[0] call saroSSC_fnc_delete;
[0] call saroSSC_fnc_spawn;

the only paramter passed is the index described above. if u like to delete the stuff and save the information about it at the same time then u dont need to call saroSSC_fnc_save because all will be saved with saroSSC_fnc_delete if its not done before with the save function.

 

I think the "2. manual mode" described in my first post is done with those functions.

Do u think there r more functions needed to handle that mode compfortable? [FEEDBACK pls]

Idk but I think that mode is such simple to use do u think that a "1. trigger mode" is needed? [FEEDBACK pls]

 

The hardest part will be to create the last mode "3. script creation mode" I ll startin to work on it soon and I think about releasing the project before this part is done. Maybe soon.

 

Please tell me ur thoughts, suggestions and advises for this project. As more opinions I get from u as more user friendly the product will be...[FEEDBACK pls]

Share this post


Link to post
Share on other sites

Taking a look at BI's Scene functions maybe of use to you as it does a similar thing by using triggers to delete/spawn units/objects/vehicles etc, may hold some code that you can steal *cough re appropriate. See an explanation HERE.

  • Like 1

Share this post


Link to post
Share on other sites

Hey Sarogahtyp, this may be just what I need.

 

Please confirm I understand this correctly:  I can create AI groups with waypoints in Editor, and then put a call to your script to cache these units, and then reactivate them later with a trigger.  Correct?

 

I like this approach, as I like the visual editor for visualizing where all the AI is, what unit types and vehicles they are, etc. (rather than scripting all that using markers for group positions).  Plus I can add this in after I get the mission working (i.e., initially not cache, but do it later).

 

Is that right?

 

This would allow me to go back and clean up old missions that weren't caching units...

 

Thanks for this!

  • Like 1

Share this post


Link to post
Share on other sites

Hey Sarogahtyp, this may be just what I need.

 

Please confirm I understand this correctly:  I can create AI groups with waypoints in Editor, and then put a call to your script to cache these units, and then reactivate them later with a trigger.  Correct?

 

I like this approach, as I like the visual editor for visualizing where all the AI is, what unit types and vehicles they are, etc. (rather than scripting all that using markers for group positions).  Plus I can add this in after I get the mission working (i.e., initially not cache, but do it later).

 

Is that right?

 

This would allow me to go back and clean up old missions that weren't caching units...

 

Thanks for this!

 

thats exactly the sense of this project and I m happy that u think it could be usefull. I m not to far away from releasing it. the main work for this purpose is done. maybe I ll drop a download link for a pre-release version within the next days for testing.

  • Like 1

Share this post


Link to post
Share on other sites

Might make sense to store the unit's traits:

 

https://community.bistudio.com/wiki?title=Special%3ASearch&profile=default&search=setUnitTrait&fulltext=Search

 

Additionally, for vehicles it might make sense to store more information about the damage, eg. which parts was damaged how much.

Thx for that hint. Added it to my todo list. These r the Infos i need because I can't know all possible commands to store and set object informations.

Share this post


Link to post
Share on other sites

I decided to post and update my TODO-list here:

look at the end of first post for the regularly updated TODO list

I know that u guys dont really know what already is done but if someone has ideas for that TODO list or thinks I should change the priority of some things on it then just post it pls...

Edited by sarogahtyp
  • Like 2

Share this post


Link to post
Share on other sites

I decided to post and update my TODO-list here:

sorted by priority

 

 store and reset group informations like group name and side

drop download link for a PRE-ALPHA version

 store and resync synced triggers

 make vecs var name working in MP like did here

 store group of vehicle and add vehicle to related group (addVehicle)

add whole functionality for flying vehicles as everything works not for it upto now

open new topic and release ALPHA version

 store and reset units trait

 store and reset units hitparts

 store and reset vehicles hitparts

 store an reset vehicles loadout

 get killed EH for group leaders works to ensure group handling works after leader died

relase BETA version

 write function to destroy info arrays

 write function to unmark groups

write the whole thing for copying the spawn script to clipboard for use in mission designers own sqf

release FINAL version

I know that u guys dont really know what already is done but if someone has ideas for that TODO list or thinks I should change the priority of some things on it then just post it pls...

 

Looks good.

 

Not sure whether it's possible, but wouldn't it be important to also store the attached eventHandlers of  units? Maybe you've already done that.

  • Like 1

Share this post


Link to post
Share on other sites

@foxhound

I appreciate your work very much but this post is not a public release. Its just a PRE-ALPHA drop for the readers of this topic only:

 

(moved to first post)Sarogahtyps Spawn Script Creator 0.1 - PRE-ALPHA(moved to first post)

 

I dropped a working mission file and I would be happy if some of u guys would test the SSC script.

Its a 2D editor mission but I think it can be converted easily.

the scripts function implementation is done with function library in description.ext

everything a mission designer should do with SSC is done in the init lines of one group member for each group which should be handled and in initServer.sqf

 

howto setup the stuff in ur own mission:

 

1. use saroSSC_mark in init lines (or wherever u want) to mark the groups

2. use saroSSC_save wherever u like to save all stuff related to the marked groups

3. use saroSSC_delete wherever u like to delete all marked groups

4. use saroSSC_spawn wherever u like to spawn all the prior saved stuff

5. watch it working

 

scripts can be found here:

functions\sarogahtyp_SSC

 

each script which is thought for use by mission designer has a header with an example of usage.

 

the main things u should understand when u use SSC:

 

1. u can pass an index to each function. the index decides which set of groups will be manipulated by the function.

2. Only the groups u marked with the same index can interact each other by syncing there waypoints, let em get in vehicles and so on

3. u only need to use the mark function with one single unit or vehicle of each group.

Share this post


Link to post
Share on other sites

Looks good.

 

Not sure whether it's possible, but wouldn't it be important to also store the attached eventHandlers of  units? Maybe you've already done that.

 

good question - i will think about it.

 

EDIT: Idk a way to detect EHs and there executed code when they fire. I decided to implement the option to pass code to the spawn function which executes after spawning. That gives mission designers the ability to add the needed EHs.

Edited by sarogahtyp
  • Like 1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×