Jump to content
Sign in to follow this  
daza

Isnull unit to trigger a warning in MP...

Recommended Posts

I've tried a few things and searched for some clues how to make this work to no avail.

I have a VIP map that has 2 playable VIPs. Lets say only VIP2 slot is filled,

and Disable AI was selected in lobby for all other slots not taken up by players. Leaving the VIP1 lifeless so to speak.

Once game starts I want to display text to all players telling them, that VIP1

isnt present on the map, due to AI being disabled and no human player has filled that slot.

Ive tried having a trigger with condition (isnull vpciv1) but nothing happens, even made the trigger count down incase it was firing too early. I have (!alive vpciv1) triggers for when it gets killed already, but that doesnt trigger either.

So i think perhaps the game knows it exists, and isnt dead, just not present on map. So how do i get around this??, as im sure some matches will be started unwittingly with only one VIP either as AI or player. The mission only ends if both VIPs are killed, so if only one dies and the other is not present the mission cant end....

Any ideas will be much apreciated. If no solution is found will have to make them unplayable, but Civ Ai can be unpredictable and sometimes ignore orders when grouped to a player.

Share this post


Link to post
Share on other sites

This may be silly, and primitive...

But couldn't you just run a trigger looking for the presence of VIP1 on the map? Then output a warning via 'On Act'? Just have said trigger covering the entire map, or just the area where VIP1 starts, and on 'Once', so it only fires if the game starts without that slot occupied?

Share this post


Link to post
Share on other sites

Thanks Hatedread for your suggestion. I did think of that, but that doesnt work either.

Wish it was possible that those 2 units cant be disabled in Lobby, that way at least AI will

still be controling VIPs if no player selects them.

Share this post


Link to post
Share on other sites

When the slot is disabled, the unit won't be created, nor will the variable given in the name field be initialisied.

That means that currently you're running code on a not-initialised variable.

You can handle this case by using the count command f.e.

To check how many vips are alive:

{alive _x} count [vpciv1,vpciv2]

It will only count the cases that are 'true', and ignore the cases being 'bool', or 'false'

To check if a variable has been initialised (unit has been created):

!isNil "vpciv1"

Further detailed notes:

Script commands with boolean return value, will return the value 'bool' (neither 'true', nor 'false') when run on not-initialisied variables.

ArmA1 could not handle that returned value within over statements. It won't throw an error message, but simply skip the whole statement that the returned value is part of. Triggers won't fire when their condition returns 'bool'. From what you've written in your post, I assume that ArmA2 behaves exactly the same way.

Examples: (Variable "ab" is not initialised. Variable "cd" and "ef" are, and have type Object)

if(isNull ab) then {

// code block 1

} else {

// code block 2

};

// both, the if and the else case will be skipped. nothing of the two code blocks is executed here

isNull ab -> returns 'bool'

isNull cd -> returns 'true'

isNull ef -> returns 'false'

(isNull ab) && (isNull cd) && (isNull ef) -> returns 'bool'

// as soon as one part of an expression returns 'bool', the whole expression will return 'bool'

Share this post


Link to post
Share on other sites

Thanks dengibtsschon. Isnil did the trick.

But my new problem is, Lets say vpciv1 isnil because it was diabled in the lobby,

and vpciv2 was killed by the enemy.

I have a trigger to fire if Vpciv2 is KIA and the other does not exist,

Trigger setup:

Act:Gamelogic

Type: End#2

Condition: (!alive vpciv2) && (isnil "vpciv1")

OnAct: tskobj5 setTaskState "SUCCEEDED"; [tskObj5] call mk_fTaskHint; vp2f=true; publicVariable "vp2f";

When vpciv2 is killed this trigger does fire, because i have a Text to display when this trigger activates. However the mission does not end. I have another trigger to do this, if both vips are isnil. Same result.

Any ideas why this isn't ending mission?

I have another trigger same setup different condition that fires if both VIPS have been killed, also with a type: End#2, and it does end the mission.

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  

×