AchtungAffen 0 Posted July 24, 2003 I've been thinking about this script for a while... in fact, this is the idea that drove me into scripting in the first place (not long ago), but what is needed, is much more than I can handle. The idea is the following: I need to know specifically wich soldiers have died, from all sides, during a mission. The problem with this is how to report the losses... I first thought using texts and the not alive trigger, still if 2 or more soldiers die right away, it would be a mess. Then I thought about tips, the one that pause the game, although it wouldn't be fun if your game is paused everytime someone dies, and a regular tip might dissapear before I can notice it, or I could be shot while trying to write down who has died. Then I thought if it is possible to put the casualties report on the end briefing... although don't have the slightest idea on how to do that. And the best solution would be if OFP can do a text file with the casualties written on it, although I'm pretty sure that is just plain impossible... Any ideas? Thanks Share this post Link to post Share on other sites
bn880 5 Posted July 24, 2003 Right now no ideas just questions: the deaths you want to record You mean you want to record AI deaths, with names etc? Ok so here is an idea: you collect information on all units killed, maybe even the time they were killed and the killer. At the (fake) end of the mission you run a cutscene with a camera script that goes around the map showing the dead bodies and displaying their names etc. in a title text. You can do this for vehicles too. Actually to be honest the camera thing is one of those I deas I had a few weeks ago and forgot about. What a dummy eh. Ah so, use a trigger to collect all units at start, install event handlers on them ("killed") and you're all set when mission objectives are complete. EDIT: I don't plan on working on this in the next few days. Share this post Link to post Share on other sites
AchtungAffen 0 Posted July 24, 2003 The only info I require is the name of the ai units killed, vehicles too, but I also need to record the death of the crew. EDIT: By name I mean the name you provide to each one of the units... not the name OFP gives them like "John Doe" or something. Actually, the cutscene idea is great, I can only see one problem... what happens if I die during the mission? The cutscene will never show up, right? I was planning to record the deaths, due to my lack of knowledge in the script thing, with a trigger for each one of the units, with the condition: not alive "Unit": nameofunitdeadvariable=true or perhaps instead of that using an array for all the deaths, and in each element put the id or name of the killed soldiers, still I don't have an idea on how to use arrays... I'm learning it now. I believe that instead of the trigger I cold use this "@ not alive "unit".... or something, but honestly, I don't know how to use that either... Share this post Link to post Share on other sites
TheMcDeth 0 Posted July 24, 2003 I did not quite understand what you want to do with the information you obtain. Here is a short script that checks if all units in _fgroup and _egroup are alive or not. If all units in certain group are dead, it sets var_2 to either 2 or 3. Then you can make a trigger with condition var_2==2 or var_2==3 to do whatever you want. "alive.sqs": _fgroup=[f_1,f_2,f_3,f_4,f_5,f_6,f_7,f_9,f_10,f_11,f_12,f_13,f_14,f_15,f_16,f_17,f_18,f_19,f_20] _egroup=[e_1,e_2,e_3,e_4,e_5,e_6,e_7,e_9,e_10,e_11,e_12,e_13,e_14,e_15,e_16,e_17,e_18,e_19,e_20] #loop #check falive = 0 ealive = 0 "if (alive _x) then {falive = falive + 1}" foreach _fgroup; ? falive == 0 : goto "fdead" "if (alive _x) then {ealive = ealive + 1}" foreach _egroup; ? ealive == 0 : goto "edead" ~10 goto "loop" #fdead var_2=2 exit #edead var_2=3 exit Share this post Link to post Share on other sites
AchtungAffen 0 Posted July 24, 2003 Thanks for your help, although for what you said and I can understand, the script only lets me know if all the units are dead. What I need is to know exactly wich units are dead or not. But I can take portions of that code for what I need, here's what I've been thinking "reportdead.sqs" _groupwest=[west1,west2,...,westN] _groupeast=[east1,east2,...,eastN] "if (alive _x) then {...what should I do here?...}" foreach _groupwest In the "what should I do here" part, the code 'And here comes the problem, the part wich I don't know how to write: Now the code should check unit by unit, from both groups, if they're alive or not, and it should write in a HintC, all units and their status, for example, this could be the hint thing: "West1:0 West2:1 West3=0 West4:0 East1:1 East2:0 East3:1 East4:1" Although I don't know if you can mix variables and text and then print them with the hintc command. So, when I activate the trigger, probably a Radio Alpha or something, it should activate that function, and make a hint appear listing the status of all the units. Is this possible? How can I finish the rest? Share this post Link to post Share on other sites
bn880 5 Posted July 24, 2003 Actually, the cutscene idea is great, I can only see one problem... what happens if I die during the mission? The cutscene will never show up, right? Nope you can edit a script called onPlayerKilled.sqs or some such and do what you want there even when you die. EDIT: You can never get a variable name of anyhting in the OFP scripting engine, you can however compare the value (like objects) to see if it's the one you want. Well actually i shouldn't say never, because you can use a metavariable search method, but it's not fool proof and too processor intensive to be useful. Share this post Link to post Share on other sites
AchtungAffen 0 Posted July 24, 2003 So, that onPlayerKilled.sqs is called by default when you die? I meant, can you do the following in OFP as you do in, for example, visual basic: Mystring1 = "West1:" Myinteger1 =1 Mystring1 = Mystring1 + str(Myinteger1) label1.text = Mystring1 ----So, the label text would display "West1: 1" If you don't know VB this does the following: the str function converts a number to a string, so if the number was 1, the string would be " 1" (space reserved for minus sign). So I add the string with the number to the original string, and then display it on the text of the object called label1. What I mean is: can I put numbers on a string variable, and then display the string variable with, for example, hintc? Share this post Link to post Share on other sites
AchtungAffen 0 Posted July 24, 2003 Well, I just tried: Seems like I can't display custom text with hintc, it doesn't work with the format option, so hintc cannot display string variables, just string text. Then I tried titletext and format, but I discovered that there's only a limited number of lines I can add, after that, it doesn't display text anymore... so, it seems that the cutscene through all the corpses would be the only option. Share this post Link to post Share on other sites
Bart.Jan 0 Posted July 25, 2003 Try this script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _units=["a1","a2","a3","a4","a5","a6","a7","a8","a9","a10","a11","a12","a13"] ;CHECKING SOLDIERS _i=0 _dead=[] #loop1 _unit=_units select _i _code=format["dd=!(alive %1)",_unit] call _code ~0.001 ?dd:_dead=_dead+[_unit] _i=_i+1 ?_i<count _units:goto "loop1" ;CREATING RESULTS ?count _dead==0:goto "end" _i=0 _units=[] _code="" #loop2 _unit=_dead select _i _code=_code+format["%1 is dead\n",_unit] _i=_i+1 dd=false ;10 names on page (11 lines on page) ?(_i mod 10)==0:dd=true ?(_i==count _dead):_units=_units+[_code+"--end of list"];_code="" ?(dd and _i!=count _dead):_units=_units+[_code+">>next page"];_code="" ~0.001 ?_i<count _dead:goto "loop2" ;SHOWING RESULTS _i=0 #loop3 _code=_units select _i cutText [format["%1",_code],"plain"] ;pause between pages ~10 _i=_i+1 ?_i<count _units:goto "loop3" #end bb=nil exit Put names of your named units as strings into array _units. (example: you have soldier named west1 -> put "west1" into array). They can be from any side. You can run script anytime during the mission, but you should use it as part of onPlayerKilled.sqs. Modify script as you wish. But better way of showing results can be dialog with scrollbars. But I can not work with dialogs in OFP. and your VB example in OFP: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Mystring1 = "West1:" Myinteger1 =1 Mystring1 = format["%1%2",Mystring1,Myinteger1] hint Mystring1result is: West1:1 or <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> Mystring1 = "West1" Myinteger1 =1 Mystring1 = format["%1: %2",Mystring1,Myinteger1] hint Mystring1result is: West1: 1 Share this post Link to post Share on other sites
AchtungAffen 0 Posted August 1, 2003 I'm sorry I haven't replied this earlier, I was giving exams. Well, I first thank your efforts on this code, although I gotta say it sadly didn't work. I really don't understand much of what this code does, specially on the showing results part. I got an error on this line: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call _code I don't understand exactly what this does, but the error was that "_code" was an invalid parameter or something of that sort. So I tried to make that line a REM to check if the code worked without it, but just nothing happens. I've tried this on OFP version 1.75 (the first Resistance Version), so perhaps its a compatibility problem. Thanks nyways. Share this post Link to post Share on other sites
Bart.Jan 0 Posted August 1, 2003 It's compatibility problem. call is supported from version 1.85. Share this post Link to post Share on other sites
AchtungAffen 0 Posted August 6, 2003 Well, it actually worked and it really helps... its exactly what I've been looking for. Thanks! But, there's a problem when I put this code on OnPlayerKilled.sqs: When I die, I see the code allright, but the mission never ends, and I can't even press "escape" to exit the mission! What should I do? Share this post Link to post Share on other sites
Bart.Jan 0 Posted August 6, 2003 Do not end the script by camDestroy but use EnableEndDialog command. Share this post Link to post Share on other sites
AchtungAffen 0 Posted August 6, 2003 Just enableenddialog would do? What if I use ForceEnd or activate an End trigger? One question: what happens when I die and the script is executed? Does the AI end working? I thought I saw all the soldiers stop firing or something. One more thing... I tried to modify the script to show damage on vehicles... but I can't make it work... here's what I did: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_units=["a1","a2","a3","a4","a5","a6","a7","a8","a9","a10","a11","a12","a13"] _i=0 _units2=[] _code="" #loop2 _unit=_units select _i _code2=format["_x=(getdammage %1)", _unit] call _code2 _code=_code+format["%1 damage: %2\n",_unit, _x] _i=_i+1 dd=false ;10 names on page (11 lines on page) ?(_i mod 10)==0:dd=true ?(_i==count _units):_units2=_units2+[_code+"--end of list"];_code="" ?(dd and _i!=count _units):_units2=_units2+[_code+">>next page"];_code="" ~0.001 ?_i<count _units:goto "loop2" ;SHOWING RESULTS _i=0 #loop3 _code=_units2 select _i cutText [format["%1",_code],"plain"] ;pause between pages ~10 _i=_i+1 ?_i<count _units2:goto "loop3" #end bb=nil exit What's wrong? Share this post Link to post Share on other sites
Bart.Jan 0 Posted August 9, 2003 I can not help you with onPlayerDead script. All I know is that it shoud be ended by enableEndDialog. In your modification try to use global varible x instead of local variable _x. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _code2=format["x=(getdammage %1)", _unit] _code=_code+format["%1 damage: %2\n",_unit,x] Or you can use already used global variable dd (instead of _x). It saves you one variable Share this post Link to post Share on other sites