jaenak 0 Posted January 31, 2004 I've got an intro I'm making and I need several of the groups not to take any damage. The "allowdammage false" command is obsolete now so the only way to do it is via getdammage and setdammage. I can do it for one person, but I don't want to put down 75 of the same trigger. I tried<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{getdammage _x >= .5} foreach units fg1but it doesn't want to accept it. And is it possible to do something like this<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{getdammage _x >= .5} foreach units [fg1,fg2,fg3,fg4,fg5]so as to cover more groups in the same trigger? Share this post Link to post Share on other sites
killswitch 19 Posted February 1, 2004 Try using either of these as trigger conditions: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">( { damage _x > 0.5 } count units fg1) > 0 or <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">({damage _x > 0.5} count (units fg1 + units fg2 + units fg3 + units fg4 + units fg5)) > 0 And then either of these in the On Activation field <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{ _x setDamage 0 } forEach units fg1 or <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{ _x setDamage 0 } forEach (units fg1 + units fg2 + units fg3 + units fg4 + units fg5) Share this post Link to post Share on other sites
jaenak 0 Posted February 1, 2004 Didn't work. They still died. Share this post Link to post Share on other sites
killswitch 19 Posted February 1, 2004 Didn't work. They still died. Whatever. I never promised it would. I should have mentioned that what I did was present you with syntactically correct code to "cover more groups in the same trigger". On to the problem... how about trying this somewhere in the intro:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{ _x addEventHandler ["dammaged", {(_this select 0) setDamage 0}] } forEach (units fg1 + units fg2 + units fg3 + units fg4 + units fg5) Share this post Link to post Share on other sites
Chris Death 0 Posted February 1, 2004 What about: "if (getdammage _x < 0.5) then {_x setdammage 0} foreach array Now ya know how to setup your array - don't you? Anyway, i'll tell ya how to do that whole thing (there are other solutions aswell, but i think the following one isn't that bad). Into the first unit's init field (the first unit you place onto the map), put: immortal_array = [] Then start creating your groups, and into their leader's init fields (or into any of them guys init field - usually the leader), put: immortal_array = immortal_array + units this Now make a trigger (size 0/0 - activation: none once) condition: true onActivation: [immortal_array] exec "immortal.sqs" And now you only need to put the following script (immortal.sqs) into your mission folder; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _array = _this select 0 ;{ _x addEventHandler ["dammaged", {(_this select 0) setDamage 0}] } forEach _array #loop "if (getdammage _x > 0.5) then {_x setdammage 0}" foreach _array ~0.1 goto "loop" OK, there will still some soldiers die upon some exellent hits, but one of the guys could even stand a shot into his right eye, when i was testing it. It depends on timing and on the kind of hit (no way to stand a grenade btw). In combination with the eventhandler "hit" you can get very good results too. If you want to put that eventhandler onto the units, you could just remove the semicolon in that line before it says: #loop hope this helps :edit - just noticed i made "< 0.5" instead of "> 0.5" - fixed that now - ~S~ CD Share this post Link to post Share on other sites
jaenak 0 Posted February 1, 2004 CD, you reminded me of a question I had initially. In a script, how would I say <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x setdammage 0} foreach units [ws1,ws2]or<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x setdammage 0} foreach units [wg1 minus ws3]where wg1 is the group name, ws1,ws2 and ws3 are the names of the three units. And in another example where wg1 and wg2 are the names of two groups how would I say<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x setdammage 0} foreach units [wg1,wg2] Share this post Link to post Share on other sites
Chris Death 0 Posted February 1, 2004 Well jaenak Quote[/b] ]{_x setdammage 0} foreach units [ws1,ws2] and Quote[/b] ]{_x setdammage 0} foreach units [wg1,wg2] should look like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> {_x setdammage 0} forEach (units ws1 + units ws2) and <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> {_x setdammage 0} forEach (units wg1 + units wg2) Quote[/b] ]{_x setdammage 0} foreach units [wg1 minus ws3] should look like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> "if (_x != ws3) then {_x setDammage 0}" forEach (units wg1) Is that OK? Â ~S~ CD Share this post Link to post Share on other sites
jaenak 0 Posted February 1, 2004 I got a little curious. In this intro cutscene I'm making I have several groups that must stay alive and a couple units out of each group will die as part of the cutscene. I'm doing a mission to test the invinsibility factor and wrote a script.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#Live {_x setdammage 0} foreach units wg1 ? gd: goto "Die" goto "Live" #Die ws3 setdammage 1 goto "Die2" #Live2 ws1 setdammage 0 ws2 setdammage 0 goto "Live2"The test mission here has three units ws1 (west soldier #1) ws2 and ws3. As you see, I also put a Radio Alpha trigger down that'll declare gd = true when I say so that ws3 will die and the script will keep ws1 & 2 alive no matter if they get hit by a laserguided bomb. It works currently. I tried replacing<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">ws1 setdammage 0 ws2 setdammage 0 with<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"if (_x != ws3) then {_x setDammage 0}" forEach (units wg1) and it works. Thank you. What if I also had a ws4 and also killed ws2. Then I'd need to take the above line of code and not only exclude ws3 from the cycle, but ws2 also. How would I do that? Reason why I'm asking all this is because at times during the cutscene I'm going to kill certain friendly units via script. They're in a large gunfight. It'd look like they just got shot. But in this test mission, this script is only taking care of one group. In the cutscene I'm probably just going to have<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"if (_x != ws3) then {_x setDammage 0}" forEach (units wg1) "if (_x != ws10) then {_x setDammage 0}" forEach (units wg2) "if (_x != ws20) then {_x setDammage 0}" forEach (units wg3)and so on so that it'd be the same idea, just several lines each taking care of their own group and each adjusted to incorporate their own units. Does this seem doable? Share this post Link to post Share on other sites
Chris Death 0 Posted February 1, 2004 Why shouldn't we still try to keep this stuff in a single line "if (_x != ws3 AND _x != ws10 AND _x !=ws20) then {_x setDammage 0}" forEach (units wg1 + units wg2 + units wg3) OK, now ws1,ws2,ws3 will be excluded from the cycle through the groups wg1 and wg2. ~S~ CD Share this post Link to post Share on other sites
Bart.Jan 0 Posted February 1, 2004 Why shouldn't we still try to keep this stuff in a single line "if (_x != ws3 AND _x != ws10 AND _x !=ws20) then {_x setDammage 0}" forEach (units wg1 + units wg2 + units wg3) OK, now ws1,ws2,ws3 will be excluded from the cycle through the groups wg1 and wg2. ~S~ CD Another way how to exclude some units from the cycle: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x setDammage 0} forEach (units wg1 + units wg2 + units wg3)-[ws1,ws2,ws3] trigger (activated repeatly) condition <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{damage _x > 0.5} count (units wg1 + units wg2 + units wg3)-[ws1,ws2,ws3] > 0 works but sometimes someone dies. There is other problem because sometimes dead units respawned via setDamage 0 are ignored by AI. Share this post Link to post Share on other sites
jaenak 0 Posted February 1, 2004 Bart, I tried the syntax in my script you suggested then nothing worked. Funny thing though, I added a ws4 to wg1 so now wg1 consists of ws1,ws2,ws3 and ws4. Â In the section labeled #Die I put<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"{_x setdammage 1}" foreach (units ws2 + units ws4)and now when I set gd to true, everyone in the whole group dies. Â Wierd. Â And by the way, "?" means if right? Â And ":" means then right? Â And "!="means not correct? Â Or does not mean "!" just like that? Â And if not is "!", then why do I often see "!=" in scripts? CD, I also added a wg2 and added that into the script. Â If I do the setdammage 1 the long way, the second group is also covered in the setdammage 0 part, so that works now. Â Now I just need to figure out why everyone in the group dies when I say the above line. Â I'm going to figure out this scripting stuff yet. Â It's coming along but scripting is a big world and there's alot to learn! Edit: Why do I always put in a Smiley and disable emoticons in the post? Share this post Link to post Share on other sites
Chris Death 0 Posted February 1, 2004 "!" means "not" "=" means "equal" "!=" means "not equal" Quote[/b] ]"{_x setdammage 1}" foreach (units ws2 + units ws4) This line sets damage of 1 for each unit in the same group of soldier ws2 and for each unit in the same group as ws4. If ws2 and ws4 are both in the same group, than you only need to do it for one of them. If you want only to kill ws2 and ws4, then you should say: "{_x setdammage 1}" foreach [ws2,ws4] ~S~ CD Share this post Link to post Share on other sites
jaenak 0 Posted February 1, 2004 I know I must be wearing on your patience but that didn't work either. Share this post Link to post Share on other sites
Taurus 20 Posted February 1, 2004 I know I must be wearing on your patience but that didn't work either. Which version of OFP do you use? if you use 1.46 things like {blablah} doesn't work Share this post Link to post Share on other sites
RED 0 Posted February 1, 2004 You are mistaken The_Taurus, it is functions that do not work in 1.46. RED Share this post Link to post Share on other sites
Taurus 20 Posted February 1, 2004 You are mistaken The_Taurus, it is functions that do not work in 1.46. RED Allright, my bad. Share this post Link to post Share on other sites
jaenak 0 Posted February 1, 2004 I've got version 1.94 beta. Maybe there's an easier way to do this. Â Is it possible to have people in a gunfight but have them intentionally miss until you tell them to dotarget and dofire? Edit: Did it again! These smiley's are getting on my nerves. I keep adding them but disabling emoticons! Share this post Link to post Share on other sites