Jump to content
Sign in to follow this  
_angus_

Trigger to end game once tank group is "no longer a threat"

Recommended Posts

Hi,

So in my latest effort the player assaults an enemy held village, and once it is clear of enemy forces, an armoured counterattack is triggered. This is a group of three tanks which head to the village on a Seek and Destroy waypoint, and the idea is when they are themselves destroyed, the mission is won. Using some code a forum member (the Prof) kindly helped me with some weeks back, I created a trigger using the following condition:

{alive _x} count [MBT1,MBT2,MBT3] == 0

It didn't work in this case, I think possibly because one of the tanks limps off into the hills, or perhaps some of the crew survived and got themselves out of harm's way.

I also tried having a large area where if the tanks weren't present the mission was won, but I don't know how to make that specific to the 3 tanks, and there will be some other enemy knocking about out there that I want to ignore at this point.

I would appreciate your wisdom on this. :)

Share this post


Link to post
Share on other sites

You can check to see how much damage the tank has.

{alive _x} count [MBT1,MBT2,MBT3] == 0 or {damage _x >= 0.7} forEach [MBT1,MBT2,MBT3]

Share this post


Link to post
Share on other sites
You can check to see how much damage the tank has.

{alive _x} count [MBT1,MBT2,MBT3] == 0 or {damage _x >= 0.7} forEach [MBT1,MBT2,MBT3]

thanks - I tried this but got the error:

Or Type nothing, expected Bool,code

I should probably add that my scripting skills are almost non-existent.

Share this post


Link to post
Share on other sites
{alive _x} count [MBT1,MBT2,MBT3] == 0 or (damage MBT1) >= 0.5 && (damage MBT2) >= 0.5 && (damage MBT3) >= 0.5

Share this post


Link to post
Share on other sites
{alive _x} count [MBT1,MBT2,MBT3] == 0 or (damage MBT1) >= 0.5 && (damage MBT2) >= 0.5 && (damage MBT3) >= 0.5

That did it, many thanks.

Does anybody know if the tank crews are taken into account in this trigger? What I'm finding is that my ragged force of survivors (this is the end of the mission) are just about ready for the Intensive Care Unit, they manage to take out the tanks, and then the tank crews get out of their burning vehicles and start fighting like the SAS! :)

Share this post


Link to post
Share on other sites

Give each one of your tanks a group name. I used T1Grp = group this in MBT1 init line.

(damage MBT1) > 0 && {alive _x} count (units T1Grp) == 0

Edited by cobra4v320

Share this post


Link to post
Share on other sites
Give each one of your tanks a group name. I used T1Grp = group this in MBT1 init line.

(damage MBT1) > 0 && {alive _x} count (units T1Grp) == 0

Apologies, but I don't quite understand. Could you break it down for me a bit more please?

Do I rename the individual tanks? And again, sorry to be thick, but what effect does this produce? I really appreciate your time. :)

Share this post


Link to post
Share on other sites

The alive condition alone checks only if the crew members are alive.

The condition canMove checks if the vehicle can move, and canFire checks if the vehicle is capable of firing. You mentioned that you wish to check if the tank group is a "threat". If you wish to only check if the tank group is "combat effective", just name your tanks like you have and use the trigger condition:

!canMove MBT1 && !canMove MBT2 && !canMove MBT3

When the vehicle is not capable of moving, the AI crew automatically disembarks the vehicle, and the AI crew may of course use the carbines, but the tanks as vehicles are out of action : )

If you need to ensure that the crew members are also dead, use the condition similar to cobra4v's post.

Group your 3 tanks together, and then click the lead tank. In the init field of that tank, write:

T1Grp = group this;

That is now the group name of your 3 tanks. Also name the lead tank MBT1. Name other individual tanks of the group MBT2 and MBT3.

then try:

((!canMove MBT1 && !canMove MBT2 && !canMove MBT3) && ({alive _x} count (units T1Grp) == 0))

and see if it helps? Can't test this right now, but should work.

Share this post


Link to post
Share on other sites

Thanks Stagwine, that sounds ideal. I will give it a go with your canmove condition and see how it plays out. I will post again later with the results. :)

---------- Post added at 14:40 ---------- Previous post was at 14:01 ----------

