TMG_On_YT

Arma 3 explosion when hitting opject (event handler)

24 posts in this topic

Hi there,

 

I need some quick help with some even handlers..

 

Anyway, the idea is in the mission you attack an oil rig. You shoot on the oil pipes which makes the oil pipes explode and burn. The idea is because of the explosions you kill the enemies inside and win the mission. Okey, so I have this script here:

 

thisaddEventHandler ["hit", "scriptedCharge = "DemoCharge_Remote_Ammo_Scripted" createVehicle (getMarkerPos "bombmrk"); scriptedChargesetdamage 1;"]

 

 

Alright, I also want, once you hit the oil pipe, the oil storage next to it will explode bybeeingtrigger with an even handler explode. Anyone can help me with this? This will BTW be a mutliplayer mission. 

1 person likes this

Share this post


Link to post
Share on other sites

I already done something like that in one of my missions. It was the contrary: blowing a tower makes oil pipes explode within 200m.  :

 

[] spawn {
  _towers = nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["house"], worldSize /2] select {_x isKindOf "land_ind_oil_tower_EP1"};
  while {true} do {
    sleep 2;
      {
        if (damage _x ==1 && !(_x getVariable ["MGI_pipeBlast",false])) then {
          _pipes = nearestTerrainObjects [_x,["house"], 200] select {!(_x isKindOf "land_ind_oil_pump_EP1")};
          for "_i" from 0 to count _pipes - 1 do {
            _pipe = _pipes select _i;
            if !(isObjectHidden _pipe) then {
              _pipe setDamage 1;
              sleep 0.1;
              "helicopterExploBig" createVehicle (getpos _pipe);
              hideObjectGlobal _pipe
            };
          };
          _x setVariable ["MGI_pipeBlast",true];
        }
      } forEach _towers;
  }
};

 

 

1 person likes this

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

I already done something like that in one of my missions. It was the contrary: blowing a tower makes oil pipes explode within 200m.  :

 


[] spawn {
  _towers = nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["house"], worldSize /2] select {_x isKindOf "land_ind_oil_tower_EP1"};
  while {true} do {
    sleep 2;
      {
        if (damage _x ==1 && !(_x getVariable ["MGI_pipeBlast",false])) then {
          _pipes = nearestTerrainObjects [_x,["house"], 200] select {!(_x isKindOf "land_ind_oil_pump_EP1")};
          for "_i" from 0 to count _pipes - 1 do {
            _pipe = _pipes select _i;
            if !(isObjectHidden _pipe) then {
              _pipe setDamage 1;
              sleep 0.1;
              "helicopterExploBig" createVehicle (getpos _pipe);
              hideObjectGlobal _pipe
            };
          };
          _x setVariable ["MGI_pipeBlast",true];
        }
      } forEach _towers;
  }
};

 

 

Hi there,

 

