aussie battler

DMS Attack Dogs Mission

19 posts in this topic

I want to add attack dog to a DMS mission. Have been reading up about Arma3 Dogs & from what I understand you have to code the attack to the dog. By default Arma3 dogs dont attack.

I have spent a good amount of time trying to get the puppy to bite, but he just sits there. Maybe I have to create a new class in DMS & call it _dog?

This spawns a dog, but the dog doesn't move:

Spoiler

private [ "_dog", "_dogPos", "_enemyUnitsArray" ]

_dog = createAgent ["Fin_blackwhite_F", _pos, [], 0, "FORM"];
_dog setVariable ["BIS_fnc_animalBehaviour_disable", true];
_dog setBehaviour "Aware";
_dog setSkill 1;
_dogPos = getPos _dog;
_enemyUnitsArray = ["Exile_Unit_Player"];  // maybe Exile_Unit_Player is wrong? I am just making shit up here
_target = nearestObjects [_dog, _enemyUnitsArray, 50]; //Seach for enemy



I know it is possible to have attack dogs, see here:

Here are some of my scource codes that I tried to pull ideas from:

Stright from Arma3 https://community.bistudio.com/wiki/Arma_3_Animals:_Override_Default_Animal_Behaviour_Via_Script#Example_script_for_dog_following_player

Spoiler

Example script for dog following player


// Spawn dog
_dog = createAgent ["Fin_random_F", getPos player, [], 5, "CAN_COLLIDE"];
 
// Disable animal behaviour
_dog setVariable ["BIS_fnc_animalBehaviour_disable", true];
 
// Following loop
0 = [_dog] spawn {
	params ["_dog"];
 
	// Force dog to sprint
	_dog playMove "Dog_Sprint";
 
	while {alive _dog} do 
	{
		_dog moveTo getPos player;
 
		sleep 0.5;
	};
};


JBoy attack dog JBOY_dogPackMemberAttack.sqf ( https://forums.bistudio.com/forums/topic/196998-jboy-dog-updated-v12/ )

Spoiler

// JBOY_dogPackMemberAttack.sqf
// Borrowed some code from AZCoder's AZC_FNC_PACK_ATTACK.  Thanks AZC!
if (!isServer)  exitwith {};
params["_dog","_dogTarget","_nearTargets"];
_lastTarget = objNull;

// ***************************************************************************************
//  Attack assigned target first.  Then loop to find more targets until all targets dead. 
// ***************************************************************************************
_pack = (_dog getVariable "vPack");

_dog setVariable ["vTarget", _dogTarget];
_dog setVariable ["vCommand", "attack"];
_lastTarget = _dogTarget;        
waitUntil {sleep 1; !(alive _dog) || !(alive _dogTarget) || typeName (_dog getVariable "vTarget")=='STRING'};

// ***************************************************************************************
// Loop until dog is dead or all targets are dead.
// ***************************************************************************************
while { alive _dog and ({alive _x} count _nearTargets) > 0 and (_pack getVariable "vMovementType") == "attack" } do
{
    // Get next nearest live prey to attack.
    // DON'T GET NEW TARGET list HERE BECAUSE PACK LOOP IS WAITING UNTIL CURRENT TARGETS ALL DEAD BEFORE GETTING NEW ONES.
    //_nearTargets = [getpos (_nearTargets select 0), ["CAManBase","Hen_random_F","Cock_random_F","Cock_white_F"], 25] call JBOY_getNearTargets;
    _dogTarget = objNull;
    _dogDistance = 5000;
    {
        _target = _x;
        if (alive _target) then
        {
            //_side = side _target;
            _dist = _dog distance _target;
            //if ((_side != sideEnemy) && (_dist < _dogDistance)) then
            if ((_dist < _dogDistance)) then
            {
                _dogTarget = _target;
                //hint " new target found";
                _dogDistance = _dist;
            };
        };
    } forEach _nearTargets;

     if (alive _dogTarget) then 
     {
                _pack setVariable ["vMovementType","roam",true]; // any dog stops attacking, they all stop.  PackLoop will re-assign another attack
                _dog setVariable ["vTarget", _dogTarget,true];
                _dog setVariable ["vCommand", "attack",true];
                _lastTarget = _dogTarget;
     };
    waitUntil {!(alive _dog) || !(alive _dogTarget) || isnull _dogTarget || ({alive _x} count _nearTargets)== 0
                || (_dog getVariable "vCommand") != "attack"
                || (_dog distance _dogTarget)>100 };
};
// ***************************************************************************************
// All targets dead, so resume normal follow the packLeader behaviour
// ***************************************************************************************
//player globalchat "all targets dead or dog dead";
//  Don't need this because dog goes to idle and target objnull in command=attack ??

if ( alive _dog ) then 
{
    if (_dog == ((_dog getVariable "vPack") getVariable "vPackLeader")) then 
    {  // if pack leader, then set to idle
        //_dog setVariable ["vTarget", objNull];
        _dog setVariable ["vCommand", "idle"];
    } else
    {  // if follower, go back to following
        //_dog setVariable ["vTarget", objNull];
        _dog setVariable ["vCommand", "followLeader"];
    };
};
 

Hungry Hungry Fish attack mod: (this is funny shit)
 https://forums.bistudio.com/forums/topic/183486-hungry-hungry-fish-soccer/
 

Spoiler

private ["_object", "_Continue", "_ClosestObject", "_dir", "_vel", "_speed", "_player", "_Getdamage"];

[] spawn FA_ArrayBuilder;

waitUntil {count FA_FishFood > 0};

//While FISHATTACK is true, run this script
while {FISHATTACK} do 
{
    [] spawn 
    {
        _object = FISHGROUP createUnit ["Tuna_F",getpos FishSpawn,[],10,"FORM"];
        _object addRating -10000;
        _object setspeaker "NoVoice";
        FA_FishActiveArray pushback _object;
        _Continue = true;
        _object addEventHandler ["HandleDamage",{_this call FishDamage;}];
        while {alive _object && _Continue} do
        {
            _ClosestObject = [FA_FishFood,_object] call BIS_fnc_nearestPosition;
            _object domove (getpos _ClosestObject);
            waitUntil {(getPos _object select 2) < 1;};
            _object setDir ([_object,_ClosestObject] call BIS_fnc_dirTo);
            _dir = direction _object;
            _vel = velocity _object;
            _speed = 4;
            _object setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)+ 6];
            
            if ((_object distance _ClosestObject) < 1) then {
            
            _object attachto [(vehicle _ClosestObject),[0,0,(random 2)]];
            [
            [
            [_object,(vehicle _ClosestObject)],
            {
                _object = _this select 0;
                _player = _this select 1;
                while {alive _object && alive _player} do
                {
                    _object say3D "Scared_Animal5";
                    _Getdamage = getDammage _player;
                    _player setdamage (_Getdamage + 0.05);
                    sleep (random 10);
                };
                detach _object;
                _object setdamage 1;
                sleep Fish_BodyRemovalRate;
                deletevehicle _object;
            }],"BIS_fnc_spawn",true,false,false] spawn BIS_fnc_MP;
            _Continue = false;

            
            };
            sleep 1;
        };
        sleep Fish_BodyRemovalRate;
        deletevehicle _object;
    };
