ColonelSandersLite 0 Posted November 27, 2006 Guess what I figured out how to do today..... Well, if you read the title, there won't be much guesswork too it. Here: mission.sqm <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> version=11; class Mission { randomSeed=10316291; class Intel { resistanceWest=0.000000; resistanceEast=1.000000; startWeather=0.000000; forecastWeather=0.000000; }; class Groups { items=1; class Item0 { side="WEST"; class Vehicles { items=1; class Item0 { position[]={5045.685059,688.765198,6305.104980}; azimut=-187.041000; id=0; side="WEST"; vehicle="OfficerW"; player="PLAYER COMMANDER"; leader=1; skill=0.600000; }; }; }; }; class Sensors { items=1; class Item0 { position[]={5083.660156,676.344727,6248.817383}; a=999999.000000; b=999999.000000; activationBy="ANY"; timeoutMin=10.000000; timeoutMid=10.000000; timeoutMax=10.000000; age="UNKNOWN"; text="qwer"; name="qwer"; expActiv="b set [1, ""test3""]"; class Effects { }; }; }; }; class Intro { randomSeed=4923907; class Intel { }; }; class OutroWin { randomSeed=10235395; class Intel { }; }; class OutroLoose { randomSeed=12376579; class Intel { }; }; init.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> a = ["test1", "test2"] [a] exec "test.sqs" ~15 a set [1, "test3"] ~15 [a] exec "test.sqs" test.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _test = _this select 0 _counter = 0 #loop ~1 player sidechat format ["%1", _test] _counter = _counter + 1 ? _counter < 25 : goto "loop" _test set [0, "test4"] player sidechat "script execution finished" The global actually accepts the variable change from the script and vise versa!!!!! If you want to know *why* it works, check the comref under Array assignment. edit: simplified even further edit 2: I'm working on a fully dynamic unit reduction script for Special Ed. The rough version using this method will be released on these forums, probably sunday. The basics are working, I'd just like to flesh out a couple of features and iron some bugs here and there. Do some commenting too. Basically, the script stores any ai squad in memory and deletes all but the leader until the player enters whatever radius. It also uses a global flag, using this method above, that will let you override/reenable it, using whatever global you specify in the script call for the group. This means you don't need to make a new version of the script for every squad, or be forced to make do without being able override it. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted November 28, 2006 Think I got all the bugs fixed and basic features I want for this done. Runs great too. The unit count in this test is 507 men. Runs perfectly smooth once the script kicks in. This is running with very high graphics settings and my own custom splice of ecp and ffur1985 woodland. This gives us whole realms of possibillities. Only thing I'd like to get down now is the possibility of spawning these men directly into memory, without actually creating them on mission start. Then, only creating the pertinent people, and leaving the rest to actually fill out only when the script is forced to spawn them, or when the player is within a certain distance. Anyways, I'm going to do some commenting, remove some debug code and poste it here after I've slept. Share this post Link to post Share on other sites
kutya 0 Posted November 28, 2006 If I'm correct, you try something like caching units. DAC has it and if you want to make it good, you need to store EVERY soldier's inventory (trouble with magazine numbers) and when respawning them apply that info to the unit. This is the main reason why I dropped this idea. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted November 28, 2006 Nah, it's simple, I'll show you after I've made a stab at of spawning these men directly into memory, without actually creating them if they're not in play. The magazines are already stored properly, one of the first things I got working correctly, all it takes is a simple loop. The point of this script though, isn't *what* it does, even though it's *neat*. The point is *how* it does it. Share this post Link to post Share on other sites
baddo 0 Posted November 28, 2006 Hi, just a thought about the "how many rounds in mags" problem: in my opinion it does not matter at all for the gameplay if you give re-spawned AI units full magazines even if they had fired some rounds already. The players will never be able to find out how many rounds there is supposed to be in enemy soldiers' magazines. Only if you see the enemy soldier all the time right from the mission start maybe then you could count how many rounds were fired but this is about re-spawn so that can't be the case or can it It might be a different matter when you are dealing with player groups. Maybe even then trying to count the rounds is wasted effort. Edit: Well at another look at kutya's post it seems like he's only talking about the number of magazines, but can that really be a problem shouldn't it be fairly easy to find out and restore later...? But then again it still doesn't matter if it is not about a player group. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted November 28, 2006 Here it is! It's a little crude in some places. However, it provides an effective demonstration of passing data back and forth by reference, and does dynamic unit reduction. Yes Baddo and kutya, it does track magazine information. It also tracks dammage, weapons, unit types, etc. Frankly though, that's not relevent in this case. That's kinda like focusing on a scratch on a Ferrari. I decided not to try spawning these men directly into memory, without actually creating them on mission start for this demonstration. It just seemed counter productive to what I was trying to show here. It's important to note that this isn't meant to be used in a mission in it's current form, although with some modification, it could be used to do a great number of things. Anything from populating the island with dynamic civillians and garrisons to god only knows what. I can't stress enough, that this demonstrations is about reference variable usage and is geared towards scripters. There aren't really any instructions, although the scripts are heavilly commented. Also, in the mission editor, be sure to turn on markers for some more coments here and there. With that in mind, here's a couple of guidelines. 1: just run the mission first, just to see what it does. Use the jeep, explore, etc 2: When running the mission, for the first min of gameplay, the units are all on the map. This is done to help demonstrate the difference in operation here. If it's not lagging on your super machine during this time, send me your computer, and I'll send you one that it will lag on . Really though, up your game settings till it *does* lag 3: after about a min, the unit reduction script will kick in. lag will spike a little because of all the operations it's doing on *everyone*. However, it should normalise within a few seconds. After this, the lag will be dramatically reduced. In my case, it was by so much, that there was in fact *no* lag. 4: explore, play around, experiment in the mission. See what happens if you go to another town. See how it reacts if you start killing people. Play with the radio. etc. After that stuff, start reading the scripts in detail. The functions aren't so important, but the scripts are. Start with init.sqs and follow execution around from there. The major issues are pretty easy to understand, and I comment the shit out of my scripts. Feel free to ask any questions though. So, without further ado: reference variable powered unit reduction demonstration Please report any bugs you spot. Share this post Link to post Share on other sites