Jump to content
G.Drunken

AI not shooting at custom composition

Recommended Posts

Greetings folks.

I've been working around setting up a new composition. First time engaging in actually using the main vehicle's init field for creating compositions. It worked well so far, managed to get everything I needed for the composition to work.

The code I'll share with you is located in the init field of AFV-4 Gorgon.

if (isServer) then {     
    this lockTurret [[0,0], true];      
    this lockTurret [[0], true];     
    this animate ["HideTurret", 1];   
    this animate ["showCamonetHull", 1];   
  
    this addWeaponTurret ["SmokeLauncher", [-1]]; 
    this addMagazineTurret ["SmokeLauncherMag", [-1]]; 
    this addMagazineTurret ["SmokeLauncherMag", [-1]];  
  
    _spawnPos = [getPos this select 0, getPos this select 1, getPos this select 2];    
    _turretArray = [_spawnPos, 180, "I_LT_01_AT_F", INDEPENDENT] call BIS_fnc_spawnVehicle;    
    _turret = _turretArray select 0;  
  
    _turret enableSimulationGlobal true;   
    _turret lockInventory true;    
    _turret lockDriver true;    
    _turret lockCargo true;    
    _turret setFuel 0; 
    
    _turret animate ["showCamonetHull", 1];   
    _turret animate ["showCamonetPlates1", 1];   
    _turret animate ["showCamonetPlates2", 1];   
   
    _turret addMagazineTurret ["100Rnd_127x99_mag_Tracer_Red", [0]];   
    _turret addMagazineTurret ["100Rnd_127x99_mag_Tracer_Red", [0]];   
    _turret addMagazineTurret ["100Rnd_127x99_mag_Tracer_Red", [0]];   
    _turret addMagazineTurret ["100Rnd_127x99_mag_Tracer_Red", [0]];   
    _turret addMagazineTurret ["100Rnd_127x99_mag_Tracer_Red", [0]];   
    _turret addMagazineTurret ["100Rnd_127x99_mag_Tracer_Red", [0]];    
    _turret attachTo [this, [.5, 0.15, 0.25], "poklop_commander", true];    
};

this addEventHandler ["Killed", { 
     params ["_unit"]; 
     { 
      detach _x; 
      deleteVehicle _x; 
     } forEach attachedObjects _unit; 
}];


this addEventHandler ["Deleted", { 
     params ["_unit"]; 
     { 
      detach _x; 
      deleteVehicle _x; 
     } forEach attachedObjects _unit; 
}];

What it does: Spawns a Gorgon with Nyx halfway hidden inside. What's left outside is the Nyx turret (Gorgon turret hidden). Initiates couple of animations for display of camo netting and such on both vehicles, adds extra magazines to the Nyx turret. It is supposed to look like the M1126 "Stryker" .

In the testing phase, I've encountered a problem. The AI (OPFOR, CSAT) wasn't shooting at the composition (operated by AAF). Mission settings stated AAF was not friendly to OPFOR, placing normal AAF vehicles in front of CSAT ones initiated combat immediately. Placing a manned composition in front of CSAT initiated nothing but a staring contest.

Turns out nothing is wrong with the code, but rather the placement of vehicles. If the vehicles are extremely close to each other, in this case the composition itself has the Nyx inside the Gorgon, the AI will not be able to determine what to shoot, therefor it will continue staring at the composition rather than shooting it when spotted. If you are to edit and include the following line:    _turret attachTo [this, [.5, 2, 0.25], "poklop_commander", true];     - this will basically put the Nyx outside the Gorgon and CSAT will immediately start to engage it. 

The question is, does anyone have any ideas on how to fix or flank around this issue? All help is welcome.

Share this post


Link to post
Share on other sites

Although I don't use the exact same methods than yours, I usually have a lot of issues regarding "shooting" every time I mess to attaching one vehicle into another, especially when their LODs/frames cross each other's.

The denying of shooting in one of the issues, but also when I have gunners on "freaky" attached vehicles, regardless they're human or NPCs, their attempts to shoot quite often end up on damaging the very same vehicle upon which they are attached to.

I don't think there is an actual solution to that, as you might have noticed that game deals relatively poorly with crazy attached stuff, for instance:
-Attached things DO receive damage and DO block shots from enemies, but enemies seem not to be able to actually target/"see" them;
-Attached things DO have collision for "people" (human or NPC soldiers can collide and walk over them), but do NOT have collision with other vehicles;
-Shots can be firef from "inside" attached objects, but will eventually damage whatever they find on their way out between the parent/original vehicle and the attached one.

  • Like 2

Share this post


Link to post
Share on other sites

Alright, I appreciate the information. Shame it's like that unfortunately.

Guess I'll start polishing the current compositions and proceed with uploads. 🙂

Share this post


Link to post
Share on other sites

By the way, years ago Quiksilver has dealt with stuff related to that, while attempting to put together his "Killdozer" invention.
I know he managed to improve damage receiving (probably messing with EventHandlers stuff), as well as avoiding the vehicle being "ejected" when hitting the others,  but I don't think he's found any solution regarding the firing against/from issues.

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×