Jump to content
GreenXp

Make AI shoot only after they got shot first ?

Recommended Posts

As the title is saying, I'm searching for a way to make indep be kind of neutral, if you don't fire they don't fire back. And no, the "Do Not Fire Unless Fired Upon" thing doesn't work, I mean, it does for like 5 seconds after they see me.

Also searching for a Holster script, I'm using the ravage mod which supposedly has one but it doesn't work, or it may interfere with other mods and that's why it doesn't work. (doesn't work on vanilla weapons either)

  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, GreenXp said:

Also searching for a Holster script

 

Hello there is in the Forum a script by Old Grampy ,

in which the enemy will not shoot if you hide your weapon.

If i find this i'll post this.

 

Here is also my holster script - mod :

 

Share this post


Link to post
Share on other sites

I tried your script like 20 min, but the mission.sqf is binarized, and the one I use on the server isn't, and I can't find a way to combine them...

Share this post


Link to post
Share on other sites

To be honest , i havent really understand anything !

 

What exacly you can't do?

- There is also the mod version.

Share this post


Link to post
Share on other sites

Ok, I'm not very good at this stuff but here is some of my mission.sqm

 

version=53;
class EditorData
{
	moveGridStep=15.697117;
	angleGridStep=0.2617994;
	scaleGridStep=1;
	autoGroupingDist=10;
	toggles=513;
	class ItemIDProvider
	{
		nextID=928;
	};
	class MarkerIDProvider
	{
		nextID=6;
	};
	class LayerIndexProvider
	{
		nextID=42;
	};
	class Camera
	{
		pos[]={12413.854,76.453064,14243.263};
		dir[]={0.67097497,-0.59618539,-0.44114903};
		up[]={0.49812803,0.80288565,-0.32750764};
		aside[]={-0.54939795,2.856832e-007,-0.83562636};
	};
};
binarizationWanted=0;
addons[]=
{
	"ryanzombiesfunctions",
	"ravage",
	"A3_Modules_F_Multiplayer",
	"CUP_Creatures_Military_CDF",

so how do I add your mission.sqm to mine if yours is like this:

 raP       ‹   version 5    EditorData ±  addons 
 A3_Ui_F  A3_Modules_F_Curator_Curator  A3_Structures_F_Civ_Camping  A3_Structures_F_Items_Electronics  A3_Characters_F  A3_Weapons_F_Rifles_MX  A3_Weapons_F_Mark_Rifles_MX  A3_Weapons_F_Acc  A3_Weapons_F_Mark_Acc  A3_Weapons_F  A3_Weapons_F_Launchers_RPG32  A3_Weapons_F_Pistols_P07  A3_Weapons_F_Items  AddonsMetaData Î  randomSeed ¡*  ScenarioData R   Mission h  ‹   moveGridStep   €?angleGridStep ’
†>scaleGridStep   €?autoGroupingDist    Atoggles    ItemIDProvider M   MarkerIDProvider `   Camera s  Î   nextID _   `   nextID    s   pos dÜ€EÃ׎BHSƒEdir ìo»1T¿æk?up †…d»p[?ëT?aside ,€?Àwm´Ô‰;Î    List Þ  R   items     Item0 2   Item1 ¤   Item2 1   Item3 µ   Item4 >   Item5 Ä  R    className A3_Ui_F  name Arma 3 - User Interface  author Bohemia Interactive  url https://www.arma3.com ¤    className A3_Modules_F_Curator  name Arma 3 Zeus Update - Scripted Modules  author Bohemia Interactive  url https://www.arma3.com 1    className A3_Structures_F  name Arma 3 - Buildings and Structures  author Bohemia Interactive  url https://www.arma3.com µ    className A3_Characters_F  name Arma 3 Alpha - Characters and Clothing  author Bohemia Interactive  url https://www.arma3.com >    className A3_Weapons_F  name Arma 3 Alpha - Weapons and Accessories  author Bohemia Interactive  url https://www.arma3.com Ä    className A3_Weapons_F_Mark  name Arma 3 Marksmen - Weapons and Accessories  author Bohemia Interactive  url https://www.arma3.com R    author player h    Intel ‡   Entities ƒ  ‹   timeOfChanges  áDstartWeather     startWind ÍÌÌ=startWaves ÍÌÌ=forecastWeather     forecastWind ÍÌÌ=forecastWaves ÍÌÌ=forecastLightnings ÍÌÌ=year ó  day    hour    minute    startFogDecay B`e<forecastFogDecay B`e<ƒ   items     Item0 ×   Item1 B   Item2 c   Item3 #
   Item4 Æ
   Item5 Å  ‹    dataType Marker position {Ë€E   @WT„E name respawn_west  text Respawn  type Empty id    B    dataType Logic  PositionInfo ±  id     type ModuleCurator_F atlOffset #ÛµA CustomAttributes Ñ  c   position ÝK‚E#ÛÝAZ/„EÑ    Attribute0 9	   Attribute1 ë	   Attribute2 –
   Attribute3 ?   Attribute4 ¸  nAttributes    c    property ModuleCurator_F_Owner  expression _this setVariable ['Owner',_value,true];  Value ¡	  ë	    data ±	  ë	    type Ö	   value #adminLogged ë	   type  STRING ë	    property ModuleCurator_F_Forced  expression _this setVariable ['Forced',_value,true];  Value U
  –
    data e
  –
    type 
  value     –
   type  SCALAR –
    property ModuleCurator_F_Name  expression _this setVariable ['Name',_value,true];  Value ü
  ?    data   ?    type *   value admin ?   type  STRING ?    property ModuleInfo  expression false  Value y  ¸    data ‰  ¸    type ¥  value    ¸   type  BOOL ¸    property ModuleCurator_F_Addons  expression _this setVariable ['Addons',_value,true];  Value "  c    data 2  c    type N  value   @@c   type  SCALAR c    dataType Trigger position Ý€E   @T„E Attributes Ä  id ;    type EmptyDetector #
    onActivation hint "press Y for ZEUS"; sizeA    AsizeB    A activationBy ANYPLAYER #
    dataType Object  PositionInfo  
   side Empty flags     Attributes À
  id     type Land_CampingTable_small_F Æ
   position ÌÀEi÷¬@Óe„EÀ
    Æ
    dataType Object  PositionInfo <   side Empty  Attributes t  id     type Land_FMradio_F atlOffset È P?Å   position WÆ€EéV¼@¬f„Eangles     1øK@    t    init playSound3D ["a3\missions_f\data\sounds\radio_track_01.ogg", this]; Å    dataType Group  side West  Entities    Attributes …  id <   ‹   items     Item0 ,  …    dataType Object  PositionInfo    side West flags     Attributes ½  id =    type B_soldier_AR_F …   position hÄ€EÊ @>U„E½   isPlayer     Inventory á  …   
 primaryWeapon Ç   secondaryWeapon    handgun ›   uniform    vest Ä   backpack ñ   map ItemMap  compass ItemCompass  watch ItemWatch  radio ItemRadio  goggles G_Combat  hmd NVGoggles  headgear H_HelmetB_grass …    name arifle_MX_SW_F  muzzle muzzle_snds_H  flashlight acc_pointer_IR  underBarrel bipod_01_F_snd  primaryMuzzleMag I      name 100Rnd_65x39_caseless_mag ammoLeft d       name launch_RPG32_F ›    name hgun_P07_F  muzzle muzzle_snds_L  primaryMuzzleMag à      name 16Rnd_9x21_Mag ammoLeft        typeName U_B_CombatUniform_mcam_tshirt isBackpack      MagazineCargo m   ItemCargo ‚  Ä   items     Item0 «   Item1 ß   Item2    Item3 J  ‚    name HandGrenade count    ammoLeft    ß    name SmokeShell count    ammoLeft        name SmokeShellGreen count    ammoLeft    J    name Chemlight_green count    ammoLeft    ‚   items     Item0 Ÿ  Ä    name FirstAidKit count    Ä    typeName V_PlateCarrier2_rgr isBackpack      MagazineCargo 
  ñ   items     Item0 @   Item1 ‚   Item2 ¹  ñ    name 100Rnd_65x39_caseless_mag count    ammoLeft d   ‚    name 16Rnd_9x21_Mag count    ammoLeft    ¹    name Chemlight_green count    ammoLeft    ñ    typeName B_AssaultPack_rgr isBackpack     MagazineCargo 8  …   items     Item0 U  …    name RPG32_F count    ammoLeft    …    ‹      

 

Share this post


Link to post
Share on other sites

Ok i got it now !

 

You don't need this at all.

You need to add only the files from the mission folder and copy the lines pf the init.sqf.

 

But why are you really editing the mission.sqm ?

 

 

 

Share this post


Link to post
Share on other sites

Looks like I forgot how to install scripts, yep, it works without the mission.sqm, idk what I was thinking about, ty.

And I honestly forgot why exactly I keep the mission.sqm not binarized, but I know something went wrong in the past and it had to do with the mission.sqm and I couldn't edit it. So I just keep it like this, bc last time I had to start it all over again.

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

I remember in the old times before the 3D editor , editing the sqm but , i don't think that now is really needed.

Share this post


Link to post
Share on other sites

So I found the script you told me about from Grumpy Old Man  

//initPlayerLocal.sqf
TAG_fnc_captiveCheck = {
	params ["_unit"];
	_unit setCaptive true;

	waitUntil {currentWeapon _unit != ""};

	_unit setCaptive false;
	{_x reveal [_unit,4]} forEach (_unit nearEntities 25);
};

player spawn TAG_fnc_captiveCheck;

Only problem is that it doesn't work if your weapon is holstered, it's like the weapon is equipped. What if instead of no gun, the gun is lowered if that's even a command for scripts, holstered would be the best but I think that needs a completely new script ?

  • Like 1

Share this post


Link to post
Share on other sites

The first one doesn't work, or I don't know how to make it work, and I'll try the second one tomorrow bc it looks too complicated to start it now. I'll tell you how it went after I finish it tomorrow.

Also, ty for your help so far.

  • Like 1

Share this post


Link to post
Share on other sites
53 minutes ago, GreenXp said:

Also, ty for your help so far.

 

initPlayerLocal.sqf

//	Once the player is in a disance from the enemies , the enemy will stop shooting.

GF_Captive_Safe_Distance = 10;	//	10m test


GF_Captive ={


player setCaptive true;

	player addEventHandler ["FiredMan", {
		params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
		
		params ["_unit"];
		_unit setCaptive false;
		hint "setCaptive false";
		_unit setVariable ["Var_GF_Captive",true];
	}];

	
		while {true} do {	
			waituntil{sleep 1;
				_nearestobjects = nearestObjects [getpos player, ["Man"],worldsize];
				{
					if (
						!(side _x isEqualto playerside)
						&& ((_x distance player) > GF_Captive_Safe_Distance)
						)then{	
							player setCaptive true;
							//	systemchat format["player > %1",GF_Captive_Safe_Distance];
						}else{
							//	systemchat "CLOSE";
					};
				}forEach _nearestobjects;	
				hint format["captive : %1",captive player];
			};
		};	
		
};	
	
player call GF_Captive;

 

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, GreenXp said:

So I found the script you told me about from Grumpy Old Man  


//initPlayerLocal.sqf
TAG_fnc_captiveCheck = {
	params ["_unit"];
	_unit setCaptive true;

	waitUntil {currentWeapon _unit != ""};

	_unit setCaptive false;
	{_x reveal [_unit,4]} forEach (_unit nearEntities 25);
};

player spawn TAG_fnc_captiveCheck;

Only problem is that it doesn't work if your weapon is holstered, it's like the weapon is equipped. What if instead of no gun, the gun is lowered if that's even a command for scripts, holstered would be the best but I think that needs a completely new script ?

 

One solution would be to have both sides set to captive (to make sure AI on player side won't engage indfor AI), also necessary to set indfor to hostile against the players side in the mission editor, which you most likely already have.

Then you can either handle the engagement to happen map wide or local within a certain radius of the firer:

//initPlayerLocal.sqf

player addEventHandler ["Fired",{
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
	units _unit apply {_x setCaptive false};
	if (time < _unit getVariable ["TAG_fnc_revealTimeout",-10]) exitWith {false};
	{
		_x reveal [_unit,4];
		_x setCaptive false
	} forEach (_unit nearEntities viewDistance);
	_unit setVariable ["TAG_fnc_revealTimeout",time + 10];//will only reveal the unit every 10 seconds when firing
}];

Make every indfor and player unit captive at mission start to make this work.

When a player fires, all player group members get captive state removed, and the firer will be revealed to everyone within view distance.

The reveal will only happen every 10 seconds for performance reasons, also in MP you might need to remoteExec the reveal.

 

You can make it a bit more sophisticated, take average reaction time into account and also consider speed of sound if wanted.

 

Cheers

 

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

So, they are prty much the same, but my problem is this: https://imgur.com/a/j2VhLqC

I'm blue coming from the side, gonna kill some enemies where red is to help green, then go in and "trade" with them, there is a trader inside that house. My problem is that if I shoot anywhere close to them they will shoot me.

My plan was to make a shop with indep inside, no matter what is going on outside they will not leave or shoot until fired upon, and once you shoot them they won't go back to being friendly. That's what I wanted to do, but as more I thing about it the more complicated it gets, so I may end up making them BluFor and make them invincible so you can't kill them and take their stuff for free.  

Share this post


Link to post
Share on other sites
9 minutes ago, GreenXp said:

So, they are prty much the same, but my problem is this: https://imgur.com/a/j2VhLqC

I'm blue coming from the side, gonna kill some enemies where red is to help green, then go in and "trade" with them, there is a trader inside that house. My problem is that if I shoot anywhere close to them they will shoot me.

My plan was to make a shop with indep inside, no matter what is going on outside they will not leave or shoot until fired upon, and once you shoot them they won't go back to being friendly. That's what I wanted to do, but as more I thing about it the more complicated it gets, so I may end up making them BluFor and make them invincible so you can't kill them and take their stuff for free.  

This is something entirely different from what you were asking in the first post.

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites

How is that different ? It's the same thing, they need to be neutral so they only shoot when fired upon...

Share this post


Link to post
Share on other sites
1 hour ago, Grumpy Old Man said:

This is something entirely different from what you were asking in the first post.

 

Cheers

 

58 minutes ago, GreenXp said:

How is that different ? It's the same thing, they need to be neutral so they only shoot when fired upon...

 

I thought that from your OP you were trying to do something where you don't want your intended targets shooting at you until you fire at them, meaning you intended to fire at them. So yeah, @Grumpy Old Man is right in that regard as his solution will have anyone near become hostile when you fire.

 

You could use something along the lines of Grumpy's solution but instead of a "Fired" event handler on the player you could put a "Dammaged" event handler on the traders.

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, GreenXp said:

as more I thing about it the more complicated it gets

welcome to the world of scripting ;-)

  • Like 2
  • Haha 1

Share this post


Link to post
Share on other sites
11 hours ago, GreenXp said:

My plan was

 

GreenXp , just really the next time , you should provide more informations , in order everyone to understand better.

 

10 hours ago, beno_83au said:

you could put a "Dammaged" event handler on the traders.

What Beno said , is what you are looking for.

  • Like 1

Share this post


Link to post
Share on other sites
15 hours ago, GEORGE FLOROS GR said:

GreenXp , just really the next time , you should provide more informations , in order everyone to understand better.

:yeahthat:--scripting is already complicated enough as it is...you really don't want to mess things up even more by NOT providing CRYSTAL CLEAR info on what you try to achieve.

Other than that, a little humble courtesy to who's try to help ya, and you're set,bro.

 

 

  • Like 1

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

×