Lucas Andreatta 1 Posted May 23, 2017 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
pierremgi 4738 Posted May 24, 2017 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
Lucas Andreatta 1 Posted May 24, 2017 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
pierremgi 4738 Posted May 24, 2017 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
Lucas Andreatta 1 Posted May 25, 2017 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
Lucas Andreatta 1 Posted May 25, 2017 In case the cache will spawn randomly in that area I mentioned above. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted May 25, 2017 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
M1ke_SK 230 Posted May 25, 2017 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
crewt 31 Posted May 25, 2017 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
M1ke_SK 230 Posted May 25, 2017 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 1 Share this post Link to post Share on other sites
pierremgi 4738 Posted May 25, 2017 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
M1ke_SK 230 Posted May 25, 2017 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
pierremgi 4738 Posted May 25, 2017 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
M1ke_SK 230 Posted May 25, 2017 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
Lucas Andreatta 1 Posted May 25, 2017 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
pierremgi 4738 Posted May 26, 2017 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
Lucas Andreatta 1 Posted May 26, 2017 I'm going to use alive module systems to spawn AI Share this post Link to post Share on other sites
pierremgi 4738 Posted May 26, 2017 1 hour ago, Lucas Andreatta said: I'm going to use alive module systems to spawn AI Or just the bis_fnc_spawnGroup. Share this post Link to post Share on other sites
Lucas Andreatta 1 Posted May 26, 2017 alive is better Share this post Link to post Share on other sites
pierremgi 4738 Posted May 26, 2017 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
Lucas Andreatta 1 Posted May 26, 2017 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
Lucas Andreatta 1 Posted May 28, 2017 Can someone CREATE this script for me? Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted June 2, 2017 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 1 Share this post Link to post Share on other sites