OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: AnarCHy on 03 Dec 2004, 05:34:00
-
(ive had trouble with too much chatter before, so im putting this blunt)
I need a trigger or script that would activate repetedly for when a specific unit in a side has died (i.e. civvie in this case)
what it would do is tell u when he/she died, in a TitleTxT in the bottom part of the screen (much like serialkiller) i.e. it would say (A civilian has died!)
and, last but not least, i need to find a way to log the number of deaths and show how many have died when a civilian dies. (in hint form)
AAA
-
to answer both questions, here's what you can do, so long as you don't create any more civs during the mission
make a civilian present trigger covering the whole map.
condition:this
activation:[thislist] exec "deadcivs.sqs" or whatever you name it
_allcivs = _this select 0
civsdead = 0
#loop
;added this just so you don't waste cpu
?_allcivs = []:exit
;what you actually need
"?!(alive _x)" foreach _allcivs:civsdead = titleText ["A civilian has died!", "bottom"];civsdead = civsdead + 1;_allcivs = _allcivs - [_x]
;don't know if i need that second part for the exit command to work
;once again, save cpu, plus it won't lag at all, you don't really need to check very often
~5
goto "loop"
then at the end of the mission just you a hint command with the variable civsdead
-
hey it worked :)
thanks for your help Trig
i put it thru its paces and found everytthing owrked fine, except from some errors I amde whilst making the mission :P
thanks
AAA
-
This sounds perfect for a script that i want, but it doesnt work for me... ??? i mean it doesnt do anything when used in a mission. I did exactly everything u said to do on the post If u can bare with my noob ness maybe make a simple sample mission.
Also if it could log the deaths of the civies could it end the mission if so many civies die?
-
i just noticed an error i made, so i'm guessing anarchy changed the script a little, but what kind of trigger is it, how is it activated, how are you calling the script?
also use what is now posted, i corrected the error
-
;D hehe.... I had the names of the script and the trigger activation diferent....
BUT in game it says theres an error with the line(w/ edited one):
"?!(alive _x)" foreach _allcivs:civsdead = titleText ["A civilian has died!", "bottom"];civsdead = civsdead + 1;_allcivs = _allcivs - [_x]
I used the edited one u put in, changed the names and that error pops up :o
now the trigger type is none, activation Civilian, and its activated with
[thislist] exec="diecivies.sqs"
-
..... ???
something got messed up on the script, it has a line in the middle of another..wtf?
here:
_allcivs = _this select 0
civsdead = 0
#loop
?_allcivs = []:exit
;what you actually need
"?!(alive _x)" foreach _allcivs:titleText ["A civilian has died!", "bottom"];civsdead = civsdead + 1;_allcivs = _allcivs - [_x]
~5
goto "loop"
-
:-\ yeah... it still not workin for me......
the error is gone with the newest version of the script, but it does absoultly nothing..... ???
-
it needs to be a 'present' trigger, with civilian
otherwise, civvies don't go into the list, nothing will.
-
Well thats fixed but now another error pops up with the part about tile text.....
:D yes anither error Whoohooo j/k
-
Try:
titleText ["A civilian has died!", "plain down"]
Planck
-
hmmm thx for advice ;D
but still doesnt work..... :-[
-
It would help a lot if we knew what the error was.
Can you post the exact error message?
Planck
-
yea that might help...
its in the line
"?!(alive _x)" foreach _allcivs:civsdead = titleText |#|(<== error there)
["A civilian has died!", "bottom"];civsdead = civsdead + 1;_allcivs = _allcivs - [_x]
and sory for long time for post, holidays and all.
-
Can you post the exact error message?
can you see any of the other stuff where it tells to the problem, or does it get cut off?
also, if you like, i just remembered that i could put in a counter and every time a civvie dies it will tell you how many have died
-
Like I said in reply #10:
Try:
titleText ["A civilian has died!", "plain down"]
That should fix the titletext problem anyway.
Planck
-
at the end it has error unkown, i think cause it cuts out at about the k
and the plain down doesnt help, same error message
-
This is the intire script that im testin
_allcivs = _this select 0
civsdead = 0
#loop
?_allcivs = []:exit
;what you actually need
"?!(alive _x)" foreach _allcivs:titleText ["A civilian has died!","plain down"];civsdead = civsdead + 1;_allcivs = _allcivs - [_x]
~5
goto "loop"
error still reads at the title text :'(
-
k, i found the error. this is really wierd, i had the same problem with another script:
"?!(alive _x)" foreach _allcivs|#|:titleText ["A civilian has died!","plain down"]...error unknown operator
...
wtf?
-
Hmmmmm.....what about:
? !("alive _x") foreach _allcivs :titleText ["A civilian has died!","plain down"]
Planck
-
Why bother with a trigger and counting alive units when
all you really seem to need is a "killed" eventHandler?
Attach a "killed"-EH to all your civvies (if lots of them, use a trigger covering the whole map to round them up in a nice array), and have the EH count the number of killed civvies and display titleTexts for you.
If you still dont want that, use something like:
in init.sqs:
civnum = "alive _x" count myCivvieTrigger
and in your repeating trigger checking for civilian present, called 'myCivvieTrigger'..
condition: civnum != "alive _x" count thislist
activation: x = "alive _x" count thislist ; titleText [format ["another %1 civvies died", x], "plain.."] ; civnum = x
Or something along those lines (SNG).
(edit: I read the post more carefully the second time)
-
Planck, dint work... :(
Mud Spike, goina have to clarify somethin
how the hell do u atach and Eh to a unit
and how do i get the Eh to title text it
basiclly what the hell is an EH ???
I think that idea might work better, 2nd one might be easier but 1str one sounds best (hittien the prob from a different angle)
-
An eventhandler detects when an event happens and then does something.
You could use their init field to add a "killed eventhandler.
civi1 addEventHandler ["killed",{_this exec "civikilled.sqs"}]
civikilled would be the script that is run when this civi is killed.
You can add the eventhandler to each civi and the script would run when they are killed.
Basically.........Anyway there is a little tutorial in the Editors Depot.
Planck