Raised This Month: $51 Target: $400
 12% 

Solved [L4D2] CoOp: Determine non-finale map success/fail


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Old 02-26-2024 , 16:42   [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #1

For finale maps, there is a finale_win (and mission_lost) event that can be checked to determine finale success.

There does not appear to be a map_win event (which I define as at least one survivor successfully made it to the checkpoint, closed the door, and triggered a changelevel to the next map in the campaign).

I thought at first that if OnMapEnd was reached it would be a success (because if mission_lost is triggered, OnMapEnd will not trigger), but that only works most of the time. There are at least two scenarios I can think of that cause problems... OnMapEnd is triggered when a new lobby connects, and OnMapEnd is triggered when a vote passes to change to a new map/campaign. It is also possible that lobby/vote connections go directly to any map in the campaign.

In either round_start or OnMapStart I want to determine if the previous map was a success, or if we got here from a new lobby connect, map vote change, or anything else that might changelevel without a map_win.

I am thinking when the ending checkpoint door is closed I may have to determine if all alive survivors are in the ending checkpoint and set an appropriate global variable to indicate a map_win, then check the value of that variable in round_start and/or OnMapStart.

Any better ideas?
__________________

Last edited by Mystik Spiral; 02-27-2024 at 07:17.
Mystik Spiral is offline
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Old 02-26-2024 , 21:56   Re: [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #2

In case anyone is interested, I effectively created my own map_win event by piggy-backing off of the door_close event (requires left4dhooks):

PHP Code:
public void Event_DoorClose(Event eventchar[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
bool bCPdoor = (GetEventBool(event"checkpoint"));
    if (
bCPdoor && L4D_IsInLastCheckpoint(client))
    {
        
g_bMapWin true;
        for (
int i 1<= MaxClientsi++)
        {
            if (
IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == SURVIVOR_TEAM && !L4D_IsInLastCheckpoint(i))
            {
                
g_bMapWin false;
                break;
            }
        }
        if (
g_bMapWin)
        {
            
//stuff
        
}
    }

I am sure that can be refined but it resolves the issue for me.
__________________
Mystik Spiral is offline
BRU7US
Member
Join Date: Jul 2020
Location: Tatarstan, Kazan
Old 02-28-2024 , 18:29   Re: [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #3

Use "map_transition" event to determine boolean variable as true. Then check this variable on forward "OnMapStart" to check previous map change type. You only need to define the correct event at which the boolean variable gets the value false, so that you can correctly distinguish when the map was changed as a result of victory or as a result of other operations

Last edited by BRU7US; 03-02-2024 at 03:46.
BRU7US is offline
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Old 02-28-2024 , 19:59   Re: [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #4

Note that I am trying to determine the success of the previous map, like a changelevel from map 3 to map 4 of a 5 map campaign, not the success of the previous campaign. This is important because I am manipulating entities in the ending checkpoint that affect the starting checkpoint in the next map. What I have works great and my tests have not revealed any problems.

I will (eventually) investigate when "map_transition" fires. I thought it would only fire for the first map of a campaign during the fly-by intro and for the last map of a campaign for the escape, but maybe it fires at the end of every map.

Thanks for the feedback!
__________________
Mystik Spiral is offline
BRU7US
Member
Join Date: Jul 2020
Location: Tatarstan, Kazan
Old 03-01-2024 , 17:38   Re: [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #5

"map_transition" fires every time your team successfully completes a map (not campaign)
BRU7US is offline
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Old 03-01-2024 , 18:08   Re: [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #6

Thanks @BRU7US!

I will probably switch to using that then since I have discovered a rare issue... if the last bot into the checkpoint warps in while the door is closed, g_bMapWin will not get set.
__________________
Mystik Spiral is offline
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Old 03-01-2024 , 21:36   Re: [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #7

I am now using map_transition. It is simpler and works better. Thanks again @BRU7US!
__________________
Mystik Spiral is offline
BRU7US
Member
Join Date: Jul 2020
Location: Tatarstan, Kazan
Old 03-02-2024 , 03:45   Re: [L4D2] CoOp: Determine non-finale map success/fail
Reply With Quote #8

Quote:
Originally Posted by Mystik Spiral View Post
I am now using map_transition. It is simpler and works better. Thanks again @BRU7US!
You are welcome!
BRU7US is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode