[src] Apocalypse

Codes already submitted by people of the forums.
Post Reply
snoopy81
Loyal fan
Posts: 338
Joined: Mon Jul 12, 2004 7:13 pm

Post by snoopy81 »

This the commented most important part, but there miss cfg, login, admincommands, and lot of places you may gave to adjust...
Some new variables and constant have been added too.

ie:
- m_sApocalypseBossMobRect; in cMap, loaded from;
//------------------------NpcID---RECT----------------------
ApocalypseBossMob = 81 79 76 136 107

- m_bIsApocalypseGateOpen: Global variable for server. After some time, the gate closes but players alreaddy at Apoc maps can go on... A GM could reopen the gate for a while if needed.

- m_iMaximumObjectDefault: Store the "normal" max mobs, because it's set to 0 to prevent respawn. At event end mob nbe is restored using this value.

- DEF_DELAYEVENTTYPE_END_APOCALYPSE: Delay in seconds to close apoc when Abaddon is dead.

- DEF_DELAYEVENTTYPE_KILL_ABADDON: Delay in seconds for AbaDDon's auto Kill, when last map is empty.

Code: Select all

//**************************************************************************************
// HBx server introduced only the skeletton off Apocalypse functions, and sometime not so good!
// I rewrote them, maybe not following the "official" pattern but it works!
// I also needed to add many new functions.
//**************************************************************************************
// SNOOPY: GlobalStartApocalypseMode
// Called by: by local command or GM command
// -> Notify all game servers to start apocalypse
// -> Used to force Open or Closed the initial Gates
//**************************************************************************************
void CGame::GlobalStartApocalypseMode(int iClientH, int iMode)
{ char * cp, cData[120];
DWORD * dwp, dwApocalypseGUID;
char cString[200];
ZeroMemory(cString, sizeof(cString));
if ((iClientH != 0) && (m_pClientList[iClientH]->m_iAdminUserLevel < 3)) {
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_ADMINUSERLEVELLOW, NULL, NULL, NULL, NULL);
return;
}
if ((m_bIsApocalypseMode == TRUE) && (iMode == 0)) return;
if (m_bIsHeldenianMode == TRUE) return;
if (m_bIsCrusadeMode == TRUE) return;

switch (iMode){
case 1: // Force open Gates
dwApocalypseGUID = 1; 
if (iClientH !=0)
{ wsprintf(G_cTxt, "Admin Order(%s): /openapocalypsegate \tAdminIP(%s)"
, m_pClientList[iClientH]->m_cCharName
, m_pClientList[iClientH]->m_cIPaddress);
wsprintf(cString, "Apocalypse gate opening in progress.");
}else
{ wsprintf(G_cTxt, "Local command: openapocalypsegate");
}; 
break;
case 2: // Force close gates
dwApocalypseGUID = 2; 
if (iClientH !=0)
{ wsprintf(G_cTxt, "Admin Order(%s): /closeapocalypsegate \tAdminIP(%s)"
, m_pClientList[iClientH]->m_cCharName
, m_pClientList[iClientH]->m_cIPaddress);
wsprintf(cString, "Apocalypse gate closing in progress.");
}else
{ wsprintf(G_cTxt, "Local command: closeapocalypsegate");
}; 
break;
case 0: // Start Apocalypse
dwApocalypseGUID = timeGetTime(); 
if (dwApocalypseGUID < 10) dwApocalypseGUID += 10;
if (iClientH !=0)
{ wsprintf(G_cTxt, "Admin Order(%s): /beginapocalypse \tAdminIP(%s)"
, m_pClientList[iClientH]->m_cCharName
, m_pClientList[iClientH]->m_cIPaddress);
wsprintf(cString, "Apocalypse starting in progress.");
}else
{ wsprintf(G_cTxt, "Local command: beginapocalypse");
}; 
break;
}
PutAdminLogFileList(G_cTxt); 
PutLogEventFileList(G_cTxt);
PutLogList(G_cTxt); 
if (iClientH !=0)
{ SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_IPACCOUNTINFO, NULL, NULL, NULL, cString);
}

