Page 1 of 1

Dynamic arrays-like algorithms for ACS?

Posted: Sun Sep 03, 2017 12:35 am
by Ravick
Hi there,

so, I was looking at the wiki about arrays (I'm kinda noob at using arrays...), it seems that dinamic arrays are only avaible to ZScript, not to ACS.
Well, lets say, in a ACS script, if you have a pool os possibilities and need to pick up just a few of them, how'd you do that?
For example, you have 10 monsters in a map, and need to ramdonly choose 3 to use in a script. If I could use dinamic arrays, I could make an array of size 10, randomize monster's numbers from 0-9, pick the monster with the corresponding index number; And then, decrease the array size to 9 and choose betwen 0-8 monsters; and so on.

How'd you do that (avoinding kludges just like having bool vars to all the 10 monsters)?

Maybe this question is ridiculously noobish, but, as I said, I'm kinda noob at this arrays-in-ACS thing anyway.

Thanks in adavced. :)

Re: Dynamic arrays... for ACS?

Posted: Sun Sep 03, 2017 12:39 am
by Graf Zahl
Global arrays are dynamic, you can use any index you like to address them and they automatically resize if needed.

Re: Dynamic arrays-like algorithms for ACS?

Posted: Sun Sep 03, 2017 1:43 am
by Ravick
Thanks, Graf! :)