To Lock Remote Statics Guns only on bases, not anywhere. Subject of complexity.

  • Offline Animatek
  • SNET Admin
  • First Blood
  • ***
  • Posts: 50
  • Editor de Profesión - ArmA III Admin from Cuba
Subject of greater complexity.
I urge my players to lock and use their autonomous weapons within their bases (in my version I use the BoS addon) as an exclusive defensive purpose, and thus avoid being left near the stores, ATMs, or enemy bases in a troll plan.

Would it be possible to force the AI not to attack until they are locked, and in turn these can only be locked within a radius close to the object that defines the base of the player (the satellite phone, in this case)?

Something like:
If case {static autonomous}
If distance_to "Land_SatellitePhone_F" is_not (less than or equal) than actual_BaseRadius*, then force R3F_islocked = false;
until R3F_ isLocked = true; force "green" (or the most pacifist color)
Sorry for the mess, but I hope you get the idea. And I do not know where I would put this code. LOL. God! I have to learn to code in ArmA 3!

*that number must be the current radius of each base so that it is always inside and so they can be resupplied and rearmed from the BoS menu.


For example:
This is the code used to detect the radius of the base.
Code: [Select]
// @file Version:
// @file Name:
// @file Author: Cael817, all credit to Killzone Kid Edited by: BIB_Monkey
// @file Created:
private _manager = nearestObject [player, "Land_SatellitePhone_F"];
private _ManagerPosition = getpos _manager;
//Get manager level
private _ManagerLevel = _manager getVariable ["ManagerLevel", 1];
//set default base radius for level 1 manager
private _BaseRadius = 10;
//set base radius based on manager level
switch (_ManagerLevel) do
{
case (2):
{
_BaseRadius = 20;
};
case (3):
{
_BaseRadius = 30;
};
case (4):
{
_BaseRadius = 40;
};
case (5):
{
_BaseRadius = 50;
};
};
{
if (!local _x) then
{
private _setOwner_time = time;
[_x, "setOwnerTo", player] call R3F_LOG_FNCT_exec_commande_MP; // Requires R3F 3.1
waitUntil {local _x || time > _setOwner_time + 1.5};
};

_x setHit ["light_1_hitpoint", 0];
_x setHit ["light_2_hitpoint", 0];
_x setHit ["light_3_hitpoint", 0];
_x setHit ["light_4_hitpoint", 0];
_x setHit ["light_1_hit", 0];
_x setHit ["light_2_hit", 0];
_x setHit ["light_3_hit", 0];
_x setHit ["light_4_hit", 0];
_x setVariable ["lights", "on", true];
} forEach nearestObjects [_ManagerPosition, [
"Static",
"Thing"
], _BaseRadius, true];

hint "Lights ON";

It is possible that more than one player intends to lock one of his autonomous static weapons within the area of an enemy base; but I think that the base system itself does not allow it; since the area must belong to you for it.
Soy administrador de ArmA III en una intranet en Cuba. No tengo experiencia en códigos ni programación, pero con ayuda he logrado un servicio eficiente y duradero, todo offline y sin internet.
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2512
I have trouble understanding what you want to do, but I know AI drones and turrets can be prevented from shooting on their own by calling
Code: [Select]
_vehicle setAutonomous false
  • Offline Animatek
  • SNET Admin
  • First Blood
  • ***
  • Posts: 50
  • Editor de Profesión - ArmA III Admin from Cuba
I have trouble understanding what you want to do

basically it is to force the players to use autonomous static weapons only as a defensive weapon in their bases; so that they are not left unattended when the players leave their bases; and that they do not use it as an offensive weapon or traps in stores, ATMs or near enemy territories.

What I need is to force the behavior of the AI only from autonomous static weapons so that it does not open fire until they are locked inside the bases of the players.

The logic (obviously not the code) that I suggest is:

Code: [Select]
if _veh isKind (any IA static turrets gun); // except remote laser designator
and
_veh R3F_isLocked = false; // in this condition
then
force _veh combatMode="BLUE"; // Force Do Not Attack while is unLocked
and
force behavior="CARELESS"; // to avoid pointing enemies