ZeroMemory(cData, sizeof(cData));
cp = (char *)cData;
*cp = GSM_BEGINAPOCALYPSE;
cp++;
dwp = (DWORD *)cp;
*dwp = dwApocalypseGUID;
cp += 4;
bStockMsgToGateServer(cData, 5);
LocalStartApocalypse(dwApocalypseGUID); // Gate will no return order to this server
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// LocalStartApocalypse
// called by: started by Gate msg
// -> Notify players
// -> Opens the gates
// -> Prevent npc generation on "kill all to go out" maps
// -> Execute local Openning or closing gates by GM command
//**************************************************************************************
void CGame::LocalStartApocalypse(DWORD dwApocalypseGUID)
{ if (dwApocalypseGUID == 1)// Means want to open Gate
{ ForceOpen_ApocalypseGate();
return;
}
if (dwApocalypseGUID == 2)// Means want to open Gate
{ ForceClose_ApocalypseGate();
return;
} 
register int i;
m_bIsApocalypseMode = TRUE;
if (dwApocalypseGUID != NULL) 
{ _CreateApocalypseGUID(dwApocalypseGUID); 
m_dwApocalypseGUID = dwApocalypseGUID;
m_dwApocalypseGateOpenTime = dwApocalypseGUID;
m_dwApocalypseGateCloseTime = dwApocalypseGUID +20*60*1000; // will close in 20 minutes
}
for (i = 1; i < DEF_MAXCLIENTS; i++) 
{ if (m_pClientList[i] != NULL) 
{ SendNotifyMsg(NULL, i, DEF_NOTIFY_APOCGATESTARTMSG, NULL, NULL, NULL, NULL); 
}
}
for (i = 0; i < DEF_MAXMAPS; i++)
{ if (m_pMapList[i] != NULL) 
{ if (m_pMapList[i]->m_iApocalypseMobGenType != 0) 
//1 for no respawn, 2 for Boss spawn when map empty
{ m_pMapList[i]->m_iMaximumObjectDefault = m_pMapList[i]->m_iMaximumObject;
m_pMapList[i]->m_iMaximumObject = 0; 
}
}
}
OpenCloseApocalypseGate();
wsprintf(G_cTxt,"(!)Apocalypse Mode ON."); 
PutLogEventFileList(G_cTxt);
PutLogList(G_cTxt); 
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// GlobalEndApocalypseMode: 
// -> Notify all game servers
//**************************************************************************************
void CGame::GlobalEndApocalypseMode(int iClientH)
{ char * cp, cData[120];
if (m_bIsApocalypseMode == FALSE) return;

if (iClientH > 0) 
{ wsprintf(G_cTxt, "Admin Order(%s): /endapocalypse \tAdminIP(%s)"
, m_pClientList[iClientH]->m_cCharName
, m_pClientList[iClientH]->m_cIPaddress);
char cString[200];
ZeroMemory(cString, sizeof(cString));
wsprintf(cString, "Apocalypse ending in progress.");
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_IPACCOUNTINFO, NULL, NULL, NULL, cString);
}else
{ wsprintf(G_cTxt, "Automated: endapocalypse");
}
PutAdminLogFileList(G_cTxt); 
PutLogEventFileList(G_cTxt);
PutLogList(G_cTxt); 

ZeroMemory(cData, sizeof(cData));
cp = (char *)cData;
*cp = GSM_ENDAPOCALYPSE;
cp++; 
bStockMsgToGateServer(cData, 5);
LocalEndApocalypse(); // Gate will not return order to this server
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// LocalEndApocalypse: started by Gate msg
// -> Notify players
// -> Close the gates
// -> Enable npc generation on all maps
//**************************************************************************************
void CGame::LocalEndApocalypse()
{ register int i; 
m_bIsApocalypseMode = FALSE;
m_bIsApocalypseGateOpen = FALSE; 
WORD dwTime = timeGetTime();
m_dwApocalypseGateCloseTime = dwTime -1;
m_dwApocalypseGateOpenTime = dwTime -100; // alreaddy closed

for (i = 1; i < DEF_MAXCLIENTS; i++) 
{ if (m_pClientList[i] != NULL)
{ SendNotifyMsg(NULL, i, DEF_NOTIFY_APOCGATEENDMSG, NULL, NULL, NULL, NULL);
if ( (m_pClientList[i]->m_iAdminUserLevel == 0)
&& (m_pMapList[m_pClientList[i]->m_cMapIndex]->m_bIsApocalypseMap == TRUE)) 
{ // forced recall
SendNotifyMsg(NULL, i, DEF_NOTIFY_TOBERECALLED, NULL, NULL, NULL, NULL);
RequestTeleportHandler(i, "0 ");
}
}
} 
// restore normal spawn on apoc maps
for (i = 0; i < DEF_MAXMAPS; i++)
{ if (m_pMapList[i] != NULL) 
{ if (m_pMapList[i]->m_iApocalypseMobGenType != 0) 
//1 for not respawn, 2 for Boss spawn.
{ m_pMapList[i]->m_iMaximumObject = m_pMapList[i]->m_iMaximumObjectDefault;
}
if (m_pMapList[i]->m_cDynamicGateType == 4 )
{ m_pMapList[i]->m_cDynamicGateType = 3;
}
if (m_pMapList[i]->m_cDynamicGateType == 2)
{ GenerateSlime(i); // to force the gate to close 
}
Open_EmptyMap_Gate(i);
}
}
wsprintf(G_cTxt,"(!)Apocalypse Mode OFF.");
PutLogEventFileList(G_cTxt);
PutLogList(G_cTxt);
}
//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// OpenCloseApocalypseGate 
// Called by ::ForceOpen_ApocalypseGate, ::ForceClose_ApocalypseGate
// Called by ::LocalStartApocalypse
// Check if Gates's needs to be openned or closed 
// then notify any change to all clients.on current server
// NB: Opens/closes only type 1 Gates
//**************************************************************************************
void CGame::OpenCloseApocalypseGate()
{ DWORD dwTime = timeGetTime();
BOOL bIsOpen = m_bIsApocalypseGateOpen; 
if ( (dwTime >= m_dwApocalypseGateOpenTime)
&& (dwTime < m_dwApocalypseGateCloseTime))
{ m_bIsApocalypseGateOpen = TRUE;
}else
{ m_bIsApocalypseGateOpen = FALSE;
}
// If nothing has changed return...
if (bIsOpen == m_bIsApocalypseGateOpen) return;

if (m_bIsApocalypseGateOpen == TRUE) 
{ wsprintf(G_cTxt,"(!)Apocalypse Gate opened.");
}else
{ wsprintf(G_cTxt,"(!)Apocalypse Gate closed.");
}
PutLogList(G_cTxt); 
PutLogEventFileList(G_cTxt);
// Then notify all clients of change,
register int i; 
for (i = 1; i < DEF_MAXCLIENTS; i++) 
{ if (m_pClientList[i] != NULL)
{ Notify_ApocalypseGateState(i);
} 
}
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// Notify_ApocalypseGateState 
// Called by ::RequestInitDataHandler (when client log in)
// Called by ::RequestTeleportHandler (when client changes map on same server)
// Called by ::OpenCloseApocalypseGate (when Gate is openned or closed)
// Notify the client of Gate's state, needed to show in player's screen
//**************************************************************************************
void CGame::Notify_ApocalypseGateState(int iClientH)
{ if (iClientH <= 0) return;
if (m_pClientList[iClientH] <= 0) return;
if (m_pClientList[iClientH]->m_bIsInitComplete == FALSE) return;
int iMapIndex = m_pClientList[iClientH]->m_cMapIndex;

int gX, gY;
gX = (m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX1 + m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX2)/2;
gY = (m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY1 + m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY2)/2;

switch (m_pMapList[iMapIndex]->m_cDynamicGateType){
case 0: // No gate on current map
if(m_bIsApocalypseGateOpen == TRUE) 
{ SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATEOPEN, 0, 0, NULL, m_pClientList[iClientH]->m_cMapName);
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATESTARTMSG, NULL, NULL, NULL, NULL);
}else
{ SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATECLOSE, 0, 0, NULL, m_pClientList[iClientH]->m_cMapName);
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATEENDMSG, NULL, NULL, NULL, NULL);
}
break;

