Jump to content
anaximandross

How to spawn in a custom composition with a script?

Recommended Posts

I am creating a small game mode, and I was wondering how to spawn in a custom composition?


I created an array of various city names around Altis, and once a city is randomly selected, i need to spawn in a composition that I will create in the editor, based on which city is selected.


 


I can post my code for what I have so far if I need to. 


 


Thanks!


 


EDIT: Just for clarification, these compositions will be spawned in in the exact same location they were created, so that may help a little. 


Share this post


Link to post
Share on other sites

So I have close to 70 compositions that are going to be spawned in when this script is activated to add them to the mission. At this point in time, I have my base mission, and then each composition is on a separate mission.sqm file. Would it be possible to use the eden editor compositions with a .sqe file, as there are saved in? 

Share this post


Link to post
Share on other sites

 

I am creating a small game mode, and I was wondering how to spawn in a custom composition?

 

You can handle "Killed" or "Respawn" events and move respawned unit to necessary position. Also you can look at code of RespawnDialog in any CTI mission.

 

For example, respawn code from BECTI:

CTI_UI_Respawn_OnRespawnReady = {
	_where = uiNamespace getVariable "cti_dialog_ui_respawnmenu_respawnat";

	_respawn_ai = false;
	_respawn_ai_gear = [];
	if (_where isKindOf "Man") then { //--- The location is an AI?
		if (_where in units player) then { //--- The AI is in the player group?
			_pos = getPos _where; //--- Get the AI position (todo: copy the stance)
			_respawn_ai_gear = (_where) call CTI_UI_Gear_GetUnitEquipment; //--- Get the AI current equipment using the Gear UI function
			deleteVehicle _where; //--- Remove the AI
			player setPos _pos; //--- Place the player where the AI was
			_respawn_ai = true;
		};
	};

	if !(_respawn_ai) then { //--- Stock respawn
		_spawn_at = [_where, 8, 30] call CTI_CO_FNC_GetRandomPosition;
		player setPos _spawn_at;
	};

	titleCut["","BLACK IN",1];

	closeDialog 0;

	if !(isNil "CTI_DeathCamera") then {
		CTI_DeathCamera cameraEffect ["TERMINATE", "BACK"];
		camDestroy CTI_DeathCamera;
	};

	if !(_respawn_ai) then { //--- Stock respawn
		[player, missionNamespace getVariable format ["CTI_AI_%1_DEFAULT_GEAR", CTI_P_SideJoined]] call CTI_CO_FNC_EquipUnit; //--- Equip the default equipment
	} else { //--- Respawn in own AI
		[player, _respawn_ai_gear] call CTI_CO_FNC_EquipUnit; //--- Equip the equipment of the AI on the player
	};

	if ((missionNamespace getVariable "CTI_UNITS_FATIGUE") == 0) then {player enableFatigue false}; //--- Disable the unit's fatigue
	CTI_P_Respawning = false;
};

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

×