Hmmmmm......... no, doesn't seem to have worked. The enemy tanks don't take part till the end of the mission, so rather than play through it, I put myself and a couple of anti armour squads on a convenient hilltop and we pasted the tanks. Despite some very satisfying columns of smoke and delayed explosions, it didn't trigger the endgame function, which did work (assuming I could actually win) with the previous conditions.

Are your conditions checking for movement capability and being alive? :-/

---------- Post added at 14:53 ---------- Previous post was at 14:40 ----------

Update: I don't know what's going on, but if I take the tanks' health down to 60% in the editor before running the mission, then when I play it, it triggers the endgame function. That's weird, because they are just as blown up in either case.

Share this post


Link to post
Share on other sites

Sorry, shouldn't post in haste when tired, had a typo too : )

What I meant is that the condition:

((!canMove MBT1 && !canMove MBT2 && !canMove MBT3) || ({alive _x} count (units T1Grp) == 0))

triggers when either the tank crews are dead too OR (||) just the tanks are just incapable of moving and thus ineffective as combat vehicles. canMove checks just if vehicle can move. That condition is a bit redundant in in this example but the difference, as I understand it, is that

({alive _x} count (units T1Grp) == 0))

requires that crew members are dead, where ever they are. I.e if the tank is burning but the driver is running 1 km away, it won't trigger as the driver is still alive.

!canMove MBT1 && !canMove MBT2 && !canMove MBT3

just checks if the vehicles alone are capable of moving, but the crew itself might still be alive and fighting as poor infantry : )

Both conditions can be useful, depending on the scenario you are creating and what is your "no longer threat" requirement. For example in my helo missions I just use the !canMove or !alive as plinking the crews, as satisfying it is, is tiresome. Usually simple no frills condition !alive will just do for many missions.

How are triggering that counter attack? Are they editor placed tanks and just further away, or do you spawn them from scripts with BIS_fnc_spawnGroup or BIS_fnc_spawnVehicle functions? Are you sure no typos, etc with the unitnames?

Share this post


Link to post
Share on other sites

Thanks Stagwine, that makes sense. I'm a bit confused as to why reducing the tanks' health made things work to some degree though, but I will try again with your script. It would be nice if the tank crew/helicopter pilot's default position after surviving the destruction of their vehicle was to flee - as opposed to adopting the "Pah, tanks! Who needs 'em?!" approach. :)

No, there's nothing very clever or technical going on in my mission editing. I just put a trigger in that caused the tanks to move in from some distance when there were no enemy left in the village (after a slight delay for dramatic effect :) ) The situation was complicated by another nearby group of vehicles that would race in and bolster the town's defences if the player failed to take out a watchtower guard at the start of the mission.

Share this post


Link to post
Share on other sites
What I meant is that the condition:

((!canMove MBT1 && !canMove MBT2 && !canMove MBT3) || ({alive _x} count (units T1Grp) == 0))

triggers when either the tank crews are dead too OR (||) just the tanks are just incapable of moving and thus ineffective as combat vehicles. canMove checks just if vehicle can move. That condition is a bit redundant in in this example but the difference, as I understand it, is that

({alive _x} count (units T1Grp) == 0))

requires that crew members are dead, where ever they are. I.e if the tank is burning but the driver is running 1 km away, it won't trigger as the driver is still alive.

!canMove MBT1 && !canMove MBT2 && !canMove MBT3

just checks if the vehicles alone are capable of moving, but the crew itself might still be alive and fighting as poor infantry : )

Argggghhhh! :) I played through the mission last night, and actually added a tank (MBT4) to your code. We cleared the village (it was heroic) and then the tanks came.

(Moving from the heroic, to the legendary) we took out the tanks. But the endgame function was not triggered. I personally walked round with a missile launcher and double fried the stationary tanks until they were smoking hulks, but the game did not end.

Checking what I'd done in the editor, I noticed that I had forgotten to put the Group line in the lead tanks's init, but the !canmove condition should have triggered the endgame anyway, shouldn't it?

On previous attempts at this I've observed reducing the tanks' initial health in the editor (not ideal for me) has seemingly made the game end where it should. Any thoughts?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×