Solarcode red 2 Posted April 7, 2023 null = this spawn {_this dotarget t6; sleep 0.5; while {alive t6 and alive _this} do {sleep 4; gl action ["useweapon",vehicle _this,_this,0]; }}; I used this code in my mission is there a way to use this or something like it but with a trigger? Right now the AI shoots as soon as the mission starts I'd like for them to only shoot once the player moves into a trigger. Share this post Link to post Share on other sites
Play3r 147 Posted April 7, 2023 put inside the ACT: in the trigger and set the trigger up how you like. Share this post Link to post Share on other sites
pierremgi 4850 Posted April 7, 2023 this refers to the shooting AI, when the code is placed inside the init field. That will not work in activation code of the trigger. If you want to use a trigger, you need to change this for an AI's name, like bob (as far as you named this AI: bob). Share this post Link to post Share on other sites
Solarcode red 2 Posted April 8, 2023 23 hours ago, Play3r said: put inside the ACT: in the trigger and set the trigger up how you like. Sorry for the late response and I think I tried this but I'll give it a shot Share this post Link to post Share on other sites
Solarcode red 2 Posted April 8, 2023 18 hours ago, pierremgi said: this refers to the shooting AI, when the code is placed inside the init field. That will not work in activation code of the trigger. If you want to use a trigger, you need to change this for an AI's name, like bob (as far as you named this AI: bob). Sorry for the late reply where would I be putting the varibles name I tried a few spoys and got the error missing ; Edit: So I figured out that part but when I walk into the trigger nothing for more context the unit is on the door gunner posistion so I'm not sure if that has something to do with I'll keep tinkering thanks for the help so far Share this post Link to post Share on other sites
Solarcode red 2 Posted April 8, 2023 Well I tried that on a regular unit walked into the trigger but they just sit there and don\t shoot so idk This is that I put into the act of the trigger: null = this spawn {_shooter1 dotarget AR8; sleep 0.5; while {alive AR8 and alive _this} do {sleep 10; gl action ["useweapon",vehicle _this,_this,0]; }}; Share this post Link to post Share on other sites
major-stiffy 279 Posted April 8, 2023 And Alive _this. _this is not defined Share this post Link to post Share on other sites
Harzach 2517 Posted April 8, 2023 Your original code: null = this spawn {_this dotarget t6; sleep 0.5; while {alive t6 and alive _this} do {sleep 4; gl action ["useweapon",vehicle _this,_this,0]; }}; @pierremgi's reply: Quote this refers to the shooting AI, when the code is placed inside the init field. That will not work in activation code of the trigger. If you want to use a trigger, you need to change this for an AI's name, like bob (as far as you named this AI: bob). Looking at a reduction of your code: null = this spawn {_this dotarget t6}; this is the data being passed to the code that is being spawned. Inside that code, this is natively defined as the magic local variable _this. If you set your unit's var name to shooter1, that's what we change this to: null = shooter1 spawn {_this dotarget t6}; Full code: null = shooter1 spawn {_this dotarget t6; sleep 0.5; while {alive t6 and alive _this} do {sleep 4; gl action ["useweapon",vehicle _this,_this,0]; }}; Let's break it down: shooter1 targets t6 wait 0.5 seconds while both shooter1 and t6 are alive: -- wait 4 seconds -- gl do action "useweapon" on shooter1's vehicle (defined as shooter1 unless they are in a vehicle) That last bit is probably not what you want to happen. Assuming via context clues that gl is a unit in a grenade launcher turret, you would want something like this: null = shooter1 spawn {_this dotarget t6; sleep 0.5; while {alive t6 and alive _this} do {sleep 4; gl action ["useweapon",vehicle gl,gl,0]; }}; Untested. Let us know how it goes. Share this post Link to post Share on other sites
Solarcode red 2 Posted April 9, 2023 8 hours ago, Harzach said: Your original code: null = this spawn {_this dotarget t6; sleep 0.5; while {alive t6 and alive _this} do {sleep 4; gl action ["useweapon",vehicle _this,_this,0]; }}; @pierremgi's reply: Looking at a reduction of your code: null = this spawn {_this dotarget t6}; this is the data being passed to the code that is being spawned. Inside that code, this is natively defined as the magic local variable _this. If you set your unit's var name to shooter1, that's what we change this to: null = shooter1 spawn {_this dotarget t6}; Full code: null = shooter1 spawn {_this dotarget t6; sleep 0.5; while {alive t6 and alive _this} do {sleep 4; gl action ["useweapon",vehicle _this,_this,0]; }}; Let's break it down: shooter1 targets t6 wait 0.5 seconds while both shooter1 and t6 are alive: -- wait 4 seconds -- gl do action "useweapon" on shooter1's vehicle (defined as shooter1 unless they are in a vehicle) That last bit is probably not what you want to happen. Assuming via context clues that gl is a unit in a grenade launcher turret, you would want something like this: null = shooter1 spawn {_this dotarget t6; sleep 0.5; while {alive t6 and alive _this} do {sleep 4; gl action ["useweapon",vehicle gl,gl,0]; }}; Untested. Let us know how it goes. Ok wow thank you I'll try this right now I appreciate all the help Share this post Link to post Share on other sites
Solarcode red 2 Posted April 9, 2023 Works perfectly for the infantry the heli gunner shoots but not at the target just off in the distance and Is there away on the deactivation to get them to stop shooting I'll try and look for something but thank you nonetheless Share this post Link to post Share on other sites
Solarcode red 2 Posted April 9, 2023 (edited) this is so complicated it's ridiculus some want to shoot some don't even though I just copied and pasted and changed the need things Edit: so I got must of them working two ai infantry just don't want to shoot idk why and the gunner of the heli doesn't shot at the object just randomly of into the distance and the tank gunner shoots jsut once Edited April 9, 2023 by Solarcode red Share this post Link to post Share on other sites
pierremgi 4850 Posted April 10, 2023 Take time to write your code and describe your scenario. So much details can ruin the desired effect (like distance between shooter and target, kind of target, properties of the ammo...) Have a look at doSuppressiveFire command, perhaps your friend here. Share this post Link to post Share on other sites
bLAcKmAgE87 13 Posted April 10, 2023 your trigger activates... in your trigger you've put... say... [] execVM 'fireIt.sqf' ; in your mission folder...you've saved a text file with the extension .sqf as fireIt ... or fireIt.sqf after selecting allFiles from the dialog in notepad. etc... 1 Share this post Link to post Share on other sites