New features and fixes in volfeatures. See details.
Fixed existing volumes not removed after a map change. Added class editor feature that can modify certain class attributes on players in a volume. Fixed typo in class attribute name. Fixed health regeneration timer not stopping if a player were kicked or timed out.
This commit is contained in:
1411
src/zr/volfeatures/volclassedit.inc
Normal file
1411
src/zr/volfeatures/volclassedit.inc
Normal file
File diff suppressed because it is too large
Load Diff
@ -78,6 +78,7 @@ public Action:VolAddVolumeCommand(client, argc)
|
||||
StrCat(buffer, sizeof(buffer), "x2, y2, z2 Coordinates to oposite corner (diagonally to oposite height)\n");
|
||||
StrCat(buffer, sizeof(buffer), "type Volumetric feature type:\n");
|
||||
StrCat(buffer, sizeof(buffer), " anticamp\n");
|
||||
StrCat(buffer, sizeof(buffer), " classedit\n");
|
||||
StrCat(buffer, sizeof(buffer), "params Parameter string with additional volume data. Generic parameters:\n");
|
||||
StrCat(buffer, sizeof(buffer), " teamfilter=all|humans|zombies\n");
|
||||
StrCat(buffer, sizeof(buffer), " delay=0\n");
|
||||
@ -103,7 +104,7 @@ public Action:VolAddVolumeCommand(client, argc)
|
||||
new dataindex;
|
||||
new paramcount;
|
||||
|
||||
decl String:params[256];
|
||||
decl String:params[512];
|
||||
decl String:argbuffer[256];
|
||||
|
||||
params[0] = 0;
|
||||
@ -418,9 +419,9 @@ public Action:VolListCommand(client, argc)
|
||||
{
|
||||
VolAnticampDumpData(volcache[Vol_DataIndex], buffer, sizeof(buffer));
|
||||
}
|
||||
case VolFeature_Knockback:
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
|
||||
VolClassEditDumpData(volcache[Vol_DataIndex], buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -587,6 +588,27 @@ VolClear(volumeIndex)
|
||||
Volumes[volumeIndex][Vol_yMax] = 0.0;
|
||||
Volumes[volumeIndex][Vol_zMax] = 0.0;
|
||||
|
||||
Volumes[volumeIndex][Vol_Effect] = VolEffect_None;
|
||||
Volumes[volumeIndex][Vol_EffectColor][0] = 0;
|
||||
Volumes[volumeIndex][Vol_EffectColor][1] = 0;
|
||||
Volumes[volumeIndex][Vol_EffectColor][2] = 0;
|
||||
|
||||
new dataindex = Volumes[volumeIndex][Vol_DataIndex];
|
||||
if (dataindex >= 0)
|
||||
{
|
||||
switch (Volumes[volumeIndex][Vol_Type])
|
||||
{
|
||||
case VolFeature_Anticamp:
|
||||
{
|
||||
VolAnticampReset(dataindex);
|
||||
}
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
VolClassEditReset(dataindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Volumes[volumeIndex][Vol_Type] = VolFeature_Invalid;
|
||||
Volumes[volumeIndex][Vol_DataIndex] = -1;
|
||||
|
||||
@ -594,6 +616,17 @@ VolClear(volumeIndex)
|
||||
Volumes[volumeIndex][Vol_TriggerDelay] = 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all volumes.
|
||||
*/
|
||||
VolClearAll()
|
||||
{
|
||||
for (new volindex = 0; volindex < ZR_VOLUMES_MAX; volindex++)
|
||||
{
|
||||
VolClear(volindex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets extra attributes on a volume.
|
||||
*
|
||||
@ -697,6 +730,13 @@ VolSetAttributes(volumeIndex, const String:attributes[])
|
||||
successfulCount++;
|
||||
}
|
||||
}
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
if (VolClassEditSetAttribute(dataindex, attribName, attribValue))
|
||||
{
|
||||
successfulCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,14 @@ VolOnPlayerEnter(client, volumeIndex)
|
||||
LogEvent(_, LogType_Normal, LOG_DEBUG, LogModule_Volfeatures, "Event", "Player %N entered volume %d.", client, volumeIndex);
|
||||
|
||||
// Forward event to features.
|
||||
|
||||
new VolumeFeatureTypes:voltype = Volumes[volumeIndex][Vol_Type];
|
||||
switch (voltype)
|
||||
{
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
VolClassEditOnPlayerEnter(client, volumeIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +71,14 @@ VolOnPlayerLeave(client, volumeIndex)
|
||||
LogEvent(_, LogType_Normal, LOG_DEBUG, LogModule_Volfeatures, "Event", "Player %N left volume %d.", client, volumeIndex);
|
||||
|
||||
// Forward event to features.
|
||||
|
||||
new VolumeFeatureTypes:voltype = Volumes[volumeIndex][Vol_Type];
|
||||
switch (voltype)
|
||||
{
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
VolClassEditOnPlayerLeave(client, volumeIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,6 +198,10 @@ VolOnDisabled(volumeIndex)
|
||||
{
|
||||
VolAnticampDisable(volumeIndex);
|
||||
}
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
VolClassEditOnDisabled(volumeIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,30 +36,32 @@
|
||||
enum VolumeAttributes
|
||||
{
|
||||
/* General */
|
||||
bool:Vol_Enabled, /** Volume state. */
|
||||
bool:Vol_InUse, /** Marks if the volume is used. */
|
||||
bool:Vol_Enabled, /** Volume state. */
|
||||
bool:Vol_InUse, /** Marks if the volume is used. */
|
||||
|
||||
/* Location */
|
||||
Float:Vol_xMin, /** Minimum x position. */
|
||||
Float:Vol_xMax, /** Maximum x position. */
|
||||
Float:Vol_xMin, /** Minimum x position. */
|
||||
Float:Vol_xMax, /** Maximum x position. */
|
||||
|
||||
Float:Vol_yMin, /** Minimum y position. */
|
||||
Float:Vol_yMax, /** Maximum y position. */
|
||||
Float:Vol_yMin, /** Minimum y position. */
|
||||
Float:Vol_yMax, /** Maximum y position. */
|
||||
|
||||
Float:Vol_zMin, /** Minimum z position. */
|
||||
Float:Vol_zMax, /** Maximum z position. */
|
||||
Float:Vol_zMin, /** Minimum z position. */
|
||||
Float:Vol_zMax, /** Maximum z position. */
|
||||
|
||||
/* Style */
|
||||
VolumeEffects:Vol_Effect, /** Visual effect to apply on the volume. */
|
||||
Vol_EffectColor[3], /** Render color of the effect. RGB colors. */
|
||||
VolumeEffects:Vol_Effect, /** Visual effect to apply on the volume. */
|
||||
Vol_EffectColor[3], /** Render color of the effect. RGB colors. */
|
||||
|
||||
/* Data */
|
||||
VolumeFeatureTypes:Vol_Type, /** The volumetric feature type. */
|
||||
Vol_DataIndex, /** Index in remote feature array. */
|
||||
VolumeFeatureTypes:Vol_Type, /** The volumetric feature type. */
|
||||
Vol_DataIndex, /** Index in remote feature array. */
|
||||
|
||||
/* Behaviour */
|
||||
VolumeTeamFilters:Vol_TeamFilter, /** Team filtering. Trigger by certain teams, or all. */
|
||||
Float:Vol_TriggerDelay /** Trigger delay. How many seconds players have to stay to trigger volume events. */
|
||||
VolumeTeamFilters:Vol_TeamFilter, /** Team filtering. Trigger by certain teams, or all. */
|
||||
Float:Vol_TriggerDelay, /** Trigger delay. How many seconds players have to stay to trigger volume events. */
|
||||
Vol_ConflictAction, /** What to do if volumes of same type overlap. */
|
||||
Vol_Priority, /** Volume priority. */
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,7 +71,7 @@ enum VolumeFeatureTypes
|
||||
{
|
||||
VolFeature_Invalid = 0,
|
||||
VolFeature_Anticamp,
|
||||
VolFeature_Knockback
|
||||
VolFeature_ClassEdit
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,6 +94,15 @@ enum VolumeTeamFilters
|
||||
VolTeam_Zombies
|
||||
}
|
||||
|
||||
/**
|
||||
* Conflict actions. What to do with overlapping volumes of same type.
|
||||
*/
|
||||
enum VolumeConflictActions
|
||||
{
|
||||
VolPriority = 0, /** Use the volume with highest priority, ignore others. */
|
||||
VolMerge /** Merge volume settings/attributes. Using priority if there's a merge conflict. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Volumes.
|
||||
*/
|
||||
@ -147,18 +158,29 @@ new Float:VolTriggerInterval;
|
||||
|
||||
// Sub features.
|
||||
#include "zr/volfeatures/volanticamp"
|
||||
#include "zr/volfeatures/volclassedit"
|
||||
|
||||
|
||||
/**
|
||||
* Initialize volumetric features.
|
||||
*/
|
||||
VolInit()
|
||||
{
|
||||
// Clear all volumes.
|
||||
VolClearAll();
|
||||
|
||||
// Initialize sub features.
|
||||
VolAnticampInit();
|
||||
VolClassEditInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize volumetric feature settings.
|
||||
*/
|
||||
VolLoad()
|
||||
{
|
||||
// Cache CVAR value.
|
||||
VolEnabled = GetConVarBool(g_hCvarsList[CVAR_VOL]);
|
||||
|
||||
// Initialize sub features.
|
||||
VolAnticampInit();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -273,7 +295,7 @@ bool:VolStartUpdateTimer()
|
||||
else
|
||||
{
|
||||
// Volumetric features disabled.
|
||||
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Volfeatures, "Config Validation", "Warning: Console variable \"zr_vol_update_interval\" is set to zero or negative. Must be positive.");
|
||||
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Volfeatures, "Config Validation", "Warning: Console variable \"zr_vol_update_interval\" is zero or negative. Must be positive.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -322,7 +344,7 @@ bool:VolStartTriggerTimer()
|
||||
else
|
||||
{
|
||||
// Trigger timer not running. Either disabled or invalid interval.
|
||||
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Volfeatures, "Config Validation", "Warning: Console variable \"zr_vol_trigger_interval\" is set to zero or negative. Must be positive.");
|
||||
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Volfeatures, "Config Validation", "Warning: Console variable \"zr_vol_trigger_interval\" is zero or negative. Must be positive.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -621,10 +643,9 @@ VolGetFreeDataIndex(VolumeFeatureTypes:volumeType)
|
||||
{
|
||||
return VolAnticampGetFreeIndex();
|
||||
}
|
||||
case VolFeature_Knockback:
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
// TOTO: Finish incomplete feature.
|
||||
return -1;
|
||||
return VolClassEditGetFreeIndex();
|
||||
}
|
||||
}
|
||||
|
||||
@ -754,9 +775,9 @@ VolumeFeatureTypes:VolGetTypeFromString(const String:volType[])
|
||||
{
|
||||
return VolFeature_Anticamp;
|
||||
}
|
||||
else if (StrEqual(volType, "knockback", false))
|
||||
else if (StrEqual(volType, "classedit", false))
|
||||
{
|
||||
return VolFeature_Knockback;
|
||||
return VolFeature_ClassEdit;
|
||||
}
|
||||
|
||||
// No match.
|
||||
@ -783,11 +804,11 @@ VolTypeToString(VolumeFeatureTypes:volType, String:buffer[], maxlen, bool:shortN
|
||||
}
|
||||
case VolFeature_Anticamp:
|
||||
{
|
||||
return shortName ? strcopy(buffer, maxlen, "anticamp") : strcopy(buffer, maxlen, "Anti camp");
|
||||
return shortName ? strcopy(buffer, maxlen, "anticamp") : strcopy(buffer, maxlen, "Anti-Camp");
|
||||
}
|
||||
case VolFeature_Knockback:
|
||||
case VolFeature_ClassEdit:
|
||||
{
|
||||
return shortName ? strcopy(buffer, maxlen, "knockback") : strcopy(buffer, maxlen, "Knock back modifier");
|
||||
return shortName ? strcopy(buffer, maxlen, "classedit") : strcopy(buffer, maxlen, "Class Editor");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user