Jump to content

Zenophon

Member
  • Content Count

    530
  • Joined

  • Last visited

  • Medals

Everything posted by Zenophon

  1. Zenophon

    Enemy Detection

    You could use these: http://community.bistudio.com/wiki/lineIntersects http://community.bistudio.com/wiki/terrainIntersect Here is an example, using generic Unit1 and Unit2, to determine if Unit1 can see Unit2: if (!(terrainIntersect [(eyePos Unit2), (eyePos Unit1)]) && {!(lineIntersects [(eyePos Unit1), (eyePos Unit2), Unit1, Unit2])}) then { // Unit1 can see Unit2... }; Just put that condition in a trigger, but you might also want to test if Unit1 is facing Unit2 (that requires some math).
  2. Assuming that the sectors are area markers, you could use their size in the argument to BIS_fnc_taskPatrol like so: 0 = [_attackGroup, (getMarkerPos _currentSector), ((getMarkerSize _sector) select 0)] call BIS_fnc_taskPatrol; BIS_fnc_taskPatrol would then only generate waypoints inside the marker area (unless the width is much greater/less than the height). In general, my function should accept some arguments to make it easy to change distances, number of people that spawn, etc. If it gets tedious tweaking things, just ask and I will post an improved version. There is a ticket for the BIS_fnc_spawnGroup issue: http://feedback.arma3.com/view.php?id=10532 It says assigned on 2013-07-04, so it seems BIS forgot about it. Like I said, it's just a copy and paste of classnames data into an accessor function. They really need to hire a junior programmer to take care of things like that.
  3. In the second script, you declare '_HStringWest' twice and never declare '_HStringGuerrila'. That seems unrelated though. The error you are getting means exactly what it says. You declare '_sector = capture;', so 'capture' could be undefined. So what is 'capture'? How is it declared? Do any other functions use it? How many threads of this function are running? You could also try adding a private statement at the beginning of the spawned code block: private ["_Tickets", "_captureTime", "_Sector", etc ...]; You could also simply use 'capture' instead of '_sector' and see if the error reports that 'capture' is undefined. If capture is defined, then the private statement could help.
  4. After fixing several mistakes, this is tested and working very well (sorry it took so long): if !(isServer) exitWith {}; private ["_sectorArray", "_soldierlistEast", "_soldierlistResistance", "_currentSector", "_sideIndex", "_attackingSide", "_attackingVehicle", "_spawnPosition", "_attackGroup", "_i", "_classesSpawned", "_attackingVehicleArray", "_vehicleListEast", "_vehicleListResistance", "_classnamesArray"]; _sectorArray = ["sector1", "sector2", "sector3"]; _soldierlistEast = ["o_Soldier_F", "o_Soldier_a_F","o_Soldier_AR_F", "o_engineer_F","o_Soldier_exp_F","o_Soldier_M_F","o_Soldier_GL_F","o_Medic_F", "o_Soldier_AA_F", "o_Soldier_AT_F", "o_officer_F","o_Soldier_lat_F","o_Soldier_lite_F","o_Soldier_M_F","o_Soldier_SL_F","o_Soldier_TL_F", "o_Soldier_AAA_F", "o_Soldier_AAR_F", "o_Soldier_AAT_F"]; _soldierlistResistance = ["i_Soldier_F", "i_Soldier_a_F","i_Soldier_AR_F", "i_engineer_F","i_Soldier_exp_F","i_Soldier_M_F","i_Soldier_GL_F","i_Medic_F", "i_Soldier_AA_F", "i_Soldier_AT_F", "i_officer_F","i_Soldier_lat_F","i_Soldier_lite_F","i_Soldier_M_F","i_Soldier_SL_F","i_Soldier_TL_F", "i_Soldier_AAA_F", "i_Soldier_AAR_F", "i_Soldier_AAT_F"]; _vehicleListEast = ["O_MRAP_02_F","O_MRAP_02_hmg_F","O_MRAP_02_gmg_F","O_Quadbike_01_F","O_Truck_02_covered_F","O_Truck_02_transport_F", "O_APC_Tracked_02_cannon_F","O_APC_Tracked_02_AA_F","O_MBT_02_cannon_F","O_MBT_02_arty_F","O_APC_Wheeled_02_rcws_F"]; _vehicleListResistance = ["I_MRAP_03_F","I_MRAP_03_hmg_F","I_MRAP_03_gmg_F","I_Quadbike_01_F","I_Truck_02_covered_F","I_Truck_02_transport_F", "I_APC_Wheeled_03_cannon_F"]; while {true} do { sleep (60 * 15); _currentSector = _sectorArray select (floor (random ((count _sectorArray) - 0.0001))); switch (toLower (getMarkerColor _currentSector)) do { case "colorblue": { _sideIndex = floor (random 1.999); _attackingSide = [east, independent] select _sideIndex; _attackingVehicleArray = [_vehicleListEast, _vehicleListResistance] select _sideIndex; _classnamesArray = [_soldierlistEast,_soldierlistResistance] select _sideIndex; }; case "colorred": { _attackingSide = independent; _attackingVehicleArray = _vehicleListResistance; _classnamesArray = _soldierlistResistance; }; case "colorgreen": { _attackingSide = east; _attackingVehicleArray = _vehicleListEast; _classnamesArray = _soldierlistEast; }; default { _attackingSide = east; _attackingVehicleArray = _vehicleListEast; _classnamesArray = _soldierlistEast; }; }; _spawnPosition = [(((getMarkerPos _currentSector) select 0) + ((200 + (random 300)) * (cos (random 360)))),(((getMarkerPos _currentSector) select 1) + ((200 + (random 300)) * (sin (random 360)))), 0]; _classesSpawned = []; for "_i" from 0 to (random 5) do { _classesSpawned set [(count _classesSpawned), ( _classnamesArray select (floor (random ((count _classnamesArray) - 0.0001))))]; }; if ((random 1) > 0.3) then { _attackGroup = [_spawnPosition, _attackingSide, _classesSpawned] call BIS_fnc_spawnGroup; } else { _attackingVehicle = _attackingVehicleArray select (floor (random ((count _attackingVehicleArray) - 0.0001))); _attackGroup = ([_spawnPosition, 0, _attackingVehicle, _attackingSide] call BIS_fnc_spawnVehicle) select 2; }; 0 = [_attackGroup, (getMarkerPos _currentSector), (50 + (random 200))] call BIS_fnc_taskPatrol; _attackGroup setCombatMode "red"; _attackGroup setSpeedMode "normal"; _attackGroup setBehaviour "aware"; }; Changes include some defensive coding (default case), some randomization (who and what to spawn, where to spawn, where to patrol), and a fix for a few issues (private statement, 2 random numbers used in case blue, wrong arguments for BIS_fnc_SpawnGroup, forgot 'toLower' in switch condition). You still probably need to make sure the position to spawn the units is not in the ocean. You could use the groups method as suggested by KevsnoTrev, but I prefer complete randomization, your choice. Also, BIS_fnc_SpawnGroup cannot work with a number of people as the third argument. It calls BIS_fnc_returnGroupComposition to get the units to spawn, but BIS_fnc_returnGroupComposition has classnames from ArmA 2. BIS needs to update that function or a number cannot work. That is definitely worthy of a ticket, and it would take less that 30 minutes for someone to do it.
  5. If you want an animation try this: http://community.bistudio.com/wiki/playMoveNow Use the the animation view in the editor to find the right one. You could also play the correct sound file, if you knew the name. Just open the sound .pbo's to find what you need. You would combine all that with the correct action and hope the AI obeys.
  6. This should cover everything else: http://community.bistudio.com/wiki/action http://community.bistudio.com/wiki/ArmA_2:_Actions The action list is for ArmA 2, but they should all work in ArmA 3. A lot of the actions teleport the unit, but you could order them to move to the correct position first.
  7. A local data type cannot be sent to another machine in the network; tasks are another local data type. Local means that a variable of that type points to something on one machine, but would point to nothing on another machine if the exact value of the pointer/reference was copied. The data does not exist in the heap on the server because the entity was created on the HC. Arrays are an exception to this. See this page: http://community.bistudio.com/wiki/publicVariable
  8. You could try some of these: http://community.bistudio.com/wiki/Category:Command_Group:_Unit_Control
  9. Zenophon

    addAction Problems!

    The init.sqf is run on all machines, so make sure you have no conditions to only run the addAction statement on the server (I assume you are the local host). You might also want to try adding this line before the addAction (could be an issue with the client synching): if !(isServer) then {waitUntil {!(isNull player)};}; Other clients will not see the action to join the camp because the function that adds that action runs only on one machine (using an action executes the code locally). You need a system to remotely execute that statement on all clients. This is probably the easiest way: http://community.bistudio.com/wiki/BIS_fnc_MP There are other ways to do it if BIS_fnc_MP does not work for you.
  10. Zenophon

    Jet rearm on landing?

    Maybe this: http://community.bistudio.com/wiki/isTouchingGround
  11. To trigger the attacks I would create a main loop like so: if !(isServer) exitWith {}; _sectorArray = ["sector1", "sector2", "sector3", etc ...]; while {true} do { sleep (60 * 15); _currentSector = _sectorArray select (floor (random ((count _sectorArray) - 0.0001))); switch (getMarkerColor _currentSector) do { case "colorblue": { _attackingSide = [independent, east] select (floor (random 1.999)); _attackingVehicle = ["", ""] select (floor (random 1.999)); }; case "colorred": { _attackingSide = independent; _attackingVehicle = ""; }; case "colorgreen": { _attackingSide = opfor; _attackingVehicle = ""; }; }; _spawnPosition = [(((getMarkerPos _currentSector) select 0) + ((random 300) * (cos (random 360)))),(((getMarkerPos _currentSector) select 1) + ((random 300) * (sin (random 360)))), 0]; if ((random 1) > 0.3) then { _attackGroup = [_spawnPosition, _attackingSide, (3 + (floor (random 2.99)))] call BIS_fnc_spawnGroup; } else { _attackGroup = ([_spawnPosition, 0, _attackingVehicle, _attackingSide] call BIS_fnc_spawnVehicle) select 2; }; 0 = [_attackGroup, (getMarkerPos _currentSector), 100] call BIS_fnc_taskPatrol; _attackGroup setCombatMode "RED"; }; Obviously, there is a lot more that you could do here, but this should provide some simple random attacks. You will also need to fill in the names of the markers and the type of vehicle that spawns. You could also adjust the spawning and patrolling distance as well as change the odds that a vehicle spawns. You might want to make those parameters eventually. I have not tested this, sorry if there are any errors.
  12. I assume HC is headless client. The script handle returned by starting a new thread ('spawn' or 'execVM') would be a variable defined on the HC. You cannot publicVariable a script handle, it is considered a local data type. Another machine cannot terminate a thread running on the HC, as the handle cannot be defined there. You must store that script handle on the HC and remote execute a function on the HC to terminate the thread.
  13. BIS_fnc_endMission has local effect; that means that it can do different things on different machines. You need to create a function that determines which side a player is on, then calls BIS_fnc_endMission with different parameters depending on where that side won or lost. To set up these different endings see this page: http://community.bistudio.com/wiki/Debriefing For example, let there be a trigger that determines if Blufor has won. That trigger calls a function, 'BluforWin'. That function must execute on all clients. BluforWin could be something like this: BluforWin = { if ((side player) == west) then { 0 = "WinBlufor" call BIS_fnc_endMission; } else { 0 = "LoseOpfor" call BIS_fnc_endMission; }; }; You must, in your description.ext, define the classes 'WinBlufor' and 'LoseOpfor'. These classes are defined on all clients, but used only on some. You would have to duplicate the above function for the Opfor winning as well as set up the relevant classes.
  14. You are using the variable 'Tasks' like it is an array without declaring it as an array. The error likely indicates that 'count' cannot act on a string. Try this method: Tasks = []; Tasks set [(count Tasks), Task]; Declare 'Tasks' before checking to add strings to it, then append the string to the array with 'set'. The 'set' command is also faster than binary addition. Furthermore, 'Task_1' etc are not defined when being compared to 'done'. I assume that since these are global variables they are being declared elsewhere; it would be helpful if you posted where and how.
  15. You do not need the " mark after _x. doStop also accepts an array of units, so you could try: doStop ((getPosATL site) nearEntities ["Man", 200]);
  16. Get the position of the module (enter a name in the 'name' field; I use 'site' here) and use nearEntities like so: { _x setUnitPos "up"; } forEach ((getPosATL site) nearEntities ["Man", 200]);
  17. These are the lines in his script that will execute only for JIP players: T_JIP = true; [] spawn { waitUntil { !(isNull player) }; T_INIT = true }; He is using the same method as I posted, except opening a new thread and using global variables to sync. The second line forces the client to wait until enough data has been exchanged with the server to initialize the player. However, the script never uses 'T_INIT', and it defines a variable 'T_JIP' that is never used ('T_JP' is used, but never altered by the if block). It never uses T_Client or T_Server either. You do not need variables to determine who is client and server because you would just use 'isServer'. 'T_INIT' would always be true if you put the waitUntil loop as the first line of your init. Unless you have some special code for JIP players, they will execute the init exactly like other clients after they initialize. There is also 'isMultiplayer' and 'isDedicated'. I suggest that you think about what you need to know and check for only that information. Unless you have modified the code beyond JTS_2009's fix, I am surprised that it works. There is a lot that is unnecessary and does not quite make sense. If you want a code review and explanation, please post your entire working init. Nevertheless, I am glad it works for you.
  18. Zenophon

    Problems with adding weapons

    You are missing "" around the names of the equipment. Try this: this addPrimaryWeaponItem "muzzle_snds_H"; And so forth for the others. Make sure that the suppressor name matches the caliber of the weapon; there are different ones.
  19. I assume that #1 is about JIP. Add this to the top of the init: if (!isServer) then {waitUntil {!(isNull player)};}; I do not know what is the server is doing when you change player slots mid-mission; you may or may not be running the init.sqf again (seems like not). I would recommend restarting the mission to test again. If you want to switch between units put 'respawn=5' in your description.ext. Also, you can just define the function in the init instead of calling a script to define the function. You could even #include "functions.sqf" if you want.
  20. To make them invisible, use this: { _x hideObject true; } forEach (units AttackC); Regarding them firing, this command might help: http://community.bistudio.com/wiki/disableAI
  21. Firstly, what error do you get? Please provide the exact description and line number. Anyway, I would rewrite that script like this: private ["_i", "_flare"]; for "_i" from 1 to 10 do { if (({alive _x} count [f1, f2, f3, f4, f5, f6, f7]) == 0) exitWith {}; sleep 150; if ((_i % 2) == 0) then { _flare = createVehicle ["F_20mm_Yellow", (player ModelToWorld [100,0,0]), [], 0, "NONE"] } else { _flare = createVehicle ["F_20mm_Yellow", (player ModelToWorld [0,100,0]), [], 0, "NONE"]; }; _flare setPosATL [((getPosATL _flare) select 0), ((getPosATL _flare) select 1), 200]; _flare setVelocity [0,0,-10]; }; As _i switches from even to odd, the 'modelToWorld' argument will change. I have tested that without the exitWith statement and with a car; it seems to work.
  22. 1. Try this: http://community.bistudio.com/wiki/attachTo 2. You could set up a trigger and use this: http://community.bistudio.com/wiki/BIS_fnc_endMission You would need to call that function with different parameters for different players. You would also need a trigger with a condition that determined which team won.
  23. The init.sqf is a file located in your mission directory, it runs automatically at mission start. You might be interested in this page: http://community.bistudio.com/wiki/6thSense.eu:EG Second, a global variable is something that is not a keyword (such as a command like 'getPos') and does not start with an underscore. An example is 'Target1'; that variable can be accessed and modified by any function. A local variable in a function (example: '_unit') is defined only in that function and in all lower scopes. Functions called by another function are a lower scope. See this page: http://community.bistudio.com/wiki/Variables Regarding a timer, you could use 'sleep x;'. You may be interested in these too: http://community.bistudio.com/wiki/waitUntil http://community.bistudio.com/wiki/addEventHandler Further reading: http://community.bistudio.com/wiki/Code_Optimisation Edit: SQS is deprecated language that you do not need to use (I never have). SQF is the standard scripting syntax.
  24. How are you spawning the subs? I tried placing one in the editor and setting the elevation to -5 meters; it seemed to work fine. I assume the subs have no one in them, if so they should not move. If there are AI in the subs, you could try this: http://community.bistudio.com/wiki/swimInDepth
  25. Zenophon

    Big Strange Condition...

    Maybe if you said what those variables represent or how they are being defined, it would be easier to suggest a cleaner way of doing it. I am guessing that 'obj#ok' means that an object is alive. If so, you could use a simple script to count the number of living objects from an array. Or are the variables defined by some other condition? You could try something like this: switch ({_x} count [obj0ok, obj1ok, obj2ok, obj3ok, obj4ok, obj5ok, objxtraok]) do { case 2: { FINALMUYMALO=true; }; case 3: { FINALMALO=true; }; case 4: { FINALREGULAR=true; }; case 5: { FUNALBUENO=true; }; case 6: { FINALMUYBUENO=true; }; }; This code will determine how many of the booleans in the array are true and act accordingly. If this is not want you want, try implementing lazy evaluation, as described on this page: http://community.bistudio.com/wiki/a_%26%26_b
×