Jump to content

stuguy

Member
  • Content Count

    107
  • Joined

  • Last visited

  • Medals

Everything posted by stuguy

  1. I hit another road block and I have been scrambling for sources and tricks to get around this. I am still working on my squad management script for easy troop management on the fly. To make things tidy and more compact, I wanted to fire off a bunch of add actions all at once in a {}forEach array; statement. However, the magic variables do not pass into the addAction, with the exception of the addAction string. _forEachIndex passes into the first segment for name string. However, magic _x and _forEachIndex do NOT pass down into the code or string of conditions segments, which I need to make each addAction unique. So I will edit the post above this one to give it the latest WORKING code that allows me to add and remove troops. I will then post the code I am experimenting with in this post. I have a working model already, but I had to manually declare each and every addAction, 9 times...not ideal. I want to handle it in a loop with magic, if possible. I'm hoping it isn't something dumb like create local variables before the addAction that equal my magic that is getting the axe in addAction. Which...come to think of it, namespaces and locals are worth trying. { player addaction [format ["Join %1",grpSigns select _forEachIndex], {cursortarget joinAssilent [_x,2]},nil,1,false,true,"",format [' (!(isnull cursortarget) && (alive cursortarget) && ((side cursortarget) == side player) && !(group cursortarget == _x) && ({ alive _x } count units (_x) > 0) && ({ alive _x } count units (_x) < 12) && (cursorTarget isKindof "Man") && !((side cursortarget) == civilian) || (captive cursorTarget))'],15,false]; }forEach myGrps; edit: this code segment will replace : TAG_fnc_recruitFriendly as I am attempting to design this to allow the player to recruit units into his team or his subordinate teams.
  2. You don't find a global ID of an object you didn't create manually, you create a hitbox under your chopper with code. Any "kindof" type truck, or specific object class that is within a certain distance from the position under your helicopter is true, then executes your code. I believe items like beanie caps and what not can also be attached to a helo and made invisible with hideObject. hideObject should allow the item to clip, but I only have experience with people in this regard. Any item that is kindof "truck" that is within a certain x and y difference of the beanie can be your hit box, if you don't feel like casting a math equation under your chopper, that is. Hat is also attachTo and set it to a relative position under your helo. edit: you can also attach triggers with boundaries under your chopper. any kindof type truck in that boundary can execute code. start here: triggername attachTo [vehiclename,[_x,_y,_z]]; don't do the item trick, that's just a dumb thought.
  3. Thanks a ton. I hope you enjoy your beer. I was aware that setGroupID had it's own format, but everything I was trying was throwing errors, and I couldn't find examples of working concepts with proper syntax making use of variables. Thanks for supplying a fix, I will use that example in all future code from now on. I hope it helps others too. Its never Nil as you fill your array with grpNull's to begin with. In previous code, I was explicitly checking for Group _this == grpNull. However, I was getting "any". So I tried a few different concepts. My original code didn't use grpNull at all. I used a switch statement and literally checked in and out squads. The program was huge, but worked flawlessly. Thanks for squaring this away. There is nothing wrong with that, but there are easier ways to do it. I saw the apply command and wanted to give it a go, but I am used to being able to cast an array type and size with one command. I was experimenting with different ideas to reduce the amount of lines of code. I love compact, efficient code. The replacement you gave me works flawlessly, thank you. Nothing wrong here either. As _x is a magic variable handled by the engine the _x in the scope of alive will not destroy/change the _x from the outer scope ( units _x ). As they are treated as byValue rather than byReference even making changes to _x within the inner scope will still not destroy/change the outer scopes value. for instance.. I spent some good amount of time trying to find more detailed documentation of magic variable inheritance, and cases where a new scope is initialized and local magic variables are the same as the level above it. I was about to start testing with hint to make sure they were the same or not just to be sure. Thanks for clarifying the inheritance of variables in that particular instance, more time saved. You never update your array with the created group, so each element is always grpNull. I believed this was the case. It was late and I didn't want to keep trying different methods to assign variables into my global array. The setting of variables in my forEach array statement was genius. You saved me quite a bit of time trying to come up with that solution. Overall, the program was solid. There were two serious bugs however. The syntax: //your condition in TAG_fnc_recruitFriendly "!( isNull cursorTarget ) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursorTarget && { side cursorTarget isEqualTo side player || captive cursorTarget }}}", //should be '(!(isnull cursortarget) && (alive cursortarget) && ((side cursortarget) == side player) && !(group player == group cursorTarget) && (cursorTarget isKindof "Man")) && !((side cursortarget) == civilian) || (captive cursorTarget)'],15,false //your condition in TAG_fnc_makeSquadLeader "!(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursorTarget && { ( side cursorTarget isEqualTo side player || captive cursorTarget ) && !(group cursorTarget in myGrps) }}}", //should be '(!(isnull cursortarget) && (alive cursortarget) && ((side cursortarget) == side player) && !(Group cursortarget in mygrps) || (Group cursorTarget == Group player) && (cursorTarget isKindof "Man")) && !((side cursortarget) == civilian) || (captive cursorTarget)'],15,false That was a quick fix when the debugger threw the error. My IDE had the entire section colored like a string, where as the original was colored properly like code. I copy pasted previously working code and that fixed that. I also added a case that prevented me from passing units that were already in MyGrps[index] back into makesquadleader. The new code looks like this: myGrps = []; myGrps resize 10; myGrps = myGrps apply { grpNull }; grpSigns = ["Me","Y-N-1-1","Y-N-1-2","Y-N-2-1","Y-N-2-2","Y-W-1-1","Y-W-1-2","Y-W-2-1","Y-W-2-2","Y-X-1-1","Y-X-1-2"]; TAG_fnc_formNewHCGroup = { params[ "_unit" ]; _CompanyNames = ["CompanyXray","CompanyNovember","CompanyNovember","CompanyNovember","CompanyNovember","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyXray"]; _PlatoonNames = ["Platoon1","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1"]; _SquadNames = ["Squad1","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad2"]; { _x params[ "_grp" ]; if ( isNull _grp || { { alive _x } count units _grp == 0 } ) exitWith { _newGrp = createGroup side player; _newGrp setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; [ _unit ] joinSilent _newGrp; myGrps set [ _forEachIndex, _newGrp ]; if !( isPlayer _unit ) then { player hcSetGroup [ _newGrp ]; }; }; }forEach myGrps; }; TAG_fnc_joinMe = { params[ "_unit" ]; _unit setCaptive false; _unit joinAsSilent [ group player, 2 ]; }; TAG_fnc_recruitFriendly = { player addaction ["Join Me", {cursorTarget call TAG_fnc_joinMe},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ((side cursortarget) == side player) && !(group player == group cursorTarget) && (cursorTarget isKindof "Man")) && !((side cursortarget) == civilian) || (captive cursorTarget)'],15,false]; }; TAG_fnc_makeSquadLeader = { player addaction ["Team Lead", {cursorTarget call TAG_fnc_formNewHCGroup},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ((side cursortarget) == side player) && !(Group cursortarget in mygrps) || (Group cursorTarget == Group player) && (cursorTarget isKindof "Man")) && !((side cursortarget) == civilian) || (captive cursorTarget)'],15,false]; }; _null = player spawn TAG_fnc_formNewHCGroup; _null = [] spawn TAG_fnc_recruitFriendly; _null = [] spawn TAG_fnc_makeSquadLeader; This program works as intended. To use, the mission only needs a player with High command module synced to him and a HC sub command synced to that in GEeditor. This code can be run via sqf or executed in the debug console. It takes a few seconds for the action menus to pop up, but they work. What's it all do? For those wondering. Your player becomes high commander and can easily walk up to units in his faction and wheel mouse units into his group, or add them to a squad leader subordinate. It also allows you to pull subordinates back into your squad via wheel mouse. Quick and easy peasy. My other mile long script has join HC squad actions and add vehicle actions, but the vehicle part is riddled with bugs. I will add those in another thread later.
  4. One last thing, another potential problem I saw was what happens when a new magic is passed in? {if ((isNil {_x}) || ({ alive _x } count units (_x) == 0)) exitWith { _x = createGroup side player; _x setGroupId ["%GroupNames %GroupCompany %GroupPlatoon %GroupSquad","Yankee",format ['"%1","%2","%3"',_array1 select _foreachindex,_array2 select _foreachindex,_array3 select _foreachindex]]; [_this] joinsilent (_x); if!(isPlayer _this)then{player hcsetgroup [_x];}; };}forEach mygrps; _x represents the magic for whatever is in that array index when it is iterated through. but look at this little number: ({ alive _x } count units (_x) == 0) count units (_x) is counting the units in magic variable _x for the groups I am iterating through. Now look over at { alive _x }. Alive _x gets passed in magic variable _x from count units, but doesn't _x already force alive _x to inherit it? Or is it overwritten with the count units result? I am curious.
  5. I have a much much longer rough copy of this that allows me to add and remove from HC with no problems. However, I am now using arrays and magic and trying to slim this thing down. This is more than a third of the size compared to what it used to be, and is ALMOST where I want it. Main issues: 1) Group ID format isn't right. I've tried all sorts of syntax variations, I am unsure how to use format with: _x setGroupId ["%GroupNames %GroupCompany %GroupPlatoon %GroupSquad","Yankee",format ['"%1","%2","%3"',_array1 select _foreachindex,_array2 select _foreachindex,_array3 select _foreachindex]]; [_this] joinsilent (_x); 2) The next not so noticeable problem, but is to me, is that there are only supposed to be 9 HC teams at any given time. The first group I assign is to be assigned to the player via: null = player spawn formnewhcgroup; This gets executed before the player uses action menu on new squads. The idea is once select 0 is assigned to the player, the if conditions that search if the index isNil or has no alive players should always be false because player is in the group. I can infinitely add HC groups from units on my side however, at least until i hit game array limitations... this isn't intended. I only want 10 groups because 9 HC groups are all f-keys register. Anyways, I don't think I can declare my array like this: mygrps = [grpNull]; for "_i" from 0 to 9 do {mygrps set [_i,grpNull];}; I'm used to actual languages that let me declare my array size and type without initializing it with anything. Sadly, I had more luck with this monster: mygrp0 = grpNull; mygrp1 = grpNull; mygrp2 = grpNull; mygrp3 = grpNull; mygrp4 = grpNull; mygrp5 = grpNull; mygrp6 = grpNull; mygrp7 = grpNull; mygrp8 = grpNull; mygrp9 = grpNull; mygrps = [mygrp0,mygrp1,mygrp2,mygrp3,mygrp4,mygrp5,mygrp6,mygrp7,mygrp8,mygrp9]; I don't think my forEach loop is keeping mygrps unique. I think the game registers isNil on every unit I select, even beyond 10 because select 1 never gets called. I noticed the problem when my unit's group ID changed as soon as I recruited a man into my HC module. I think they are hijacking select 0. edit: I think the difference is noticeable between my longer older variable array, and the newer grpNull array that is assigned inside of another scope locally, instead of being a global and passed in to be modified.
  6. I am very familiar with programming and I have been experimenting how ARMA passes variables to functions. I think I understand how params and param work, but I am having difficulty calling a function to return a desired result. This below code is simply trying to call on a function that requires the input of a group, in this instance, I am sending it "group player" with the call function. From what I understand, the function returns the last line, so the count should return the number of men in the group. However, it sends an error stating that it is expecting a number, but is getting type string. This is confusing because I am sending it Group Player, an array of men to be counted. Just writing a count out with "_num = count units group player" works without a hitch. So why is it I am unable to pass it the _grp parameter? getGrpCount = { param ["_grp"]; count units _grp; }; _num = [group player] call getGrpCount; hint format ["%1",_num]; no workie _num = count units group player; hint format ["%1",_num]; works Existing user? Sign In
  7. oh man. that's a big help. I was relying solely on the mission editor command exec utility, and the errors are teeny weeny and not always easy to read. I started using hints more as I tested my functions, I will be sure to use typeName, good call. Thanks for the advice.
  8. I am using the addaction menu to add quick on the fly troop management and vehicle assignment scripts. I have the troop management down solid. Units can come in and out of my group, and in and out of my high command module with the flick of the mouse wheel. However, the same cannot be said completely about assigning the vehicles. I got the assign part down, though I currently am not assigning drivers (yet). The problem is that when I choose to unassign one of my highcommand subordinates from their vehicle with my script, that vehicle is no longer eligible for reassignment or unassignment. My addaction for that car/tank/truck is just gone. Reactivating the script doesn't work. I can, however, reassign the group to another vehicle, however, if I unassign them, the same happens once again, vehicle is no longer eligible for reassignment. Just a note here, these groups were added under player with the "player hcSetGroup [group];". I do have a synced HCcommand module to my player, and a synced subordinate command module to the hc module on the map. addhcvehicle = { player addaction ["Assign to Squad 1", {mygrp1 addVehicle cursorTarget},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ({ alive _x } count units mygrp1 > 0) && ((side cursorTarget) == side player) && (locked cursortarget < 2) && !(cursorTarget isKindof "Man"))'],15,false]; }; null = []spawn addhcvehicle; removehcvehicle = { player addaction ["Remove from Squad 1", {mygrp1 leaveVehicle cursorTarget},nil,1,false,true,"",format ['(!(isnull cursortarget) && (alive cursortarget) && ({ alive _x } count units mygrp1 > 0) && (locked cursortarget < 2) && ({if (assignedVehicle _x == cursortarget) exitwith {true}}forEach units mygrp1))'],15,false]; }; null = []spawn removehcvehicle;
  9. Thanks for the response. I was wondering why the first script was getting the axe when everyone piled out of the car, and what you say makes perfect sense. I am about done with my new library and it is running much better than this first post. Hell, even the second post I made got overhauled. As for testing for inanimate objects, I am currently writing up a library of iskindof and vehicle type features so I can fix the bugs in my unit and vehicle interactions, as well as expand the potential for assigning vehicle crews to various types of vehicles without having to micromanage units. I rather like what I have at the moment, aim and click, and the dude is in your group. Aim and click and the dude is assigned to a car or in a subcommander module, or both. No thousands of menus and getting shot in the back, no fuss.
  10. that makes much more since. I didn't even realize that error. Come to think of it, the debuger mentioned something about string. Thank you for the clarification. Keep in mind, I only started getting back into arma scripting only yesterday, so I don't see as clearly as you do.
  11. I kept reading and reading. I think I found a better solution: mygrp1 = createGroup side player; [commander cursorTarget ] joinSilent mygrp1; {_x joinAssilent [mygrp1,2];}forEach crew cursorTarget - [commander cursorTarget]; driver cursortarget assignAsDriver cursortarget; commander cursortarget assignAsCommander cursortarget; gunner cursortarget assignAsGunner cursortarget; crew cursortarget allowGetIn true; player hcsetgroup [mygrp1,""]; My scripts have the ability to flip my men between HC and my group with addaction menu without hassle, so I realized that I could just put dudes in the vehicle manually from my group and run the above code to lock them in place. I can create conditions that check for particular vehicle classes and adjust the assignment parameters as needed. I am now playing with an additional fire team in a BMP2 and assigning that seperate HC group as cargo, and will likely use radio commands to set their orders to get in and out.
  12. I RTFM. The way I understood it was that param "extracts a single value with given index from input argument". I had thought I was passing in a single variable and thus only needed to use param.
  13. I figured it out. It was passing an array when the code is expecting an object type. I simply erased the [] before call and used _this. Though, I am still confused why param ["_grp"] doesn't seem to want to work even with the array fix. getGrpCount = { count units _this; }; _num = group player call getGrpCount; hint format ["%1",_num];
  14. I am working on a mission template that adds a fully controllable nose cam to the C130, implementing FLIR w/ nose cam and weapon's ordinance spawned from the side of the craft, gathering target data from laser range finder spawned from the camera targeting the ground. Other things in progress are as follows: Currently available: I will post updates in this thread, I will also be asking questions......contributors will be appreciated and thoroughly credited in the scripts.:D
  15. dudez, why not getpos the airplane and like, load a normal airstrike or even script out another airstrike from the exact location of the old air craft. assuming manzilla knows how to use the normal airstrike scripts, triggers should suffice for this. I dont think you can change the airstrike type either, but you can at least spawn another type of mission on top of the vehicle you want to delete or add etc... what the player can't see wont hurt him right?
  16. ok, camsettarget seems to do what I want, but I need a way to control the objects it targets. Is there a way to add and subtract numbers from an object's attach to position? I know how to script a keyboard key to do a function, but I don't know how to write the function to add or subtract to the X Y and Z of the attached object's location. I think I have to setup a constant variable and modify that, but how is this setup? anyone?
  17. stuguy

    Math

    This is my working cam. Simply make a C130 on a map and set it as flying, and name the guy c130. Then add a player character and move him in cargo. It may be beneficial to give the player an HC Commander module so you can tell the C130 where to fly. I am going to do a before and after, this is before: Init.sqf script\Flir_Function.sqf script\Flir_Main.sqf This cam works for me, but I can't control it. Now, the new cam. I implemented the stuff you sent me earlier. I applied it as logically as I could in my script, but the cam is now broken, however, the FLIR operates. Take a look: Init.sqf (no change) script\Flir_Function.sqf script\FLIR_Main.sqf I can switch back and forth between the two sets, and I just can't see what I am doing wrong when I add in the new set of camera commands :confused: Can anyone take a peak at this and see what's wrong? -Stu
  18. Does anyone know where the targeting aperture scripts for the gunships and UAVs are located?
  19. like the scopes when you are in the cobra and stuff. those are cams that are linked to the right click on the mouse. I am interested in how they scripted those. I can't use mando missile stuff in my own mod.
  20. stuguy

    Math

    yea, exactly :D i generally know all the commands, but the syntax illudes me for the setpos getpos stuff. and adding and subtracting from a variable ---------- Post added at 07:50 PM ---------- Previous post was at 07:43 PM ---------- just so there is no confusion. I attached my cam to a C130 with _cam attachTo [c130, [0,14,-5]]; I want to create an invisible object or cam that sticks out farther than the cam so I can do a camsettarget on that invisible object. When I do key presses, it would move the object left or right, up and down, on an azimuth/inclination/declination type of thing. Probably done with a simple array. I just don't know how to go about moving my object with script. I can simply paste the object change position script into my key event handler segment already working on my script. ---------- Post added at 07:51 PM ---------- Previous post was at 07:50 PM ---------- _cam = "camera" camcreate (position c130); _cam CameraEffect ["EXTERNAL","FRONT"]; _cam attachTo [c130, [0,14,-5]]; showCinemaBorder false; cameraEffectEnableHUD true; _cam camSetFov 1; _cam CamCommit 0; here's the cam
  21. The placement of these codes can be done in the init field of a unit or object in the mission editor, or in text files named anything.sqf, saved into the mission directory on your computer where the mission.sqm is located (documents\arma2\missions\etc. I like using Arma Edit for my text editor when writing these codes. Or you can use notepad. If you want to hammer out or copy paste scripts into the mission editor's unit's init fields, be my guest, but that gets messy, and difficult to troubleshoot where you went wrong with commands.
  22. camcreate sucks. How do you make a camera where I can control the camera with the mouse? Like the "camconstruct" version of the camera, but actually capable of being attached to a flying target... I have tried Mando's predicam, freelook cam, the coinmodule's cam's...I got my interface and the Flir setup for my C130 nose cam, but absolutely zero call functions for the mouse or setbank calls work with the "camera" in camcreate. Basically, I just need a standard camera that can be attached to my plane. Here is what I have so far, minus the mouse events... Code ok, camsettarget seems to do what I want, but I need a way to control the objects it targets. Is there a way to add and subtract numbers from an objects attach to position? sadly, I know how to script the change, just not the math :P
×