sleep Fish_RespawnRate;
};


Arma2 Clay Dogs Attack.sqf:

Spoiler


_dog = _this select 0;
_target = _this select 1;

_sound = createSoundSource ["Sound_BadDog", getPos _dog, [], 0];
_sound attachTo [_dog, [0,0,0]];

while {(alive _dog) && (alive _target)} do
{
    _dog doMove getPos _target;
    If ((_dog distance _target < 2) && (vehicle _target == _target)) Then
    {
        _dog doTarget _target;
        _dog lookAt _target;

        _dog switchMove "CLAY_DogAttack";
        sleep 0.35; 
        _dog setVelocity [0, 0, 2.5];

        If (((boundingBox _target select 1) select 2) > 1) Then
        {
            _target setHit ["legs", 1];
            _target setDamage (damage _target + 0.2);
            _target playMove "AmovPpneMstpSrasWrflDnon";
        }
        Else
        {
            _target setHit ["hands", 1];
            _target setDamage (damage _target + 0.2);
        };
        sleep 1;

        while {(alive _dog) && (alive _target) && (_dog distance _target < 2)} do
        {
            _dog doTarget _target;
            _dog lookAt _target;

            If (random 10 < 3) Then
            {
                _dog switchMove "CLAY_DogAttack";
                sleep 0.35; 
                _dog setVelocity [0, 0, 2.5];
            };

            _target setDamage (damage _target + (0.05 + random 0.05));
            sleep 1;
        };
    };
    sleep 1;
};
deleteVehicle _sound;

Random dog script I found in pastebin for Arma3 (it had the dog attacking at the end of the script):

 

Spoiler

BURK_dog setVariable ["BIS_fnc_animalBehaviour_disable", true];
BURK_dogFollowing = true;
BURK_dogSeeking = false;

private ["_safeZoneLocations","_safeZone"];

_safeZoneLocations = [[4992.7798,8005.0698,0],[8800.5742,10690.531,0],[4382.4014,4812.313,0]];

