Jump to content

demonized

Member
  • Content Count

    2658
  • Joined

  • Last visited

  • Medals

Posts posted by demonized


  1. In your init.sqf:

    onTeamSwitch "group player selectLeader player";

    Does this not work in multiplayer?

    Dont think that works in MP, but i hope i am wrong.

    If that does not work, try a simple loop in unit init.

    _null = this spawn {
    if (!local _this) exitWith {};
    while {true} do {
    	waitUntil {sleep 0.5; alive player AND player != leader (group player)};
    	(group player) selectLeader player;
    };
    };
    

    will run until mission end, and when player is alive and not a teamleader, he will be teamleader.


  2. using isKindOf command witk the cfgVehicles list and you can get loosely or very specifically what killed the unit together with a "killed" eventhandler;

    note that this is not the cfgVehicles list for arma3, but will give you an idea what to search for when using subgroups, Landvehicle is car is hmwwtow, air is helicopter etc...

    example:

    this addEventHandler ["Killed", {
    _killer = _this select 1;
    _vehicle = vehicle _killer;
    if (_vehicle isKindOf "Man") then {
    	hint "its a man";
    };
    if (_vehicle isKindOf "Tank") then {
    	hint "its a tank";
    };
    if (_vehicle isKindOf "Plane") then {
    	hint "its a plane";
    };
    if (_vehicle isKindOf "Helicopter") then {
    	hint "its a helicopter";
    };
    if (_Vehicle isKindOf "HMMWVTOW") then {
    	hint "its a hmww with tow missiles";
    };
    }];
    


  3. youre absolutely right, my bad, was at work writing with phone, and obviously not focused :)

    try this

    place a global variable in init.sqf:

    zone1 = true;
    

    place a trigger with anyone present, repeatedly.

    in condition place:

    zone1 and this
    

    on activation:

    {_x setDammage (getDammage _x + 0.1)} foreach units thisList; zone1 = false;
    

    on deactivation:

    zone1 = true;
    


  4. Easy way: repeatedly trigger. Anyone present.

    {
    _x setDammage 0.1;
    } foreach (units thisList);
    

    Where you can change amount of damage and the time on trigger.

    Will damage alle units inside trigger x amount / seconds.

    ---------- Post added at 11:20 AM ---------- Previous post was at 11:15 AM ----------

    Can also use a if statement to determin if unit is in a vehicle or not inside the foreach statement.

    if (vehicle _x == _x) then {_x setDammage 0.1};
    


  5. Hmmmm never saw that command.

    By the by Demonized,im using your A2 flare script,its great.I have a question about it,is it safe to still use in arma3 without any forseeable conflicts?Im using GAIA from MCC and she likes flares also,should this be a problem?

    PS;I really like the way your flares are fired lower,unlike gaia it gives a better representation of enemy position.Hell AI are firing them into building windows with enemy inside and its an awesome sight:D

    I havent looked at that script in years, i will take a look when i get the chance to.


  6. i feel this code is too much, but maybe it will get you going on creating a more efficient code...

    its a server side code only created once at mission start, iterates allUnits and adds eventHandlers to them no matter locality player, AI, players AI etc.. and gives them the old "killed" eventhandler wich in turn updates a number, wich is hinted on server with BIS_fnc_MP.

    Note: a mistake at first, but it seems this local eventhandler broadcasted the number anyway to server even though it should only react locally, maybe too tired...

    tested quickly in editor, MP hosted and also dedi using TADST dedi tool.

    if (!isServer OR !isNil "CountDead_fnc") exitWith {};
    CountDead_fnc = {
    _this addEventHandler ["killed", {
    	_side = side (group (_this select 0));
    	switch _side do {
    		case west: {DeadWestCount = DeadWestCount + 1};
    		case east: {DeadEastCount = DeadEastCount + 1};
    		case resistance: {DeadGuerCount = DeadGuerCount + 1};
    		case civilian: {DeadCivCount = DeadCivCount + 1};
    	};
    }];
    };
    DeadWestCount = 0;
    DeadEastCount = 0;
    DeadGuerCount = 0;
    DeadCivCount = 0;
    
    _null = [] spawn {
    _added = [];
    while {true} do {
    	{
    		if !(_x in _added) then {
    			_added = _added + [_x];
    			[_x, "CountDead_fnc", _x] call BIS_fnc_MP;
    		};
    	} foreach allUnits;
    	[format ["West units killed %1 \n East units killed %2 \n Resistance units killed %3 \n Civilian units killed %4",DeadWestCount,DeadEastCount,DeadGuerCount,DeadCivCount],"hintSilent"] call BIS_fnc_MP;
    	sleep 1;
    };
    };
    

    you can use the

    DeadWestCount = 0;
    DeadEastCount = 0;
    DeadGuerCount = 0;
    DeadCivCount = 0;
    

    to check for a limit of your choosing.

    like in a end trigger condition

    DeadWestCount > 200
    

    etc.... and so on and soforth :D


  7. I got it all running and put out every sleep command.

    unfortunately in the editor and on dedicated, like 50 % of the units are not completely executed/equipped.

    try using call instead of spawn, what you do now is start a script removing all, then when "started"(NOTE!! it may not yet be completed) start several different scripts equipping.

    do it in order, call will complete one, then go to next line.

    _RSF call fnc_removeall;
    
    //    clothing
    [_RSF,1] call fnc_giveHeadGear;
    [_RSF,3] call fnc_giveFaceW; 
    etc....
    

    the only thing you need to change in your functions is add a

    true

    without the

    ;

    also why have 180 functions, when you can create one removeFunction and one addStuff function, and rather have seperate equipment lists based on type or whatever you seperate units by.

    it would streamline your work much more and make it a lot easier for you.

    Example buildup:

    1 removeallstuff fnc.

    1 addallstuff fnc

    1 script called from init.sqf as you have.

    then in that script find out what type player is and seperate types by switch, and pass a array with info to the add fnc.

    [[weapon,mags], hat, west, [inventory items], etc.....]
    

    then in the add fnc

    weapon would be [_this sellect 0;

    wich would return a array where select 0 is the weapon and select 1 is the ammo count.

    you can add and change and seperate as much you want....

    Just a thought.


  8. not sure what was wrong but its working for me now, i changed it a bit so you dont need the onplayerrespawn.sqf, also it should be safe against multiple loops because of players joining, maybe that was the issue....

    let me know if it works for you.

    place this in init.sqf:

    grantUnlimitedAmmo = compile preprocessFileLineNumbers "unlimitedAmmo.sqf";
    
    [] spawn {
    if (!isNil "UNLAMMO_ARR") exitWith {};
    UNLAMMO_ARR = []; // empty global array for check, and to notify not to start a second loop on player connect if already running.
    if !(isServer) exitWith {};  // exit if not server.
    while {true} do {
    	{
    		if (!(_x in UNLAMMO_ARR) AND alive _x) then {
    			[[_x, 1], "grantUnlimitedAmmo", _x] call BIS_fnc_MP;
    			UNLAMMO_ARR = UNLAMMO_ARR + [_x];
    		};
    	} foreach allUnits;
    	{
    		if !(alive _x OR isNull _x) then {UNLAMMO_ARR = UNLAMMO_ARR - [_x]};
    	} foreach UNLAMMO_ARR;
    	sleep 1;
    };
    };
    

    place the script named UnlimitedAmmo.sqf in your mission folder, good to go, at least in SP and hosted MP, not checked MP dedi, but think it will be ok there to.

    //////////////////////////////////////////////////////////////////
    // Function file for Armed Assault
    // Created by: TODO: Author Name
    //////////////////////////////////////////////////////////////////
    
    //Unlimited Ammo Script by XxanimusxX
    _unit = _this select 0;
    _ammoCount = _this select 1;
    _primeWpn = "";
    _prevWpn = "";
    _magazineType = "";
    _foundMags = 0;
    hint format["%1 is added",_unit];
    diag_log format["%1 is added",_unit];
    
    while {alive _unit} do {
       waitUntil {sleep 0.5; currentWeapon _unit != ""};
       _primeWpn = currentWeapon _unit;
    
       if (_primeWpn != _prevWpn) then
       {
           _prevWpn = _primeWpn;
           _magazineType = getArray(configFile >> "cfgWeapons" >> _primeWpn >> "magazines") select 0;
       };
    
       _foundMags = 0;
       {
           if (_x == _magazineType) then
           {
               _foundMags = _foundMags + 1;
           };
       } forEach (magazines _unit);
    
       if (_foundMags < _ammoCount) then
       {
           for "_i" from 1 to (_ammoCount - _foundMags) do
           {
               _unit addMagazine _magazineType;
           };
       };
    
       sleep 1;
    };
    

    dont use this part of your code, only what i described above will give all player and AI spawned or respawned or preplaced throughout the entire mission unlimited ammo.

    // DO NOT USE //
    [player, 2] spawn grantUnlimitedAmmo;  //controls player ammo
    {                                     
       if (!(isPlayer _x)) then 
       { 
           [_x, 2] spawn grantUnlimitedAmmo;  //controls AI ammo
       }; 
    } foreach allUnits; 
    //Unlimited Ammo*****************************************************
    //  DO NOT USE //
    


  9. make your hunting squads in the editor, place this in init of each hunter squad:

    _null = this spawn {
    Hunt_players_fnc = {
    	_player = "";
    	{
    		if (isPlayer _x AND alive _x) then {_player = _x};
    	} foreach (playableUnits + switchAbleUnits);
    	_wp = _this addWaypoint [getPos _player, (50 + (floor(random 200)))];
    	_wp setWaypointStatements ["true", "_null = (group this) spawn Hunt_players_fnc;"];
    	_wp setWaypointType "SAD";
    	_wp setWaypointCombatMode "RED";
    	_wp setWaypointSpeed "FULL";
    };
    
    _null = (group _this) spawn Hunt_players_fnc;
    };
    

    code creates a SAD wp in a random position 250 - 50m around one of the players, they will go search and destroy and when completed create again same way.

    • Like 2

  10. You wouldn't (by chance) know how to use logic (similar to what you have here) to make a trigger that could be used in a "Rearm at ammo box" task would you? I would start a new thread for this, but I am not allowed to apparently... All the tutorials I see about triggers are "Kill target". None of them have been able to show me how to set a task for "Use ammo box" or even "Go to ammo box"... Any advice would be appreciated :)

    What JShock wrote would work fine i think.

    But im guessing that you would have a purpose for the use of rearm, like getting a specific weapon or item, for that i would use the other EH containerClosed

    this addEventHandler
    [
    "[color="#0000FF"]ContainerClosed[/color]",
    {
    	if ("srifle_LRR_SOS_F" in (weapons player)) then {
    		_taskID = "";//<<your task name/ID
    		[[_taskID,"Succeeded"],"BIS_fnc_taskSetState",side (_this select 1),false,false] call BIS_fnc_MP;
    		(_this select 0) removeEventHandler ["ContainerClosed",0];
    	};
    }
    ];
    

    basically this eventhandler triggers when container is closed, and checks if you have taken a specific weapon in this case a sniper rifle, if yes, remove EH and complete task just like JShock wrote, if not do nothing.

    Can also switch out weapon with item or whatever like this for example, a mine detector:

    this addEventHandler
    [
    "[color="#0000FF"]ContainerClosed[/color]",
    {
    	if ("MineDetector" in (items player + assignedItems player)) then {
    		_taskID = "";//<<your task name/ID
    		[[_taskID,"Succeeded"],"BIS_fnc_taskSetState",side (_this select 1),false,false] call BIS_fnc_MP;
    		(_this select 0) removeEventHandler ["ContainerClosed",0];
    	};
    }
    ];
    


  11. maybe this way? not tested.

    if all your playable units is these 4.

    {!alive _x} count playableUnits == {!isNull _x} count playableUnits
    

    if not, you have more than 4 playable units, but these 4 specific ones only needed for end check:

    {!isNull _x AND !alive _x} count [unitName1, unitName2, unitName3, unitName4] == {!isNull _x} count [unitName1, unitName2, unitName3, unitName4]
    


  12. Place a scorcher or any other vehicle, no need to use a never fire ("BLUE") waypoint or the group setCombatMode "BLUE" code, its auto.

    Sync it with provider module.

    place this code in the vehicles init:

    _null = this spawn {
    _veh = vehicle _this;
    _grp = (crew _veh) select 0;
    while {true} do {
    	_grp setCombatMode "BLUE";
    	waitUntil { sleep 1; currentCommand _veh == "FIRE AT POSITION" };
    	_grp setCombatMode "YELLOW";
    	waitUntil { sleep 1; currentCommand _veh != "FIRE AT POSITION" };
    };
    };
    

    Now place yourself and sync with a requester module.

    What code does: sets arty to blue, wait for your arty req command, and sets it to yellow, then when rounds complete, goes back to blue again.

×