if _veh distance_to "Land_SatellitePhone_F" > _BaseRadius; // Check distance from player base, kinda.
then
force _veh R3F_isLocked = false; // keeping it in "BLUE" and "CARELESS" mode away from player base

if _veh distance_to "Land_SatellitePhone_F" <= _BaseRadius; //
waitUntil
_veh R3F_isLocked = true; // wait for conditions
then
force _veh combatMode="RED"; // Now is functionally
force _veh behavior="COMBAT"


The thing is I don't know how write this for make it work, and I don't know where put the code. Now do you get it?
Soy administrador de ArmA III en una intranet en Cuba. No tengo experiencia en códigos ni programación, pero con ayuda he logrado un servicio eficiente y duradero, todo offline y sin internet.
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2512
Yeah it's a little bit complicated, I would say you'd need to put the code in a separate file, assign it as a function in globalCompile.sqf, call the function in vehicleSetup.sqf, and remoteExec it in objectLockStateMachine.sqf, that way you wouldn't need the waitUntil.
  • Offline Animatek
  • SNET Admin
  • First Blood
  • ***
  • Posts: 50
  • Editor de Profesión - ArmA III Admin from Cuba
Could you, please, write the code for me? I do not know how to do it. All I did here was apply logic according to what I want. Mainly how to define _BaseRadius as the example I shared above does. Because I do not know if putting _BaseRadius will be enough if it is already defined in the BoS functions.
Soy administrador de ArmA III en una intranet en Cuba. No tengo experiencia en códigos ni programación, pero con ayuda he logrado un servicio eficiente y duradero, todo offline y sin internet.
  • Offline Animatek
  • SNET Admin
  • First Blood
  • ***
  • Posts: 50
  • Editor de Profesión - ArmA III Admin from Cuba
@AgentRev, I'm sorry, master, if I make you cry... this is my attempt of coding

Code: [Select]
private ["_static"];
private _static = cursorObject;
private _manager = nearestObject [player, "Land_SatellitePhone_F"];
private _ManagerPosition = getpos _manager;
private _distance = _static distance2d _ManagerPosition;
//Get manager level
private _ManagerLevel = _manager getVariable ["ManagerLevel", 1];
//set default base radius for level 1 manager
private _BaseRadius = 10;
//set base radius based on manager level
switch (_ManagerLevel) do
{
case (2):
{
_BaseRadius = 20;
};
case (3):
{
_BaseRadius = 30;
};
case (4):
{
_BaseRadius = 40;
};
case (5):
{
_BaseRadius = 50;
};
};

if ({_static iskindof _x} count[
"B_SAM_System_02_F",
"B_HMG_01_A_F",
"B_GMG_01_A_F",
"B_SAM_System_01_F",
"B_AAA_System_01_F",
"O_HMG_01_A_F",
"O_GMG_01_A_F",
"I_HMG_01_A_F",
"I_GMG_01_A_F"]>0) && (!({_static iskindof _x} count["B_Static_Designator_01_F","O_Static_Designator_02_F"])>0) then     // except remote laser designator

if (_static getVariable ["R3F_LOG_disabled", false]) then // if is unLocked
{
_static setcombatMode="BLUE"; // Force Do Not Attack while is unLocked
_static setbehavior="CARELESS"; // and avoid pointing enemies
};
if (_static _distance > _BaseRadius) then // Check distance from player base, kinda.
{
_static setVariable ["R3F_LOG_disabled", false, true]; // keeping it unlocked and in "BLUE" and "CARELESS" mode, if it is away from player base
playSound "FD_CP_Not_Clear_F";
["Please, lock this in your base.", 5] call mf_notify_client;
};
else
if (_static _distance <= _BaseRadius) then // Now is functionally
{
if (_static getVariable ["R3F_LOG_disabled", false]) then // wait for it...
_static setcombatMode="RED";
_static setbehavior="COMBAT";
};

how bad is it?
Soy administrador de ArmA III en una intranet en Cuba. No tengo experiencia en códigos ni programación, pero con ayuda he logrado un servicio eficiente y duradero, todo offline y sin internet.