Could you explain me a bit more how to use this? (I'm a bit new to making missions)

 

thanks 

Share this post


Link to post
Share on other sites

So, first of all, it's not the exact code you want; As I said, you blow a tower (no matter how), you make the pipes explode.

 

Just place it in initServer.sqf or even, in a trigger (server only) with true as condition (easy for test it).

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

So, first of all, it's not the exact code you want; As I said, you blow a tower (no matter how), you make the pipes explode.

 

Just place it in initServer.sqf or even, in a trigger (server only) with true as condition (easy for test it).

 

 

Does this trigger when I shoot an object? I still don't really understand it... I just wanne put a simple hit even handler and an explode handler next to it. I think thats a bit easier and quicker. Do you know whats wrong with my current code? 

Share this post


Link to post
Share on other sites

Your current code must be corrected and applied on an edited object (i;e. you place your own pipes in editor, then you place this kind of code in init filed of the pipes). For map objects, you have to select them with a code.

As you wrote something with an EH, i guessed you were skilled at this kind of scripting.

My script doesn't use an EH here (my bad!) but loop all game long for any oil tower with damage set to 1. A 2sec loop is not so CPU demanding. Then, when any tower is blown, the surrounding pipes are also blown.

If you just need something more local (a particular oil plant, just change the nearestTerrainObjects parameters (mine are for whole map).

Share this post


Link to post
Share on other sites
13 minutes ago, pierremgi said:

Your current code must be corrected and applied on an edited object (i;e. you place your own pipes in editor, then you place this kind of code in initfiled of the pipes). For map objects, you have to select them with a code.

As you wrote something with an EH, i guessed you were skilled at this kind of scripting.

My script doesn't use an EH here (my bad!) but loop all game long for any oil tower with damage set to 1. A 2sec loop is not so CPU demanding. Then, when any tower is blown, the surrounding pipes are also blown.

If you just need something more local (a particular oil plant, just change the nearestTerrainObjects parameters (mine are for whole map).

 

I put this code in an opject init in the editor. It tell me error: missing ] whenever I click okey

Share this post


Link to post
Share on other sites

Ah OK, man. I thought you were speaking about my (working) code!. For your code:

1 this addEventHandler [....]    separate this and addEventHandler...

 

2 quotes into quotes are like " ' ' "  not " " " "  , but you can use this addEventHandler ["hit", { scriptedCharge = "DemoCharge_Remote_Ammo_Scripted" createVehicle ....  }] for your code.

 

3 but all of this concerns syntax so far. Your main problem is the pipes don't take any damage and don't have hit parts. So, your EH will never ever trigger...

 

The reasons why:

1 I did a loop waiting for damage on TOWERS (script works on tower collapsed by explosive)

 

2 I hide the pipes after explosion, because they'll never be destroyed

 

3 I added a variable to make sure i can't "blow" existing pipes twice (blowing another near tower , then avoiding a second unwanted explosion on already hidden pipes)

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

Ah OK, man. I thought you were speaking about my (working) code!. For your code:

1 this addEventHandler [....] (separated this and addEventHandler...

 

2 quotes into quotes are like " ' ' "  not " " " "  , but you can use this addEventHandler ["hit", { "scriptedCharge = "DemoCharge_Remote_Ammo_Scripted" createVehicle ....  }] for your code.

 

3 but all of this concerns syntax so far. Your main problem is the pipes don't take any damage and don't have hit parts. So, your EH will never ever trigger...

 

The reasons why:

1 I did a loop waiting for damage on TOWERS (script works on tower collapsed by explosive)

 

2 I hide the pipes because they never be destroyed

 

3 I added a variable to make sure i can't "blow" existing pipes twice (blowing another near tower , then avoiding a second unwanted explosion)

 

I tried the code and now it give me this:

 

https://gyazo.com/98ea77bb8cb5c49b792acd2fe4165a13

 

I'm a bit nooby sorry... Anyway, I thought maybe you could link me your mission so I can try it out and check the code?

Share this post


Link to post
Share on other sites

1:     don't use local variable _towers in a variable name of an object (but you don't need any name as well)

2:    0 = [] spawn instead of  [] spawn   (add:  0 =  or null = ) (I place mine into a server only trigger. server only is important for MP but I guess you are writing for SP mission).

Share this post


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

1:     don't use local variable _towers in a variable name of an object (but you don't need any name as well)

2:    0 = [] spawn instead of  [] spawn   (add:  0 =  or null = ) (I place mine into a server only trigger. serveronly is important for MP but I guess you are writing for SP mission).

 

I tried playing around with this and I still don't have any results... Do u have any link I can download the mission from? 

Share this post


Link to post
Share on other sites

place a trigger (let none,none, that doesn't matte) , server only, condition field : true instead of this

then in on activation field:

Spoiler

0 = [] spawn {
  _towers = nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["house"], worldSize /2] select {_x isKindOf "land_ind_oil_tower_EP1"};
  while {true} do {
    sleep 2;
    {
      if (damage _x ==1 && !(_x getVariable ["MGI_pipeBlast",false])) then {
        _pipes = nearestTerrainObjects [_x,["house"], 200] select {!(_x isKindOf "land_ind_oil_pump_EP1")};
        for "_i" from 0 to count _pipes - 1 do {
          _pipe = _pipes select _i;
          if !(isObjectHidden _pipe) then {
             _pipe setDamage 1;
             sleep 0.1;
            "helicopterExploBig" createVehicle (getpos _pipe); hideObjectGlobal _pipe
          };
        };
        _x setVariable ["MGI_pipeBlast",true];
     }
   } forEach _towers;
  }
};

 

run the mission

 

Place a charge on a oil tower (not pump , not pipe). Blow the oil tower. Enjoy! (if there is any pipe within 200 m from the tower)

 

Tested in this mission.

Share this post


Link to post
Share on other sites
19 hours ago, pierremgi said:

place a trigger (let none,none, that doesn't matte) , server only, condition field : true instead of this

then in on activation field:

  Hide contents

0 = [] spawn {
  _towers = nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["house"], worldSize /2] select {_x isKindOf "land_ind_oil_tower_EP1"};
  while {true} do {
    sleep 2;
    {
      if (damage _x ==1 && !(_x getVariable ["MGI_pipeBlast",false])) then {
        _pipes = nearestTerrainObjects [_x,["house"], 200] select {!(_x isKindOf "land_ind_oil_pump_EP1")};
        for "_i" from 0 to count _pipes - 1 do {
          _pipe = _pipes select _i;
          if !(isObjectHidden _pipe) then {
             _pipe setDamage 1;
             sleep 0.1;
            "helicopterExploBig" createVehicle (getpos _pipe); hideObjectGlobal _pipe
          };
        };
        _x setVariable ["MGI_pipeBlast",true];
     }
   } forEach _towers;
  }
};

 

run the mission

 

Place a charge on a oil tower (not pump , not pipe). Blow the oil tower. Enjoy! (if there is any pipe within 200 m from the tower)

 

Tested in this mission.

Thanks,

 

What pipe should I use? Any pipe? 

Share this post


Link to post
Share on other sites
19 hours ago, pierremgi said:

place a trigger (let none,none, that doesn't matte) , server only, condition field : true instead of this

then in on activation field:

  Reveal hidden contents

0 = [] spawn {
  _towers = nearestTerrainObjects [[worldSize/2,worldSize/2,0], ["house"], worldSize /2] select {_x isKindOf "land_ind_oil_tower_EP1"};
  while {true} do {
    sleep 2;
    {
      if (damage _x ==1 && !(_x getVariable ["MGI_pipeBlast",false])) then {
        _pipes = nearestTerrainObjects [_x,["house"], 200] select {!(_x isKindOf "land_ind_oil_pump_EP1")};
        for "_i" from 0 to count _pipes - 1 do {
          _pipe = _pipes select _i;
          if !(isObjectHidden _pipe) then {
             _pipe setDamage 1;
             sleep 0.1;
            "helicopterExploBig" createVehicle (getpos _pipe); hideObjectGlobal _pipe
          };
        };
        _x setVariable ["MGI_pipeBlast",true];
     }
   } forEach _towers;
  }
};

 

run the mission

 

Place a charge on a oil tower (not pump , not pipe). Blow the oil tower. Enjoy! (if there is any pipe within 200 m from the tower)

 

Tested in this mission.

I see this is for placed oil pipes on the map... Maybe there is a way to spawn explosion with exc on server or something? It's for a cinematic/mission thing and maybe I can get someone to excecute something on the server which will spawn some explosions on my command (So I can tell him to exc some code the same moment I shoot on the oil pipe) is this possible? 

Share this post


Link to post
Share on other sites

erh... Sorry I will try to be more understandable. Not my native language.

You have map embedded pipes on some maps like Takistan, but you can add some edited object, industrial ones. Their classes are shown in editor.

 

For embedded objects, you have to select / catch them with the nearestTerrainObjects "house" type. You can't name them or add any code like in edited object attributes.

 

For all of them, both edited or embedded, there is no damaged/destroyed simulation (a different shape), so ther is no damage/hit possibilities. They are like static, non-simulated objects.

 

My script is working for embedded object. The reason why is used nearestTERRAINObjects instead of nearestObjects.

So this code will not work with edited pipes.

 

Share this post


Link to post
Share on other sites
5 minutes ago, pierremgi said:

erh... Sorry I will try to be more understandable. Not my native language.

You have map embedded pipes on some maps like Takistan, but you can add some edited object, industrial ones. Their classes are shown in editor.

 

For embedded objects, you have to select / catch them with the nearestTerrainObjects "house" type. You can't name them or add any code like in edited object attributes.

 

For all of them, both edited or embedded, there is no damaged/destroyed simulation (a different shape), so ther is no damage/hit possibilities. They are like static, non-simulated objects.

 

My script is working for embedded object. The reason why is used nearestTERRAINObjects instead of nearestObjects.

So this code will not work with edited pipes.

 

I see this is for placed oil pipes on the map... Maybe there is a way to spawn explosion with exc on server or something? It's for a cinematic/mission thing and maybe I can get someone to excecute something on the server which will spawn some explosions on my command (So I can tell him to exc some code the same moment I shoot on the oil pipe) is this possible?  (I replied this before if you didnt saw)

Share this post


Link to post
Share on other sites

Make it simple.

First, say what map you want to use, what position, what things you want to blow. I don't understand the final aim and you don't seem to apply my script in a right way.

Share this post


Link to post
Share on other sites
1 minute ago, pierremgi said:

Make it simple.

First, say what map you want to use, what position, what things you want to blow. I don't understand the final aim and you don't seem to apply my script in a right way.

Ok idea:

 

First of all this is in a cinematic/multiplayer thing ran on a server. The idea is:

 

I go with a boat towards an (made in editor) oil rig in Tanoa.

I shoot the oil rig and the oil rig explodes killing enemies inside. 

 

I can execute commands on the server so it would be possible to have someone execute an command on the same time I shoot so it looks like (on the video) I shoot and destory the oil rig. So I was wondering, is it possible, to put some kind of command on the opjectsinit which causes a big explosion which can be triggered through a server command. 

Share this post


Link to post
Share on other sites

All edited objects are on server anyway. All players are on clients + hosted server, never on dedicated.

There is no oli rig on Tanoa (if i'm right) . So, what object(s) classes are you using? Sugar cane plants like  "land_SCF_01_pipe_line_8m_F" ? (visible under cursor when over the object list at right)

Or an addon?

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

All edited objects are on server anyway. All players are on clients + hosted server, never on dedicated.

There is no oli rig on Tanoa (if i'm right) . So, what object(s) classes are you using? Sugar cane plants like  "land_SCF_01_pipe_line_8m_F" ?(visible under cursor when over the object list at right)

Or an addon?

 

Me and a couple friends have an Arma 3 server and make cinematics. I was wondering if its possible to have some code which will trigger an explosion on the location the object is placed. The idea is I shoot the oil rig their oil pipes and the oil rig explodes. We can have someone that executes code on the server at the same moment we shoot so it LOOKS like I make the oil pipes explode. Anyway, the oil rig is made in editor and any way we can trigger an explosion would be cool. Oil rig:https://gyazo.com/300f730b15557d07f296254fddb9dbdf

 

I hope this explains it

Share this post


Link to post
Share on other sites

I'm sorry. I can't help you more. I don't know where this oil rig comes from.

Share this post


Link to post
Share on other sites
Just now, pierremgi said:

I'm sorry. I can't help you more. I don't know where this oil rig comes from.

I said 2 times its a made opbject by someone... Its not part of tanoa map. Its just assets combined together. 

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