OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: AnarCHy on 03 Dec 2004, 05:34:00

Title: die civvies die
Post 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
Title: Re:die civvies die
Post by: Triggerhappy on 03 Dec 2004, 21:43:18
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

Code: [Select]
_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
Title: Re:die civvies die
Post by: AnarCHy on 06 Dec 2004, 04:54:15
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
Title: Re:die civvies die
Post by: Major Draper on 16 Dec 2004, 06:25:53
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?
Title: Re:die civvies die
Post by: Triggerhappy on 16 Dec 2004, 22:29:08
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
Title: Re:die civvies die
Post by: Major Draper on 17 Dec 2004, 02:14:30
 ;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"
Title: Re:die civvies die
Post by: Triggerhappy on 17 Dec 2004, 03:23:26
..... ???
something got messed up on the script, it has a line in the middle of another..wtf?

here:
Code: [Select]
_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"
Title: Re:die civvies die
Post by: Major Draper on 17 Dec 2004, 07:09:41
 :-\ yeah... it still not workin for me......

the error is gone with the  newest version of the script, but it does absoultly nothing..... ???
Title: Re:die civvies die
Post by: Triggerhappy on 17 Dec 2004, 21:45:35
it needs to be a 'present' trigger, with civilian
otherwise, civvies don't go into the list, nothing will.
Title: Re:die civvies die
Post by: Major Draper on 18 Dec 2004, 01:01:03
Well thats fixed but now another error pops up with the part about tile text.....

 :D yes anither error Whoohooo j/k
Title: Re:die civvies die
Post by: Planck on 18 Dec 2004, 01:05:18
Try:

titleText ["A civilian has died!", "plain down"]


Planck
Title: Re:die civvies die
Post by: Major Draper on 18 Dec 2004, 03:27:10
hmmm thx for advice ;D

but still doesnt work..... :-[
Title: Re:die civvies die
Post by: Planck on 18 Dec 2004, 14:06:00
It would help a lot if we knew what the error was.

Can you post the exact error message?


Planck
Title: Re:die civvies die
Post by: Major Draper on 28 Dec 2004, 04:16:18
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.
Title: Re:die civvies die
Post by: Triggerhappy on 28 Dec 2004, 05:14:55
Quote
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
Title: Re:die civvies die
Post by: Planck on 28 Dec 2004, 19:23:16
Like I said in reply #10:
Quote
Try:

titleText ["A civilian has died!", "plain down"]

That should fix the titletext problem anyway.


Planck
Title: Re:die civvies die
Post by: Major Draper on 30 Dec 2004, 03:16:35
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
Title: Re:die civvies die
Post by: Major Draper on 30 Dec 2004, 03:20:16
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  :'(
Title: Re:die civvies die
Post by: Triggerhappy on 30 Dec 2004, 05:47:04
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?
Title: Re:die civvies die
Post by: Planck on 30 Dec 2004, 19:40:06
Hmmmmm.....what about:

? !("alive _x") foreach _allcivs :titleText ["A civilian has died!","plain down"]


Planck
Title: Re:die civvies die
Post by: Mud_Spike on 30 Dec 2004, 20:06:23
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)
Title: Re:die civvies die
Post by: Major Draper on 31 Dec 2004, 02:04:13
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)
Title: Re:die civvies die
Post by: Planck on 31 Dec 2004, 02:12:40
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