Add ship to Sob Group in the .lua file of campaign

Hello,

In my mission i need to add one ship as been built on the new sobgroup newly created … But i haven’t found the SobGroup_ function make this possible … :confused:

I need to add all ship goa_teltak on the sobgroup named : sg_teltak …

Anyone can help me ? :stuck_out_tongue:

SobGroup_SobGroupAdd(a,b) takes B and adds it to A. here’s a snippet of code from my own efforts:

–We do this because Create makes the ship in the target group, it doesn’t add it do it
–it returns a ‘runtime sobgroup’ that contains it, so we take that return value and add it back
SobGroup_SobGroupAdd(sup_a,SobGroup_CreateShip(sup_a,gn_scout))

It’s strange, it doesn’t work… Here’s the code with your function:

function Rule_BuildTeltak()
 g_playerID = 0
 if (Stats_ShipsCreated( g_playerID, GetShipId( "goa_teltak" ) ) >= 1) then
  SobGroup_SobGroupAdd("sg_teltak1",SobGroup_CreateShip("sg_teltak1","goa_teltak"))
  Objective_SetState( g_obj_build_teltak_id , OS_Complete)
  Rule_Remove("Rule_BuildTeltak")
  Rule_Add("Rule_Coordinate")
 end
end

I want to verify that the player has made a Tel’tak and that, once it’s done, this one is placed in the sg_teltak. The point is that I never seen any function that works like that.
And I’d like to do another thing as well: All constructed Tel’taks (during this game) will be added in this sobgroup, but how? Any idea?

Well, that particular snippet was meant as an example of use of SobGroup_SobGroupAdd, not a full solution to your problem. It spawns an entirely new ship and puts it in an existing group, your needs are slightly different.

So, we have no solution to place 1 ship has been build by the player to one sobgroup (in the full party).

It’s a shame.

If we have no solution, the dev need to add functionality : Create one sobgroup for each type of ship.

For example : At the begining of game :
SobGroup_Create(“sg_hgn_interceptor”)

And all Interceptor built by player (for player /me out) adding automatically to this sg.

For now, if i understand, we can’t make this, the only solution is to spawn new ship to the player, and we can’t use the ship built by the player ?

We need to think more on this subject …

PS : For this post : I need this, to know if the player ship “Goa_teltak” is on one Volume (Nebula) with the SobGroup_AreAnySquadronsInsideNebula, so i need absolutely the Sobgroup to make this possible ! :stuck_out_tongue:

Other idea :

http://hw2bsg.org/wiki.hw2.info/FunctionPlayer_FillShipsByType.html

Can use this ?

Player_FillShipsByType("sg_teltak", 0, "goa_teltak")

I found the equivalent in the Campaign files in the game. At the end of Mission, all ship (for example : Hgn_Interceptor) go dock instant. But for this manipulation, SobGroup is needed :stuck_out_tongue: And the dev use the Player_FillShipsByType to place all ship in one sobgroup …

But, did I well understand ?

Bad idea. The game won’t accept this function in my own script.

I make this :
First, i need to know if the player built this fu***** teltak.
Second, if teltak is built, i place all ship on this aera or i use the Player_FillShipByType(“sg_teltak”,0, “goa_teltak”).

This part generate error. But the sobgroup is not empty (i force the game to check this before go other step). With my next step i would know if this sobgroup have one ship in the nebula. If this function return true, the pointer > Removed.
But, nothing happened.

So, i need to restart this part …

The full part :

    function Rule_BuildTeltak()
	if (Event_IsDone("BuildTeltak")) then
		Rule_Add("StateBuildTeltak")
		Rule_Remove("Rule_BuildTeltak")
	end
end

function StateBuildTeltak()
	SobGroup_Create("sg_teltak")
		if (Stats_ShipsCreated( g_playerID , GetShipId("goa_teltak") ) == 1) then
			-- Player_FillShipsByType("sg_teltak", 0, "goa_teltak" )
			Player_FillSobGroupInVolume("sg_teltak", 0, "vol_player_0")
			Rule_Add("BuildTEST")
			Rule_Remove("StateBuildTeltak")
		end
end

function BuildTEST()

			if (SobGroup_Empty("sg_teltak") == 0) then 
				Objective_SetState( g_obj_build_teltak_id , OS_Complete)
				print("Yo man, tu a build le bon vaisseau !")
				Rule_Remove("BuildTEST")
				Rule_Add("Rule_Coordinate")
				Rule_Add("GetMoreRU")
			end

end

function GetMoreRU()
	if (Player_GetRU(0) >= 5500) then 
		Objective_SetState( g_obj_harvest_sec_id , OS_Complete)
		Rule_Remove("GetMoreRU")
	end
end

function Rule_Coordinate()
	Event_Start("coordinate")
	Rule_Add("AddingPointer")
	Rule_Remove("Rule_Coordinate")
end

function AddingPointer()
	tVol_1 = {5000, -10000, 10000}
	Volume_AddSphere("vol_obj_coord", {tVol_1[1], tVol_1[2], tVol_1[3],}, 2500)
	EventPointer_AddVolume("vol_obj_coord", HW2_rgb(230,0,0), 800)
	Rule_Add("Check_DWhithPointer")
end

function Check_DWhithPointer()
		if (SobGroup_AreAnySquadronsInsideNebula("sg_teltak", "Neb_coord") == 1) then 
				Objective_SetState( g_obj_send_teltak_id, OS_Complete )
				print("On the Nebula.")
				EventPointer_Remove("vol_obj_coord") -- remove the pointer - ok
				Rule_Remove("Check_DWhithPointer")
				Rule_AddInterval("Rule_END", 3)
		end
end

Any idea ? Other ways possible ? (The player absolutely need to build this teltak ^^)