OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Clue on 12 May 2004, 18:16:02
-
I've searched the forum and the FAQs to find a way to make all the east surrender if they suffer heavy losses and are outnumbered by west units in a given area. The nearest I can find is:
Submitted by: SFG
Credits: Black_Feather
Checking to see how much of the team is still alive
--------------------------------------------------------------------------------
you can use this to get a percentage, 0.8 is 80%
"!Alive _x" count units bravo >= 0.8 *Count units bravo
--------------------------------------------------------------------------------
Submitted on: October 17, 2002, 02:31
... but it only seems to apply to a single group, and I'm not sure how to make it activate a surrender script if more than 80% have been killed.
Any help would be greatly appreciated, or I'll have to come up for a different ending for my mission.
Thanks in advance.
-
I think you can use a trigger set to East (or whoever is the side that you want to surrender) present and change the condition to:
"!Alive _x" count units thislist >= 0.8 *Count units thislist
Posted from work so test to see if it really works! ;)
Wadmann
-
Thanks Wadmann... I'll give it a go this evening
:D
-
No joy I'm afraid...
I put in the trigger
Activation:East, Once
Condition: "!Alive _x" count units thislist >=0.8 *count units this list
but I kept getting the error message:
"!Alive _x" count units thislist >=0.8 *count units this list : Error units:Type,Array, expected Object,Group
...when I previewed it.
I tinkered with it a bit and changed the condition to:
Condition: "!Alive _x" count thislist >= 0.8 *Count units inthislist
No error message came up, but neither did anything happen when I shot 80% of the enemy (I was testing this with 10 enemy troops)
I'm already at the limits of my scripting knowledge... any ideas?
???
-
Wait wait wait :)
The trigger will never give you a count of dead things - only things that are alive. So that condition statement is meaningless - the count can never be .8 of itself...count will always equal count.
Have one trigger, East, Present, Once
And in the On Activation line do
varTotalBadGuys=count thislist
Then have a second trigger, East, Present, Repeatedly
in its condition have
count thislist <= .2*varTotalBadGuys
In its activation field have your surrender routines, or make the trigger a Type:End1 whatever.
I think that will do the trick.
-
errm - there's something goin wrong here
First: it's thislist and not this list
you see - one word not two
When using it in two words, it is: list this
Second: thislist or list triggername is already an array,
therefore you don't need to add units before.
units groupname = an array of units
thislist = an array of objects, related to a trigger's activation details.
list this or list triggername = equal to thislist
Third: i would recommend to create a reference to the number
of all units in the trigger list at the beginning:
max_units = count list triggername
Then i would use max_units as a base and compare the actual
number of alive units in the trigger to it.
"alive _x" count thislist < (max_units * 0.8)
:note - you need to take care that max_units needs to be already a valid number, to make the condition work.
Therefore i would further suggest to do it that way:
trigger A: (that's the trigger we're talking about)
Activation: whatever_side_you_want / present / once
name: triggerA
condition: this
onActivation: max_units = count thislist
trigger B: (that's the one where you check for the 80 percents)
condition: "alive _x" count list triggerA < (max_units * 0.8)
onActivation: hint "whatever you want"
::note - off course you don't need that hint at the end - just follow the message, the hint tells you ;)
~S~ CD
-
??
You never need to do an alive check on units from a trigger list...it only has units that are alive in the first place, unless I've REALLY missed something going on here.
-
He want's to know, when 20 % of the unit's in the trigger's
list got killed.
~S~ CD
-
No, he wants to know when 80 percent of the original force has been killed, so the remaining 20 percent can surrender.
A trigger list will only EVER contain alive units...so it is useless to perform an alive check on units in a trigger list.
The example I posted will do what his original post suggested he wanted.
-
ah yeah, it's the other way around - however
Your post was made, while i did mine therefore i didn't
take notice about you already posting a working solution.
Off course you're right about the fact that the units refering
to a trigger's list are always alive, but i was just trying to
make clue's method to work - therefore i didn't think about
this fact - should have been mentioned as FOUR: in my first
reply ;)
Ya know, sometimes when listing things up, and then going
deeper into it one can forget to take another look at the surface.
~S~ CD
-
Good to see some real scripters arrived on scene and just in the nick of time as I was about to muck it up again! ;D
It is replies like these that I copy into my ever-increasing library of "Things that I should know but can't remember"! CD is great about describing the details that keep me from making a bigger mess of things but it appears that Kammak taught me an important lesson:
The trigger will never give you a count of dead things
Sorry to send you off course Clue, but I am glad others stepped in to save the day!
Wadmann
-
@Chris Death: I understand - ...forest for the trees! :)
-
Cheers guys,
That's quite a lot for me to take on board, so I'll have a tinker with the mission and see if I've understood it all. Thanks for all the help... I'll let you know how it goes.
:)
-
Progress report...
Okay... I've used Kammak's two trigger solution and it seems to work fine... but is there any way to make it happen only if west troops outnumber the east?
i.e. east troops lost 80% and east alive troops is less than west alive troops
Also, I'm having a few problems getting all remaining east players to surrender. At the moment the trigger activates "surrender.sqs", which begins like this
"_x setcaptive true" foreach east_units
"removeallweapons _x" foreach east_units
...and then on into some animation commands
but nothing seems to be happening when the casualty limit is reached (other than my hint "whatever I want")
Hope I'm not being unreasonable with all these questions... thanks guys!
-
A breakthrough..!
I've managed to sort out getting all the remaining enemy troops to surrender by using:
{[_x] exec "surrender.sqs"} foreach thislist
so now I just need to find out how to make it happen only if the west side outnumbers the east side.
-
One idea:
On the second trigger, change it to Anybody, Present, Repeatedly
Condition:
(player countEnemy thislist <= .2*varTotalBadGuys) && (player countFriendly thislist > player countEnemy thislist)
That should do it. But I have not actually tested it! And this is assuming the player is not on the side you want to surrender! :)
-
Scratch that condition above.
Try this instead as the condition for the second trigger (Anybody,Repeatedly, Present):
(east countSide thislist<=.2*varTotalBadGuys) && (west countSide thislist > east countside thislist)
This I tested and seems to work okay.
-
Thanks again Kammak!
I give it a go this afternoon, and hopefully there'll be a new mission ready for beta testing soon.
;D
-
So near... and yet so far :-\
The new trigger works fine but with one small problem... everybody surrenders (east and west)!
At the moment I have this in the 'On Activation' box of trigger 2:
{[_x] exec ""surrender.sqs""} forEach thislist
which obviously counts all units in the trigger. How do I get it to only effect the East units? Would it be something like:
{[_x] exec ""surrender.sqs""} forEach thislist and not ((west_units) in thislist)
or am I way off the mark?
-
Nearly there... :)
I put a new line in the surrender.sqs...
? side _Unit == west : goto exit
... and this seemed to do the trick. Now only the East units surrender.
I still have one more question though :-[
Once the surrender.sqs has been activated, I want to begin a cutscene. How do I make the camera target the nearest alive east unit (who is now surrendering)? In an ideal world it would be the nearest eastern unit to the player, but it doesn't have to be.
I can't quite get my head around the randomness of eastern casualties to work out how to target!
You've been most helpful so far guys... hope I'm not asking for too much.