Jump to content

dreadedentity

Member
  • Content Count

    1224
  • Joined

  • Last visited

  • Medals

Everything posted by dreadedentity

  1. I don't really have any experience with playing sounds, but I did find this in the documentation for say which apparently is just say2D in stereo. "Unit will say given sound. When the Unit is a Person, it will also perform corresponding lipsync effect provided an appropriate .lip file has been created for this sound. A unit that has been killed or does not exist will not say anything. Compare this with playSound which will always play a sound at the location of the player. If the camera is not within given range, title is not shown and the sound will not be heard. Sound is defined in CfgSound of the Description.ext." So it makes sense that the music rises and drops, depending on what you're doing with your camera. Also, the muffling could possibly be from the camera moving between the player and an object like a building or something. It seems like the easiest way to fix this would be creating a new unit (or small object) to play your sound from, and using the script to keep him (or it) just behind the camera with setPos.
  2. dreadedentity

    Keep your powder dry

    You need to know the classname for the ammo before you can do anything with it with BIS's functions, if you do know that then: player removeMagazine "musketAmmo"; player addMagazine "ruinedMusketAmmo"; The way you're wording your posts and your "MAKE ARMA NOT WAR CONTESTANT" profile badge makes me think you're doing some kind of full conversion mod so you probably do know the classname already. That code is pretty self-explanatory, it just removes one magazine of "TYPE" and adds another one of "TYPE", you can change the object from "player" to anything you like. Although, if I remember my history correctly most weapons in the 18th century were muzzle-loaded and shooters stored their powder inside a bull horn bored out to be a container (these were supposedly waterproof but, hell, I wasn't alive in the 18th century). So I think to fit with history, when a player loads their musket, it would require some powder too. I'm sure that's more than a bit complicated to script in, but I'm all for realism and it would create a cool element where players won't be able to fire despite having ammo. For ease of display, you could even create the powder as a grenade type so it would be displayed right underneath the musket's actual ammo. Also, you wouldn't have to create a "ruined powder" item because powder would simply dissolve and disperse when submerged. Just a few thoughts.
  3. What exactly are you trying to do? I think you'll just have to write a script and attach it to each vehicle to execute it locally.
  4. I have a piece of code uses event handlers to check if a squad has been killed, for performance. However, it seems that I have no idea how to use them. I wrote up a small test script to try to understand more about them, but I'm just not getting it. Can somebody explain to me how to use these please? (btw, if you are going to test that code in a map those coordinates are just above and to the left of the 'a' in 'airfield' on stratis island. unitArray = createGroup west; missionNamespace setVariable ["1", group1 createUnit ["B_Soldier_F", [1690,5575,0], [], 0, "NONE"]] addEventHandler ["killed", hint "you killed the first unit."]; //originally, I had the addEventHandler's underneath the createUnit but they don't work. somehow I merged them with createUnit without getting a script error but they still don't work. //(unitArray select 1) addEventHandler ["killed", {[this] joinSilent grpNull;}]; missionNamespace setVariable ["2", group1 createUnit ["B_Soldier_F", [1690,5575,0], [], 0, "NONE"]] addEventHandler ["killed", {[this] joinSilent grpNull;}]; //(unitArray select 2) addEventHandler ["killed", {[this] joinSilent grpNull;}]; //commented this out because for some reason it throws //"Error zero divisor". When I researched the issue, I saw that the most relevant reason this error is thrown is if you try to access an //array index that doesn't exist. But this one does exist so I have no idea why an error gets thrown here. while {true} do { hintSilent format["%1", units group1]; [(units group1) select 1] joinSilent grpNull; //this works, the units get taken out of my squad correctly. }; The hint is shown as soon as I preview. I assume normal function of hint is supposed to go to all players, however, the unit was not killed so I don't understand why it's run. For the second unit, I assume that code is not run in the local scope of the unit, explaining why "this" doesn't work. I find that unnecessarily complicated and ridiculous.
  5. dreadedentity

    How exactly do I use event handlers?

    Thanks for the help, I just got my code to work. What I ended up doing was writing a custom spawn function and calling that within my script. FNC_createWithEH = { //taken parameters [unit, position, group] _object = (_this select 2) createUnit [(_this select 0), (_this select 1), [], 0, "NONE"]; _object addEventHandler ["killed", {[_this select 0] joinSilent grpNull;}]; _object //returns object }; This will take 3 parameters (just the parameters that are required to spawn units), create a unit, then apply the "killed" event handler to it. If the unit gets killed, it leaves the group. The function returns the object so you can name it whatever you want. An example of its use would be something like: _group = createGroup west; _number = 5 for "_i" from 1 to _number do { missionNamespace setVariable [format["%1", _i], ["B_Soldier_F", position player, _group] call FNC_createWithEH]; };
  6. dreadedentity

    Keep your powder dry

    while {true} do { // hintSilent format ["position above sea level: %1", (getPosASL player) select 2]; _state = animationState player; // hintSilent _state; }; At first I thought that you could check a player's position above sea level (at around -1 meter, a person's torso is submerged), then I thought you would have to make a custom event handler to reliably check that. BUT then I thought, wait there's already an event handler you can use which is "AnimChanged". So I think the best way to check this is to add an event handler and then check if the returned string is equal to the name for any of the swimming animations. Hopefully this will work (I'm still trying to learn event handler's, myself): this addEventHandler ["AnimChanged", { if (_this select 1 == "abswpercmstpsnonwnondnon") then { //replace some ammo with destroyed ammo or whatever }; }]; That is just the animation name for when a unit is floating still in the water. If you uncomment the second "hintSilent", and put it in an active script, you can see all of the animations for yourself (note: they are super long). Hopefully that gets you pointed in the right direction/direction you were looking for.
  7. dreadedentity

    disableAI "move" and setunitpos do not work!

    Post your script otherwise all I can say is your script is using the wrong names to execute commands. Both work just fine. Tested by going into editor, placing player, placing another unit and grouping it to player. In it's init I typed: this setUnitPos "DOWN"; this disableAI "MOVE"; Unit will not move. I've shot him, ordered him to move, and ordered him to get into a vehicle. Unit starts prone, but I can order him to change stance. (perhaps your squad leaders are ordering units to get up)
  8. I'm not sure about the advanced flight model, but I'm pretty sure there are no AI in your chopper. An easy way to tell is that a helicopter with no pilot slowly tips downward and to the right, until it eventually crashes. I'm pretty sure it was specifically programmed this way. (it was pretty "funny" when players would take all your helicopters in a mission in arma 2, fly up, click autohover and eject. sarcasm, of course, it wasn't funny at all.) Anyway where I'm getting with this is createVehicle only spawns an empty vehicle. You probably actually need AI in your helicopter. Luckily, this is very easy to do. Put this after your createVehicle: createVehicleCrew _myCustomVehicle; You could also use BIS_fnc_spawnVehicle; <--click that. Hope that helps
  9. I may be wrong since there are quite a number of quirks in the Arma engine that I haven't grasped yet, but the reason I see nested if's as a better option is because if the first condition is false, then the entire statement is skipped. But from what I understand about lazy evaluation from other languages I've used, all conditions are checked whether previous conditions are true or false. So without knowing if the Arma engine efficiently handles lazy evaluations, I saw nesting as the best option.
  10. Yes. That was just an example for concept. Of course you wouldn't check if the player is alive for your scripts, 99% require the player to be alive anyway.
  11. Exactly. I ran another few tests and it seems I was wrong about my initial assumption that the last units will never be deleted from the group. They are deleted but it is extremely slow, something like 20-30 seconds. That's much too slow, especially since they were removed one at a time, everyone might consider writing their own "alive" checks and removing dead units from groups. Purposefully done, I did this to highlight the fact that groups can be filled with dead units and still exist.
  12. Probably. But remember what Killzone_Kid said, It seems that the best way to cut down performance loss would be to use a ton of nested "if" statements if (alive player) then { if (player distance myCustomObject <= 5) then { //do a bunch of code }; }; Is inherently faster than if (alive player) and (player distance myCustomObject <= 5) then { //do a bunch of code }; It's the same code, despite being longer, and more confusing to keep track of. Why is this? It works faster because of the way "if" statements are handled in every programming language, ever. In the first code, if (alive player) returns false, BOOM done. Right there. The second "if" statement is skipped because all code inside the first "if" statement gets nuked if the condition is false, the game just no longer cares about what's in it. But in the second code, I believe the game will check both conditions, even if the first one is false. That is processing power your computer/the server is wasting. In fact, the fastest way might even be just creating a trigger with the radius being the distance you would like the script to be accessible from, setting the activation to Anybody present, make it repeatable, and type this in activation: for "_i" from 0 to (count thisList) do { (thisList select (_i)) addAction ["My Custom Action", "action.sqf", [], 6, true, true]; }; Now, there is a little problem with this that I didn't think about before I started writing it. After the first player walks in the trigger it fires, and it will not fire again until everybody has left the trigger radius. But I trust that you got it from here.
  13. dreadedentity

    Error if: Type Number, expected Bool

    Yeah, that was it, thanks a lot. Works like a dream now
  14. Hey all, Having a little trouble with a condition at the moment. Pulling my hair out because it should work perfectly. if ((_params select 0) * (_params select 0)) >= ((_posInTrigger select 0) * (_posInTrigger select 0)) + ((_posInTrigger select 1) * (_posInTrigger select 1)) then { hint "Circle check complete."; _loop = false; } else {}; //this else is only here because I thought I was going to add code, but I don't actually need it. This is just a simple hypotenuse (the line that connects 2 perpendicular lines to form a right triangle, if you forgot) length check. When the script runs, I get "Error if: Type Number, expected Bool" as a script error. So I've spent a fair bit of time looking for missed ), ], and ; but everything seems to be good. So I got a little creative. _bullshi = [0, 0, 0]; _bullshi set [0, (_posInTrigger select 0) * (_posInTrigger select 0)]; _bullshi set [1, (_posInTrigger select 1) * (_posInTrigger select 1)]; _bullshi set [2, (_params select 0) * (_params select 0)]; if (_bullshi select 2) >= (_bullshi select 0) + (_bullshi select 1) then //if ((_params select 0) * (_params select 0)) >= ((_posInTrigger select 0) * (_posInTrigger select 0)) + ((_posInTrigger select 1) * (_posInTrigger select 1)) then { hint "Circle check complete."; _loop = false; } else {}; Yet, again, "Error if: Type Number, expected Bool". What is wrong here? Thanks SOLVED: I FORGOT TO ENCLOSE THE CONDITION WITH PARENTHESIS
  15. Not sure about performance, but with the parameters you're passing to addAction, it might not have the effect you want. Those 2 bool values at the end are important. priority - I usually set my addActions with a priority of 6, to force my options to the top of the list. The default value is 1.5, so by setting 0 you're forcing it to the bottom of the list. showWindow (first bool) - Setting this to true will make it so that the action text appears just below the aiming reticule. Players will only know that you can read the signs if they happen to scroll their mouse wheel while looking at the sign, or have their action menu open while looking at the sign for some reason. hideOnUse (second bool) - Setting this to true will close the action menu after using your custom action. With the way you have it, the menu will stay open after use, possibly leading players to spam click, if your script doesn't have an immediate effect like if you have a sleep command in it (requires you to spawn a new thread). Depending on what you wanted to do, in your script you would removeAction to prevent players from running the script over and over again. But judging by the action text, you're not spawning any units, so you probably don't want/need to do that.
  16. dreadedentity

    Ferrying Squad Help

    to add to this, in case you don't know what you should put in the condition field, name your vehicle something then use this in the trigger count assignedCargo VEHICLE_NAME = NUMBER_OF_UNITS_IN_SQUAD assignedCargo adds all the units in a vehicle's cargo into an array, count counts the number of elements in an array. This works because units ordered into vehicles will attempt to get into cargo seats before filling crew positions (I think I remember reading this somewhere). Anyway, placing units in the editor or using the createUnit function in a script will spawn units with full crew positions anyway.
  17. dreadedentity

    How to script in a president slot

    You're asking for a lot here. Do you have a money system set up? A voting system? A job system? Recurring payments? A tax system? Shops? I'm really tired right now, but I wrote some code that might help you. It should all work okay. isPresident = player0; //not sure how null works in arma 3 so this is a throwaway value almostPres = player0; highestVotes = 0; voteArray = [ARRAY WITH ALL PLAYERS]; //you'll probably need this to keep track of votes voteNumbers = [0]; // voteTie = []; //not sure how you're going to handle the voting part, maybe a GUI box that players can click on to vote for their friends? { if (voteArray select (_x - 1)) > highestVotes then { call compile format ["almostPres = player%1;", _x]; }; } forEach voteArray; //{ // if ((voteArray select (_x - 1)) = highestVotes) then // { // voteTie set [_x, = // This code was supposed to check for ties and then order a re-vote but I'm too tired to think isPresident = almostPres; //"officially" makes the president the president isPresident setPos [houseXCoord, houseYCoord, houseZCoord]; //teleports president to his house and if someone could tell me how to make the PHP Code that would be nice, I just use "code" and "/code" and my code doesn't have cool colors Good Luck
  18. I'm posting my reply now but I'm going to keep looking at it and make edits with additional things, if I find them. Not sure what this was so I looked at the documentation for exitWith. "When you use exitWith not inside a loops, the behaviour is undefined - sometimes it may exit the script, sometimes some other scope, but this is not intended and designed behaviour of this command, and it is not guaranteed to work reliably. It exits the loop only, not the script." I think we've found the source of your unreliability. So if you just used a normal if-then statement that executed your code, it should work more reliably. SMO_SpawnPatrolGroup = { _spawnGroup = [getMarkerPos markerSpawn, EAST, ["O_Soldier_TL_F", "O_Soldier_F"]] call BIS_fnc_spawnGroup; _spawnGroup }; I believe if you put this function declaration in your init.sqf, it will be compiled at the beginning of the mission, whereas now it compiles right after the trigger is activated and then it runs. Since this is a globally defined function, you shouldn't keep it within your script. Here is the documentation for addEventHandler An important quote from that page, "Multiplayer: Event handlers are persistent (i.e. they stay attached to a unit, even after it dies and respawns)." It seems that you should remove the Event upon each unit's death using removeEventHandler Good Luck EDIT: Also, please make sure you have good formatting for your code. I'm pretty new to the BIS forums, and their code, but when I was active on other coding forums I would sometimes completely skip over posts from people with terrible/no formatting. So if anyone wants to look over the code, I have already formatted it so I could dissect it. Here you go: if (!isServer) exitWith {}; markerSpawn = "spawnPatrol2"; _doAutoRespawn = true; SMO_SpawnPatrolGroup = { _spawnGroup = [getMarkerPos markerSpawn, EAST, ["O_Soldier_TL_F", "O_Soldier_F"]] call BIS_fnc_spawnGroup; //remove the underscore ( _ ) in the beginning of the variable name to make it a global variable, if you plan on moving the function to init.sqf _spawnGroup //not sure why this is here, could probably remove it without it having any effect. }; _thisSpawnedGroup = call SMO_SpawnPatrolGroup; // check if unit exists, if not, spawn a new one: if (_doAutoRespawn) then { //Add event Handler to each unit of group, do something when all are dead { _x addEventHandler ["killed", { _grp = group (_this select 0); //firstly, the group function doesn't take arrays for it's argument, //secondly, I've seen no other code that //modify's _this, so you probably don't need to have this. //Try using just "_grp = group _this". if ({ alive _x } count units _grp < 1) then { player sideChat "All units from the group have died!"; _thisSpawnedGroup = call SMO_SpawnPatrolGroup; }; }]; } forEach units _thisSpawnedGroup; } //not sure if this makes a difference since it's at the end of the script, but you forgot a semicolon at the end of this "if" statement. Your code "if (_doAutoRespawn) then" doesn't actually check if the units are dead, it just checks whether or not you set a variable to true. Here's the documentation for units Try this code instead: if (spawnGroup = grpNull) then //checks if group "spawnGroup" is empty, meaning all the units in it have been killed OR if (count units spawnGroup = 0) then //counts the units in "spawnGroup" and checks if it is 0, meaning all the units in it have been killed OR if (units spawnGroup = []) then //takes the unit array of "spawnGroup" and checks it, [] (supposedly) means it is empty, all of the units in it have been killed Please forgive me if my code doesn't work, or if I am completely wrong with my explanations. I don't actually test these codes unless I explicitly say in one of my posts that I am. I'm mostly just using the documentation for various functions and my programming experience.
  19. dreadedentity

    Spawning a group on a marker

    Here you go buddy, https://community.bistudio.com/wiki/Arma_3_CfgVehicles_GUER And you also have blufor, and opfor. And overall page with all Arma 3 assets. (weapons, vehicles, magazines) https://community.bistudio.com/wiki/Arma_3_Assets EDIT: Oops, Baconator got to it first. When I refreshed the page, I didn't see that there was a second page.
  20. Hello all, I am beginning to experiment with more high-level scripting commands, to make the missions I create for my group much better, but I've hit a snag while trying to spawn some units after certain conditions have been met by one of my players. Here are the documentation's for call, compile, and format. I feel that the explanations are more convoluted than they need to be. Anyway, I'm just wondering if this code: { call compile format["group%1 = createGroup west;", (_x + 1)] } forEach [1, 2, 3, 4, 5] will create 5 empty BLUFOR groups, named, group1, group2, group3, group4, and group5. Thanks. EDIT: And can also be used for variables. So if I changed that to be something like: { call compile format["var%1 = (_x + 1);", (_x + 1)] } forEach [1, 2, 3, 4, 5] Then will I now have 5 variables named var1, var2, var3, var4, and var5 that I can use in other code? Thanks again.
  21. dreadedentity

    Quick question on dynamic variable names

    Thanks for the reply Haha thanks, not sure what was going through my mind. I thought I had to use the array index for some reason, so that's why I added 1 to it. I'm having a little trouble with a mission I'm making using call compile format (will change it to missionNamespace setVariable in a bit), but I don't want to start a new thread for it. { call compile format["[[15500 + (_x * 100), 14000 + (_x * 100), 100], 315, ""B_Heli_Attack_01_F"", aiHeli%1] call bis_fnc_spawnvehicle;", _x]; } forEach [1, 2, 3, 4, 5, 6]; { call compile format ["aiHeli%1 move (getPos OPtank%1);", _x]; } forEach [1, 2, 3, 4]; aiHeli5 move (getPos OPheli1); aiHeli6 move (getPos OPheli1); The Blackfoot's spawn fine, but they don't move to the enemy units! They prefer to stay right where they spawned and fire guided rockets from there. It's just not going to be a proper invasion if blufor doesn't flex their muscles a bit. How can I force them to move closer to their targets before firing?
  22. dreadedentity

    AI not getting out of Assault boats

    Alright, thanks for the help Ranger
  23. I wanted to make a beach insertion with inflatable landing craft. I have a boat named "boat1" which is not grouped to my units and my squad all with "this moveInCargo boat1;" in their INIT fields (this works fine). Now, the boat has a TRANSPORT UNLOAD waypoint set on the beach, but when it gets there it kicks me out but none of my squad. This is really confusing me because I made a quick helicopter insertion before I worked on this mission and the T UNLOAD worked perfectly. I believe it may have something to do with the waypoint placement being unreachable with the boat (too far inland) because when I manually order my squad to disembark, the boat driver continues with his waypoints, which are exiting the boat and then joining my squad. One last piece of supporting evidence, I removed the JOIN waypoint and added that code to the UNLOAD's "On Act." field but that also doesn't run until I manually order my squad to dismount. I don't know why this isn't working and I've tried everything I can think of so if somebody more experienced could help me figure this out, that'd be great. NOTE: The beach landing consists of 4 boats (hence boat1) intended to be led by human players, but for testing purposes requires AI. I have watched the other squads disembark properly but I'm not sure if that's because of a successful UNLOAD or because the squad leaders are ordering their troops to disembark. Not sure if that makes a difference. Thanks.
  24. dreadedentity

    Spawning a group on a marker

    How are you trying to spawn these units? It looks like you want to spawn 2 units at 10 positions. _newGrp = createGroup west; _mkr1Pos = getMarkerPos "mkr1"; _loop = 1 while (_loop < 10) do { _unit = _newGrp createUnit ["B_Soldier_F", _mkr1Pos, ["mk1", "mkr2", "mkr3], 0, "NONE"]; _loop = _loop + 1; // ^ He forgot a quote here so that's why this didn't work. }; Use Baconator's code and modify it to do what you want. This is what I came up with. _newGrp = createGroup west; //create a new group of BLUFOR soldiers _markerArray = [getMarkerpos "spwnpos1", getMarkerpos "spwnpos2", getMarkerpos "spwnpos3", getMarkerpos "spwnpos4", getMarkerpos "spwnpos5", getMarkerpos "spwnpos6", getMarkerpos "spwnpos7", getMarkerpos "spwnpos8", getMarkerpos "spwnpos9", getMarkerpos "spwnpos10"]; //setting up an [url="https://community.bistudio.com/wiki/Array"]Array[/url] with the positions of all your spawners. { { _unit = _newGrp createUnit ["B_Soldier_F", _markerArray select _x, [], 0, "NONE"]; //nested loop makes a blufor soldier named _unit, part of _newGrp, and cycles through all 10 spawn locations } forEach [1, 2]; //made a trash array with no name, just to spawn 2 units } forEach _markerArray; //lastly, _x is a local variable that forEach uses for it's index, that's why we don't have to define it but can use it. The spawn code I posted earlier using _x was just bad practice, don't do that. This code will cycle through each spawn location, one by one, spawning 2 units. If you switch around "_markerArray" and "[1, 2]" it will create 1 unit at all the locations, but go through it twice. That could be useful if you're trying to get the units spread out quickly. Good Luck
  25. dreadedentity

    Spawning a group on a marker

    Use the createUnit (array) function Object = group createUnit [type, position, markers, placement, special] Object: A variable. Use this to manipulate the unit you are about to create. Group: You need to create a group firsthand or something. Use this code in the INIT field on your squad leader: group1 = group this; "group1" is the name of the group and "group" is the command to create groups "this" literally refers to [b]this[/b] game object Or do whatever you want. Position: [x, y, z] Markers, Placement, Special: The documentation is super weak for these last 3 parts. I have no idea what markers are but, literally, as I typed this sentance, I realized what placement and special are. Placement: When you place a unit down in the editor, "Placement Radius" is the box above "OK". I guess this number (in meters) means how far away a unit may spawn from where you put the unit down in the editor. Special: Above "Control" when you put down a unit in the editor. None, Flying, In Cargo, In Formation are the types. Here's a little example that I'm using in a mission right now: _x = group1 createUnit ["B_Soldier_F",(getPos player1),[],0,"None"]; B_Soldier_F is a blufor rifleman so use this page to pick out which unit you want to spawn. (getPos player1) probably isn't very helpful to you because you'll be spawning your enemy units directly next to your player (talk about an element of surprise!) Instead, replace that with [x, y, z] and fill in your coordinates. Conveniently, if you look at the bottom in the editor, you can see the coordinates down to the 1/10th meter. Put your createUnit function in "On Act." field of the trigger you want to set off the ambush. Hope this helps. EDIT: This method requires at least one enemy unit to be present so you can make a group. Without it, you won't be able to spawn the other units. Since I don't know how to make an empty group, this is the best I could do.
×