Jump to content

Grumpy Old Man

Member
  • Content Count

    4313
  • Joined

  • Last visited

  • Medals

Posts posted by Grumpy Old Man


  1. Something like this:

    TAG_fnc_handleSlingMass = {
    	params ["_chopper"];
    	_chopper addEventHandler ["RopeAttach",{
    		params ["_chopper", "_rope", "_slingLoad"];
    		_massArray = [["B_Quadbike_01_F",50],["B_T_Boat_Transport_01_F",100]];//quadbike will have 50 mass, boat will have 100 during slingloaded state
    		_vehClasses = _massArray apply {_x#0};
    		_vehMasses = _massArray apply {_x#1};
    		_index = _vehClasses find typeOf _slingLoad;
    		_slingLoaded = _slingLoad getVariable ["TAG_fnc_slingLoaded",false];//this is needed because EH fires for every attached rope, so you prevent overwriting the actual mass with the replacement mass
    		if (_index > -1 AND !_slingLoaded) then {
    			_slingLoad setVariable ["TAG_fnc_slingLoaded",true];
    			_slingLoad setVariable ["TAG_fnc_oldMass",getMass _slingLoad];
    			_slingLoad setMass _vehMasses#_index;
    		};
    	}];
    	_chopper addEventHandler ["RopeBreak",{
    		params ["_chopper", "_rope", "_slingLoad"];
    		_oldMass = _slingLoad getVariable ["TAG_fnc_oldMass",200];//200 will be used as a default value
    		_slingLoad setMass _oldMass;
    	}];
    	true
    };
    _handleMass = [chopper] call TAG_fnc_handleSlingMass;
    //to test on quadbike named test:
    onEachFrame {hintSilent format ["Current Mass:%1\nStored Mass: %2",getMass test,test getVariable ["TAG_fnc_oldMass",-1]]};

    Cheers

    • Like 2

  2. 39 minutes ago, gc8 said:

    I always though that people who truncate their javascript by taking off the spaces save some bandwidth when the web page script is send to client. Does arma sqf benefit from taking away spaces? I don't know.

     

    Makes sense to speed up websites like that, in arma .sqf files are downloaded with the mission file and usually remain in memory.

    Unless you broadcast the actual function via network, removing whitespaces in .sqf has no real benefits (unless someone else can come up with one).

     

    Cheers

    • Like 1

  3. The respawn module has an expression field that will be executed upon respawn, passed parameters are [newVehicle,oldVehicle], so could go like this:

    
    //respawn module expression field:
    params ["_newVehicle","_oldVehicle"];
    _newVehicle addWeaponTurret ["gatling_30mm",[0]];   
    _newVehicle addMagazineTurret ["250Rnd_30mm_HE_shells",[0]];
    _newVehicle addMagazineTurret ["250Rnd_30mm_HE_shells",[0]];
    _newVehicle addMagazineTurret ["250Rnd_30mm_APDS_shells",[0]];
    _newVehicle addMagazineTurret ["250Rnd_30mm_APDS_shells",[0]];
    _newVehicle addMagazineTurret ["250Rnd_30mm_APDS_shells",[0]];
    _newVehicle addMagazineTurret ["250Rnd_30mm_APDS_shells",[0]];
    _newVehicle addWeaponTurret ["missiles_Jian",[0]];   
    _newVehicle addMagazineTurret ["4Rnd_LG_Jian",[0]];
    _newVehicle addMagazineTurret ["4Rnd_LG_Jian",[0]];
    _newVehicle addMagazineTurret ["4Rnd_LG_Jian",[0]];
    _newVehicle addMagazineTurret ["4Rnd_LG_Jian",[0]];
    _newVehicle addMagazineTurret ["4Rnd_LG_Jian",[0]];

    Cheers


  4. Posted this in a thread earlier this week (last week? who knows):

    
    GOM_fnc_spawnPatrol = {
    	params ["_pos","_units","_side","_size","_distance"];
    	_grp = createGroup [_side,true];
    	for "_i" from 0 to _size do {
    		selectRandomWeighted _units createUnit [_pos, _grp];
    	};
    	//patrol random points at n distance
    	while {{alive _x} count units _grp > 0} do {
    		waitUntil {sleep (5 + random 20);unitReady leader _grp AND combatMode leader _grp != "COMBAT"};
    		_grp move (_pos getPos [random _distance,random 360]);
    	}
    };
    
    //90% chance to spawn soldier_f, 10% chance to spawn TL_F
    _units = [
    	"O_G_Soldier_F",0.9,"O_G_Soldier_TL_F",0.1
    ];
    
    _patrol = [getPos player,_units,east,10,50] spawn GOM_fnc_spawnPatrol;

    Easy to go from there.

     

    Cheers

    • Like 1
    • Thanks 1

  5. Back in the days we ended arguments under 4 eyes in the backyard of an abandoned factory.

    Not that easy over forum posts, well maybe I'll live the day to see teleporters become a thing...

     

    5 hours ago, HazJ said:

    The reason behind it.

    Doubt that someone other than the dev who implemented it can give a proper reasoning.

    Same goes for why most script commands are always overriden by default AI (i.e.: make vehicle always have its lights on, no matter the behavior etc...)

     

    Only thing I can think of is to somehow work out the screen coordinates of the control, get its center position and align the text from there, your usual workaround.

     

    Cheers

    • Like 1
    • Thanks 1

  6. 20 hours ago, Buddski said:

    Mission file each time it is saved from 3Den editor appears to save a new randomSeed number. In industrial modeling and simulation a random seed can be presented to the simulation software at initialization to ensure the repeatability of the simulation, important during troubleshooting code. My head thinks of it as it initializes the random number generator to present a similar pattern of random generation so that from simulation to simulation you can determine if code is working the same or not. 

    I am working with A3Wasteland mission, adding new sub-missions which are randomly selected from arrays. While i dont see exactly the same sequence of "randomness", across 3 or 4 restarts i am seeing a bias towards missions and mission locations selected "randomly" from the same missions spawn locations, making it feel not too random.

    Has anyone pushed the randomSeed around to better understand the role it plays in this software? If i delete the randomSeed in mission.sqm the mission seizes at startup. But is there a way to change by code, perhaps in one of the init statements, if so which so that each restart this is a different number?

     

    Any thoughts or am i chasing a red herring?

     

     

    Depends on how many missions you want to rotate.

    If you only have 5 missions and want to play a random mission out of those 5 for 3 or 4 restarts you're absolutely right in seeing a pattern, since the brain is a pattern detection device.

    Try this:

    test = ["A","B","C","D","E"];
    output = [];
    for "_i" from 1 to 10 do {output pushBack selectRandom test};
    systemchat str output;
    hint str output;
    //will print ["E","D","E","A","C","D","E","B","D","C"]
    //consolidated in order of first occurence: [["E",3],["D",3],["A",1],["C",2],["B",1]]

    That's bound to happen with a small sample size.

    Increase the for loop to 100 and see the difference, a more normal distribution on occurrences, the order might still pick the same mission 2-3 times in a row.

     

    Better randomize an array of missions to choose from, play through all of them and randomize it again after the last one.

     

    Cheers

    • Like 1

  7. Doubt this even works because wlkscore is never initialized.

    Seems like an odd approach, why not use EntityKilled eventhandler and run it from initServer.sqf?

    Something like this:

    //initServer.sqf
    wlkscore = 0;
    addMissionEventHandler ["EntityKilled", {
    	params ["_unit", "_killer", "_instigator", "_useEffects"];
    
    	if (isPlayer _unit AND side group _unit isEqualTo civilian) then {
    		wlkscore = wlkscore + 30
    	};
    
    	if (!isPlayer _unit and side group _unit isEqualTo independent) then {
    		wlkscore = wlkscore + 3
    	};
    
    }];

    Might be easier to handle everything from the server with a single EH.

     

    Cheers


  8. The error you're getting depends on what "this" is, first parameter you're passing to bis_fnc_taskPatrol.

     

    Here's a barebones version that I enjoy using for simple unit spawning and sending them on patrol:

    GOM_fnc_spawnPatrol = {
    	params ["_pos","_units","_side","_size","_distance"];
    	_grp = createGroup [_side,true];
    	for "_i" from 0 to _size do {
    		selectRandomWeighted _units createUnit [_pos, _grp];
    	};
    	while {{alive _x} count units _grp > 0} do {
    		waitUntil {sleep (5 + random 20);unitReady leader _grp AND combatMode leader _grp != "COMBAT"};
    		_grp move (_pos getPos [random _distance,random 360]);
    	}
    };
    _units = [
    	"O_G_Soldier_F",0.9,"O_G_Soldier_TL_F",0.1
    ];
    _patrol = [getPos player,_units,east,10,50] spawn GOM_fnc_spawnPatrol;

    Using selectRandomWeighted you can dictate the chance which unit class will be picked, in the above case 90% chance to spawn a rifleman, 10% chance to spawn a TL.

    Can easily enhance this to add custom speedModes and combat modes upon spawning.

     

    Cheers

    • Like 2

  9. 56 minutes ago, taro8 said:

    CUP's UH-1H Gunship and others, I just use the clear all pylons and all of the weapons stay with 0 ammo, able to be chosen and no pylon models shown (no matter what combination of weapons). It looks like there is some issue with the script not removing the weapons just the magazines.
    I doubt its CUP issue as I set up the pylons for the  UH-1H myself and there wasn't anything put of ordinary there. Also there isn't any scripting magic in CUP pylons, it just uses the vanilla setup.
    The ACE rearm works fine with all helicopters even the Huey Gunship.

    EDIT: Ok, so the
    (vehicle player) setPylonLoadOut ["pylon1", ""];
    Leaves the weapon on the vehicle if you remove all the instances for the weapon (ie. remove all DAR launchers from AH-9). This means that you need to do something extra to properly remove the pylon without leaving any leftovers.
    Ok so, if you use the setPylonLoadOut then it does remove the magazine, it is reported as just "" . The issue is not with the magazine, but with the weapon staying on the vehicle. I also just checked, the weapons do stay, I used the setPylonLoadOut on both of the AH-9's pylons and the DAR launcher was still there with 0 ammo. The pylon magazines are gone, but the weapons command still shows that the helo has the DAR launcher weapon

     

    Looks like the hydra weapon still stays on the helicopter, pylons removed and 0 ammo, as you stated.

    On the wipeout the clear all pylons command removes all weapons and pylons correctly, GOM_fnc_clearAllPylons in line 679 of GOM_fnc_aircraftLoadoutInit.sqf is executed to clear all pylons (which works for all vanilla aircraft I tested so far).

    Feel free to adjust it so it removes any possible remainders (not really sure why the hydra weapon still stays on the chopper even with pylon and mags removed, maybe there's something I missed), the following lines from the aforementioned function should leave no weapon on the aircraft:

    	_pylonWeapons = [];
    	{ _pylonWeapons append getArray (_x >> "weapons") } forEach ([_veh, configNull] call BIS_fnc_getTurrets);
    	{ [_veh,_x] remoteexec ["removeWeaponGlobal",0] } forEach ((weapons _veh) - _pylonWeapons);

    Cheers


  10. You could use the take eventhandler and simply check if the item taken is a compatible mag and do your swap.

     

    player addEventHandler ["Take", {
    	params ["_unit", "_container", "_item"];
    	_compatibleMags = ["someClassnames"];
    	if (_item in _compatibleMags) then {
          _unit removeMagazine "rhs_30Rnd_545x39_7N10_AK"; 
          _unit addMagazine ["rhs_30Rnd_545x39_AK",_ammoCount]; 
        };
    }];

    Just an untested quick example, adjust as needed.

    This will check if the item is in the compatible mag array and switch it out.

     

    Cheers

    • Like 2

  11. 10 hours ago, taro8 said:

    Hello.
    For some odd reason the pylon weapons "stay" on the craft, even if they are removed or replaced. They have 0 ammo, but they are still remain in addition to whatever new pylon weapon gets mounted.
    Is there any way to fix that?

    Does this happen in an empty mission without mods?

    If so please post which aircraft and setting (best step by step) is causing this.

     

    Cheers


  12. 1 hour ago, Naiss said:

    I ran your code in the debug console from the wiki that you added and before it displayed CIV when I use side player the first time but once I ran your code it showed east but not with playerSide, it does not seem to update the playerSide, it still does only return Civ when I use playerSide but side player returns east as it should if that make sense

    Elaborate further on how the initial sides have been set up, was the unit initially civ (editor placed civilian)?

     

    Cheers


  13. 6 minutes ago, Naiss said:

    I have a lot of codes that has playerside stuff and i just wanna find a simpler way to change side without needing to go into the lobby or change code

    Uhm maybe you're not following through on this one or I'm confused but have you tried using

    side player

    to check for a players side?

    As stated above by @mrcurry, read the whole thing, heh.

     

    Cheers


  14. 13 minutes ago, davidoss said:

    The biggest problem is that i have no space in my mind for this

    I started this very quickly solved some problems and reach some point where i i have no idea what is where.

    Exactly i stacked on reverse stuff like this:

     

    player single click object in his inventory field - control "item price" displays clicked item price stored in [player trade array] -works

     

    player dbclick object in his inventory field. - control "item price" displays clicked item price stored in [player trade prices array] -works

                                                                               - removing item form inventory field -works

                                                                               - adding removed row to control "items to sell" -works

                                                                                - control "balance" displays its value + clicked item price stored in [player trade prices  array] -works

    And now how to reverse things when player changes his mind and wants item back before push sell.

    I tried to update variables values containing items classes stored in controls namespaces but it has make a mess along indexes count after removelb and displays fake values

    Its really complicated  i can barely explain this.

    I can link the files if you have mind space for this

    Don't try to make everything with one function, make multiple functions that do one thing only.

    I guess you can also add custom eventhandlers to handle what you need.

     

    Cheers

    • Like 1
×