Home   Help Search Login Register  

Author Topic: surrender when any unit is dead  (Read 1325 times)

0 Members and 1 Guest are viewing this topic.

Offline prodetar2

  • Members
  • *
surrender when any unit is dead
« on: 15 Jun 2007, 20:58:11 »
Hey people, ive been busy lately trying to get the hang of ofp scripting but im stuck atm.

im now trying to let a group of soldiers surrender to you when you kill one of them (as a test)

now what i need to know is: what command do i use (even when the soldiers are not in the same group)

i now have a trigger with (anyuthing in () is not working from what i know... error reports flood in then):

condition: (eachunit = thislist) ;not alive east1
onactivation: (foreachunit east switchmove "FXStandSur")

now what did i do wrong? probably everything but hey, i aint learning for nothing ;)

i tried searching the forum but i only got hits from stuff i could not understand very well.. so can anyone assist? thnx ahead ;)
(if this has been asked before could someone add a link to that thread? thnx)
« Last Edit: 15 Jun 2007, 21:01:12 by prodetar2 »
BOOM!

"You are dead"

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: surrender when any unit is dead
« Reply #1 on: 15 Jun 2007, 23:12:10 »
the idea is sound, it's just the syntax that's a bit skee-wiff. first you need to know how many units are in the surrendering group. then you can use the trigger:

condition: (({alive _x} count units enemy_group) < number_of_units)
on activation: {_x switchmove "FXStandSur"} foreach units enemy_group

naturally, you replace enemy_group with the name of the surrendering group, and number_of_units with the original number in the group (before one is killed). you might also want to put a pause in the trigger (put something like 3 in each of the three 'countdown' boxes - it may be that the loon you kill tries to surrender too if the trigger fires immediately.

experiment a little - you're on the right track  :good:

Offline prodetar2

  • Members
  • *
Re: surrender when any unit is dead
« Reply #2 on: 16 Jun 2007, 00:29:28 »
ok thnx for reply. now a small question about group id.

how do i name a group?

something like group1 = thisgroup??

thnx ahead :)
BOOM!

"You are dead"

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: surrender when any unit is dead
« Reply #3 on: 16 Jun 2007, 00:31:06 »
in the init box of the group leader type

Code: [Select]
group_name = group this

Offline prodetar2

  • Members
  • *
Re: surrender when any unit is dead
« Reply #4 on: 16 Jun 2007, 13:02:14 »
hey thx it all works :) but now another thing.. they all surrender when 1 unit of the group is dead. do i need to change the < number_of_units) in order to make sure they surrender after like... 4 dead team mates??

thnx again ;)  :D
BOOM!

"You are dead"

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: surrender when any unit is dead
« Reply #5 on: 16 Jun 2007, 13:40:58 »
looking at the condition line -

Code: [Select]
(({alive _x} count units enemy_group) < number_of_units)
the first bit - ({alive _x} count units enemy_group) gives the number of units in the group who are still alive. number_of_units is the original size of the group before anyone is killed. so if you only want the trigger to fire after 4 (or more) units have been killed, the condition would read

Code: [Select]
(({alive _x} count units enemy_group) <= (number_of_units - 4))