case 1: // Initial Dynamic gates (toh, IB, D4...)
if(m_bIsApocalypseGateOpen == TRUE) 
{ SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATEOPEN, gX, gY, NULL, m_pClientList[iClientH]->m_cMapName);
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATESTARTMSG, NULL, NULL, NULL, NULL);
}else
{ SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATECLOSE, gX, gY, NULL, m_pClientList[iClientH]->m_cMapName);
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATEENDMSG, NULL, NULL, NULL, NULL);
}
break;

case 2: // Empty maps Dynamic gates (inferniaA, inferniaB, procella...)
if (m_pMapList[iMapIndex]->m_iTotalAliveObject == 0)
{ SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATEOPEN, gX, gY, NULL, m_pClientList[iClientH]->m_cMapName);
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATESTARTMSG, NULL, NULL, NULL, NULL);
}else
{ SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATECLOSE, gX, gY , NULL, m_pClientList[iClientH]->m_cMapName);
}
break;

case 3: // Hide the n°3 gates ..
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATECLOSE, gX, gY, NULL, m_pClientList[iClientH]->m_cMapName);
break;

case 4: // Show the gate on abaddon map..when Abaddon spawning.
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATEOPEN, gX, gY, NULL, m_pClientList[iClientH]->m_cMapName);
SendNotifyMsg(NULL, iClientH, DEF_NOTIFY_APOCGATESTARTMSG, NULL, NULL, NULL, NULL);
break;
}
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// Use_ApocalypseGate 
// Called by ::CheckClientResponseTime()
// Test if client uses Dynamic Gate, then TP him
//**************************************************************************************
void CGame::Use_ApocalypseGate(int iClientH)
{ if (iClientH <= 0) return;
if (m_pClientList[iClientH] <= 0) return;
if (m_pClientList[iClientH]->m_bIsInitComplete == FALSE) return;
if (m_bIsApocalypseMode == FALSE) return;
int iMapIndex = m_pClientList[iClientH]->m_cMapIndex;
if (m_pMapList[iMapIndex]->m_cDynamicGateType == 0 ) return; // No Dynamic Gate on this map

if ( (m_pMapList[iMapIndex]->m_cDynamicGateType == 1 )
&& (m_bIsApocalypseGateOpen == FALSE)) 
return; // Dynamic Gate is closed

if ( (m_pMapList[iMapIndex]->m_cDynamicGateType == 2 )
&& (m_pMapList[iMapIndex]->m_iTotalAliveObject != 0)) 
return; // There are still creatures on the map

if (m_pMapList[iMapIndex]->m_cDynamicGateType == 3 )
return; // Type 3 will be changed to 4 at Abaddons spawning.

if ( (m_pClientList[iClientH]->m_sX >= m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX1)
&& (m_pClientList[iClientH]->m_sX <= m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX2)
&& (m_pClientList[iClientH]->m_sY >= m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY1)
&& (m_pClientList[iClientH]->m_sY <= m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY2))
{ RequestTeleportHandler(iClientH, "2 "
, m_pMapList[iMapIndex]->m_cDynamicGateCoordDestMap
, m_pMapList[iMapIndex]->m_sDynamicGateCoordTgtX
, m_pMapList[iMapIndex]->m_sDynamicGateCoordTgtY); 
}
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// Open_EmptyMap_Gate 
// Called by ::NpcKilledHandler when last npc killed on map
// Show just openned gates to the client
//**************************************************************************************
void CGame::Open_EmptyMap_Gate(int MapIndex)
{ if (m_pMapList[MapIndex]->m_cDynamicGateType < 2 ) return; 
//if (m_pMapList[MapIndex]->m_cDynamicGateType == 3 ) return; 
register int i;
for (i = 1; i < DEF_MAXCLIENTS; i++) 
{ if (m_pClientList[i] == NULL) continue;
if (m_pClientList[i]->m_cMapIndex != MapIndex) continue;
Notify_ApocalypseGateState(i); 
} 
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// GenerateApocalypseBoss 
// Called by ::NpcKilledHandler
// Creates the appropriate npc depending on map definition file
// then change the Dynamic Gate type from 3 to 4 (to open it)
//**************************************************************************************
void CGame::GenerateApocalypseBoss(int MapIndex)
{ if (m_pMapList[MapIndex]->m_iTotalAliveObject != 0) return;
char cName[21], cNpcName[21], cNpcWaypoint[11]; 
int x, i5;
int iNamingValue;
ZeroMemory(cNpcWaypoint, sizeof(cNpcWaypoint));

iNamingValue = m_pMapList[MapIndex]->iGetEmptyNamingValue();
if (iNamingValue == -1) 
{}else 
{ ZeroMemory(cNpcName, sizeof(cNpcName));
switch (m_pMapList[MapIndex]->m_iApocalypseBossMobNpcID) {
case 0: return; break;
case 49: strcpy(cNpcName, "Hellclaw");break;
case 50: strcpy(cNpcName, "Tigerworm");break; 
case 66: strcpy(cNpcName, "Wyvern");break; 
case 73: strcpy(cNpcName, "Fire-Wyvern");break; 
case 81: strcpy(cNpcName, "Abaddon");break; 
default: strcpy(cNpcName, "Demon");break; 
}
ZeroMemory(cName, sizeof(cName));
wsprintf(cName, "XX%d", iNamingValue);
cName[0] = '_';
cName[1] = MapIndex+65; 
if (bCreateNewNpc(cNpcName, cName, m_pMapList[MapIndex]->m_cName, 0, 0
, DEF_MOVETYPE_RANDOMAREA, NULL, NULL, cNpcWaypoint, &m_pMapList[MapIndex]->m_sApocalypseBossMobRect, NULL, -1, FALSE, FALSE, FALSE, TRUE) == FALSE) 
{ m_pMapList[MapIndex]->SetNamingValueEmpty(iNamingValue);
} 
else 
{ wsprintf(G_cTxt, "(!) %s has spawned in %s"
, cNpcName
, m_pMapList[MapIndex]->m_cName);
PutLogList(G_cTxt); 
PutLogFileList(G_cTxt); 
PutLogEventFileList(G_cTxt);
}

// Search npc ID
for (i5 = 1; i5 < DEF_MAXNPCS; i5++)
{ if ((m_pNpcList[i5] != NULL) && (memcmp(m_pNpcList[i5]->m_cName, cName, 5) == 0) ) 
{ break;
}
}

// Show Spawns on minimap, and tell everybody on Apocalypse server.
for (x = 1; x < DEF_MAXCLIENTS; x++)
if ( (m_pClientList[x] != NULL) 
&& (m_pClientList[x]->m_bIsInitComplete == TRUE))
{ if(memcmp(m_pMapList[MapIndex]->m_cName, m_pMapList[m_pClientList[x]->m_cMapIndex]->m_cName, strlen(m_pMapList[MapIndex]->m_cName)) == 0)
{ SendNotifyMsg(NULL, x, DEF_NOTIFY_SPAWNEVENT, m_pNpcList[i5]->m_sX, m_pNpcList[i5]->m_sY, m_pMapList[MapIndex]->m_iApocalypseBossMobNpcID, NULL, NULL, NULL);
}
// Tell everybody on this server if Abaddon has appeared
if (m_pMapList[MapIndex]->m_iApocalypseBossMobNpcID == 81) 
{ char cInfoString[100];
ZeroMemory(cInfoString, sizeof(cInfoString));
wsprintf(cInfoString, "Abbadon has appeared ...");
SendNotifyMsg(NULL, x, DEF_NOTIFY_IPACCOUNTINFO, NULL, NULL, NULL, cInfoString);
}
}

// Prepare Abaddon's death, and Apocalypse end.
if (m_pMapList[MapIndex]->m_iApocalypseBossMobNpcID == 81)
{ // Abaddon should die by himself 
DWORD dwTime = timeGetTime();
dwTime += 1000*60*5; // 5 minute
bRegisterDelayEvent(DEF_DELAYEVENTTYPE_KILL_ABADDON, 0, dwTime, i5
, DEF_OWNERTYPE_NPC, MapIndex, 0, 0, 0, 0, 0);
dwTime = timeGetTime();
dwTime += 1000*60*15; // 15 minutes
bRegisterDelayEvent(DEF_DELAYEVENTTYPE_END_APOCALYPSE, 0, dwTime, 0
, 0, MapIndex, 0, 0, 0, 0, 0);
}

// Finally open the Exit Gate if type 3 & not 2 
if (m_pMapList[MapIndex]->m_cDynamicGateType == 3 )
{ m_pMapList[MapIndex]->m_cDynamicGateType = 4;
Open_EmptyMap_Gate(MapIndex);
}
}
}
//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// GenerateSlime 
// Generate a npc now to close the gate
//**************************************************************************************
void CGame::GenerateSlime(int MapIndex)
{ 
if (m_pMapList[MapIndex]->m_iTotalAliveObject != 0) return;
char cName[21], cNpcName[21], cNpcWaypoint[11]; 
int iNamingValue;
ZeroMemory(cNpcWaypoint, sizeof(cNpcWaypoint));

iNamingValue = m_pMapList[MapIndex]->iGetEmptyNamingValue();
if (iNamingValue == -1) {
}
else {
strcpy(cNpcName, "Slime");
ZeroMemory(cName, sizeof(cName));
wsprintf(cName, "XX%d", iNamingValue);
cName[0] = '_';
cName[1] = MapIndex+65; 

if (bCreateNewNpc(cNpcName, cName, m_pMapList[MapIndex]->m_cName, 0, 0
, DEF_MOVETYPE_RANDOMAREA, NULL, NULL, cNpcWaypoint, &m_pMapList[MapIndex]->m_sApocalypseBossMobRect, NULL, NULL, FALSE, FALSE, FALSE, TRUE) == FALSE) 
{ m_pMapList[MapIndex]->SetNamingValueEmpty(iNamingValue);
} 
}
}

//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// ForceOpen_ApocalypseGate 
// Local execution off a global GM command to force open the gate
// Beware this will affect only current server
//**************************************************************************************
void CGame::ForceOpen_ApocalypseGate()
{ if (m_bIsApocalypseMode == FALSE) return; 
DWORD dwTime = timeGetTime();
m_dwApocalypseGateOpenTime = dwTime;
m_dwApocalypseGateCloseTime = dwTime +15*60*1000; // will close in 15 minutes
OpenCloseApocalypseGate();
}
//**************************************************************************************
// SNOOPY: Revamped Apocalypse functions:
// ForceClose_ApocalypseGate 
// GM command to force open the gate
// Beware this will affect only current server
//**************************************************************************************
void CGame::ForceClose_ApocalypseGate()
{ if (m_bIsApocalypseMode == FALSE) return; 
DWORD dwTime = timeGetTime();
m_dwApocalypseGateCloseTime = dwTime -1;
m_dwApocalypseGateOpenTime = dwTime -100; // alreaddy closed
OpenCloseApocalypseGate();
}
//*************************************************************************************
Of course there is some fixed to do in game.h, map.h, GM commands, and reading mapdata

Map loading part:

Code: Select all

::__bReadMapInfo(..)
...
	m_pMapList[iMapIndex]->m_iApocalypseMobGenType = 0;  // 26 ApocalypseMobGenType
	m_pMapList[iMapIndex]->m_iApocalypseBossMobNpcID = 0;	// 27 ApocalypseBossMob
	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.left   =  0;
	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.top    =  0;
	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.right  =  0;
	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.bottom =  0;
	m_pMapList[iMapIndex]->m_cDynamicGateType = 0;  	// 28 DynamicGateType
	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX1 =  0;	// 29 DynamicGateCoord 
	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX2 =  0;  
	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY1 =  0;  
	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY2 =  0;  
	ZeroMemory(m_pMapList[iMapIndex]->m_cDynamicGateCoordDestMap, sizeof(m_pMapList[iMapIndex]->m_cDynamicGateCoordDestMap));
	m_pMapList[iMapIndex]->m_sDynamicGateCoordTgtX = 0;
	m_pMapList[iMapIndex]->m_sDynamicGateCoordTgtY = 0;
	m_pMapList[iMapIndex]->m_bIsRecallImpossible = FALSE;	// 30 Recal impossible
	m_pMapList[iMapIndex]->m_bIsApocalypseMap = FALSE;  // 31 ApocalypseMap 
	m_pMapList[iMapIndex]->m_bIsCitizenLimit = FALSE;  // 32 CitizenLimit
...
...
...
  	case 26: // ApocalypseMobGenType
    if (_bGetIsStringIsNumber(token) == FALSE) {
    	PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseMobGenType - Wrong Data format.");
    	delete pContents;
    	delete pStrTok;
    	return FALSE;
    }
    m_pMapList[iMapIndex]->m_iApocalypseMobGenType = atoi(token);
    cReadModeA = 0;
    cReadModeB = 0;
    break;

  	case 27: // ApocalypseBossMob //SNOOPY replaced coord by RECT structure.
    switch (cReadModeB) {
    case 1: // 3CB6Ch m_pMapList[]->m_ApocalypseBossMobNpcID
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	m_pMapList[iMapIndex]->m_iApocalypseBossMobNpcID = atoi(token);
    	cReadModeB = 2;    	
    	break;
    case 2: // 3CB70h m_pMapList[]->ApocalypseBossMobRectX1
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	//m_pMapList[iMapIndex]->m_sApocalypseBossMobRectX1 = atoi(token);
    	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.left = atoi(token);
    	cReadModeB = 3;    	
    	break;
    case 3: // 3CB74h m_pMapList[]->ApocalypseBossMobRectY1
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	//m_pMapList[iMapIndex]->m_sApocalypseBossMobRectY1 = atoi(token);
    	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.top = atoi(token);
    	cReadModeB = 4;    	
    	break;
    case 4: // 3CB78h m_pMapList[]->ApocalypseBossMobRectX2
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	//m_pMapList[iMapIndex]->m_sApocalypseBossMobRectX2 = atoi(token);
    	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.right = atoi(token);
    	cReadModeB = 5;    	
    	break;
    case 5: // 3CB7Ch m_pMapList[]->ApocalypseBossMobRectY2
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	//m_pMapList[iMapIndex]->m_sApocalypseBossMobRectY2 = atoi(token);
    	m_pMapList[iMapIndex]->m_sApocalypseBossMobRect.bottom = atoi(token);
    	cReadModeA = 0;
    	cReadModeB = 0;    	
    	break;
    }
    break;

  	case 28: //DynamicGateType // 28
    if (_bGetIsStringIsNumber(token) == FALSE) {
    	PutLogList("(!!!) CRITICAL ERROR! Map Info file error DynamicGateType - Wrong Data format.");
    	delete pContents;
    	delete pStrTok;
    	return FALSE;
    }
    m_pMapList[iMapIndex]->m_cDynamicGateType = atoi(token);
    // DynamicGateType = 1: Opens Gate when Apoc begins
    // DynamicGateType = 2: Open the gate when map is empty
    // DynamicGateType = 3: Gate stays closed
    // DynamicGateType = 4: Gate is openned. (set by server when Abaddon is spawning)
    // DynamicGateType = 5: Gate is used by GM command

    cReadModeA = 0;
    cReadModeB = 0;
    break;
        
  	case 29: //DynamicGateCoord // 29
    // DynamicGateCoord	= 59 196 60 197        abaddon    -1  -1
    switch (cReadModeB) {
    case 1: // 3CA20h
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX1 = atoi(token);
    	cReadModeB = 2;
    	break;

    case 2: // 3CA24h
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY1 = atoi(token);
    	cReadModeB = 3;
    	break;

    case 3: // 3CA28h
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectX2 = atoi(token);
    	cReadModeB = 4;
    	break;

    case 4: // 3CA2Ch
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	m_pMapList[iMapIndex]->m_sDynamicGateCoordRectY2 = atoi(token);
    	cReadModeB = 5;
    	break;

    case 5: // 3CA30h
    	ZeroMemory(m_pMapList[iMapIndex]->m_cDynamicGateCoordDestMap, sizeof(m_pMapList[iMapIndex]->m_cDynamicGateCoordDestMap));
    	memcpy(m_pMapList[iMapIndex]->m_cDynamicGateCoordDestMap, token, strlen(token));
    	cReadModeB = 6;
    	break;

    case 6: // 3CA3Ch
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	m_pMapList[iMapIndex]->m_sDynamicGateCoordTgtX = atoi(token);
    	cReadModeB = 7;
    	break;

    case 7: // (ty = 3CB60h) unknown (3CA3Eh)
    	if (_bGetIsStringIsNumber(token) == FALSE) {
      PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseBossMob - Wrong Data format.");
      delete pContents;
      delete pStrTok;
      return FALSE;
    	}
    	m_pMapList[iMapIndex]->m_sDynamicGateCoordTgtY = atoi(token);
    	cReadModeA = 0;
    	cReadModeB = 0;
    	break;
    }
    break;
  	
  	case 30: // RecallImpossible // 30
    if (_bGetIsStringIsNumber(token) == FALSE) {
    	PutLogList("(!!!) CRITICAL ERROR! Map Info file error RecallImpossible -  Wrong Data format.");
    	delete pContents;
    	delete pStrTok;
    	return FALSE;
    }
    m_pMapList[iMapIndex]->m_bIsRecallImpossible = (BOOL) atoi(token);
    cReadModeA = 0;
    cReadModeB = 0;
    break;

  	case 31: // ApocalypseMap // 31
    if (_bGetIsStringIsNumber(token) == FALSE) {
    	PutLogList("(!!!) CRITICAL ERROR! Map Info file error ApocalypseMap -  Wrong Data format.");
    	delete pContents;
    	delete pStrTok;
    	return FALSE;
    }
    m_pMapList[iMapIndex]->m_bIsApocalypseMap = (BOOL) atoi(token);
    cReadModeA = 0;
    cReadModeB = 0;
    break;
  	
  	case 32: // CitizenLimit // 32 
    // (SNOOPY: Added to forbid civ instead of fixed limitation at ML & PL)
    if (_bGetIsStringIsNumber(token) == FALSE) {
    	PutLogList("(!!!) CRITICAL ERROR! Map Info file error CitizenLimit -  Wrong Data format.");
    	delete pContents;
    	delete pStrTok;
    	return FALSE;
    }
    m_pMapList[iMapIndex]->m_bIsCitizenLimit = (BOOL) atoi(token);
    cReadModeA = 0;
    cReadModeB = 0;
    break;
...
...
  	if (memcmp(token, "ApocalypseMobGenType", 20) == 0) 
  	{	cReadModeA = 26;
    cReadModeB = 1;
  	}
  	if (memcmp(token, "ApocalypseBossMob", 17) == 0) 
  	{	cReadModeA = 27;
    cReadModeB = 1;
  	}
  	if (memcmp(token, "DynamicGateType", 15) == 0) 
  	{	cReadModeA = 28;
    cReadModeB = 1;
  	}
  	if (memcmp(token, "DynamicGateCoord", 16) == 0) 
  	{	cReadModeA = 29;
    cReadModeB = 1;
  	}
  	if (memcmp(token, "RecallImpossible", 16) == 0) 
  	{	cReadModeA = 30;
    cReadModeB = 1;
  	}  	
  	if (memcmp(token, "ApocalypseMap", 13) == 0) 
  	{	cReadModeA = 31;
    cReadModeB = 1;
  	}  	
  	if (memcmp(token, "CitizenLimit", 12) == 0) 
  	{	cReadModeA = 32;
    cReadModeB = 1;
}
Of course some cReadModeA may change in your server. . .

<span style='color:purple'>Using that I think a decent coder may have Apoc working. If your C++ knowledge is limited to Copy'n Paste, no hope !</span>
_\_ _<br> / , \__/ . \ Admin of Equilibrium Project<br> II\ \___ . O<br> III \_/ \ _ / <a href='http://www.equiprojet.com' target='_blank'>http://www.equiprojet.com</a><br> II I¯I
locobans
Outpost Junkie
Posts: 2264
Joined: Tue Jul 13, 2004 3:51 am
Location: Behind You
Contact:

Post by locobans »

Thanks a lot ^_
QUOTE (ADDKiD @ Dec 1 2006, 4:01 PM) <br>You guys make me laugh alot, half the shit I say, is bullshit...<br><br><img src='http://img485.imageshack.us/img485/492/banssig1ng.gif' border='0' alt='user posted image' /><br><br><b>I see no changes at all, wake up in the morning and ask myself...<br>Is life worth living? Should I blast myself?</b><br><br><b><a href='http://2paclegacy.com' target='_blank'>2PacLegacy.com</a></b>
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

wow, what an awesome code !!

I'll try it

<3 Snoopy, merci beaucoup !!!
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
juggalo2
Spamtastic
Posts: 1144
Joined: Sun Jul 17, 2005 5:28 pm

Post by juggalo2 »

good job snoopy
<img src='http://lifeplaysu420.com/unknow/nightsign.png' border='0' alt='user posted image' /><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Wanna make money for surfing the net sing up at <br><a href='http://www.cashfiesta.com/php/join.php? ... yprivitera' target='_blank'>cash fiesta</a><br>its all free hey why ntot make money while fucking around on the computer<br><br><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
XsX
Regular
Posts: 32
Joined: Sat May 15, 2004 8:53 pm

Post by XsX »

this 2nd tp(inferniaA, inferniaB) don't open ......... 0 npcs, don't open
diuuude
Outpost bitch
Posts: 592
Joined: Wed Dec 28, 2005 11:57 pm

Post by diuuude »

XsX wrote:this 2nd tp(inferniaA, inferniaB) don't open ......... 0 npcs, don't open
it works fine for me... how do you call the func Open_EmptyMap_Gate()?


right after :

Code: Select all

NKH_GOTOPOINT1:;

i added this :

Code: Select all

if ((m_bIsApocalypseMode == TRUE) && (m_pMapList[m_pNpcList[iNpcH]->m_cMapIndex]->m_iTotalAliveObject == 0) && (m_pMapList[m_pNpcList[iNpcH]->m_cMapIndex]->m_iApocalypseMobGenType  == 2)) {
  Open_EmptyMap_Gate(m_pNpcList[iNpcH]->m_cMapIndex);
	}
<a href='http://www.technohell.net' target='_blank'><b><span style='color:red'>>>> Helbreath Ressources Website Here <<<</span></b></a><br>C++ Sources, Tools, Server Files, Help on Forum, C++ Snippets, Toplist... Updated often, come visit us !
locobans
Outpost Junkie
Posts: 2264
Joined: Tue Jul 13, 2004 3:51 am
Location: Behind You
Contact:

Post by locobans »

:) With a few help...I ve got this...lolz Though...still not enough...

It's just as snoopy said, "these are the core functions" needs more tweakning in order to get them to work.


1. /beginapocalypse, enter via the portal on IceBound to Druncncity. On my Druncncity.txt there ain't no DymanicGate, just:

Code: Select all

//-Teleportation-Set----SX-----SY-----DestMapName---------DX-----DY----Dir---;
teleport-loc     =      33    82      inferniaA           -1     -1    7
teleport-loc     =      34    82      inferniaA           -1     -1    7
teleport-loc     =      35    82      inferniaA           -1     -1    7
teleport-loc     =      35    83      inferniaA           -1     -1    7
teleport-loc     =      36    83      inferniaA           -1     -1    7
teleport-loc     =      36    84      inferniaA           -1     -1    7

teleport-loc     =      147   62      inferniaB           -1     -1    7
teleport-loc     =      148   62      inferniaB           -1     -1    7
teleport-loc     =      149   62      inferniaB           -1     -1    7
teleport-loc     =      149   63      inferniaB           -1     -1    7
teleport-loc     =      150   63      inferniaB           -1     -1    7
teleport-loc     =      150   64      inferniaB           -1     -1    7
Teleports, so I can pass to InferniaA or InferniaB withouth needing to clear Druncncity, though I kill those mobs. (set only a pit of 2 monsters to finish faster).

2. I went to InferniaA and killed all mobs there, since on my inferniA.txt I have a DynamicGate:

Code: Select all

DynamicGateType  = 2
//------------------------RECT-----------------TargetMap---TargetCoord
DynamicGateCoord	= 115 105 115 105	maze    -1  -1
After killing all inferniaA mobs, nothing happens...no msg or anything, wich I found weird since should have a msg saying
InferniaA portal or something oppened, so players know they killed all mobs. Anyways I try to go to the DynamicGate...and guess what?
It's not opened...I stand in it...and doesn't teleport me.

3. I went to InferniaB and killed all mobs there, to see if same problem with InferniaA, according to the InferniaB.txt:

Code: Select all

DynamicGateType  = 2
//------------------------RECT-----------------TargetMap---TargetCoord
DynamicGateCoord	= 39 119 39 119        maze    -1  -1
After killing all mobs, nothing happens...no msg or anything and went to the DynamicGate...and It wasn't opened...Standend
in it and didin't teleported me...

4. So I used the teleport command and went to maze, according to my maze.txt there's no DynamicGate but still I killed all mobs
And went to the correct teleport

Code: Select all

//-Teleportation-Set----SX-----SY-----DestMapName---------DX-----DY----Dir---;
teleport-loc     =      38    164     procella           -1     -1    7
It teleported me to procella.

5. At procella, killed all mobs, no msg or anything and tried to go to the DynamicGate

Code: Select all

DynamicGateType  = 2
//------------------------RECT-----------------TargetMap---TargetCoord
DynamicGateCoord	= 59 196 60 197        abaddon    -1  -1
And nothing...It wasn't opened...It was normal...shouldn't a graphica appear on it or something? didin't teleported me like
InferniA and InferniaB.

6. I went for myself into abaddon map...and...killed all mobs on abaddon map....and...no msg or anything plus no abaddon spawned.

Code: Select all

ApocalypseMobGenType    = 2
//------------------------NpcID---RECT----------------------
ApocalypseBossMob       = 71      79 76 136 107
Here I attached a ScreenShot saying how many mobs are still on maps.

<a href='http://img62.imageshack.us/img62/5750/mapsempty0kb.jpg' target='_blank'>http://img62.imageshack.us/img62/5750/m ... 0kb.jpg</a>
QUOTE (ADDKiD @ Dec 1 2006, 4:01 PM) <br>You guys make me laugh alot, half the shit I say, is bullshit...<br><br><img src='http://img485.imageshack.us/img485/492/banssig1ng.gif' border='0' alt='user posted image' /><br><br><b>I see no changes at all, wake up in the morning and ask myself...<br>Is life worth living? Should I blast myself?</b><br><br><b><a href='http://2paclegacy.com' target='_blank'>2PacLegacy.com</a></b>
RageIlluminati
Outpost bitch
Posts: 559
Joined: Wed Mar 30, 2005 6:45 am

Post by RageIlluminati »

You do not need to kill mobs on DruncnCity.. there are ordinary teleports to InfA and InfB..

in the matter of fact.. no need to kill mobs from InferniaA too.. if you just kill mobs on InferniaB you get dynamic gate to maze... (there are gates from infB to infA and opposite way too)

on maze you do not need to kill mobs at all... just find the right teleport..

on procella you have to kill all mobs.. then opens dynamic gate to Abaddon...

after all mobs are killed in Abaddon.. summons Abaddon.. after killing Abaddon... attackmode will be safe.. and dissapears notice that in 10 minutes all players get forced recall from Abaddon map...

at least that is the way it is on these official HBchina files..
<img src='http://helbreath.pri.ee/userbars/hbest-gamemaster2.jpg' border='0' alt='user posted image' /> <img src='http://helbreath.pri.ee/userbars/hbsoccer-owner.jpg' border='0' alt='user posted image' /> <img src='http://helbreath.pri.ee/userbars/scorpa-rider.jpg' border='0' alt='user posted image' /> <img src='http://helbreath.pri.ee/userbars/logout-master.jpg' border='0' alt='user posted image' /> <br>.<br>................................Ego sum Rage, flagellum Dei!<br><br>The problem with America is stupidity. I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? (bash.org)
snoopy81
Loyal fan
Posts: 338
Joined: Mon Jul 12, 2004 7:13 pm

Post by snoopy81 »

I encountered this point too. It has to do with the way the mobs are counted.
There is 2 ways, 1 decrementing at mob's death, one at mob disapearance, and sometimes the figures are not the same.

I had to fix that twice when I changed this for "/monstercount" command.
_\_ _<br> / , \__/ . \ Admin of Equilibrium Project<br> II\ \___ . O<br> III \_/ \ _ / <a href='http://www.equiprojet.com' target='_blank'>http://www.equiprojet.com</a><br> II I¯I
Post Reply