Jump to content

Grumpy Old Man

Member
  • Content Count

    4333
  • Joined

  • Last visited

  • Medals

Everything posted by Grumpy Old Man

  1. Grumpy Old Man

    Addaction in building doors

    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
  2. Grumpy Old Man

    help with eventHandler please!

    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
  3. Grumpy Old Man

    [Release] GOM - Aircraft Loadout V1.35

    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
  4. Grumpy Old Man

    Remove item from backpack in box

    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
  5. 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
  6. Grumpy Old Man

    Faster than logic

    I guess that refers to the garbage collector. You can always test stuff. Cheers
  7. Grumpy Old Man

    Faster than logic

    You could also use deleteGroupWhenEmpty. Cheers
  8. Grumpy Old Man

    help with eventHandler please!

    It's basically select without enhanced syntax but higher precedence. Pretty neat for better readability. Cheers
  9. Grumpy Old Man

    help with eventHandler please!

    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
  10. Grumpy Old Man

    help with eventHandler please!

    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
  11. Grumpy Old Man

    Detect open windows

    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
  12. Just don't forget to post a solution if you found one, though the example on the wiki should be close enough, heh. Cheers
  13. Well you could use drawIcon on map display (12 ctrl 51 as seen on the wiki I guess?). Cheers
  14. The post you're quoting is from @Larrow though, I didn't even post in this thread, heh. Cheers
  15. 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
  16. 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
  17. Grumpy Old Man

    Scripted Takecover for ai.

    Setting the behavior to "STEALTH" should do just that. Cheers
  18. 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
  19. 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
  20. Grumpy Old Man

    show script error

    You're still getting script errors? Cheers
  21. 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
  22. Why not use initPlayerLocal.sqf? Cheers
  23. Grumpy Old Man

    [Release] GOM - Aircraft Loadout V1.35

    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
  24. Grumpy Old Man

    [Release] GOM - Aircraft Loadout V1.35

    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
  25. Grumpy Old Man

    [Release] GOM - Aircraft Loadout V1.35

    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
×