while {BURK_dogFollowing} do
{
 _safeZone = false;
 {
  if (player distance _x < 200) then
  {
   _safeZone = true;
  };
 } forEach _safeZoneLocations;

 if (_safeZone) then
 {
  BURK_dog playMove "Dog_Sit";
 }
 else
 {
 
  if !(alive BURK_dog) exitWith
  {
   player removeAction Dogfollow;
   player removeAction dogseek;
   player removeAction Dogpassive;
   player removeAction Dogstay;
   player removeAction Dogrun;
   player removeAction Dogsprint;
   player removeAction agressiveAction;
   player removeAction passiveAction;
   playerHasDog = false;
  };
  if ((alive BURK_dog) && !(Agressive)) then
  {
   BURK_dog moveTo getPos player;    
  };
  if ((alive BURK_dog) && (Agressive)) then
  {
   // Scan
   _dogPos = getPos BURK_dog;

   _target = _dogPos nearEntities ["Man",50];
  
   _distanceArray = [];
   {
    if ((_x in units group player) || (_x == player) || (_x isKindOf "animal") || then
    {
     
    }
    else
    { 
     _tar = player distance _x;
     _distanceArray = _distanceArray + [[_tar,_x]];
    }; 
   } forEach _target;

   if ((alive BURK_dog) && !(_distanceArray isEqualTo []) && (Agressive)) then
   {
    _distanceArray sort true;
    _actualTarget = (_distanceArray select 0) select 1;
    _targetPos = getPos _actualTarget;

    _damage = damage _actualTarget;
    //hint str _distanceArray;
    if (random 1 > 0.5) then
    { 
     [BURK_dog,_actualTarget] say3d "dog_one";
    }; 

    BURK_dog moveTo _targetPos;

    if (BURK_dog distance _actualTarget < 2) then
    {
     BURK_dog say3d "dog_ruff";
     _dir = getDir BURK_dog;
     BURK_dog attachTo [_actualTarget, [0, -0.5, 0.1] ];
     BURK_dog setDir _dir;
     uiSleep 0.5;
     _actualTarget setDamage _damage + 0.2;
     detach BURK_dog;
    };  
   }
   else 
   {
    BURK_dog moveTo getPos player; 
   }; 
  };
  uiSleep 1;
 };
 uiSleep 1; 
};
 


Goat attack (found in Pastebin):

 

Spoiler

There is no standard way of making animals attack if that's what you want. You can force it though (assuming you're using ArmA3).

Here's how:
- put down a marker, name it goatSpawn.
- put down your unit, in its init line put: goat = createAgent ['Goat_random_f', getMarkerPos 'goatSpawn', [], 0, 'NULL']; goat addRating -10000; this spawns a goat at the marker and makes it renegade, so units will attack it.
- put down one trigger with a short timer, set the condition to !isNil 'goat' and the on activation to goat moveTo (position player);, this makes the goat charge the player in ALL ITS FURY!
- put down the second trigger with the condition (player distance goat) < 5; and activation player setDamage 1;, this kills the player at a certain distance from the goat. You can use the setDamage command, I personally find the results of nul = "M_PG_AT" createVehicle (getPos goat) far more entertaining.

That is the idea behind it, it's clunky and the moveTo command sometimes fails so you have to refresh the goats mind in the debug. The full solution to it should of course use scripts.
 

 

20170605014722_1.jpg

Share this post


Link to post
Share on other sites

I can't help from a programming perspective but out of curiosity, have you contacted the guy that created the video at the top?

From Youtube:

Quote

hey guys, I got the animationnames from guessing around while browsing the configs. playmove and stuff works but I do remember something was werid before I got it to work. The jump and landing is a super unprofessional loop changing the vectorDirAndUp arrays of the dog and attaching it to the unit. There's also a hidden dummy unit involved but can't remember. PM me on the BI forum (Mad_Cheese) and I'll sort you out

Might be worth trying to PM him on the BI forums if you haven't already....  It also sounds like this was a bit of a hacked together mess to make it work and possibly not very performance-friendly.

Share this post


Link to post
Share on other sites
Advertisement

Hey @Riker2335

That video is a few years old, but your right I should see if Mad_Cheese is still about.

I think I have been looking at this wrong. I should look at the dog as a ai soldier in dog clothes.
 

Thanks for the suggestion.

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

No problem at all, glad I could be of some help and yes... probably just an AI in dogs clothing with a melee attack or something to that effect.

I suspect the animations are going to be the hard part once you've got it actually attacking.

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Chernaruski

I ended up using John's script for spawning a companion dog that you could tame with beef parts or dog food.

John has left Exile & took down the scripts with him. Not sure what happened there, but it probably wasnt pretty. John had some great scripts & cool survival servers.

I puzzled the script together with what code was left on the forums here & combined it with the attack part with this mod by Jboy http://www.armaholic.com/page.php?id=31864

  • Like 1

Share this post


Link to post
Share on other sites

Can you share the dog companion script you using or you preffer to keep it offgrid (understandable, if so)  ?
I'm no scripter & heavily rely on anything arma/exile community have to offer. I would love to implement any interaction with dogs on my little cozy server and as far as I understand this is the closest thing to it.

Edited by Chernaruski

Share this post


Link to post
Share on other sites

@Chernaruski  I have sent John a message seeing if I could release his dogs script that I modified. I am not even sure if he will receive the email as his name doesn't come up anymore when you @mention him.

I noticed that all mentions of the script have now been deleted altogether. Pity that the script would just get dumped & never get enjoyed.

 

Share this post


Link to post
Share on other sites

@Chernaruski I have been told that John still checks messages. If he is not keen on releasing the script again I could write in Jboys dog code for you.

Jboy has roaming attack dogs in packs that you are after. If you are keen on dogs I'll ask Jboy if he is cool with an Exile release.
 

Edited by aussie battler

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.