2009-05-16 01:37:23 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-05-30 04:17:01 +02:00
|
|
|
* Zombie:Reloaded
|
2009-05-16 01:37:23 +02:00
|
|
|
*
|
2009-05-30 04:17:01 +02:00
|
|
|
* File: volevents.inc
|
|
|
|
* Type: Module
|
|
|
|
* Description: Handles generic events for volumetric features.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-05-16 01:37:23 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a player enters a volume.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param volumeIndex The volume index.
|
|
|
|
*/
|
|
|
|
VolOnPlayerEnter(client, volumeIndex)
|
|
|
|
{
|
2009-05-30 04:17:01 +02:00
|
|
|
// Check if volumetric features is enabled.
|
|
|
|
if (!VolEnabled)
|
|
|
|
{
|
|
|
|
// Volumetric features disabled.
|
|
|
|
return;
|
|
|
|
}
|
2009-07-16 10:05:40 +02:00
|
|
|
|
|
|
|
LogEvent(_, LogType_Normal, LOG_DEBUG, LogModule_Volfeatures, "Event", "Player %N entered volume %d.", client, volumeIndex);
|
|
|
|
|
2009-05-16 01:37:23 +02:00
|
|
|
// Forward event to features.
|
2009-07-16 10:05:40 +02:00
|
|
|
|
2009-05-16 01:37:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a player leaves a volume.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param volumeIndex The volume index.
|
|
|
|
*/
|
|
|
|
VolOnPlayerLeave(client, volumeIndex)
|
|
|
|
{
|
2009-05-30 04:17:01 +02:00
|
|
|
// Check if volumetric features is enabled.
|
|
|
|
if (!VolEnabled)
|
|
|
|
{
|
|
|
|
// Volumetric features disabled.
|
|
|
|
return;
|
|
|
|
}
|
2009-05-16 01:37:23 +02:00
|
|
|
|
2009-07-16 10:05:40 +02:00
|
|
|
LogEvent(_, LogType_Normal, LOG_DEBUG, LogModule_Volfeatures, "Event", "Player %N left volume %d.", client, volumeIndex);
|
|
|
|
|
2009-05-16 01:37:23 +02:00
|
|
|
// Forward event to features.
|
2009-07-16 10:05:40 +02:00
|
|
|
|
2009-05-16 01:37:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a player spawned. Used for initializing player data.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
VolOnPlayerSpawn(client)
|
|
|
|
{
|
2009-05-30 04:17:01 +02:00
|
|
|
// Check if volumetric features is enabled.
|
|
|
|
if (!VolEnabled)
|
|
|
|
{
|
|
|
|
// Volumetric features disabled.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cache player location.
|
2009-05-16 01:37:23 +02:00
|
|
|
VolUpdatePlayerLocation(client);
|
|
|
|
}
|
|
|
|
|
2009-07-17 18:15:44 +02:00
|
|
|
/**
|
|
|
|
* Called when a player died.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
VolOnPlayerDeath(client)
|
|
|
|
{
|
|
|
|
// Send player left volume event to all volumes the player was in.
|
|
|
|
for (new volindex = 0; volindex < ZR_VOLUMES_MAX; volindex++)
|
|
|
|
{
|
|
|
|
// Check if volume is unused.
|
|
|
|
if (!Volumes[volindex][Vol_InUse])
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if volume is disabled.
|
|
|
|
if (!Volumes[volindex][Vol_Enabled])
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if player is inside the volume.
|
|
|
|
if (VolPlayerInVolume[client][volindex])
|
|
|
|
{
|
|
|
|
// Mark as not in the volume and trigger event.
|
|
|
|
VolPlayerInVolume[client][volindex] = false;
|
|
|
|
VolOnPlayerLeave(client, volindex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 04:17:01 +02:00
|
|
|
/**
|
|
|
|
* Called when a player disconnects.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
VolOnPlayerDisconnect(client)
|
|
|
|
{
|
|
|
|
// Disable trigger delay counters.
|
|
|
|
VolResetCountDown(client);
|
2009-07-17 18:15:44 +02:00
|
|
|
|
|
|
|
// Trigger death event to clean up.
|
|
|
|
VolOnPlayerDeath(client);
|
2009-05-30 04:17:01 +02:00
|
|
|
}
|
|
|
|
|
2009-05-16 01:37:23 +02:00
|
|
|
/**
|
|
|
|
* Called when the round starts. Main enable event for volumetric features.
|
|
|
|
*/
|
|
|
|
VolOnRoundStart()
|
|
|
|
{
|
2009-05-30 04:17:01 +02:00
|
|
|
// Check if volumetric features is enabled.
|
|
|
|
if (!VolEnabled)
|
|
|
|
{
|
|
|
|
// Volumetric features disabled.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-16 01:37:23 +02:00
|
|
|
// Start main timer.
|
|
|
|
VolStartUpdateTimer();
|
2009-07-16 10:05:40 +02:00
|
|
|
|
|
|
|
// Start volumes.
|
|
|
|
VolEnableVolumes();
|
2009-05-16 01:37:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the round ends. Main disable event for volumetric features.
|
|
|
|
*/
|
|
|
|
VolOnRoundEnd()
|
|
|
|
{
|
|
|
|
// Stop main timer.
|
|
|
|
VolStopUpdateTimer();
|
|
|
|
|
2009-07-16 10:05:40 +02:00
|
|
|
// Stop volumes.
|
|
|
|
VolDisableVolumes();
|
2009-05-16 01:37:23 +02:00
|
|
|
}
|
2009-05-30 04:17:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a volume is disabled.
|
|
|
|
* @param volumeIndex The volume index.
|
|
|
|
*/
|
2009-07-16 10:05:40 +02:00
|
|
|
VolOnDisabled(volumeIndex)
|
2009-05-30 04:17:01 +02:00
|
|
|
{
|
2009-07-17 18:15:44 +02:00
|
|
|
// Check if volumetric features is enabled.
|
|
|
|
if (!VolEnabled)
|
|
|
|
{
|
|
|
|
// Volumetric features disabled.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-16 10:05:40 +02:00
|
|
|
new VolumeFeatureTypes:voltype = Volumes[volumeIndex][Vol_Type];
|
2009-05-30 04:17:01 +02:00
|
|
|
|
2009-07-16 10:05:40 +02:00
|
|
|
// Forward stop event to features.
|
|
|
|
switch (voltype)
|
|
|
|
{
|
|
|
|
case VolFeature_Anticamp:
|
|
|
|
{
|
|
|
|
VolAnticampDisable(volumeIndex);
|
|
|
|
}
|
|
|
|
}
|
2009-05-30 04:17:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a volume is enabled.
|
|
|
|
* @param volumeIndex The volume index.
|
|
|
|
*/
|
2009-07-16 10:05:40 +02:00
|
|
|
VolOnEnabled(volumeIndex)
|
2009-05-30 04:17:01 +02:00
|
|
|
{
|
2009-07-17 18:15:44 +02:00
|
|
|
// Check if volumetric features is enabled.
|
|
|
|
if (!VolEnabled)
|
|
|
|
{
|
|
|
|
// Volumetric features disabled.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-16 10:05:40 +02:00
|
|
|
new VolumeFeatureTypes:voltype = Volumes[volumeIndex][Vol_Type];
|
2009-05-30 04:17:01 +02:00
|
|
|
|
2009-07-16 10:05:40 +02:00
|
|
|
// Forward stop event to features.
|
|
|
|
switch (voltype)
|
|
|
|
{
|
|
|
|
case VolFeature_Anticamp:
|
|
|
|
{
|
|
|
|
VolAnticampEnable(volumeIndex);
|
|
|
|
}
|
|
|
|
}
|
2009-05-30 04:17:01 +02:00
|
|
|
}
|