theavonlady 2 Posted October 28, 2004 When firing ordnance from an aircraft, does the "fired" event handler get triggered? Do you specify the AddEventHanlder "fired" command in the player's INIT field or in the aircraft's or it doesn't make a difference? Is there any way to find out which target a weapon such as a guided missile is locked on when fired? TIA! Share this post Link to post Share on other sites
hardrock 1 Posted October 28, 2004 (theavonlady @ Oct. 28 2004,16:13) said: When firing ordnance from an aircraft, does the "fired" event handler get triggered? Yes, the fired EH of the aircraft gets triggered, altough I'm not too sure if the fired EH of the pilot or gunner does so too. [b said: Quote[/b] ]Is there any way to find out which target a weapon such as a guided missile is locked on when fired? No, at least no easy one. You could make a bit of scripting and tricking to find it out but it doesn't work very well. You can make for example a weapon that is extremly fast and maneuvrable but does no damage, use this weapon instead of the normal one and grab the projectile on firing. Now check via script until the projectile is near an enemy plane and you got your target. Now you can spawn the missile under your plane and direct it to your target. Another possibility (that works "only" in missions) is add a certain script to the incomingMissile eventhandler of every flyable unit (or also the armored ones, if you like). When you fire a missile on someone, this script will be triggered by the target. Share this post Link to post Share on other sites
theavonlady 2 Posted October 28, 2004 (hardrock @ Oct. 28 2004,18:00) said: Another possibility (that works "only" in missions) is add a certain script to the incomingMissile eventhandler of every flyable unit (or also the armored ones, if you like). When you fire a missile on someone, this script will be triggered by the target. Thanks. What are the values passed by when "icomingMissile" is triggered? Come to think of it, is there complete event handler documentation anywhere? Couldn't find it at OFPEC. Share this post Link to post Share on other sites
RED 0 Posted October 28, 2004 From the command ref: "IncomingMissile" string:ammo,object:whoFired So: _this select 0 = Vehicle EH added to _this select 1 = Ammo type used _this select 2 = What unit fired it RED Share this post Link to post Share on other sites
raedor 8 Posted October 28, 2004 official comref >>> scripting topics >>> event handlers Share this post Link to post Share on other sites
Wadmann 0 Posted October 28, 2004 As an EH reference, I use Igor Drukov's Event Handlers tutorial that may be found here. Wadmann Share this post Link to post Share on other sites
theavonlady 2 Posted October 28, 2004 (Wadmann @ Oct. 28 2004,22:52) said: As an EH reference, I use Igor Drukov's Event Handlers tutorial that may be found here. Specifically, it's here. Thanks again. Share this post Link to post Share on other sites
killswitch 19 Posted October 28, 2004 (theavonlady @ Oct. 28 2004,16:13) said: Do you specify the AddEventHanlder "fired" command in the player's INIT field or in the aircraft's or it doesn't make a difference? A fired EH for a plane is added to the plane. A fired EH for a playable unit is...yep, added to that unit. Consider this contrived example: one can imagine setting up the plane's fired EH in the init line of a playable unit and that unit's fired EH in the init line of the plane. Not that there's any compelling reason to do so, but doing that mental exercise and understanding the following - why it could be done, how it could be done and why it's unadvisable to do so is good training in mission editing. Share this post Link to post Share on other sites
theavonlady 2 Posted November 10, 2004 OK, a bit off the original topic but I'm getting a generic syntax error message on this line, taken from a Russian AA solider's INIT statement: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler [""fired"",{IF ((_this select 0) == ""9K32Launcher"") THEN (Eaa1 action [""Rearm"",CrateEaa1])}] The "#" error mark in the error message shows up immediately after the word "THEN". Any ideas? TIA! Share this post Link to post Share on other sites
hardrock 1 Posted November 10, 2004 the THEN code has to be in curled brackets, not normal [b said: Quote[/b] ]this addEventHandler ["fired",{IF ((_this select 0) == "9K32Launcher") THEN {Eaa1 action ["Rearm",CrateEaa1]}}] Edit: code mistakes removed, you don't need doublequotes if it's not in the config.cpp's eventhandlers class Share this post Link to post Share on other sites
theavonlady 2 Posted November 10, 2004 (hardrock @ Nov. 10 2004,14:17) said: the THEN code has to be in curled brackets, not normal [b said: Quote[/b] ]this addEventHandler [""fired"",{IF ((_this select 0) == ""9K32Launcher"") THEN {Eaa1 action [""Rearm"",CrateEaa1]}}] That was quick! I think I already tried that but I'll doublecheck. Share this post Link to post Share on other sites
hardrock 1 Posted November 10, 2004 read again, I also removed some other errors Share this post Link to post Share on other sites
theavonlady 2 Posted November 10, 2004 (hardrock @ Nov. 10 2004,14:17) said: Edit: code mistakes removed, you don't need doublequotes if it's not in the config.cpp's eventhandlers class Don't I need doublequotes because it's in MISSION.SQM? Share this post Link to post Share on other sites
hardrock 1 Posted November 10, 2004 ah now that makes sense. the double quotes are needed, if the command is placed inside a string, like <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = "command_with_double_quotes" or call "command_with_double_quotes" if you made just single quotes, ofp would thing that the string ends here which is not true, so double quotes are needed (btw you can also make curled brackets instead of quotes/doublequotes) Share this post Link to post Share on other sites
theavonlady 2 Posted November 10, 2004 (theavonlady @ Nov. 10 2004,14:19) said: (hardrock @ Nov. 10 2004,14:17) said: the THEN code has to be in curled brackets, not normal [b said: Quote[/b] ]this addEventHandler [""fired"",{IF ((_this select 0) == ""9K32Launcher"") THEN {Eaa1 action [""Rearm"",CrateEaa1]}}] That was quick! Â I think I already tried that but I'll doublecheck. Doublecheck and the same error occurs. for verification, here's my command from the INIT line: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler [""fired"",{IF ((_this select 0) == ""9K32Launcher"") THEN {Eaa1 action [""Rearm"",CrateEaa1]}}] Yes, this is driving me bananas, too! Share this post Link to post Share on other sites
hardrock 1 Posted November 10, 2004 try write IF and THEN lowercase Share this post Link to post Share on other sites
theavonlady 2 Posted November 10, 2004 (hardrock @ Nov. 10 2004,14:42) said: try write IF and THEN lowercase Now you're desperate! So am I! So I got rid of the IF THEN logic and just issue the ACTION "REARM" command. No errors now but no action either. I'll open up a separate thread for that problem. In the meantime, the syntax problem here remains unresolved. Share this post Link to post Share on other sites
hardrock 1 Posted November 10, 2004 (theavonlady @ Nov. 10 2004,14:39) said: (hardrock @ Nov. 10 2004,14:42) said: try write IF and THEN lowercase Now you're desperate! No, I meant it serious Just tested it out, and for me it works quite well with lower-case if and then in opposition to the error-message with IF and THEN Share this post Link to post Share on other sites
theavonlady 2 Posted November 10, 2004 (hardrock @ Nov. 10 2004,16:54) said: (theavonlady @ Nov. 10 2004,14:39) said: (hardrock @ Nov. 10 2004,14:42) said: try write IF and THEN lowercase Now you're desperate! No, I meant it serious Just tested it out, and for me it works quite well with lower-case if and then in opposition to the error-message with IF and THEN Nope. LC'd if/then and got the exact same generic synatx error message after "then". Code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler [""fired"",{if ((_this select 0) == ""9K32Launcher"") then {Eaa1 action [""Rearm"",CrateEaa1]}}] EDIT: For the record, I've detoured around this problem, using an alternative method. Details here. Share this post Link to post Share on other sites