Jump to content

kronzky

Member
  • Content Count

    903
  • Joined

  • Last visited

  • Medals

Everything posted by kronzky

  1. The library includes the following functions: toArray: Converts string to an array Length: Returns length of string Left: Returns leftmost characters of string Right: Returns rightmost characters of string Mid: Returns substring InStr: Tests for presence of search string Index: Returns the position of a search string Replace: Replaces every sub-string occurrence Upper: Converts string to uppercase Lower: Converts string to lowercase findFlag: Finds a specific string in a mixed array getArg: Returns an argument value from a mixed array Compare: Compares two strings ArraySort: Sorts multi-dimensional arrays The package also contains a demo mission with multiple examples for each function. Everything is available here.
  2. kronzky

    String Library

    I *knew* I forgot something... Check out the added "Replace" function. It will replacement every occurrence of a string; and the replacement string can have a different size than the replaced one (it can even be empty, in which case the original strings will be removed). Hopefully that'll do the job.
  3. kronzky

    String Library

    Now that we have some more string functions available in ArmA I have updated this library to take advantage of it - and to make it about 100 times faster... The calling syntax is still the same (even though some functions aren't really necessary anymore, I left them in for compatibility reasons). A few new things: (All string positions is 0-based, i.e. the first position in the string is 0.) <span style='font-size:10pt;line-height:100%'>StrMid</span> Can now also accept just a single parameter (the position). In that case the string from that position on is returned.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_mid=["abcdefgh",3] call KRON_StrMid; _mid will contain "defgh" <span style='font-size:10pt;line-height:100%'>StrIndex</span> Returns the position of a sub-string.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_index=["abcdefg","cd"] call KRON_StrIndex; _index will be 2 <span style='font-size:10pt;line-height:100%'>Replace</span> Replaces every occurrence of a sub-string. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_new=["abcabc","b","XXX"] call KRON_Replace; _new will contain: "aXXXcaXXXc" <span style='font-size:10pt;line-height:100%'>FindFlag</span> Searches a mixed array for a string, and returns true or false, depending on presence. The main purpose of this is to search the parameter array (_this) for a specific flag. Case-insensitive.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nul=[1,100,"Slow",false] exec "test.sqf"; Inside test.sqf: _flg=[_this,"slow"] call KRON_FindFlag; _flg will be true <span style='font-size:10pt;line-height:100%'>getArg</span> Returns an "argument" that has been supplied with a specific tag. The concept behind this is a bit more complicated to explain, but again, the main purpose is to parse the parameter array (_this). Instead of having to enter arguments at specific positions in the parameter array, they can now be supplied anywhere in the array. i.e. all the following calls would return the same values if they are parsed as follows:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_min=parseNumber([_this,"min"] call KRON_getArg); _med=parseNumber([_this,"med"] call KRON_getArg); _max=parseNumber([_this,"max"] call KRON_getArg); will get the same results with any of these calls: nul=[this,"min:100","max:200","med:150"] exec "script.sqf" nul=[this,"MIN:100","Med:150","max:200"] exec "script.sqf" nul=[this,"Max:200","Min:100","Med:150"] exec "script.sqf" <span style='font-size:10pt;line-height:100%'>Compare</span> Compares two strings. Returns -1 if first arguments is smaller, 1 if second is smaller, and 0 if they are equal. Optional case-sensitivity via "case" flag. (Order is: numbers, uppercase, lowercase).<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_cmp=["bbb","aaa"] call KRON_Compare; _cmp will be 1 (2nd element is smaller) <span style='font-size:10pt;line-height:100%'>ArraySort</span> Sorts a multi-dimensional array. Pretty straightforward for single-dimensional arrays:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">["bbb","aaa","ccc"] will turn into ["aaa","bbb","ccc"] A bit more complicated for multi-dimensional ones, as you can specify which column to sort on:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_arr=[["bbb",2],["aaa",3],["ccc",1]]; _srt=[_arr] call KRON_ArraySort; _srt will contain [["aaa",3],["bbb",2],["ccc",1]] If I specify '1' as the sort column (the numbers) it will look like this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_arr=[["bbb",2],["aaa",3],["ccc",1]]; _srt=[_arr,1] call KRON_ArraySort; _srt will contain [["ccc",1],["bbb",2],["aaa",3]] With the optional parameter "desc" the sort order is reversed:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_arr=[["bbb",2],["aaa",3],["ccc",1]]; _srt=[_arr,1,"desc"] call KRON_ArraySort; _srt will contain [["aaa",3],["bbb",2],["ccc",1]] And with the optional parameter "case" capitalization is taken into account (order is: numbers, uppercase, lowercase). <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_arr=[["bbb",2],["aaa",3],["CCC",1]]; _srt=[_arr,"case"] call KRON_ArraySort; _srt will contain [["CCC",1],["aaa",3],["bbb",2]] Download location is in the first post.
  4. The top of the script has several examples listed on how to call it. Check it for some of the optional parameters. The basic call syntax is: nul=[this] execVM "track.sqf" In order to call two separate scripts (or commands) from the init line you have to separate them by semicolons:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nul=[this,"Alpha","RANDOM","MIN:",1,"MAX:",6] execVM "ups-f.sqf"; nul=[this] execVM "track.sqf"
  5. kronzky

    Switching Sides in mission.

    I *think* civilians have different AI configurations, so they may not be the best fighters, and could end up running away quite often. Two things you could try: 1) Set your rank as high as possible 2) Set their allowFleeing value to zero
  6. Put this in the unit's init line: this setUnitPos "UP"
  7. kronzky

    Switching Sides in mission.

    Well... You didn't say anything about enemy encounters... Anyway, you're close. Use the grouping as you've done it now, but instead of killing him off, just set his "Condition of presence" (bottom of unit form) all the way to the left. That way you're still grouped with him (and considered a BLUFOR unit), but he never shows up, and you will also not get any death messages.
  8. kronzky

    Switching Sides in mission.

    I think all you need is a more specific trigger setup, that ignores any empty vehicles. Try this in the condition line of the trigger:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">({isPlayer (driver _x)} count thislist)>0 It counts any human drivers of vehicles in the trigger (a pedestrian is "driving" himself, so that'll be true as well), and if there are any, the trigger fires.
  9. kronzky

    nearestObjects, question.

    Definitely! nearestObjects considers all sub-members of the specified class, so you only need to look for the highest class relevant to your situation. But you probably figured that out already by now... ;)
  10. kronzky

    Kill Enemy General

    There is no specific command to do exactly that, but what you can try is to is to set up a trigger of type "[one side] DETECTED BY [other side]", and synch that with a "GETIN" waypoint near a chopper. You may also have to give him some fight suppression orders (via Combat Mode "Never fire"), or remove his ammo, so that he doesn't get involved in a firefight first. Here's a little demo mission.
  11. kronzky

    Squads Fleeing or Wandering

    You may want to look into the allowFleeing and disableAI "move" commands. Depending on your specific situation, applying one (or both) commands should keep your units in check.
  12. kronzky

    Beginner's questions

    Well... Understanding the fundamentals of scripting, and understanding somebody's fairly complex ready-to-use script are two totally different goals. You could, theoretically, find out exactly how to use Mandoble's script, but still not understand the least bit of it. But if you want to learn scripting, in order to be able to write something like that from scratch yourself at some point, requires a different approach. And the commitment of a significant amount of time - expect to spend a few weeks to months (depending on your previous programming experience) to really understand the fundamentals of ArmA scripting. And don't get too fixated on tutorials either. It is very hard to teach programming from scratch (this applies to *any* programming language, just just ArmA scripting). It's a way of thinking that you have to acquire yourself. It's not a specific skill that anybody can teach anybody. You have to discover yourself what approach works for you, and work your way up. Any tutorial will always only represent the approach that worked for the specific person that wrote the tutorial (and on top of that, he may not be a good teacher either, since *knowing* and *teaching* are two very different skills). So - with all that in mind, here's my universal programming tutorial... a) Look through some of the available scripts to see which commands are the most common. b) Look up these commands on the Wiki, and try to understand what they actually do. c) Create EXTREMELY SIMPLE scripts to test out what the commands do, and how to use them. d) Repeat this over and over again, until you are familiar with a good basic set of commands. e) Take those existing scripts you picked up in step a) and try to make sense out of them now (either by reading them over and over again, or by modifying them, to see what kind of difference those changes make).
  13. You certainly *could* create units out of the blue (via the createVehicle and related commands), but it'd be much easier and much more realistic if the units existed from the beginning, but at some point away from their final point on engagement. Just start'em out somewhere far enough away, give'em a conditional or synchronized waypoint so they end up at their destination in time, and you've solved the problem of having units at the right place at the right time, plus you don't end up with unrealistically spawned enemies that are beamed into place out of nowhere. This also adds some more variety to the mission, as they player could now decide to intercept those forces on their way to their destination, rather than only having one, and only one, way of fighting the enemy. And isn't that what OFP/ArmA is all about?
  14. Both suggestions are very true (using a large, overlapping trigger, and having a light "margin of error" for that end condition). Since you say you're new to scripting, it might not be that obvious though, how to determine how many units are left. So here's a screenshot of how you should probably set up that end-condition trigger:
  15. You have to create the description.ext file manually. But, as I said, creating voice radio messages is not that trivial, so you'd definitely have to go through a few tutorials to figure it out (it's not something that can be explained in a brief message here). Also, when looking for tutorials search for OFP ones as well. There will be quite a few more around, and the procedure is the same.
  16. If you're talking about the radio messages that appear at the bottom of the screen, that's pretty straightforward, and once you go through the commands listed in the Wiki's Command Group: Radio Control you should have a pretty good idea of what's going on. If you mean audible radio messages, then that's a whole different story (and a lot harder)... There are some tutorials floating around for that. OFPEC's tutorial section would be a good place to start, but it seems they're having problems with it right now. Armaholic is another good place to look, and they seem to have a good one available here.
  17. You may want to try a trigger setup like this: It's constantly being triggered by itself (that's what the tests and resettings of the "loop" variable do), because otherwise a regular presence trigger will not re-fire if a matching unit is already in its radius (i.e. once a player enters the zone, the next player will not activate the trigger again). Then it goes through the list of units in the trigger area (the content of the thislist array), and checks whether the unit is human or not (via the isPlayer command). It takes the name of each player, and adds it to an array. In this example that array is constantly being displayed on the screen, but I'm sure you'll be able to tweak this setup to suit your demands.
  18. kronzky

    Queen's gambit animations list

    Thanks for those lists, da rat and trini scourge! I've added the definitions to my Animation Viewer, and will also add it to the Wiki ASAP.
  19. Rather than going through a lot of explaining, here's a screenshot of a trigger setup that will detect any smoke grenade within a 50 meter radius:
  20. kronzky

    Functions (.sqfs)

    Say _a was larger then _b, how would this return these values to the script it was running from, and how would I use them? Actually, the answer to that is right behind the example in the Biki: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fMax = compile preprocessFile "max.sqf"; maxValue = [3,5] call fMax; // maxValue is now 5 The "maxValue = [3,5] call fMax;" is where the assignment of the return value happens. You can then use the variable maxValue to do with it whatever you want... Here's the whole thing demonstrated in one file, this time as an inline function. Save it as "inlinedemo.sqf", then call it with "nul=[] execVM inlinedemo.sqf", and you'll see... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">whatsbigger = { private ["_a","_b","_return"]; _a = _this select 0; _b = _this select 1; if (_a>_b) then {_return=_a} else {_return=_b}; _return; }; _x=1; _y=2; _big=[_x,_y] call whatsbigger; player sidechat format["%1,%2: %3",_x,_y,_big]; _x=22; _y=11; _big=[_x,_y] call whatsbigger; player sidechat format["%1,%2: %3",_x,_y,_big]; Just comfirming that if vehicle _x did not equal _x then _x would setbehavior to safe if not ('if' statement was wrong) then it would setbehavior "safe" also? http://community.bistudio.com/wiki/Function#Example_3:_Inline_Function call FNC_helloall by itself in say a radio command would return scalarbool array etc? That example doesn't make much sense, since it will always set the behavior to "safe", no matter whether the unit is in a vehicle or not... Also, in order for this to work, "_this" has to be an array that contains a number of units. (Are you sure this isn't supposed to be "thislist", which is the array a trigger generates?)
  21. kronzky

    Vbs1,vbs2 ,ofp or arma

    I doubt this is actually a military setup. Looks more like a fancy arcade game. After all, what would be the educational value of a setup like this (shooting at passing cars, from a pretty permanent looking arrangement of sandbags)? Probably some theme park where you can "play soldier" for a day. The dead giveaway though, I'd say, is the shopping bag that girl brought along...
  22. kronzky

    Evolution - Single Player

    Not by me, I'm afraid. I recently moved over to VBS2, and am more than busy there... But if anybody else wants to take a shot at it, go for it. As I mentioned above, as far as I'm concerned, this mission is now in the public domain, and you can do with it whatever you want.
  23. kronzky

    Cowards

    Make sure you have the latest patch of ArmA. There used to be an issue with units not getting up after being shot at, but that was fixed in a patch (not sure if it was the 1.08 or 1.09 one though).
  24. kronzky

    Evolution - Single Player

    As far as I'm concerned, I'm ready to release it into the "public domain" (i.e. you can do with it whatever you want). But since KilJoy is still the main creator of the mission, I wanted to check with him first. Unfortunately, his mailbox is overflowing, so I wasn't able to PM him yet. But since he was never too interested in the SP version anyway, I wouldn't really expect him to veto that idea. So you guys can probably go crazy modifying it to your heart's content. But please don't open a new thread for each single variation. Please keep'em all in here. Thanks.
  25. kronzky

    Evolution - Single Player

    Oh, well... That's defined in init.sqf. Look for the variable EVO_citydef, which contains 11 nested arrays (one for each city). Parameter 5 in each array is for the number of infantry groups, parameter 6 for armored groups. So, for Paraiso it's: ["par",parlist,apar,false,<span style=color:red'>12,6</span>,parso1,"s","paraiso], which means <span style='color:red'>12</span> infantry and <span style='color:red'>6</span> armored groups. Good luck...
×