Jump to content
donpachiyarou

How to make a "Automatic Shield"?

Recommended Posts

Hi

I want to make a "Automatic shield" against the bullet which will hit the player(bullet which will not hit player shuld be ignored)

I tried EH"Suppressed" and found that this EH wont run when the bullet hit the player,it runs only when  the bullet "miss" the player.I want the  "Suppressed" which have opposite role(=runs when the bullet will hit the unit)

and it always runs too late,it runs when the bullet come very very close to the player(smaller than 5m maybe?)

I want to make "Automatic shield" by

1.detect bullet which may hit the player when distance between bullet&player<5~10m

2.when incoming bullet is detected,create VR object like Sphere(20cm)or ProtectionZone or Helipad or  something which have "Shiled looking"and put it near the player( I want this looks like Defense Spell found in "Frieren: Beyond Journey's End")

and create explosive(grenade or 40mm HE?) and attach it to the incoming bullet.

3.make the attached explosive explode by using "trriggerammo" or setdamage 1;and delete the incoming bullet&Shield

Is there any good idea to do this idea?

thanks!

 

Share this post


Link to post
Share on other sites

 

this addEventHandler ["FiredMan", {
     params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
    private _ang=_projectile getreldir (getAttackTarget _unit);
    private _L=_projectile distance (getAttackTarget _unit);
    private _dst=_L*tan(_ang);
    private _teki=(getAttackTarget _unit);
    systemchat format["%1",_dst];
    if  (_dst<10) then
                      {private _sld="Sign_Sphere200cm_F" createvehicle [0,0,0];_sld attachto[(getAttackTarget _unit),[0,0,1]];_sld setObjectScale 1.7;_sld setObjectTextureGlobal [0, "#(rgb,8,8,3)color(0,0,1,1)"];
                      private _mkr="B_30mm_HE_Tracer_Red" createvehicle[0,0,0];_mkr attachto[_projectile,[0,0,0]];private _tate="ProtectionZone_F" createvehicle[0,0,0];_tate attachto[(getAttackTarget _unit),[0,0,0]];_tate setObjectScale 0.2;
       [_projectile,_sld,_teki,_tate] spawn{params["_projectile","_sld","_teki","_tate"];while{alive _projectile && (_projectile getreldir _teki<10)}do
      {sleep 0.3;};sleep 0.5;deletevehicle _sld;deletevehicle _tate;};
                       };
  }];

 

I think this working.But I want to limit the use of this Auto Deploy Shield by Consuming specific item which soldier have in their backpack(this shouldnt work without specific item )

how can I check if (aimed soldier has specific item in their backpack)?

and,does this script eat server's resource?(2500K/DDR3 16GB/SSD128GB/FTTH1Gbps)

Share this post


Link to post
Share on other sites
38 minutes ago, donpachiyarou said:

how can I check if (aimed soldier has specific item in their backpack)?

 

You can use BIS_fnc_hasItem

Share this post


Link to post
Share on other sites

That is what I want so much,Thanks!

Now it's woking in my Server (I think)

onplayerrespawn.sqf
  [player,"Auto Deploy Shield Standby","", "","( (currentweapon _this=="""")&&([_target, ""FirstAidKit"", true] call BIS_fnc_hasItem)&&(vehicle _this==_this) )","( (currentweapon _this=="""")&&([_target, ""FirstAidKit"", true] call BIS_fnc_hasItem)&&(vehicle _this==_this) )",
  {_a0="Sign_Sphere200cm_F" createVehicle [0,0,0];_a0 attachto[_caller,[0,0,0.9]];_a0 setObjectTexture [0,"#(rgb,8,8,3)color(0.2,0.6,0.8,0.3)"];_a0 setObjectScale 2.3;}
  ,{private _a1=getobjectscale _a0;if (_a1<1) then{deletevehicle _a0;};},{deletevehicle _a0;_caller removeitem "FirstAidkit";},{deletevehicle _a0;_caller removeitem "FirstAidkit";},["_a0","_a1"],8,1000,false]call BIS_fnc_holdActionAdd;

Enemy's init (In domination 4.65,spawnvehicle.sqf/makemgroup.sqf)

_one_unit addEventHandler ["FiredMan", {  //https://forums.bohemia.net/forums/topic/230250-changing-bullet-velocity-without-a-mod/ 2023.1.1
    params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
       private _teki=(getAttackTarget _unit);
       private _atc=attachedobjects _teki;
       private _size=getobjectscale (_atc select 0);
       if ( (_teki iskindof "SoldierWB")&&(_atc select 0 !=objnull) )then
         {
          private _tate="ProtectionZone_F" createvehicle[0,0,0];_tate attachto[(getAttackTarget _unit),[0,0,1]];_tate setObjectTexture [0,"#(rgb,8,8,3)color(0.2,0.6,0.8,0.3)"];_tate setObjectScale 0.03; 
           [_projectile,_teki,_tate,_atc,_size] spawn{params["_projectile","_teki","_tate","_atc","_size"];while{alive _projectile && (_projectile getreldir _teki<10)}do 
            {sleep 0.3;};sleep 0.1;deletevehicle _tate;(_atc select 0) setobjectscale (_size-0.15);}; 
         };
     }];

https://www.youtube.com/watch?v=O3EUSfOZCYA

  • Like 2

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

×