Merged heads.

This commit is contained in:
richard 2009-09-27 23:52:20 +02:00
commit b3c31afff9
8 changed files with 1734 additions and 38 deletions

View File

@ -140,6 +140,7 @@ public OnPluginStart()
CommandsInit();
WeaponsInit();
EventInit();
VolInit();
}
/**

View File

@ -292,6 +292,168 @@ stock ClassValidateAttributes(classindex)
return flags;
}
/**
* Validates a set of editable attributes.
*
* @param attributes Attribute set to validate.
* @return 0 if successful, or a bit field (positivie number) of
* failed attributes.
*/
stock ClassValidateEditableAttributes(attributes[ClassEditableAttributes])
{
new flags;
// Alpha initial.
new alphaInitial = attributes[ClassEdit_AlphaInitial];
if (alphaInitial >= 0)
{
if (!(alphaInitial >= ZR_CLASS_ALPHA_INITIAL_MIN && alphaInitial <= ZR_CLASS_ALPHA_INITIAL_MAX))
{
flags += ZR_CLASS_ALPHA_INITIAL;
}
}
// Alpha damaged.
new alphaDamaged = attributes[ClassEdit_AlphaDamaged];
if (alphaDamaged >= 0)
{
if (!(alphaDamaged >= ZR_CLASS_ALPHA_DAMAGED_MIN && alphaDamaged <= ZR_CLASS_ALPHA_DAMAGED_MAX))
{
flags += ZR_CLASS_ALPHA_DAMAGED;
}
}
// Alpha damage.
new alphaDamage = attributes[ClassEdit_AlphaDamage];
if (alphaDamage >= 0)
{
if (!(alphaDamage >= ZR_CLASS_ALPHA_DAMAGE_MIN && alphaDamage <= ZR_CLASS_ALPHA_DAMAGE_MAX))
{
flags += ZR_CLASS_ALPHA_DAMAGE;
}
}
// Overlay.
if (!StrEqual(attributes[ClassEdit_OverlayPath], "nochange", false))
{
decl String:overlay_path[PLATFORM_MAX_PATH];
decl String:overlay[PLATFORM_MAX_PATH];
if (strcopy(overlay_path, sizeof(overlay_path), attributes[ClassEdit_OverlayPath]) > 0)
{
// Check if the file exists.
Format(overlay, sizeof(overlay), "materials/%s.vmt", overlay_path);
if (!FileExists(overlay))
{
flags += ZR_CLASS_OVERLAY_PATH;
}
}
}
// Fov.
new fov = attributes[ClassEdit_Fov];
if (fov >= 0)
{
if (!(fov >= ZR_CLASS_FOV_MIN && fov <= ZR_CLASS_FOV_MAX))
{
flags += ZR_CLASS_FOV;
}
}
// Napalm time.
new Float:napalmTime = attributes[ClassEdit_NapalmTime];
if (napalmTime >= 0.0)
{
if (!(napalmTime >= ZR_CLASS_NAPALM_TIME_MIN && napalmTime <= ZR_CLASS_NAPALM_TIME_MAX))
{
flags += ZR_CLASS_NAPALM_TIME;
}
}
// Immunity mode not implemented yet.
// Health regen interval.
new Float:healthRegenInterval = attributes[ClassEdit_RegenInterval];
if (healthRegenInterval >= 0.0)
{
if (!(healthRegenInterval >= ZR_CLASS_REGEN_INTERVAL_MIN && healthRegenInterval <= ZR_CLASS_REGEN_INTERVAL_MAX))
{
flags += ZR_CLASS_REGEN_INTERVAL;
}
}
// Health regen amount.
new healthRegenAmount = attributes[ClassEdit_RegenAmount];
if (healthRegenAmount >= 0)
{
if (!(healthRegenAmount >= ZR_CLASS_REGEN_AMOUNT_MIN && healthRegenAmount <= ZR_CLASS_REGEN_AMOUNT_MAX))
{
flags += ZR_CLASS_REGEN_AMOUNT;
}
}
// Infect gain.
new infectGain = attributes[ClassEdit_InfectGain];
if (infectGain >= 0)
{
if (!(infectGain >= ZR_CLASS_HEALTH_INFECT_GAIN_MIN && infectGain <= ZR_CLASS_HEALTH_INFECT_GAIN_MAX))
{
flags += ZR_CLASS_HEALTH_INFECT_GAIN;
}
}
// Kill bonus.
new killBonus = attributes[ClassEdit_KillBonus];
if (killBonus >= 0)
{
if (!(killBonus >= ZR_CLASS_KILL_BONUS_MIN && killBonus <= ZR_CLASS_KILL_BONUS_MAX))
{
flags += ZR_CLASS_KILL_BONUS;
}
}
// Speed.
new Float:speed = attributes[ClassEdit_Speed];
if (speed >= 0)
{
if (!(speed >= ZR_CLASS_SPEED_MIN && speed <= ZR_CLASS_SPEED_MAX))
{
flags += ZR_CLASS_SPEED;
}
}
// Knock back.
new Float:knockBack = attributes[ClassEdit_KnockBack];
if (knockBack > ZR_CLASS_KNOCKBACK_IGNORE)
{
if (!(knockBack >= ZR_CLASS_KNOCKBACK_MIN && knockBack <= ZR_CLASS_KNOCKBACK_MAX))
{
flags += ZR_CLASS_KNOCKBACK;
}
}
// Jump heigt.
new Float:jumpHeight = attributes[ClassEdit_JumpHeight];
if (jumpHeight >= 0.0)
{
if (!(jumpHeight >= ZR_CLASS_JUMP_HEIGHT_MIN && jumpHeight <= ZR_CLASS_JUMP_HEIGHT_MAX))
{
flags += ZR_CLASS_JUMP_HEIGHT;
}
}
// Jump distance.
new Float:jumpDistance = attributes[ClassEdit_JumpDistance];
if (jumpDistance >= 0.0)
{
if (!(jumpDistance >= ZR_CLASS_JUMP_DISTANCE_MIN && jumpDistance <= ZR_CLASS_JUMP_DISTANCE_MAX))
{
flags += ZR_CLASS_JUMP_DISTANCE;
}
}
return flags;
}
/**
* Checks if the specified class index is a valid index.
*

View File

@ -60,8 +60,8 @@ ClassHealthRegenStop(client)
public Action:ClassHealthRegenTimer(Handle:timer, any:client)
{
// Kill the timer if the player is dead.
if (!IsPlayerAlive(client))
// Kill the timer if the player is dead or not in game.
if (!IsClientConnected(client) || !IsClientInGame(client) || !IsPlayerAlive(client))
{
tHealthRegen[client] = INVALID_HANDLE;
return Plugin_Stop;

View File

@ -114,11 +114,11 @@
#define ZR_CLASS_DEFAULT_OVERLAY_PATH "overlays/zr/zvision"
#define ZR_CLASS_DEFAULT_NVGS "no"
#define ZR_CLASS_DEFAULT_FOV 90
#define ZR_CLASS_DEFAULT_HAS_NAPALM "yes"
#define ZR_CLASS_DEFAULT_HAS_NAPALM "no"
#define ZR_CLASS_DEFAULT_NAPALM_TIME 10.0
#define ZR_CLASS_DEFAULT_IMMUNITY_MODE ZR_CLASS_IMMUNITY_DISABLED
#define ZR_CLASS_DEFAULT_IMMUNITY_AMOUNT 0.0
#define ZR_CLASS_DEFAULT_NO_FALL_DAMAGE "on"
#define ZR_CLASS_DEFAULT_NO_FALL_DAMAGE "yes"
#define ZR_CLASS_DEFAULT_HEALTH 6000
#define ZR_CLASS_DEFAULT_HEALTH_REGEN_INTERVAL 0.0
#define ZR_CLASS_DEFAULT_HEALTH_REGEN_AMOUNT 2
@ -167,6 +167,7 @@
#define ZR_CLASS_SPEED_MAX 2000.0
#define ZR_CLASS_KNOCKBACK_MIN -30.0
#define ZR_CLASS_KNOCKBACK_MAX 30.0
#define ZR_CLASS_KNOCKBACK_IGNORE -31.0 /** Used by class editor volumetric feature. */
#define ZR_CLASS_JUMP_HEIGHT_MIN 0.0
#define ZR_CLASS_JUMP_HEIGHT_MAX 5.0
#define ZR_CLASS_JUMP_DISTANCE_MIN 0.0
@ -272,6 +273,48 @@ enum ClassAttributes
Float:Class_JumpDistance
}
/**
* Structure of class attributes that are allowed to be modified directly,
* while the player is alive.
*
* Note: This structure is also used as a mask to tell if a individual
* attribute should be ignored or not. Negative valueas usually indicate
* ignored attributes. Booleans are now ints so they can be negative.
* Strings have reserved keywords like "nochange" that indicate a ignored
* attribute.
*/
enum ClassEditableAttributes
{
/* Model */
ClassEdit_AlphaInitial = 0,
ClassEdit_AlphaDamaged,
ClassEdit_AlphaDamage,
/* Hud */
String:ClassEdit_OverlayPath[PLATFORM_MAX_PATH],
ClassEdit_Nvgs,
ClassEdit_Fov,
/* Effects */
ClassEdit_HasNapalm,
Float:ClassEdit_NapalmTime,
/* Player behaviour */
ClassEdit_ImmunityMode,
Float:ClassEdit_ImmunityAmount,
ClassEdit_NoFallDamage,
Float:ClassEdit_RegenInterval,
ClassEdit_RegenAmount,
ClassEdit_InfectGain,
ClassEdit_KillBonus,
Float:ClassEdit_Speed,
Float:ClassEdit_KnockBack,
Float:ClassEdit_JumpHeight,
Float:ClassEdit_JumpDistance
}
/**
* Class attributes that support multipliers.
*/
@ -533,7 +576,7 @@ ClassLoad(bool:keepMultipliers = false)
/* Effects */
ClassData[ClassCount][Class_HasNapalm] = ConfigKvGetStringBool(kvClassData, "have_napalm", ZR_CLASS_DEFAULT_HAS_NAPALM);
ClassData[ClassCount][Class_HasNapalm] = ConfigKvGetStringBool(kvClassData, "has_napalm", ZR_CLASS_DEFAULT_HAS_NAPALM);
ClassData[ClassCount][Class_NapalmTime] = KvGetFloat(kvClassData, "napalm_time", ZR_CLASS_DEFAULT_NAPALM_TIME);

File diff suppressed because it is too large Load Diff

View File

@ -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++;
}
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -59,7 +59,9 @@ enum VolumeAttributes
/* 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. */
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");
}
}