Results 1 to 9 of 9

Thread: Gear Script and Respawn Problems

  1. #1

    Gear Script and Respawn Problems

    Hi all, firstly I'm a bit green when it comes to scripting and I was wondering if someone could help me out of a hole.

    My gaming unit uses pre-defined loadouts (BAF content as we're UK), defined in the init box, for each role on the battlefield. However, this means that if a slight change to our standard loadouts is needed, its a matter of changing the init box for each unit in our mission library. Obviously, this takes an inordinate amount of time, and I've been experimenting with a few things, but am a bit stuck.

    Any idea how I go about doing this? Is simply a matter of writing .sqf script that i could call in the init line? I'd appreciate any pointers on how I could start. I've tried a couple of things (messing about with F2 and shacktac gear script) which either didn't really work too well or perform as intended i.e. didn't seem to work after respawn.

    Speaking of which, we've also been having some weird issues with respawn during our official missions, where sometimes a members gear suddenly changes when someone is killed i.e. section automatic rifleman suddenly becomes an Anti-Tank specialist. I recently added more playable unit slots to one of our stock missions, and some weird shit started going on with a squad leader loadout being placed on an engineer unit that didn't have anything in its init box. This bug seemed to disappear when the placement of the units was spaced out on the map a little more.

    Although I don't think its the problem, our respawn script is called through kill event as follows:

    Code:
    ///_xhandle = this addEventHandler ["killed", format["[_this,%1] execvm 'weaponRespawn.sqf'",[weapons this, magazines this]]];
    
    
    _unit = (_this select 0) select 0;
    _weapons = (_this select 1) select 0;
    _magazines = (_this select 1) select 1;
    
    waituntil {alive player};
    
    _unit = player;
    removeallweapons _unit;
    {_unit addmagazine _x} foreach _magazines;
    {_unit addweapon _x} foreach _weapons;
    I would really appreciate any help or ideas.

  2. #2
    Master Sergeant sxp2high's Avatar
    Join Date
    Jul 16 2009
    Location
    nearestLocation [(getPos player), "nameCity"];
    Posts
    605
    There is a good working script by Xeno for this.

    Just put a trigger somewhere.
    Activation: NONE PRESENT
    Size 0,0

    Condition: local player

    On Activation: nul = execVM "RespawnWeapons.sqf";


    RespawnWeapons.sqf:
    Code:
    // By Xeno
    
    
    while {true} do {
        waitUntil {!alive player};
        _weapons = weapons player;
        _magazines = magazines player;
        waitUntil {alive player};
        _p = player;
        removeAllItems _p;
        removeAllWeapons _p;
        {_p addMagazine _x} forEach _magazines;
        {_p addWeapon _x} forEach _weapons;
        _primw = primaryWeapon _p;
        if (_primw != "") then {
            _p selectWeapon _primw;
            // Fix for weapons with grenade launcher
            _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
            _p selectWeapon (_muzzles select 0);
        };
    };


    For changing default loadout by class i created something for my last mission:
    Code:
    //// Get soldier class
    _Unit = _this select 0;
    _UnitType = typeOf _Unit;
    
    
    //// Maybe this helps
    waitUntil {!isNull player};
    
    
    //// Changed default gear, cause mk16 is unreal :-(
    
    
    //// Squad leader & Team leader
    if (_UnitType == "US_Soldier_SL_EP1" || _UnitType == "US_Soldier_TL_EP1") exitWith {
    
        removeAllWeapons _Unit;
    
        _Unit addWeapon "ACE_M4A1_RCO_GL";
        _Unit addWeapon "M9";
    
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "30Rnd_556x45_Stanag";
        _Unit addMagazine "Smokeshell";
        _Unit addMagazine "Smokeshellred";
        _Unit addMagazine "1Rnd_HE_M203";
        _Unit addMagazine "1Rnd_HE_M203";
        _Unit addMagazine "1Rnd_HE_M203";
        _Unit addMagazine "1Rnd_HE_M203";
        _Unit addMagazine "15Rnd_9x19_M9";
        _Unit addMagazine "15Rnd_9x19_M9";
        _Unit addMagazine "15Rnd_9x19_M9";
        _Unit addMagazine "15Rnd_9x19_M9";
        _Unit addWeapon "Binocular_Vector";
        _Unit addMagazine "ACE_Battery_Rangefinder";
        _Unit addWeapon "ACE_Earplugs";
    
    };
    
    
    //// Auto rifleman
    if (_UnitType == "US_Soldier_AR_EP1") exitWith {
    
        removeAllWeapons _Unit;
    
        _Unit addWeapon "M249_m145_EP1";
        _Unit addWeapon "M9";
    
        _Unit addMagazine "100Rnd_556x45_M249";
        _Unit addMagazine "100Rnd_556x45_M249";
        _Unit addMagazine "100Rnd_556x45_M249";
        _Unit addMagazine "100Rnd_556x45_M249";
        _Unit addMagazine "100Rnd_556x45_M249";
        _Unit addMagazine "HandGrenade_West";
        _Unit addMagazine "HandGrenade_West";
        _Unit addMagazine "15Rnd_9x19_M9";
        _Unit addMagazine "15Rnd_9x19_M9";
        _Unit addMagazine "15Rnd_9x19_M9";
        _Unit addMagazine "15Rnd_9x19_M9";
    // he already got them    _Unit addWeapon "ACE_Earplugs";
    
    };
    
    
    AND SO ON ......
    Called through unit init line:
    nul = [this] execVM "Loadout.sqf";

  3. #3
    Brilliant mate, thank you very much this works now. With a couple of slight modifications, I've managed to get the respawn with ruck contents working also.

  4. #4
    I've used the Xeno script for a while now, but with one added function.
    hideBody.

    Code as follows:=
    Code:
    // By Xeno
    
    
    while {true} do {
        waitUntil {!alive player};
        _weapons = weapons player;
        _magazines = magazines player;
        waitUntil {alive player};
        _p = player;
        removeAllItems _p;
        removeAllWeapons _p;
        hideBody _p;
        {_p addMagazine _x} forEach _magazines;
        {_p addWeapon _x} forEach _weapons;
        _primw = primaryWeapon _p;
        if (_primw != "") then {
            _p selectWeapon _primw;
            // Fix for weapons with grenade launcher
            _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
            _p selectWeapon (_muzzles select 0);
        };
    };
    This has worked fine in Arma2 until I installed OA and BAF Pack.

    Now the hidebody doesn't work anymore.

    Has anyone suggestions?

  5. #5
    Quote Originally Posted by Beerkan View Post
    I've used the Xeno script for a while now, but with one added function.
    hideBody.

    Code as follows:=
    Code:
    // By Xeno
    
    
    while {true} do {
        waitUntil {!alive player};
        _weapons = weapons player;
        _magazines = magazines player;
        waitUntil {alive player};
        _p = player;
        removeAllItems _p;
        removeAllWeapons _p;
        hideBody _p;
        {_p addMagazine _x} forEach _magazines;
        {_p addWeapon _x} forEach _weapons;
        _primw = primaryWeapon _p;
        if (_primw != "") then {
            _p selectWeapon _primw;
            // Fix for weapons with grenade launcher
            _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
            _p selectWeapon (_muzzles select 0);
        };
    };
    This has worked fine in Arma2 until I installed OA and BAF Pack.

    Now the hidebody doesn't work anymore.

    Has anyone suggestions?



    Take a look at which unit you are actually trying to hide.

  6. #6
    On the hidebody, I think you want to use addaction here?

  7. #7
    Quote Originally Posted by Bon View Post
    Take a look at which unit you are actually trying to hide.
    The script works fine, except the hidebody function.

    I'm trying to "hideBody _p;"

    and _p; is declared in the line " _p = player;"

    therefore I am trying to hide player, or the entity that called the script.

    N.B. this worked before in Arma2.

    Also my init.sqf file calls the script with

    dummy = [true,true] execVM "respawnGear.sqf";

    The script is NOT called in the init of the unit.


    UPDATE

    Code:
    while {true} do {
        waitUntil {!alive player};
        _weapons = weapons player;
        _magazines = magazines player;
        _deadbody = player;
        waitUntil {alive player};
        _p = player;
        removeAllItems _p;
        removeAllWeapons _p;
        hideBody _deadbody;
        {_p addMagazine _x} forEach _magazines;
        {_p addWeapon _x} forEach _weapons;
        _primw = primaryWeapon _p;
        if (_primw != "") then {
            _p selectWeapon _primw;
            // Fix for weapons with grenade launcher
            _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
            _p selectWeapon (_muzzles select 0);
        };
    };
    based on what Bon suggested to look at, i.e. that the first script is trying to hide the player when he's actually just respawed. This change makes it work.
    Last edited by Beerkan; Sep 27 2010 at 20:17. Reason: update

  8. #8
    edit: nvm you got it
    Last edited by Bon; Sep 27 2010 at 20:17.

  9. #9
    Is there any way of getting the gear script posted above by sxp2high to apply to a particular unit rather than a whole class?

    e.g. if I want the same unit class in different groups to have a slightly different standard loadout.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •