-
Content Count
4333 -
Joined
-
Last visited
-
Medals
Everything posted by Grumpy Old Man
-
Addaction in building doors
Grumpy Old Man replied to Cigs4's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Well there's plenty of ways to implement it. You can have a GUI that displays all buildings within your radius, work with a predefined array of buildings to purchase, or have another addAction to purchase the building you're looking at. As long as you pass a building object and owner the script will do its job. You can put the functions into initPlayerLocal.sqf or however you seem fit. Cheers -
help with eventHandler please!
Grumpy Old Man replied to DarkViper98's topic in ARMA 3 - MISSION EDITING & SCRIPTING
You can easily track shots via fired EH and use setVariable to store them, same principle as above applies here, just use the shots for the lockout instead of the time. Cheers -
[Release] GOM - Aircraft Loadout V1.35
Grumpy Old Man replied to Grumpy Old Man's topic in ARMA 3 - MISSION EDITING & SCRIPTING
To refuel/repair/rearm ground vehicles you can simply park them next to support vehicles. Besides a few hidden selections or textures, there's not much to customize on a ground vehicle. You can also take a look at my vehicle tuning script for that. Cheers -
Remove item from backpack in box
Grumpy Old Man replied to MFiveASP's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Something like this should work: { clearMagazineCargo (_x # 1); } forEach everyContainer ammocrate; Just make sure to use the proper clearXY commands for items, magazines etc. respectively. Cheers -
( SOLVED) how do i delete a B_IRStrobe that have been created by CreateVehicle
Grumpy Old Man replied to Play3r's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I'd do something like this: strobe = "B_IRStrobe" createVehicle position ammobox; strobe attachTo [ammobox, [0, 0., 0.40]]; //delete strobe and light fx: _delete = [] spawn { sleep 5; _fx = attachedObjects strobe; { deleteVehicle _x } forEach (_fx + [strobe]); }; Cheers -
I guess that refers to the garbage collector. You can always test stuff. Cheers
-
You could also use deleteGroupWhenEmpty. Cheers
-
help with eventHandler please!
Grumpy Old Man replied to DarkViper98's topic in ARMA 3 - MISSION EDITING & SCRIPTING
It's basically select without enhanced syntax but higher precedence. Pretty neat for better readability. Cheers -
help with eventHandler please!
Grumpy Old Man replied to DarkViper98's topic in ARMA 3 - MISSION EDITING & SCRIPTING
The variable TAG_fnc_suppressLockout holds the time from which the script shall continue again. -10 is used as a cautionary measure, allowing the script to work at mission start. It's basically the init value. The variable time basically holds the runtime of the mission, starting with 0 at mission start. Assuming the mission is running for exactly 5 minutes (300s) and random [6,8,13] returns 7.5, the EH will exit until time returns more than 307.5. Cheers -
help with eventHandler please!
Grumpy Old Man replied to DarkViper98's topic in ARMA 3 - MISSION EDITING & SCRIPTING
So you basically want a temporary timed lockout within the eventhandler, so it only fires at most every n seconds? Your snippet could also use a good amount of simplification and a few adjustments. It's usually best practice to put the most likely exit condition at the top and only continue the script if it doesn't apply. Also in this case you really don't need an alive check, since dead units can't say stuff through the say/say3D/say2D commands. I'm also not sure if you understand the firedNear EH, it only gets executed when someone within ~69m of the EH unit is using a weapon, not if anyone is getting shot at, at least that's what I think you expect from the EH, judging by your first paragraph. What exactly are you expecting from this: {_firer = _x;} forEach _soldiersWEST; _firer = _this select 1; The second line makes the first one obsolete. Same here: _WeaponFirer = primaryWeapon _firer; _WeaponFirer = _this select 3; You can also simplify this: _chanceSuppress = if ((random 100) >= 50) then {true} else {false}; //should be expressed like this: _chanceSuppress = random 100 >= 50; There's also no need to compare primaryWeapon _firer to _Weaponfirer, since this will essentially be the same. This check is also rather obsolete, since a unit will always belong to a group unless you designate it to grpNull: if (count _unitsSuppress <= 1) then { You can use an exitWith condition and exit with the say for a single unit, if the group only holds one unit, depends on how you want this to play out, easy enough to modify it to your needs, heh. Here's a tidied up version: TAG_fnc_suppressSound = { params ["_unit"]; sleep random [0.8,1.2,1.8]; _unit say3D [selectRandom ["suppress1", "suppress2", "suppress3", "suppress4", "suppress5"], 100, 1] }; _soldier addEventHandler ["FiredNear", { params ["_soldier","_firer","","_WeaponFirer"]; if (side _soldier isEqualTo side _firer) exitWith {false};//remove this if needed _chanceSuppress = random 100 >= 50; if !(_chanceSuppress) exitWith {false}; _unitsSuppress = units group _soldier; if (count _unitsSuppress isEqualTo 1) then { if (random 100 >= 75) then { (_unitsSuppress#0) spawn TAG_fnc_suppressSound; }; }; if (random 100 >= 75) then { (selectRandom _unitsSuppress) spawn TAG_fnc_suppressSound; }; }]; This will play the suppression sound after a short delay to simulate human reaction time. Now for the timed lockout to prevent spam you can do something like this: TAG_fnc_suppressSound = { params ["_unit"]; sleep random [0.8,1.2,1.8]; _unit say3D [selectRandom ["suppress1", "suppress2", "suppress3", "suppress4", "suppress5"], 100, 1] }; _soldier addEventHandler ["FiredNear", { params ["_soldier","_firer","","_WeaponFirer"]; _lockoutTime = group _soldier getVariable ["TAG_fnc_suppressLockout",-10]; if (time < _lockoutTime) exitWith {false}; group _soldier setVariable ["TAG_fnc_suppressLockout",time + random [8,12,15]]; if (side _soldier isEqualTo side _firer) exitWith {false};//remove this if needed if (random 100 <= 50) exitWith {false}; _unitsSuppress = units group _soldier; if (count _unitsSuppress isEqualTo 1) then { if (random 100 >= 75) then { (_unitsSuppress#0) spawn TAG_fnc_suppressSound; }; }; if (random 100 >= 75) then { (selectRandom _unitsSuppress) spawn TAG_fnc_suppressSound; }; }]; This will exit the EH if the lockout is still active, so it will only activate between every 8-15 seconds after last activation. You can adjust the frequency with the "random [8,12,15]" bit, the values being min,mid,max. In this case it will average around 12. I also put the sound stuff in its own function. Should get you started, though I think firedNear is the wrong EH for something like this. Cheers -
You could do with lineIntersect and check every building position, similar to example 2 in a post I made: Other than that if it's for vanilla buildings on maps like takistan then you could go through all buildings and add them manually to an array, shouldn't take too long. Cheers
-
[Solved] Custom marker dimensions
Grumpy Old Man replied to anfo's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Just don't forget to post a solution if you found one, though the example on the wiki should be close enough, heh. Cheers -
[Solved] Custom marker dimensions
Grumpy Old Man replied to anfo's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Well you could use drawIcon on map display (12 ctrl 51 as seen on the wiki I guess?). Cheers -
Turning all map objects into super simple objects in EDEN.
Grumpy Old Man replied to LSValmont's topic in ARMA 3 - MISSION EDITING & SCRIPTING
The post you're quoting is from @Larrow though, I didn't even post in this thread, heh. Cheers- 20 replies
-
- 3
-
- objects
- simple objects
-
(and 2 more)
Tagged with:
-
Random buildingPos in a random building
Grumpy Old Man replied to iV - Ghost's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Why the excessive use of private? You could approach it like this: //init.sqf or where you think fits best TAG_fnc_occupiedPositions = []; TAG_fnc_availablePositions = []; _allBuildings = nearestObjects [_markerpos,["building"],100]; _allBuildings apply {TAG_fnc_availablePositions append (_x buildingPos -1)}; //when spawning a unit if !(TAG_fnc_availablePositions isEqualTo []) then { _posIndex = round random count TAG_fnc_availablePositions - 1; _pos = TAG_fnc_availablePositions # _posIndex; _unit = createGroup east createUnit [typeOf player,_pos]; TAG_fnc_occupiedPositions pushBack (TAG_fnc_availablePositions deleteAt _posIndex);//move position to occupied array _unit setVariable ["TAG_fnc_spawnPosID",_posIndex]; _unit addEventHandler ["Killed",{ params ["_unit"]; _posIndex = _unit getVariable ["TAG_fnc_spawnPosID",-1]; TAG_fnc_availablePositions pushBack (TAG_fnc_occupiedPositions deleteAt _posIndex); diag_log format ["Unit died - Clearing position index %1",_posIndex]; }]; } else { diag_log "Cancelled AI spawn - no more available positions" }; Not tested and just quickly typed, should work though, adjust as you seem fit. This will allow to only spawn one unit per position and locks the position until the unit has died. Should get you started. Cheers -
Random buildingPos in a random building
Grumpy Old Man replied to iV - Ghost's topic in ARMA 3 - MISSION EDITING & SCRIPTING
While nearEntities is pretty fast and checks a sphere this will only work if the units are stationary on the building positions. You could have 2 arrays, one holding all positions, and another one holding all occupied positions. When you spawn a unit you can check if the position is already occupied, if not spawn a unit there and put the position into the occupied array. You can free occupied positions either by a killed eventHandler or after a certain time, plenty of ways to go about this. Cheers -
Scripted Takecover for ai.
Grumpy Old Man replied to Robustcolor's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Setting the behavior to "STEALTH" should do just that. Cheers -
AddAction for multiple AI units. Possible?
Grumpy Old Man replied to Nicoman35's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Ah, I see. Well you can always have an array of all mortar units and go from there, like so: //inside mortar group team leader or whatever you seem fit TAG_fnc_mortarUnits = units group this; //initPlayerLocal.sqf or similar player addAction ["Mortars rearm!",{ params ["_object","_caller","_ID"]; _needRearm = TAG_fnc_mortarUnits select {/*your rearm condition*/}; hint format ["Mortars need rearm:\n\n%1",_needRearm]; { //rearm stuff here } forEach _needRearm; }, [], 1, true, true, "", "_target == _this and count (TAG_fnc_mortarUnits select {/*your rearm condition*/}) > 0"]; This action will only be visible if at least one unit from the mortar array matches the filter condition and execute the rearm code on all units in need of rearming. Adjust rearm code and condition as needed, should get you started. Cheers -
AddAction for multiple AI units. Possible?
Grumpy Old Man replied to Nicoman35's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Well you can have one action on every unit, that adds units to an array and then another action that does something with all units in that array, if I understood your intentions correctly. Cheers -
You're still getting script errors? Cheers
-
Using initPlayerServer.sqf ?
Grumpy Old Man replied to gc8's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Sure, local to each client and passes player object, as you stated in your second post. If you need to pass player object to the server you can always use initPlayerLocal.sqf with remoteExec. Be more specific about what you want to achieve, maybe initPlayerServer will work better, the notion that "initPlayerServer.sqf should be avoided" which you quoted is not a general statement and related to a specific use case of CfgRemoteExec. Cheers -
Using initPlayerServer.sqf ?
Grumpy Old Man replied to gc8's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Why not use initPlayerLocal.sqf? Cheers -
[Release] GOM - Aircraft Loadout V1.35
Grumpy Old Man replied to Grumpy Old Man's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Just did some more testing of the damage stuff: onEachFrame { _veh = test; _part1 = getAllHitPointsDamage _veh # 2; _part2 = getAllHitPointsDamage _veh #2 findIf {_x > 0}; _part3 = getAllHitPointsDamage _veh #2 # (0 max (getAllHitPointsDamage _veh #2 findIf {_x > 0})); hintSilent format ["Hitpoints Damage:\n%1\n\nHitpoint Index:\n%2\n\nReturned Damage:\n%3\n\nVehicle Damage:\n%4",_part1,_part2,_part3,damage _veh]; } This can be used to test certain vehicles for damage, returning a hitpoints damage values array, the index of a damaged hitpoint (-1 if not found), the damage amount of the first found damaged hitpoint (0 if nothing is damaged) and the vehicle damage (which for some reason will return 0 even if a vehicle has some damaged hitpoints). So to return if ANY part of a vehicle has been damaged, the _part3 variable will do, like so: //line 1025 in scripts\GOM\functions\GOM_fnc_aircraftLoadoutInit.sqf _curDamage = getAllHitPointsDamage _veh #2 # (0 max (getAllHitPointsDamage _veh #2 findIf {_x > 0})); This should work, unless there's something odd at play, maybe some .rpt logs might provide further info if it still doesn't work. Cheers -
[Release] GOM - Aircraft Loadout V1.35
Grumpy Old Man replied to Grumpy Old Man's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Could be, the snippet I posted should return any damage on any hitparts of the vehicle, so not sure why it's not working, would be worth investigating further if vanilla vehicles are also affected. Nice, I like it, keeps the center of the screen free to observe, heh. Cheers -
[Release] GOM - Aircraft Loadout V1.35
Grumpy Old Man replied to Grumpy Old Man's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Seems odd, getAllHitPointsDamage returns all data needed, unless there's something off with the vehicle (mod I assume?). Can you try with a vanilla chopper and see if it's the same issue? Cheers