Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions cfg/cmt/randomcoop3.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//All of the official campaigns, undivided

sm_addmap c1m1_hotel random
sm_addmap c1m2_streets random
sm_addmap c1m3_mall random
sm_addmap c2m1_highway random
sm_addmap c2m2_fairgrounds random
sm_addmap c2m3_coaster random
sm_addmap c2m4_barns random
sm_addmap c3m1_plankcountry random
sm_addmap c3m2_swamp random
sm_addmap c3m3_shantytown random
sm_addmap c4m1_milltown_a random
sm_addmap c4m2_sugarmill_a random
sm_addmap c4m3_sugarmill_b random
sm_addmap c4m4_milltown_b random
sm_addmap c5m1_waterfront random
sm_addmap c5m2_park random
sm_addmap c5m3_cemetery random
sm_addmap c5m4_quarter random
sm_addmap c6m1_riverbank random
sm_addmap c6m2_bedlam random
sm_addmap c7m1_docks random
sm_addmap c7m2_barge random
sm_addmap c8m1_apartment random
sm_addmap c8m2_subway random
sm_addmap c8m3_sewers random
sm_addmap c8m4_interior random
sm_addmap c9m1_alleys random
sm_addmap c10m1_caves random
sm_addmap c10m2_drainage random
sm_addmap c10m3_ranchhouse random
sm_addmap c10m4_mainstreet random
sm_addmap c11m1_greenhouse random
sm_addmap c11m2_offices random
sm_addmap c11m3_garage random
sm_addmap c11m4_terminal random
sm_addmap c12m1_hilltop random
sm_addmap c12m2_traintunnel random
sm_addmap c12m3_bridge random
sm_addmap c12m4_barn random
sm_addmap c13m1_alpinecreek random
sm_addmap c13m2_southpinestream random
sm_addmap c13m3_memorialbridge random

sm_addmap c1m4_atrium finale
sm_addmap c2m5_concert finale
sm_addmap c3m4_plantation finale
sm_addmap c4m5_milltown_escape finale
sm_addmap c5m5_bridge finale
sm_addmap c6m3_port finale
sm_addmap c7m3_port finale
sm_addmap c8m5_rooftop finale
sm_addmap c9m2_lots finale
sm_addmap c10m5_houseboat finale
sm_addmap c11m5_runway finale
sm_addmap c12m5_cornfield finale
sm_addmap c13m4_cutthroatcreek finale

sm_tagrank random 0
sm_tagrank random 1
sm_tagrank finale 2

sm_cvar cmt_poolsize 1000 //ie no limit
sm_cvar cmt_veto_count 0
67 changes: 67 additions & 0 deletions cfg/cmt/randomcoop5.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//All of the official campaigns, undivided

sm_addmap c1m1_hotel random
sm_addmap c1m2_streets random
sm_addmap c1m3_mall random
sm_addmap c2m1_highway random
sm_addmap c2m2_fairgrounds random
sm_addmap c2m3_coaster random
sm_addmap c2m4_barns random
sm_addmap c3m1_plankcountry random
sm_addmap c3m2_swamp random
sm_addmap c3m3_shantytown random
sm_addmap c4m1_milltown_a random
sm_addmap c4m2_sugarmill_a random
sm_addmap c4m3_sugarmill_b random
sm_addmap c4m4_milltown_b random
sm_addmap c5m1_waterfront random
sm_addmap c5m2_park random
sm_addmap c5m3_cemetery random
sm_addmap c5m4_quarter random
sm_addmap c6m1_riverbank random
sm_addmap c6m2_bedlam random
sm_addmap c7m1_docks random
sm_addmap c7m2_barge random
sm_addmap c8m1_apartment random
sm_addmap c8m2_subway random
sm_addmap c8m3_sewers random
sm_addmap c8m4_interior random
sm_addmap c9m1_alleys random
sm_addmap c10m1_caves random
sm_addmap c10m2_drainage random
sm_addmap c10m3_ranchhouse random
sm_addmap c10m4_mainstreet random
sm_addmap c11m1_greenhouse random
sm_addmap c11m2_offices random
sm_addmap c11m3_garage random
sm_addmap c11m4_terminal random
sm_addmap c12m1_hilltop random
sm_addmap c12m2_traintunnel random
sm_addmap c12m3_bridge random
sm_addmap c12m4_barn random
sm_addmap c13m1_alpinecreek random
sm_addmap c13m2_southpinestream random
sm_addmap c13m3_memorialbridge random

sm_addmap c1m4_atrium finale
sm_addmap c2m5_concert finale
sm_addmap c3m4_plantation finale
sm_addmap c4m5_milltown_escape finale
sm_addmap c5m5_bridge finale
sm_addmap c6m3_port finale
sm_addmap c7m3_port finale
sm_addmap c8m5_rooftop finale
sm_addmap c9m2_lots finale
sm_addmap c10m5_houseboat finale
sm_addmap c11m5_runway finale
sm_addmap c12m5_cornfield finale
sm_addmap c13m4_cutthroatcreek finale

sm_tagrank random 0
sm_tagrank random 1
sm_tagrank random 2
sm_tagrank random 3
sm_tagrank finale 4

sm_cvar cmt_poolsize 1000 //ie no limit
sm_cvar cmt_veto_count 0
92 changes: 42 additions & 50 deletions src/custom_map_transitions.sp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public Plugin:myinfo =
#define BUF_SZ 64
#define DOOR_DELAY 0.1

#define SURVIVOR_NICK_BILL 0
#define SURVIVOR_ROCHELLE_ZOEY 1
#define SURVIVOR_COACH_LOUIS 2
#define SURVIVOR_ELLIS_FRANCIS 3

const TEAM_SURVIVOR = 2;

