CptBBQ 10 Posted June 25, 2011 Hi all! I´m currently planing a simple ambient civilian script and I´d like to get some additional input before I get started. First up, I know there´s already a module built in for this purpose but that doesn't work for me perfectly in some aspects. Also, this is meant as a little scripting practice for myself. Anyway, I´m aiming for a straightforward approach without sacrificing too much resources to the feature. Also, I don´t want it to eat up my 144 groups limit, so I cannot use waypoints. The problem I see is, how would I keep track of each single unit, to issue them a new move order, as soon as the previous order is completed. Or in other words, what would be the most efficient way to check the distance to an individual target position for about 100 units? I came up with two simple concepts, but I´ve got no idea which one would be more efficient - or whether any of them is actually any good... Trigger method - create 1 trigger per unit - order unit to move towards trigger - unit reaches trigger - script is fired that places the trigger on a new random position - goto step 2 'Loop' method - store all civ units in unitArray - store individual target positions with setVariable "inside" each civ unit - iterate through unitArray, checking distance to target for each unit - if distance is smaller than x a new target position is chosen - goto step 2 Which method would you go with? Do you have an idea for a different approach? Any input is appreciated. Cheers, CptBBQ Share this post Link to post Share on other sites
Charles Darwin 10 Posted June 25, 2011 What aspect of the alice module doesn't work I ask to get a better idea of what you want Share this post Link to post Share on other sites
CptBBQ 10 Posted June 25, 2011 Well, maybe I´m doing it wrong, but mostly I have problems with vehicles. Parked vehicles spawn on the weirdest positions, ignoring editor placed objects. And it seems to be impossible to get a decent moving traffic using alice. Also, I heard there are some MP issues which I´d like to avoid. I was hoping to be able to use my script for pedestrians as well as civs in vehicles and in houses, mostly on a dedicated server. Share this post Link to post Share on other sites
Charles Darwin 10 Posted June 25, 2011 For pedestrians I would use alice for vehicles I would use method 1 you might look into some civilian traffic scripts on armaholic never used them but might be what your looking for Share this post Link to post Share on other sites
CptBBQ 10 Posted June 25, 2011 So, you´d say having something like 40 triggers active for this purpose wouldn´t be too bad for the performance? I´m actually hoping triggers are the way to go, but I don´t know how badly their resource demand adds up when used in those numbers. Share this post Link to post Share on other sites
demonized 20 Posted June 25, 2011 i would use seperate scripts with waitUntil commands, wich is basically the same as a trigger waiting to activate, but difference is that you can make the waitUntil check only so and so seconds, opposite of the trigger who checks many times a second. [url="http://community.bistudio.com/wiki/waitUntil"]waitUntil [/url]{sleep 2; (_car1 distance _somePosition) < 10};[/Code]that will make the waituntil 20- 60 times more resource friendly than a trigger, add that 100 times and you see where you save.but again, 50 triggers doing distance checks will not impact alot, though in a full mission with alot of scripts and stuff you will notice it. Share this post Link to post Share on other sites
Muzzleflash 111 Posted June 25, 2011 (edited) [url="http://community.bistudio.com/wiki/waitUntil"]waitUntil [/url]{sleep 2; (_car1 distance _somePosition) < 10};[/Code]that will make the waituntil 20- 60 times more resource friendly than a trigger, add that 100 times and you see where you save.No it will only make it 4 times more performance friendly than a trigger. A trigger only checks twice per second.However, triggers might not be the best way. Sometimes move orders get lost or civilians die or the ai does something else unintentional. You might need to check if the ai has lost it's move order somehow. You cannot do this by a simple: civilian in thisList condition. You will probably be better of using on large single script running or 1 script for each civilian. Running 50 scripts in parallel will not be a problem, especially not if you include some sleeps.EDIT:Oh and by using triggers you will need to use global variables in every trigger. Edited June 25, 2011 by Muzzleflash Share this post Link to post Share on other sites
CptBBQ 10 Posted June 26, 2011 Wow, I really feel enlightened now =) Thanks for all the infos. I actually feared 50 parallel scripts could be problematic, even if most of them were 'sleeping' at any time. I think now I´ve got a good idea of what my script will have to look like. Thanks again to all of you. Cheers, Bbq Share this post Link to post Share on other sites