Results 1 to 3 of 3

Thread: Making enemy AI passive to players until they pick up a primary weapon

  1. #1

    Making enemy AI passive to players until they pick up a primary weapon

    I've come to a complete loss; I have little to no scripting experience in any medium, however myself and a couple of people have managed to mangle this together:

    Init:
    Code:
    waitUntil {!isNil primaryWeapon this}; [this] exec "WeaponCaptive.sqf";
    weaponCaptive.sqf:
    Code:
    (_this select 0) setCaptive true; waitUntil {isNil primaryWeapon this}; [this] exec "NoWeaponCaptive.sqf"
    noweaponCaptive.sqf:
    Code:
    (_this select 0) setCaptive false; waitUntil {!isNil primaryWeapon this}; [this] exec "WeaponCaptive.sqf"
    What is supposed to be happening is unit(s) start with the initial state of being setCaptive true, so enemy AI do not react to them, then once they've picked up a gun their state becomes setCaptive false, then if they drop their weapon they return to the initial state of setCaptive true. The snippets above give undefined errors on both the 'this' within the {}'s and the exec part. Looking for some assistance - absolutely anything will be welcome.

  2. #2
    I shall not insult moderators
    Join Date
    Nov 25 2010
    Posts
    1,576
    Quote Originally Posted by Gilson View Post
    I've come to a complete loss; I have little to no scripting experience in any medium, however myself and a couple of people have managed to mangle this together:
    One or two bad things there - you can't wait in a vehicle init.
    I have tested this - seems to work perfectly:
    Unit init:
    Code:
    removeAllWeapons this; this setCaptive true; nul = [this] execVM "WeaponCaptive.sqf";
    Code:
    private ["_unit"];
    _unit = _this select 0;
    while {true} do {
    if (primaryWeapon _unit != "") then {
    _unit setCaptive false;
    } else {
    _unit setCaptive true;
    };
    sleep 1;
    };
    for testing:
    Add a weapon to a unit with a radio trigger:
    Code:
    {unitName addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3]; unitName addWeapon "M4A1";
    Place a weapon on the ground that you can pick up then drop (put this in the init of a traffic cone) you can also make a unit pick up this with the 6 key menu:
    Code:
    wpnhld1 = "WeaponHolder" createVehicle (position player); wpnhld1 addWeaponCargoGlobal ["M4A1",1]; wpnhld1 addMagazineCargoGlobal ["30Rnd_556x45_Stanag",5];
    Last edited by PELHAM; Apr 17 2012 at 00:38.

  3. #3
    Private First Class
    Join Date
    Dec 19 2009
    Posts
    15
    Author of the Thread
    It works perfectly and is exactly what I needed. Many thanks for your help and work.

Similar Threads

  1. GeneralCarver Second Primary Weapon Script
    By GeneralCarver in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 2
    Last Post: Dec 11 2010, 20:32
  2. restrict/remove primary weapon?
    By Garbol87 in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 2
    Last Post: Dec 20 2009, 02:59
  3. Help!!! No primary weapon
    By XXLpeanuts in forum ARMA - TROUBLESHOOTING
    Replies: 4
    Last Post: Oct 14 2007, 11:10
  4. How to prevent players to pick up weapons
    By Gorgi Knootewoot in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 2
    Last Post: Sep 17 2006, 17:45
  5. Auto Rearm for Primary Weapon
    By ryankaplan in forum OFP : MISSION EDITING & SCRIPTING
    Replies: 3
    Last Post: Mar 15 2006, 19:55

Posting Permissions

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