Jump to content
target_practice

Setting certain objects to only be present if another object is present?

Recommended Posts

I'm trying to make an occupied campsite that has a random chance to spawn.

I know that I can use the probability slider to set this, but that applies for each individual object.

I was wondering if it would be possible to have only one object in the camp have a probability of presence, and have all other objects set to only spawn if that object does.

Is there also better way of doing this?

Share this post


Link to post
Share on other sites

Use a variable in the init of the object that has % presence set.

Ex. Objspawn=true

Then in the init of the other objects check if Objspawn is true. If not the use "this deletevehicle" in the init of the other objects.

Can't test but I'm sure if the % presence does not spawn unit the init does not fire.

  • Like 1

Share this post


Link to post
Share on other sites

The secret to using the Arma 2 or Arma 3 editor is to test, test and test.

 

Place a soldier on the map. 

 

In front of the soldier place a box on the map and name it  box1.

 

Start the mission to test whether the box is there.

 

Set the box probability of presence to 20%.  Start the mission lots of times and note the box appears sometimes and not other times.

 

Place a second box on the map and name it  box2.

 

Start the mission to check that box2 appears.

 

In box2 in the field named  "condition of presence"  remove the word "true"  and replace it with    alive box1;

 

Start the mission lots of times.  When box1 appears, box2 will also appear.  If box1 does not appear, box2 will not appear.

.

  • Like 1

Share this post


Link to post
Share on other sites

try this:

 

in the init of th object that randomly spawns in due to presence slider put this in the init

missionnamespace setvariable ["RandonSpawn1",true];

The in the other object put this

if (isnil {missionnamespace getvariable "RandonSpawn1"} ) then {deletevehicle this};

If too many object to manually add in code then there is another option using a game logic and a for each loop referring to syncedobjects - i will have to hunt out the code.

 

refer attached rar file - mission in VR map (google drive) - i used to test this out.....

hope it helps. 

let me know how you get on.

 

if you have other random spawn objects you can change the name that is in the original object and then refer to it in the other objects by that name.

  • Like 1

Share this post


Link to post
Share on other sites

Are things like 'Objspawn' and 'missionnamespace' actual functions or are they just defined variables and arguments?

Share this post


Link to post
Share on other sites

Are things like 'Objspawn' and 'missionnamespace' actual functions or are they just defined variables and arguments?

 

objSpawn is a variable

missionNameSpace is an area where the variables are stored while the mission is running.

 

based on my testing the second option posted works well, the first was a brainstorm that was unfortunately not well thought out - thinking either too early or lack of coffee.... ;-)

 

looking back now Joe98 also has an idea that will end up with the same result.

ArmA - 1001 ways to do the same thing.

Share this post


Link to post
Share on other sites

try this:

 

in the init of th object that randomly spawns in due to presence slider put this in the init

missionnamespace setvariable ["RandonSpawn1",true];

The in the other object put this

if (isnil {missionnamespace getvariable "RandonSpawn1"} ) then {deletevehicle this};

If too many object to manually add in code then there is another option using a game logic and a for each loop referring to syncedobjects - i will have to hunt out the code.

 

refer attached rar file - mission in VR map (google drive) - i used to test this out.....

hope it helps. 

let me know how you get on.

 

if you have other random spawn objects you can change the name that is in the original object and then refer to it in the other objects by that name.

 

if that is working depends on the order the init lines of both objects are processed.

if ur random objects init line is processed after the init line of the other object then the variable Randonspawn1 is nil and the second object is deleted always.

to avoid that I suggest to use a script which u execute in the second units init line:

 

check_spawn.sqf - should created in missions root folder

params ["_unit"]; // the object passed to this script

if (isServer) then  //do it on server only
{
 waitUntil { sleep 1; BIS_fnc_init}; //waits until init lines are processed
 if (isNil {missionnamespace getVariable "RandonSpawn1"} ) then {deleteVehicle _unit};
};

the init line of ur random object should look like Kev said:

missionnamespace setVariable ["RandonSpawn1",true];

the second objects init line should look like this:

nul=this execVM "check_spawn.sqf";

Share this post


Link to post
Share on other sites
waitUntil { sleep 1; BIS_fnc_init};

i am not sure if that is correct synax to achieve

//waits until init lines are processed

 

Share this post


Link to post
Share on other sites
waitUntil { sleep 1; BIS_fnc_init};

i am not sure if that is correct synax to achieve

 

what could be wrong?

 

Edit: BIS_fnc_init I got from here:

https://community.bistudio.com/wiki/Initialization_Order

 

do u think it could be Nil until its set true by engine?

Edited by sarogahtyp

Share this post


Link to post
Share on other sites

The secret to using the Arma 2 or Arma 3 editor is to test, test and test.

 

Place a soldier on the map. 

 

In front of the soldier place a box on the map and name it  box1.

 

Start the mission to test whether the box is there.

 

Set the box probability of presence to 20%.  Start the mission lots of times and note the box appears sometimes and not other times.

 

Place a second box on the map and name it  box2.

 

Start the mission to check that box2 appears.

 

In box2 in the field named  "condition of presence"  remove the word "true"  and replace it with    alive box1;

 

Start the mission lots of times.  When box1 appears, box2 will also appear.  If box1 does not appear, box2 will not appear.

.

 

 

try this:

 

in the init of th object that randomly spawns in due to presence slider put this in the init

missionnamespace setvariable ["RandonSpawn1",true];