new Handle: g_hCvarDebug;
Expand Down Expand Up @@ -78,11 +83,19 @@ new Handle: g_hForwardEnd;

new Handle: g_hCountDownTimer;

static Handle hDirectorChangeLevel;
static Address TheDirector = Address_Null;

new bool:g_bNativeStatistics = false;

new const String: g_csSurvivorModels[][] = {
"models/survivors/survivor_biker.mdl",
"models/survivors/survivor_coach.mdl",
"models/survivors/survivor_gambler.mdl",
"models/survivors/survivor_manager.mdl",
"models/survivors/survivor_mechanic.mdl",
"models/survivors/survivor_namvet.mdl",
"models/survivors/survivor_producer.mdl",
"models/survivors/survivor_teenangst.mdl",
};


// ----------------------------------------------------------
// Library tracking
Expand Down Expand Up @@ -171,7 +184,6 @@ public OnPluginStart() {
PluginStartInit();

PrepareScoreSignature();
PrepareMapChangeSignature();
}

PluginStartInit() {
Expand Down Expand Up @@ -205,31 +217,6 @@ void PrepareScoreSignature() {
g_hSDKCallSetCampaignScores = EndPrepSDKCall();
}

void PrepareMapChangeSignature() {
Handle hGamedata = LoadGameConfigFile("l4d_mapchanger");
if (hGamedata == null) {
SetFailState("Failed to load \"l4d_mapchanger.txt\" gamedata.");
}

StartPrepSDKCall(SDKCall_Raw);
if (! PrepSDKCall_SetFromConf(hGamedata, SDKConf_Signature, "CDirector::OnChangeChapterVote")) {
SetFailState("Error finding the 'CDirector::OnChangeChapterVote' signature.");
}
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);

hDirectorChangeLevel = EndPrepSDKCall();
if (hDirectorChangeLevel == null) {
SetFailState("Unable to prep SDKCall 'CDirector::OnChangeChapterVote'");
}

TheDirector = GameConfGetAddress(hGamedata, "CDirector");
if (TheDirector == Address_Null) {
SetFailState("Unable to get 'CDirector' Address");
}

delete hGamedata;
}


// ----------------------------------------------------------
// Hooks
Expand All @@ -248,6 +235,9 @@ public OnMapStart() {
g_bCoopEndSaferoomClosed = false;
g_bSwitchingForCoop = false;


PrecacheModels();

// let other plugins know what the map *after* this one will be (unless it is the last map)
if (! g_bMaplistFinalized || g_iMapsPlayed >= g_iMapCount-1) {
return;
Expand Down Expand Up @@ -283,6 +273,10 @@ public Action:Timed_PostOnRoundStart(Handle:timer) {
}

public OnRoundEnd() {
if (! g_bMapsetInitialized) {
return;
}

PrintDebug(4, "[cmt] OnRoundEnd");

if (IsCoopMode()) {
Expand Down Expand Up @@ -311,6 +305,10 @@ public void OnDoorClose(Event event, const char[] name, bool dontBroadcast) {
return;
}

if (! g_bMapsetInitialized) {
return;
}

PrintDebug(6, "[cmt] OnDoorClose for checkpoint door");

if (! IsCoopMode()) {
Expand Down Expand Up @@ -341,6 +339,9 @@ public void OnDoorOpen(Event event, const char[] name, bool dontBroadcast) {
if (! event.GetBool("checkpoint") || g_bSwitchingForCoop) {
return;
}
if (! g_bMapsetInitialized) {
return;
}

PrintDebug(6, "[cmt] OnDoorOpen for checkpoint door");

Expand All @@ -359,6 +360,9 @@ public Action:Event_PlayerDeath(Handle:hEvent, const String:name[], bool:dontBro
if (! g_bCoopEndSaferoomClosed || ! IsCoopMode()) {
return Plugin_Continue;
}
if (! g_bMapsetInitialized) {
return Plugin_Continue;
}

new victim = GetClientOfUserId(GetEventInt(hEvent, "userid"));

Expand Down Expand Up @@ -743,34 +747,14 @@ void GotoNextMap(bool:force = false) {
void GotoMap(const char[] sMapName, bool:force = false) {
if (force || IsCoopMode()) {
PrintDebug(2, "[cmt] Forcing next map (%s)", sMapName);
//ForceChangeLevel(sMapName, "Custom map transitions.");
ForceNextMapSdk(sMapName);
ForceChangeLevel(sMapName, "Custom map transitions.");
return;
}

PrintDebug(2, "[cmt] Using SetNextMap (%s)", sMapName);
SetNextMap(sMapName);
}

void ForceNextMapSdk(const char[] sMapName) {
DataPack dp = new DataPack();
dp.WriteString(sMapName);

CreateTimer(2.0, Timer_AlternateChangeMap, dp, TIMER_FLAG_NO_MAPCHANGE | TIMER_DATA_HNDL_CLOSE);

SDKCall(hDirectorChangeLevel, TheDirector, sMapName);
}

public Action Timer_AlternateChangeMap(Handle timer, DataPack dp) {
static char g_sNewMap[BUF_SZ];

dp.Reset();
dp.ReadString(g_sNewMap, sizeof g_sNewMap);

ServerCommand("changelevel %s", g_sNewMap);
ServerExecute();
}


// ----------------------------------------------------------
// Score handling logic
Expand Down Expand Up @@ -980,6 +964,14 @@ stock GetPrettyName(String:map[]) {
return 0;
}

void PrecacheModels() {
for (new i = 0; i < sizeof(g_csSurvivorModels); i++) {
if (! IsModelPrecached(g_csSurvivorModels[i])) {
PrecacheModel(g_csSurvivorModels[i], true);
}
}
}

// ----------------------------------------------------------
// Basic helpers
// ----------------------------------------------------------
Expand Down