Joe98 92 Posted September 5, 2019 I place myself on the map and arrange it so I start at one of 30 places at random. I place 2 enemy soldiers on the map. They are named red1 and red2 I want the 2 enemy soldiers to start the mission about 200 meters to my north. When the mission starts a script runs and places the 2 soldiers 200 meters to my north as planned. However I want red2 to appear sometimes and not other times. I means I never know how many enemy there are. So, in the init of red2 I set it so that he appears only 50% of the time Now, from time to time red2 is deleted. It means the script above stops with an error message: "object red2 does not exist" or words to that effect. In the meantime if I wish to delete red2 in a script, I can use: deletevehicle red2 So, I am looking for a command along the lines of: deletevehicle red 2 and do so at random. What is the command for this? . Share this post Link to post Share on other sites
wogz187 1086 Posted September 5, 2019 I'm not sure I understood the request exactly but you could try, In the init file put, red1=objNull; Then something like, random=[0,1] BIS_fnc_selectRandom; If (red1 !=objNULL && random ==1) then {deletevehicle red1;}; Have fun! 2 Share this post Link to post Share on other sites
ZaellixA 383 Posted September 5, 2019 Yep, wogz187's script seems about right, or you could actually do it the other way around (depending on the structure of your other scripts and calls)..., that is instead of deleting red2 at random, create red2 at random, with pretty much the same effect. 2 Share this post Link to post Share on other sites
Dedmen 2716 Posted September 6, 2019 19 hours ago, wogz187 said: random=[0,1] BIS_fnc_selectRandom; That has been replaced by the engine command https://community.bistudio.com/wiki/selectRandom 3 Share this post Link to post Share on other sites
killzone_kid 1333 Posted September 6, 2019 20 hours ago, wogz187 said: Then something like, random=[0,1] BIS_fnc_selectRandom nothing will happen unless you call it first 2 Share this post Link to post Share on other sites
engima 328 Posted September 6, 2019 if (random 100 < 75) then { // With a chance of 75% deleteVehicle red2; }; 1 Share this post Link to post Share on other sites
Von Quest 1163 Posted September 6, 2019 If using the Editor, just set the unit to 50% probably in the probability setting. Just double-click to open the settings. No need to script. 1 Share this post Link to post Share on other sites
engima 328 Posted September 6, 2019 3 minutes ago, Von Quest said: If using the Editor, just set the unit to 50% probably in the probability setting. Just double-check to open the settings. No need to script. It seems like he knows that, and actually is looking for a way to do it in a script also. Reason unknown though. I need to add that you can check the existance of a variable (or unit) with isNil: if (!isNil ”red2”) then { // red2 exists and handling it here will not generate script errors. }; 2 Share this post Link to post Share on other sites
wogz187 1086 Posted September 6, 2019 5 hours ago, Dedmen said: That has been replaced by the engine command https://community.bistudio.com/wiki/selectRandom Yeah, George said you'd make fun of me for using that. He's either super-smart or you're very predictable. 😄 I guess it doesn't have to be either or. 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted September 6, 2019 9 hours ago, wogz187 said: I guess it doesn't have to be either or. 1 Share this post Link to post Share on other sites
wogz187 1086 Posted September 7, 2019 @everybody, Let's be honest though, if I forget to type "call", I probably should stick to the selectRandom method. Thanks, Dedmen. 2 Share this post Link to post Share on other sites
Joe98 92 Posted September 7, 2019 15 hours ago, engima said: if (random 100 < 75) then { // With a chance of 75% deleteVehicle red2; }; Thank you to enigma. This is what I was looking for. I wrote it like this: if (random 100 < 50) then {deleteVehicle red2 }; // Giving a chance of 50% of being deleted 3 Share this post Link to post Share on other sites
killzone_kid 1333 Posted September 7, 2019 deleteVehicle selectRandom [objNull, red2] will also give you 50/50 chance. Or call selectRandom [{}, {deleteVehicle red2}] 4 Share this post Link to post Share on other sites