Jump to content
Lucas Andreatta

Spawn ammo caches and marks

Recommended Posts

Hello, I am creating an insurgency mission, I already have the script to make the AI drop intel, but I need another one to make Spawn ammo caches and another one for when to get the intel, go creating marks with the distances from the Cache.

Intel script:

 

0 = [] spawn {
  if (isServer) then {
    while {true} do {
      {
        _unit = _x;
        if !(_unit getVariable ["hasIntelEVH",false]) then {
          _unit addEventHandler ["killed",{
            params ["_unit"];
            if (random 100 < ("droprate" call BIS_fnc_getParamValue) ) then {
              _suitcase = "Land_Suitcase_F" createVehicle (getpos _unit);
              [_suitcase,["Pick up INTEL", {params ["_suitcase","_caller","_id"]; hint "you have intel, clever one, you.";  [_suitcase,_id] remoteExec ["removeAction"]; deleteVehicle _suitcase } ] ]  remoteExec ["addAction",0,_suitcase];
            };
          }];
          _unit setVariable ["hasIntelEVH",true];
        };
      } forEach (allUnits select {side _x == EAST});
      sleep 10;  
    };
  };
};

 

Share this post


Link to post
Share on other sites

ammo caches are also vehicles, like "Box_FIA_Support_F" class, so use the same createVehicle on the same event or something else.

You have to choose a position and we can't do that for you. random places around killed units? or on existing markers that you just have to make them visible?)... so many things are possible.

 

 

Share this post


Link to post
Share on other sites

It could be inside an ellipse marker, but as it takes the intel, it has to be approaching the possible location of the cache. The goal is to stay dynamic to the point where the creator of the mission has no idea where the cache might be.

Share this post


Link to post
Share on other sites

Could you translate that in action/event terms, like:

- when an enemy unit is killed, the enemy unit drop an intel case (done)

- then spawn a cache, where? I don't understand the "approaching the possible location" in this case....

Share this post


Link to post
Share on other sites

For example, takes 10 (ten) intels, marks on the map an ellipse with the cache position of 400x400. Grab another 10 intels, the ellipse turns from 300x300 and so on until you get 50x50 or smaller.

Share this post


Link to post
Share on other sites

You can do all that from inside the addAction.

When one intel found, use setvariable and getvariable to check if the caller has any intel, if he has none, set the value to 1 since he found the first one.

Then increase the value with every intel he finds. When the value is bigger than 10 use createMarker.

 

Commands are all on the wiki.

 

Cheers

Share this post


Link to post
Share on other sites

Better use 

 

addMissionEventHandler ["EntityKilled", { //your code }];

than looping eveny 10 seconds for every unit on map.

Share this post


Link to post
Share on other sites
24 minutes ago, M1ke_SK said:

Better use 

 


addMissionEventHandler ["EntityKilled", { //your code }];

than looping eveny 10 seconds for every unit on map.

 

 

 

 

 

 

 

In case of a Mission eventhandler you don't have to loop it everytime, or am I mistaken?

Share this post


Link to post
Share on other sites
10 hours ago, crewt said:

In case of a Mission eventhandler you don't have to loop it everytime, or am I mistaken?

 

You dont need loop with mission eventhandler

  • Like 1

Share this post


Link to post
Share on other sites
27 minutes ago, M1ke_SK said:

 

You dont need loop with mission eventhandler

Yep!

I didn't remarked this MEH. Sure, it's easier than looping for adding an EH on each new spawned unit! I have to change for that in a bunch of my scripts...

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

Yep!

I didn't remarked this MEH. Sure, it's easier than looping for adding an EH on each new spawned unit! I have to change for that in a bunch of my scripts...

 

Make sure you wrap it in if(isServer) { ... } condition, to run it only by server.

Share this post


Link to post
Share on other sites
2 minutes ago, M1ke_SK said:

 

Make sure you wrap it in if(isServer) { ... } condition, to run it only by server.

What about HCs? I mean if some Ais are managed by headless client, so, should we wrap in something like:

 

if (isServer or ! hasInterface) then {

... MEH [ <code with if  (local _x) then { do something with _x} ]

}

(I added local just in case but useless?)

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

What about HCs? I mean if some Ais are managed by headless client, so, should we wrap in something like:

 

if (isServer or ! hasInterface) then {

... MEH [ <code with if  (local _x) then { do something with _x} ]

}

(I added local just in case but useless?)


with headless client you can use these

if (!hasInterface) then 
{ 
	//run on headless clients and dedicated server 
}; 

if (!hasInterface && !isDedicated) then 
{ 
	//run on headless clients only 
};

 

Share this post


Link to post
Share on other sites
0 = [] spawn {
  if (isServer) then {
    while {true} do {
      {
        _unit = _x;
        if !(_unit getVariable ["hasIntelEVH",false]) then {
          _unit addEventHandler ["killed",{
            params ["_unit"];
            if (random 100 < ("droprate" call BIS_fnc_getParamValue) ) then {
              _suitcase = "Land_Suitcase_F" createVehicle (getpos _unit);
              [_suitcase,["Pick up INTEL", {params ["_suitcase","_caller","_id"]; hint "you have intel, clever one, you.";  [_suitcase,_id] remoteExec ["removeAction"]; deleteVehicle _suitcase } ] ]  remoteExec ["addAction",0,_suitcase];
            };
          }];
          _unit setVariable ["hasIntelEVH",true];
        };
      } forEach (allUnits select {side _x == EAST});
      sleep 10;  
    };
  };
};

the drop intel script, how i do?

Share this post


Link to post
Share on other sites
4 hours ago, M1ke_SK said:


with headless client you can use these


if (!hasInterface) then 
{ 
	//run on headless clients and dedicated server 
}; 

if (!hasInterface && !isDedicated) then 
{ 
	//run on headless clients only 
};

 

So, I should precise I'm scripting for the Ai units, regarless of player(s),  so  the (isServer or ! hasInterface) seems to me the good option:

SP isServer  , all units are on server , OK

MP hosted/dedicated,  isServer allows the access of all units on server,

Furthermore, if any units on HCs (so obviously not on server) ! hasInterface is working.

 

My question was more about the locality of some AI units when a PC has an HC. I guess Ai units spawned on HC are owned by HC. So, i missed something or some MP scripts should have some lines about HCs. Not so often read about that.

Share this post


Link to post
Share on other sites
2 minutes ago, Lucas Andreatta said:

alive is better

No, just heavier for what you intend to do.

Share this post


Link to post
Share on other sites

But does bis_fnc_spawnGroup dynamically respawn AI?

How does the spawn cache and markup script work?

Share this post


Link to post
Share on other sites
On 28.5.2017 at 4:51 PM, Lucas Andreatta said:

Can someone CREATE this script for me?

This forum is about mission editing and scripting.

Try to ask there.

 

Cheers

  • Like 1

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

×