Home   Help Search Login Register  

Author Topic: Check if leader is dead?  (Read 579 times)

0 Members and 1 Guest are viewing this topic.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Check if leader is dead?
« on: 24 Nov 2004, 15:08:26 »
Hi!

How do I check whether a leader of a group is dead? Is it something like: "not alive leader" foreach units grp1?

How do I do it?

Thx a bunch, yer the best!
Weeee...

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Check if leader is dead?
« Reply #1 on: 24 Nov 2004, 15:10:43 »
give the group a name.  Put something like

AlphaGrp = group this  

in the init field of a unit inthe group.

then

if not (alive leader AphaGrp) then{...}

seems to be what you want

« Last Edit: 24 Nov 2004, 15:11:16 by THobson »

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Check if leader is dead?
« Reply #2 on: 24 Nov 2004, 15:15:27 »
Wow, that was quick. Thx. But how do I put this in a trigger? I suppose the stuff you wrote works only in a script?

thx
Weeee...

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Check if leader is dead?
« Reply #3 on: 24 Nov 2004, 15:15:54 »
Not correct THob, as leader is changed when the current leader dies.

Easier would be to just give him a name and check with the alive command.

! (alive d00d1)

:beat: *Gets Shot* :beat:
« Last Edit: 24 Nov 2004, 15:16:10 by dmakatra »

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Check if leader is dead?
« Reply #4 on: 24 Nov 2004, 15:18:46 »
Yes, but  I want the leader to change once the old leader gets killed. I'm making a group that has a leader operating a machinegun. Once he dies the new leader will use the machinegun and so on...
Weeee...

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Check if leader is dead?
« Reply #5 on: 24 Nov 2004, 15:21:11 »
_leader = (leader grpalpha)
#loopelyloopyloop
? ! (alive _leader) : _leader = (leader grpalpha)
~0.0001
goto "loopelyloopyloop"

I don't know if this will work (if _leader will automaticly change) but I'm quite sure it will.

:beat: *Gets Shot* :beat:

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Check if leader is dead?
« Reply #6 on: 24 Nov 2004, 15:24:09 »

You can put
not(alive leader AlphaGrp)  in the condition field of a trigger

You can also put

if (boolean) then {...} else {...}

in the activation field of a trigger as well if you need to.
« Last Edit: 24 Nov 2004, 15:25:01 by THobson »

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Check if leader is dead?
« Reply #7 on: 24 Nov 2004, 15:25:40 »
Thx, mate. But do I really need to change the leader? I mean, once the old leader dies a new one will take his place automatically, right? What I really need to know is how to  check whether the leader of the group is dead using a trigger. :)

After that this will kick in:

leader grpr5 assignAsgunner mgr1; [leader grpr5] orderGetIn true

(edit) Ah, THobson. Didn't see your answer. OK, I'll try that, thx.
« Last Edit: 24 Nov 2004, 15:27:03 by Wildebeest »
Weeee...

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Check if leader is dead?
« Reply #8 on: 24 Nov 2004, 15:26:18 »
OoooOoooOooO, wel all fancy with C++ inspired code now are we? ;D

D'OH, I just saw the weakness of my script... Use THob's.

:beat: *Gets Shot* :beat:

EDIT: Dammit, what is with you and posting before me... >:( ;D

Actually, easiest (not most good looking way) is to just loop a small line of code doing just that all the time. Like this:

#Loop
leader grpwhatever assignas blah
whateverwhateverwhatever
~0.01
goto "loop"
« Last Edit: 24 Nov 2004, 15:28:19 by dmakatra »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Check if leader is dead?
« Reply #9 on: 24 Nov 2004, 15:28:43 »
I am at work right now so can't spend much time on this but you can do some research yourself.

I have a mission called Defensive Strike - it is inthe missions department.  There is a script in it that takes action whenever the leader of a particular group is killed.  What it actually does is reports the name of the dead leader and the name of the new one.  

Download it, de_pbo it and see how I did it.  I can't remember the details now, but I do remember that OFP seems to take several seconds to recognise the death of a leader.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Check if leader is dead?
« Reply #10 on: 24 Nov 2004, 15:30:49 »
You've been most helpful, friend. Thanks a lot. I'll try and find your mission. Have a good time at work!

Also, thx dmakatra... I think your solution might work actually.

Yes it did. Thanks a lot man!

Making a mission in which you protect a convoy in Africa. There is a machinegun on a hill and when you kill the gunner you find out that more and more gunners follow. Maybe if you demolish the MG something else will happen? The guys who were supposed to  act as spare gunners might attack or something. Jeez, I'm a genious!
« Last Edit: 24 Nov 2004, 15:37:36 by Wildebeest »
Weeee...