The in the other object put this

if (isnil {missionnamespace getvariable "RandonSpawn1"} ) then {deletevehicle this};

If too many object to manually add in code then there is another option using a game logic and a for each loop referring to syncedobjects - i will have to hunt out the code.

 

refer attached rar file - mission in VR map (google drive) - i used to test this out.....

hope it helps. 

let me know how you get on.

 

if you have other random spawn objects you can change the name that is in the original object and then refer to it in the other objects by that name.

Both these methods work for me, but is there any particular advantage to using the more complex variable method?

Also, if the variable method is used, is it a good idea to have it serverside only as sarogahtyp suggests?

Share this post


Link to post
Share on other sites

my variant ensures that the commands r processed in the correct order always.

as i said above if the other variant works is depending from the order in which the engine processes the init lines...

Share this post


Link to post
Share on other sites

The secret to using the Arma 2 or Arma 3 editor is to test, test and test.

 

Place a soldier on the map. 

 

In front of the soldier place a box on the map and name it  box1.

 

Start the mission to test whether the box is there.

 

Set the box probability of presence to 20%.  Start the mission lots of times and note the box appears sometimes and not other times.

 

Place a second box on the map and name it  box2.

 

Start the mission to check that box2 appears.

 

In box2 in the field named  "condition of presence"  remove the word "true"  and replace it with    alive box1;

 

Start the mission lots of times.  When box1 appears, box2 will also appear.  If box1 does not appear, box2 will not appear.

.

i ve first not read that solution carefully. if u ask me, thats the easiest way and the easiest way is mostly the best...

my solution was thought to correct a problem wit KevsNoTrevs solution

Share this post


Link to post
Share on other sites

This seems quiet familiar with what i am Dealing at the moment so i will post my problem here.

 

So i want to do a simple MP mission which starts in two WY-55 Helllcat's. The thing is i want that the Hellcats only spawn when a Player is sloted in the right Slot like as troope Leader.

So i placed a two Hellcat's in the Air at the entrance point. I am doing that in Eden so if there is a better way tell me.

 

Variable names of the Hellcat's: "Hellcat_1" and "Hellcat_2"

Variable names of the Troop Leader: "troop_leader_1"

 

now i want to set the vehicle existance condition let's use "Hellcat_1" for this

possibillity is set on 100%

condition for existance

alive troop_leader_1

it could be that i have to execute this over an trigger in the eden editor i tried a lot of thing yeasterday over 6 hours bot nothing seemed to work

 

I even tried to use the init from "troop_leader_1" with that kind of code in it:

Hellcat_1 = true

but this seemed only to work with a placed module.

 

 

Maybe you can help me out here it seems it is not complete wrong but also not right. :)

Share this post


Link to post
Share on other sites

This seems quiet familiar with what i am Dealing at the moment so i will post my problem here.

 

So i want to do a simple MP mission which starts in two WY-55 Helllcat's. The thing is i want that the Hellcats only spawn when a Player is sloted in the right Slot like as troope Leader.

 

 

It's a little confusing about what you're trying to do.  What players are there and how are they supposed to start?  It sounds like you want to start the mission with a Hellcat air insertion, but only if someone is as Squad Leader?  What is supposed to happen if no one is Squad Leader?

Share this post


Link to post
Share on other sites
So i want to do a simple MP mission which starts in two WY-55 Helllcat's. The thing is i want that the Hellcats only spawn when a Player is sloted in the right Slot like as troope Leader.

You could spawn the heli from the leaders init..

if ( isPlayer this ) then {
    [getMarkerPos "Hellcat_1_spawn",markerDir "Hellcat_1_spawn", "I_Heli_Light_03_F", independent] call BIS_fnc_spawnVehicle;
};

So if this unit is a player it spawns a hellcat flying a the marker position Hellcat_1_spawn fully crewed.

Share this post


Link to post
Share on other sites

Well okay... I will do it with Pictures to show what i meant to do over the Eden Editor.

 

First i wanted to set an Condition of Presence lets use the idea i got out of larrow:

 

pgqLM.png

 

The vehicle is boarded with playable units under it the -> Leader_mission <-

 

pgqPu.png

 

Now i thought this could maybe work. But now the vehicle does not change to true as soon as Leader_Mission is spawned or in this case alive.

I thought this would work but it seems this is only possible while the Mission initializes itself.

 

I wanted to do it like this because it would make sense to me i even tried it over a trigger but this seems only to work with moduls.

Any ideas how to realize this. And hopefully this brings you near to that what i want to do.

 

If you still not understanding it please tell it to me and be clear over the points what you don't understand that i can provide you the information

 

 

@kylania

 

 

What players are there and how are they supposed to start?  It sounds like you want to start the mission with a Hellcat air insertion, but only if someone is as Squad Leader?

 

Yup you got it. This is supposed to be a roleplay mission so don't worry about the other Players onboard of the Hellcat they will be sloted in the right places if i need 2 Hellcats if not i will place them into the right Hellcat.

 

Think about a Mission with two Squad leaders and their Teams if there is only 1 Team Full only 1 Hellcat shall spawn if 2 Teams are present 2 Hellcats shall spawn

 

 

What is supposed to happen if no one is Squad Leader?

 

If there is no Squad Leader the Hellcat shall either not spawn or be deleted whatever the best solution for my problem is.

Share this post


Link to post
Share on other sites

There is always more than one path up the mountain.  I detailed my approach to this same problem in this thread.

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

×