HAFGaming1 0 Posted April 12, 2019 this addEventHandler ["HandleDamage", {1}]; so that works perfectly to make a specific unit die in one shot of any weapon...but what if I want to make all opfor units effected by this code? how would I do it? I think I have to run the script through the init folder in my mission because I'm using the SpawnAI module in the editor... so yeah... been searching google for 3 days and I can't figure this out. Long story short I made a quick "capture the tower" style mission for me and my buddies. We are blufor, all the ai are opfor. I need to make all the opfor die after one shot of any caliber no matter where the round hits on the body. I'm using a SpawnAI module to spawn in all AI units so I won't be able to use the code above since the units aren't present in the editor to apply the code in their init... The whole point of this is to have wave after wave of 100s of opfor and they all die in one shot, so we can have a lot of fun. Share this post Link to post Share on other sites
sarogahtyp 1109 Posted April 12, 2019 { _d = _x addEventHandler ["HandleDamage", {1}]; } count (allUnits select {side _x isEqualTo east}); 1 Share this post Link to post Share on other sites
pierremgi 4906 Posted April 13, 2019 If you spawn AI (and for MP): in initPlayerLocal.sqf: [] spawn { while {true} do { { _x setVariable ["HAF_spawned",true]; _x addEventHandler ["handleDamage", {1}] } forEach (allUnits select {isNil {_x getVariable "HAF_spawned"} && side _x == EAST}); uiSleep 2; }; }; 1 Share this post Link to post Share on other sites
HAFGaming1 0 Posted April 13, 2019 Man you guys replied faster then I expected, I'm at work now I will try when I get home and give an update. Thanks so much for the help! Share this post Link to post Share on other sites
MechSlayer 18 Posted April 13, 2019 { if (_x side == east) then {_x addEventHandler ["HandleDamage", {1}];}; } forEach allPlayers; For players only and for AI and Players { if (_x side == east) then {_x addEventHandler ["HandleDamage", {1}];}; } forEach allUnits; Share this post Link to post Share on other sites
HAFGaming1 0 Posted April 13, 2019 Thank you so much, guys! You have no idea how happy I am to get this working! PS.Sarogahtyp, your code works but only when the AI is already placed. Such as if I let the AI spawn, then execute the code, it will work. But the next wave of AI to spawn from the SpawnAI module are not affected, then I have to run the code again. This is useful though because in the editor I would not have to place the code in EVERY unit init expression. Though if my mission spawns any AI it will not work on those ai. Thank you! pierremgi, Your code is 100% what I was hoping for. I don't understand the HAF_spawn thing, I don't know what that tells the computer. but hey it works flawlessly. Thank you! The code only needs to be executed once, and it will affect ALL opfor units. (didn't test for players)MechSlayer, I have not tested your code yet because of my buddies not being online. BUT I feel like I can manipulate this code to make the players take more shots before they die. Not sure, I barely know how to code but makes sense in my head... lol... Thank you! Share this post Link to post Share on other sites
HAFGaming1 0 Posted April 13, 2019 Okay so now I'm confused on what is going on. I can run the scripts and they work. Once I go back into the editor to adjust the mission the script will never work again for that mission. I've restarted the mission, I've restarted the game, I've put "//" in front of the execVM"OSK.sqf"; so it doesnt run it automatically, then try that excVM code in the debug, I've taken the script out of the mission entirely then run the script itself in the debug and clicked server, global, and local execute. No matter what it will only work one time per mission then never work again. Gives me this error...Using script from pierremgi, though it does this with any of the scripts. Am i doing something wrong? Is this just an Arma thing? Share this post Link to post Share on other sites
pierremgi 4906 Posted April 13, 2019 Did you create the initPlayerLocal.sqf as I recommended. What is your whole osk.sqf? Share this post Link to post Share on other sites
HAFGaming1 0 Posted April 13, 2019 idk if there's any meaning with the initPlayerLocal name I tried it and got the same issue so I changed it back to OSK (One Shot Kill) just so I don't get confused later Okay so I'm gonna go with #3 that its an arma thing cause now it's showing that error, but the code is still working... Thanks for having some patients and helping me with that script and replying man... Gotta love the newbies right? Share this post Link to post Share on other sites
pierremgi 4906 Posted April 13, 2019 Hmm Perhaps you copied/pasted the code and sometimes there is an unwanted character like a dot after the code Try editing your osk.sqf and sweeping all character after my last semi-column ; Same for your init.sqf No other clue. Share this post Link to post Share on other sites
HAFGaming1 0 Posted April 14, 2019 1 hour ago, pierremgi said: Hmm Perhaps you copied/pasted the code and sometimes there is an unwanted character like a dot after the code Try editing your osk.sqf and sweeping all character after my last semi-column ; Same for your init.sqf No other clue. Hey man either way I appreciate the help 👍👍 Share this post Link to post Share on other sites
MechSlayer 18 Posted April 14, 2019 18 hours ago, HAFGaming1 said: MechSlayer, I have not tested your code yet because of my buddies not being online. BUT I feel like I can manipulate this code to make the players take more shots before they die. Not sure, I barely know how to code but makes sense in my head... lol... Thank you! { if (_x side == east) then {_x addEventHandler ["HandleDamage", { params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"]; _damage = _damage/2 //Receive two times less damage use * if you want it to receive more damage _damage; }];}; } forEach allPlayers; Share this post Link to post Share on other sites
pierremgi 4906 Posted April 14, 2019 @MechSlayer For MP, you consider that players can join. so a simple {...} forEach allPlayers will run for connected/defined players but not for further JIP. You also wrote the same way, about allUnits, as HAFGaming1 told from start he uses a spawnAI module . So, definitely, even if your EH codes work, you fail to answer by using allUnits and allPlayers in a one shot manner. You miss spawned units (see above) and JIP. Spoiler Here, players are BLUFOR, enemies are OPFOR. So: [] spawn { while {true} do { { _x setVariable ["HAF_spawned",true]; if (side _x == EAST) then { _x addEventHandler ["handleDamage", {1}] } else { if (isPlayer _x) then { _x addEventHandler ["handleDamage", {params ["", "", "_dam"]; _dam = _dam/2; _dam}] } } } forEach (allUnits select {isNil {_x getVariable "HAF_spawned"}}); uiSleep 2; }; }; 1 Share this post Link to post Share on other sites