Jump to content

Grumpy Old Man

Member
  • Content Count

    4313
  • Joined

  • Last visited

  • Medals

Everything posted by Grumpy Old Man

  1. Grumpy Old Man

    [SOLVED] Addaction run once

    In the script parameter. Cheers
  2. Grumpy Old Man

    [SOLVED] Addaction run once

    With multiple actions on the same object this could lead to unwanted removal of actions added by other scripts/addOns. Cheers
  3. Grumpy Old Man

    [SOLVED] Addaction run once

    Inside the addAction: _this#0 removeAction _this#2 Cheers
  4. Grumpy Old Man

    Draw circle on terrain in script

    For using proper math you'd use something like this: _centerPos = getPosATL player; _centerPos params ["_centerPosX","_centerPosY"]; _distance = 20; _angle = 2;//will place objects every 2° for "_i" from 0 to (360-_angle) step _angle do { "Sign_Arrow_F" createVehicle [_distance*cos(_i) + _centerPosX,_distance*sin(_i) + _centerPosY]; }; Basic formula to get positions of a circle. Cheers
  5. On a sidenote, you can look at script commands sorted by functionality: Go to the Scripting Commands page Click Scripting Commands by Functionality Click Command Group: Markers All there in plain text. Cheers
  6. Pretty much this. Working with grids should be pretty mandatory in a game like this, I usually prefer to hand out target locations like that. 8 digit grid should be precise enough for buildings, though I usually prefer to flatten the approximate 4 digit grid area with a 15 minute barrage of 230mm MLRS. Here's some functions to convert position to 6/8/10 digit grid and 6/8/10 digit grid to map position: GOM_fnc_gridToPos = { params ["_grid"]; _count = count _grid; _banana = _count / 2; _multis = [1,10,100]; _counts = [10,8,6]; _multi = _multis select (_counts find _count); _posX = (parseNumber (_grid select [0,_banana])) * _multi; _posY = (parseNumber (_grid select [_banana,_banana + _banana])) * _multi; [_posX,_posY,0] }; GOM_fnc_posToGrid = { params ["_pos",["_gridSize",6,[0]]]; _divisors = [100,10,1]; _gridSizes = [6,8,10]; _divisor = _divisors select (_gridSizes find _gridSize); _gridResolution = _gridSize / 2; _pos params ["_posX","_posY"]; _posX = str round floor (_posX / _divisor); _posY = str round floor (_posY / _divisor); while {count _posX < _gridResolution} do { _posX = "0" + _posX; }; while {count _posY < _gridResolution} do { _posY = "0" + _posY; }; _posX + _posY }; Cheers
  7. Grumpy Old Man

    Why doesn't this code work?

    {if (side = civilian) Can't work. Side requires an argument, check the syntax. The equal sign assigns a value to a variable, you need double equal signs for a comparison (==) or isEqualTo. Cheers
  8. Grumpy Old Man

    Open/Lock doors from container

    Animations using animate command won't animate when called from init field, since the init field of objects is called before the mission begins. Add a spawn and a sleep, should usually do the trick. Cheers
  9. Something like this could do: //init.sqf GOM_fnc_unitKnowsAboutSide = { params ["_unit","_side",["_range",viewDistance]]; count (_unit nearTargets _range select {_x#2 isEqualTo _side}) > 0; }; //simple loop to test: _loop = [civ,west] spawn { waitUntil { hintSilent format ["Waiting for %1 targets...",_this#1]; _this call GOM_fnc_unitKnowsAboutSide }; hintSilent format ["%1 target found!",_this#1]; }; //to check from trigger: [yourCiv,west] call GOM_fnc_unitKnowsAboutSide The check is extremely fast, probably better to ditch the function (adds quite some overhead) and just use the count nearTargets line to match your needs. Cheers
  10. Quick? That happened 4 years ago, how about that? Heh... Cheers
  11. Here's what I was using back in the days. Cheers
  12. Your example shouldn't run in the first place, the function definitions have the prefix GOM, then later down the line you changed it to GRM, so there's that. The # command is greedy or whatever's the term, so an additional bracket is needed: _targetPos = (effectiveCommander _mortar targetKnowledge (selectRandom _nearby))#6; (effectiveCommander _mortar) commandArtilleryFire [_targetPos,_mag,_rounds]; Cheers
  13. What do you mean with "almost"? Your question was: Does exactly what you asked for. You can adjust the condition and other stuff as you seem fit. Currently they're firing as long as anyone on their side knows about the target: side _mortar knowsAbout _x > 0 You can increase the number from 0 up to 4, which means they will only fire if you've recently revealed yourself (it's a bit more complicated but that about sums it up). Also you could use targetKnowledge (parameter 7) to fire on the position the enemy last saw you at: //replace this line: (effectiveCommander _mortar) commandArtilleryFire [(getPosATL (selectRandom _nearby)),_mag,_rounds]; //with the following: _targetPos = (effectiveCommander _mortar targetKnowledge (selectRandom _nearby)#6); (effectiveCommander _mortar) commandArtilleryFire [_targetPos,_mag,_rounds]; Cheers
  14. Grumpy Old Man

    Open/Close Bargate solution !

    Not sure what you want, you can't lock the bargate with a key, the setVariable option you mentioned only works on building doors from what I know. Your only way would be to bruteforce the bargate closed if no blufor is nearby, if that's what you want: _gateStuff = [gate] SPAWN { params ["_gate"]; while {alive _gate} do { //small delay before closing the gate again sleep 5; waitUntil { _gate animate ["Door_1_rot", 0]; count (_gate nearEntities 8 select {side _x isEqualTo west}) > 0 }; _gate animate ["Door_1_rot", 1]; waitUntil {sleep 1; count (_gate nearEntities 8 select {side _x isEqualTo west}) == 0}; _gate animate ["Door_1_rot", 0]; }; }; Cheers
  15. Grumpy Old Man

    A way to "Spawn" Trigger?

    Depending on trigger activations this might not work since a trigger automatically deactivates once its condition is no longer met. Given the example of both triggers being activated by blufor units, as soon as no blufor unit is inside the trigger1 area, the trigger will deactivate and triggerActivated trigger1 returns false. Works like a toggle, in the case of the thread starter a switch like behavior is needed. Cheers
  16. Grumpy Old Man

    A way to "Spawn" Trigger?

    You can do this very easily, trigger1 onAct field: missionNamespace setVariable ["GOM_fnc_switch1",true] In trigger2 condition field: this AND missionNamespace getVariable ["GOM_fnc_switch1",false] Cheers
  17. Grumpy Old Man

    Group icons on map

    Well you'd have to find a way to call those functions anyway, so there's no way around using a script in the first place. I guess HC modules simply go through the config, no idea how to access group icons otherwise, group icons are defined via cfgGroupIcons. Cheers
  18. Grumpy Old Man

    Group icons on map

    Quickly threw this one together: findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", " _display = _this#0; { _icon = getText (configfile >> 'CfgVehicles' >> typeof _x >> 'icon'); _display drawIcon [ _icon, [0,0,1,1], getPosVisual _x, 24, 24, getDirVisual _x, name _x, 1, 0.03, 'TahomaB', 'right' ]; _display drawLine [ getPosVisual _x, getPosVisual leader _x, [0,0,1,1] ]; } forEach allUnits; { _offSet = [50,50,0]; _iconPos = getPosVisual leader _x vectorAdd _offSet; _icon = getText (configfile >> 'cfgGroupIcons' >> _x getVariable ['GOM_fnc_groupIcon','b_inf'] >> 'icon'); _grpInfoText = _x getVariable ['GOM_fnc_groupInfoText','Unnamed']; _display drawIcon [ _icon, [1,1,1,1], _iconPos, 24, 24, 0, _grpInfoText, 1, 0.03, 'TahomaB', 'left' ]; _display drawLine [ _iconPos, getPosVisual leader _x, [0,0,1,1] ]; } forEach allGroups; "]; This will draw all units as icons, lines from each unit to its group leader and a designated group icon with customizable offset with another line connecting it to the respective group leader. You can add custom info per group like this: group this setVariable ["GOM_fnc_groupInfoText","1st Airborne"];//some random text you want group this setVariable ["GOM_fnc_groupIcon","b_air"];//has to be valid icon class from configfile >> "cfgGroupIcons", defaults to "b_inf" Cheers
  19. Grumpy Old Man

    Open/Close Bargate solution !

    playerSide will be different on every client, just use nearEntities to filter for west units: _gateStuff = [gate] SPAWN { params ["_gate"]; while {alive _gate} do { waitUntil {sleep 1; count (_gate nearEntities 8 select {side _x isEqualTo west}) > 0}; _gate animate ["Door_1_rot", 1]; waitUntil {sleep 1; count (_gate nearEntities 8 select {side _x isEqualTo west}) == 0}; _gate animate ["Door_1_rot", 0]; }; }; Cheers
  20. Hopefully the next iteration will bring improvement in that area, though I'll still be skeptical and won't buy it depending on how AI turns out in the first place. Seeing how walkable moving objects are done in a plethora of games from 10 years ago should leave anyone positive. Cheers
  21. Grumpy Old Man

    Helicopter tactics and technology

    Considering arma, I'd say it's: Head dive onto the enemy and pull up when altitude < 25m. Cheers
  22. Grumpy Old Man

    Diary record "focus"

    There doesn't seem to be such a command. Might be worth giving the development branch a shot, having the ability to influence which record is shown per default really should be a given. Cheers
  23. Grumpy Old Man

    Random Mortar Script?

    Here's a bit of a beefed up version of ambient arty impacts: //init.sqf GOM_fnc_spawnArtyShells = { params ["_impactCenter","_shellAmount","_shellType","_delayBetweenShells"]; for "_i" from 1 to _shellAmount do { _rndPos = _impactCenter getPos [random [0,50,0],random 360]; _rndPos set [2,500]; _shell = _shellType createVehicle _rndPos; _shell setPosASL _rndPos; _shell setVectorDirAndUp [[0,0,-1],[0,0.8,0]]; _shell setVelocityModelSpace [0,0,-70]; sleep _delayBetweenShells; }; }; GOM_fnc_ambientArty = { params ["_centerObject","_shellType","_minDistance","_maxDistance",["_delayBetweenShells",1.5],["_delayBetweenRounds",15],["_simultaneousRounds",1],["_minShellAmount",2],["_maxShellAmount",6]]; GOM_fnc_ambientArtyEnabled = true; while {GOM_fnc_ambientArtyEnabled} do { for "_i" from 1 to _simultaneousRounds do { _impactCenter = _centerObject getPos [_minDistance + random _maxDistance,random 360]; _shellAmount = _minShellAmount + round random _maxShellAmount; _spawn = [_impactCenter,_shellAmount,_shellType,_delayBetweenShells] spawn GOM_fnc_spawnArtyShells; waitUntil {scriptDone _spawn}; sleep _delayBetweenRounds; } }; }; //to call it: _centerObject = player;//center object of bombing _shellType = "Sh_82mm_AMOS";//bomb type _minDist = 150;//minimum impact distance to center _maxDist = 1500;//max impact distance to center _delayBetweenShells = 2;//seconds between single shells _delayBetweenRounds = 10;//seconds between rounds _simultaneousRounds = 4;//number of bombings at the same time _minShellAmount = 2;//minimum number of shells per bombing _maxShellAmount = 6;//max number of shells per bombing _bomb = [_centerObject,_shellType,_minDist,_maxDist,_delayBetweenShells,_delayBetweenRounds,_simultaneousRounds,_minShellAmount,_maxShellAmount] spawn GOM_fnc_ambientArty; To make the arty stop simply set GOM_fnc_ambientArtyEnabled to false. Cheers
  24. Grumpy Old Man

    Counting when interacted with

    Basically what glorious @Larrow posted. Also good practice to keep things simple, like his suggestion of changing notFound to isFound to prevent double negatives from confusing you when debugging. These things tend to be hard to follow through and to get a grasp at first glance: //bad notDoSomething = true; if (!notDoSomething) then { //do something }; //good doSomething = false; if (doSomething) then { //do something }; Cheers
×