Nutty_101 0 Posted May 28, 2007 I would like to attach event handlers to the phone poles but it seems that you cannot as they have no class names. The only thing i can come up with is their id or an "SloupyEle.p3d". I can destroy then and run a script that checks it over and over but that does me no good since it could end up being used to gain repair points. I need to check if the person who killed the pole was an enemy or not. Item: White telephone pole Example id: 390446 Location: GD26 (North side of Eponia to the base to the north) Share this post Link to post Share on other sites
Big Dawg KS 6 Posted May 28, 2007 Give it a killed EH. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(getpos player nearestObject 390446) addEventhandler ["killed",{Killer = _this select 1}] Share this post Link to post Share on other sites
Nutty_101 0 Posted May 28, 2007 Give it a killed EH.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(getpos player nearestObject 390446) addEventhandler ["killed",{Killer = _this select 1}] Not working, can't add action to them either. Share this post Link to post Share on other sites
kronzky 5 Posted May 29, 2007 If you expect that pole to be blown up via a satchel charge, what you could do is stick a small object into the ground next to it, and attach an EH to that. (It wouldn't catch a situation where the pole is blown up via an RPG aimed right at it, as that wouldn't necessarily damage the buried object, but depending on your mission configuration this might work.) As an example, put a radio next to the pole, give it the name "radio", and put the following code into its init line (broken up into several lines here for better readability): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">pole=getpos radio nearestObject 390446; polepos=[getpos pole select 0,getpos pole select 1, -.1]; radio setpos polepos; radio addEventhandler ["hit","if (_this select 0!=_this select 1) then {if (damage pole==1) then {killer=_this select 1}}; radio setDamage 0; radio setpos polepos;"] What this does is put the pole object into the variable "pole", remember its (underground) position, and then put the radio there. It then attaches an EH for a "hit" event to the radio. This EH first checks whether the radio is damaging itself (which can happens if it flies through the air after an explosion), and if not, then check the damage to the pole. If the damage is 1 (dead) it assigns the unit who caused this to the variable "killer". After each hit the radio's position and damage are reset, so that it doesn't get pushed away by a minor explosion. You could then have a trigger with the condition "!alive pole" that would fire as soon as it's knocked over. Share this post Link to post Share on other sites
Nutty_101 0 Posted May 29, 2007 If you expect that pole to be blown up via a satchel charge, what you could do is stick a small object into the ground next to it, and attach an EH to that. (It wouldn't catch a situation where the pole is blown up via an RPG aimed right at it, as that wouldn't necessarily damage the buried object, but depending on your mission configuration this might work.)As an example, put a radio next to the pole, give it the name "radio", and put the following code into its init line (broken up into several lines here for better readability): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">pole=getpos radio nearestObject 390446; polepos=[getpos pole select 0,getpos pole select 1, -.1]; radio setpos polepos; radio addEventhandler ["hit","if (_this select 0!=_this select 1) then {if (damage pole==1) then {killer=_this select 1}}; radio setDamage 0; radio setpos polepos;"] What this does is put the pole object into the variable "pole", remember its (underground) position, and then put the radio there. It then attaches an EH for a "hit" event to the radio. This EH first checks whether the radio is damaging itself (which can happens if it flies through the air after an explosion), and if not, then check the damage to the pole. If the damage is 1 (dead) it assigns the unit who caused this to the variable "killer". After each hit the radio's position and damage are reset, so that it doesn't get pushed away by a minor explosion. You could then have a trigger with the condition "!alive pole" that would fire as soon as it's knocked over. Humm, ill play with that one. Are there any invisible objects we have at our disposal? Pretty much it generates a mission for players or the AI to repair the power lines if they get cut. This kills power to the base until the power gets restored stopping all automated AA, lights and production in the base. Once the poles are killed a player or AI (if no one takes the mission) will have to run out and repair the poles. This awards some points so i was hoping to avoid having someone sitting there taking the poles down and running the repair mission for quick points. Share this post Link to post Share on other sites
mr.peanut 1 Posted May 29, 2007 Use a trigger that checks the damage of the pole. If there are many poles, then write a script instead to loop through the poles checking the damage. Add actions to gamelogics set to the poles' positions. Share this post Link to post Share on other sites
kronzky 5 Posted May 29, 2007 Humm, ill play with that one. Are there any invisible objects we have at our disposal? The only invisible object I'm aware of is the helipad. But you need an item that can register damage (to fire the "hit" EH), and I'd doubt any invisible object would do that. But you can certainly try... Use a trigger that checks the damage of the pole. If there are many poles, then write a script instead to loop through the poles checking the damage. Add actions to gamelogics set to the poles' positions. Since he needed the cause of the damage a simple trigger wouldn't be enough. That's why all the hoop-jumping... Share this post Link to post Share on other sites
Nutty_101 0 Posted May 30, 2007 Yeah other objects work for the nukes that happen to them, but i cannot detect the person who ran the poles down with a tank. I ended up reverting to checking who is closest to the pole. Gonna be false hits but oh well. Share this post Link to post Share on other sites