Bingo-66d21d294c551e45 1 Posted November 22, 2022 I'm trying to select a random soldier to kill. Once this soldier has been killed I'd like to remove his value from my array "_zones". I'm finding it difficult to do so. My current code is - _zones = [B1, B2, B3, B4]; selectRandom _zones; _zones setdamage 1; _zones deleteAt (_zones find _zones); Share this post Link to post Share on other sites
pierremgi 4833 Posted November 23, 2022 selectRandom _zones should return an element (a unit), then you can damage it. so, in your code, _zones setDamage 1 has not sense. You can't inflict damages on array, only element(s) of its. Follow the syntax of deleteAt (example 1) private _zones = [B1, B2, B3, B4]; // array of units I guess private _chosenUnit = _zones deleteAt floor random count _zones; _chosenUnit setDamage 1; NB: now _zones is equal to former _zones less the _chosenUnit in a loop: private _zones = [B1, B2, B3, B4]; private "_chosenUnit"; for "_i" from 0 to count _zones -1 do { _chosenUnit = _zones deleteAt floor random count _zones; _chosenUnit setDamage 1; }; Of course it's just an example, pointing at the array resizing, then the randomization excluding already chosen elements. 1 Share this post Link to post Share on other sites
Bingo-66d21d294c551e45 1 Posted November 25, 2022 On 11/23/2022 at 7:00 AM, pierremgi said: selectRandom _zones should return an element (a unit), then you can damage it. so, in your code, _zones setDamage 1 has not sense. You can't inflict damages on array, only element(s) of its. Follow the syntax of deleteAt (example 1) private _zones = [B1, B2, B3, B4]; // array of units I guess private _chosenUnit = _zones deleteAt floor random count _zones; _chosenUnit setDamage 1; NB: now _zones is equal to former _zones less the _chosenUnit in a loop: private _zones = [B1, B2, B3, B4]; private "_chosenUnit"; for "_i" from 0 to count _zones -1 do { _chosenUnit = _zones deleteAt floor random count _zones; _chosenUnit setDamage 1; }; Of course it's just an example, pointing at the array resizing, then the randomization excluding already chosen elements. I don't know how you do it mate. Absolute legend. Worked like a charm Share this post Link to post Share on other sites