2009-04-15 23:40:45 +02:00
/*
* ============================================================================
*
2009-07-05 08:49:23 +02:00
* Zombie : Reloaded
2009-04-15 23:40:45 +02:00
*
2009-06-12 05:51:26 +02:00
* File : classcommands . inc
* Type : Core
* Description : Console commands for working with classes .
*
* 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-04-15 23:40:45 +02:00
*
* ============================================================================
*/
2009-05-21 07:13:51 +02:00
ClassOnCommandsCreate ()
{
2009-06-17 23:32:46 +02:00
// Register ZClass command.
RegConsoleCmd ( SAYHOOKS_KEYWORD_ZCLASS , ZClassCommand , " Opens class selection menu. " );
2009-05-21 07:13:51 +02:00
// Create base class commands.
RegConsoleCmd ( " zr_class_dump " , ClassDumpCommand , " Dumps class data at a specified index in the specified cache. Usage: zr_class_dump <cachetype> <index|targetname> " );
2009-06-18 02:09:55 +02:00
RegConsoleCmd ( " zr_class_dump_multipliers " , ClassDumpMultipliersCommand , " Dumps class attribute multipliers for the specified team. Usage: zr_class_dump_multipliers < \" zombies \" | \" humans \" > " );
RegAdminCmd ( " zr_class_modify " , ClassModifyCommand , ADMFLAG_CONFIG , " Modify class data on one or more classes. Usage: zr_class_modify <classname| \" zombies \" | \" humans \" | \" admins \" > <attribute> <value> [is_multiplier] " );
2009-06-18 03:33:09 +02:00
RegAdminCmd ( " zr_class_set_multiplier " , ClassSetMultiplierCommand , ADMFLAG_CONFIG , " Sets the multiplier on a class attribute. Usage: zr_class_set_multiplier < \" zombies \" | \" humans \" > <attribute> <value> " );
RegAdminCmd ( " zr_class_reload " , ClassReloadCommand , ADMFLAG_GENERIC , " Refreshes the player cache and reloads class attributes on one or more players. Usage: zr_class_reload <target> " );
2009-05-21 07:13:51 +02:00
}
/**
* Hook commands related to classes here .
*/
ClassOnCommandsHook ()
{
// Forward event to sub-modules.
ClassOverlayOnCommandsHook ();
}
2009-06-17 23:32:46 +02:00
/**
* Command callback ( zclass )
* Opens class selection menu .
*
* @ param client The client index .
* @ param argc Argument count .
*/
public Action : ZClassCommand ( client , argc )
{
// If client is console, then stop and tell them this feature is for players only.
if ( ZRIsConsole ( client ))
{
2009-08-09 22:44:28 +02:00
TranslationReplyToCommand ( client , " Must be player " );
return Plugin_Handled ;
}
// Check if class selection is allowed.
if ( ! ClassAllowSelection ( client ))
{
TranslationReplyToCommand ( client , " Classes Selection Not Allowed " );
2009-06-17 23:32:46 +02:00
return Plugin_Handled ;
}
// Send class menu.
ClassMenuMain ( client );
// This stops the "Unknown command" message in client's console.
return Plugin_Handled ;
}
2009-04-15 23:40:45 +02:00
/**
2009-05-21 07:13:51 +02:00
* Command callback . ( zr_class_dump )
2009-04-15 23:40:45 +02:00
* Dumps class data at a specified index in the specified cache .
2009-05-21 07:13:51 +02:00
*
* @ param client The client index .
* @ param argc Argument count .
2009-04-15 23:40:45 +02:00
*/
2009-05-21 07:13:51 +02:00
public Action : ClassDumpCommand ( client , argc )
2009-04-15 23:40:45 +02:00
{
2009-06-18 02:09:55 +02:00
decl String : syntax [ 320 ];
2009-04-15 23:40:45 +02:00
syntax [ 0 ] = 0 ;
if ( argc < 2 )
{
// Write syntax info.
StrCat ( syntax , sizeof ( syntax ), " Dumps class data at a specified index in the specified cache. Usage: zr_class_dump <cachetype> <index|targetname> \n \n " );
StrCat ( syntax , sizeof ( syntax ), " Cache types: \n " );
StrCat ( syntax , sizeof ( syntax ), " original - Unmodified class data \n " );
StrCat ( syntax , sizeof ( syntax ), " modified - Newest class data \n " );
StrCat ( syntax , sizeof ( syntax ), " player - Players class data \n " );
ReplyToCommand ( client , syntax );
return Plugin_Handled ;
}
new cachetype = - 1 ;
new index = - 1 ;
decl String : type [ 64 ];
decl String : target [ 64 ];
decl String : buffer [ 2048 ];
// Quick initialize buffer.
buffer [ 0 ] = 0 ;
// Get cache type.
GetCmdArg ( 1 , type , sizeof ( type ));
// Set cache type depending on parameter setting.
if ( StrEqual ( type , " original " , false ))
{
cachetype = ZR_CLASS_CACHE_ORIGINAL ;
}
else if ( StrEqual ( type , " modified " , false ))
{
cachetype = ZR_CLASS_CACHE_MODIFIED ;
}
else if ( StrEqual ( type , " player " , false ))
{
cachetype = ZR_CLASS_CACHE_PLAYER ;
// Get client index.
GetCmdArg ( 2 , target , sizeof ( target ));
index = FindTarget ( client , target , _ , false );
// Check if failed.
if ( index < 0 )
{
ReplyToCommand ( client , " Invalid target name. " );
return Plugin_Handled ;
}
}
// Check if cachetype is valid.
if ( cachetype < 0 )
{
ReplyToCommand ( client , " Invalid cache type. " );
return Plugin_Handled ;
}
// Validate class index.
if ( cachetype != ZR_CLASS_CACHE_PLAYER )
{
// Get class index.
GetCmdArg ( 2 , target , sizeof ( target ));
index = StringToInt ( target );
if ( ! ClassValidateIndex ( index ))
{
ReplyToCommand ( client , " Invalid class index. " );
return Plugin_Handled ;
}
}
// Dump the specified cache.
ReplyToCommand ( client , " DUMPING CACHE: \" %s \" (%d classes total) \n ======================================== \n " , type , ClassCount );
ClassDumpData ( index , cachetype , buffer , sizeof ( buffer ));
2009-05-14 09:32:01 +02:00
// Print all data to client.
decl String : partbuffer [ 1024 ];
new pos ;
new cellswritten = 1 ; // Initialize for the loop.
2009-04-15 23:40:45 +02:00
2009-05-14 09:32:01 +02:00
while ( cellswritten )
{
cellswritten = strcopy ( partbuffer , sizeof ( partbuffer ), buffer [ pos ]);
ReplyToCommand ( client , partbuffer );
pos += cellswritten ;
}
return Plugin_Handled ;
2009-04-15 23:40:45 +02:00
}
2009-05-10 18:49:47 +02:00
2009-06-18 02:09:55 +02:00
/**
* Command callback . ( zr_class_dump_multipliers )
* Dumps class attribute multipliers for the specified team .
*
* @ param client The client index .
* @ param argc Argument count .
*/
public Action : ClassDumpMultipliersCommand ( client , argc )
{
decl String : buffer [ 512 ];
decl String : linebuffer [ 128 ];
decl String : arg [ 16 ];
buffer [ 0 ] = 0 ;
if ( argc < 1 )
{
// Write syntax info.
ReplyToCommand ( client , " Dumps class attribute multipliers for the specified team. Usage: zr_class_dump_multipliers < \" zombies \" | \" humans \" > " );
return Plugin_Handled ;
}
new teamid = - 1 ;
// Get team id.
GetCmdArg ( 1 , arg , sizeof ( arg ));
if ( StrEqual ( arg , " zombies " , false ))
{
teamid = ZR_CLASS_TEAM_ZOMBIES ;
}
else if ( StrEqual ( arg , " humans " , false ))
{
teamid = ZR_CLASS_TEAM_HUMANS ;
}
if ( teamid >= 0 )
{
Format ( linebuffer , sizeof ( linebuffer ), " Dumping multipliers for team: %s \n ---------------------------------------- \n " , arg );
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Napalm time: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_NapalmTime ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Health: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_Health ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Health regen interval: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_HealthRegenInterval ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Health regen amount: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_HealthRegenAmount ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Health infect gain: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_HealthInfectGain ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Speed: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_Speed ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Knock back: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_Knockback ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Jump height: %f \n " , ClassMultiplierCache [ teamid ][ ClassM_JumpHeight ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
Format ( linebuffer , sizeof ( linebuffer ), " Jump distance: %f " , ClassMultiplierCache [ teamid ][ ClassM_JumpDistance ]);
StrCat ( buffer , sizeof ( buffer ), linebuffer );
ReplyToCommand ( client , buffer );
return Plugin_Handled ;
}
else
{
ReplyToCommand ( client , " Invalid team name specified. " );
return Plugin_Handled ;
}
}
2009-05-10 18:49:47 +02:00
/**
* Modifies class data on one or more classes .
*
* Syntax : zr_class_modify < class > < attribute > < value > [ is_multiplier ]
*
* class : The class to modify . Can be any class name , or one of the
* following team names ; " all " , " humans " , " zombies " or
* " admins " .
* attribute : The name of the class attribute .
* value : Value to set . Use quotes if value is a string .
* is_multiplier : Optional . specifies wether the original value should be
* multiplied by the specified value . Defaults to false .
*
* Note : Original values are retrieved from the original class cache , not the
* modified class cache .
*/
2009-05-21 07:13:51 +02:00
public Action : ClassModifyCommand ( client , argc )
2009-05-10 18:49:47 +02:00
{
decl String : syntax [ 1024 ];
syntax [ 0 ] = 0 ;
if ( argc < 3 )
{
// Write syntax info.
StrCat ( syntax , sizeof ( syntax ), " Modifies class data on one or more classes. Usage: zr_class_modify <class> <attribute> <value> [is_multiplier] \n \n " );
StrCat ( syntax , sizeof ( syntax ), " class: The class to modify. Can be any class name, or one of the following team names; all, humans, zombies or admins. \n " );
StrCat ( syntax , sizeof ( syntax ), " attribute: The name of the class attribute. \n " );
StrCat ( syntax , sizeof ( syntax ), " value: Value to set. Use quotes if value is a string. \n " );
StrCat ( syntax , sizeof ( syntax ), " is_multiplier: Optional. specifies wether the original value should be multiplied by the specified value. Not all attributes support multiplying. Defaults to false. \n \n " );
StrCat ( syntax , sizeof ( syntax ), " Note: Original values are retrieved from the original class cache, not the modified class cache. " );
ReplyToCommand ( client , syntax );
return Plugin_Handled ;
}
decl String : classname [ 64 ];
decl String : attributename [ 128 ];
decl String : value [ 256 ];
decl String : ismultiplier [ 4 ];
new attributeflag ;
new ClassDataTypes : attributetype ;
new bool : isgroup ;
new bool : hasmultiplier ;
new Handle : classlist ;
new classindex ;
new bool : listresult ;
classlist = CreateArray ();
// Get command arguments.
GetCmdArg ( 1 , classname , sizeof ( classname ));
GetCmdArg ( 2 , attributename , sizeof ( attributename ));
GetCmdArg ( 3 , value , sizeof ( value ));
// Get last command argument if specified.
if ( argc == 4 )
{
GetCmdArg ( 4 , ismultiplier , sizeof ( ismultiplier ));
if ( StringToInt ( ismultiplier ))
{
hasmultiplier = true ;
}
}
// Get attribute flag.
attributeflag = ClassAttributeNameToFlag ( attributename );
// Validate attribute flag.
if ( attributeflag < 0 )
{
ReplyToCommand ( client , " Invalid class attribute specified. " );
return Plugin_Handled ;
}
// Get attribute data type.
attributetype = ClassGetAttributeType ( attributeflag );
// Check if classname is a group. Add classes to the class list
// and use the specified team filter.
if ( StrEqual ( classname , " all " , false ))
{
listresult = ClassAddToArray ( classlist );
isgroup = true ;
}
else if ( StrEqual ( classname , " humans " , false ))
{
listresult = ClassAddToArray ( classlist , ZR_CLASS_TEAM_HUMANS );
isgroup = true ;
}
else if ( StrEqual ( classname , " zombies " , false ))
{
listresult = ClassAddToArray ( classlist , ZR_CLASS_TEAM_ZOMBIES );
isgroup = true ;
}
else if ( StrEqual ( classname , " admins " , false ))
{
listresult = ClassAddToArray ( classlist , ZR_CLASS_TEAM_ADMINS );
isgroup = true ;
}
// Check if classname is a group.
if ( isgroup )
{
// Check if the list is valid.
if ( ! listresult )
{
ReplyToCommand ( client , " Failed to get classes in the specified team: \" %s \" . " , classname );
return Plugin_Handled ;
}
// Loop through all classes in the list.
new listsize = GetArraySize ( classlist );
for ( new i = 0 ; i < listsize ; i ++ )
{
classindex = GetArrayCell ( classlist , i );
switch ( attributetype )
{
case ClassDataType_Boolean :
{
if ( ! ClassModifyBoolean ( classindex , attributeflag , bool : StringToInt ( value )))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
case ClassDataType_Integer :
{
if ( hasmultiplier )
{
if ( ! ClassModifyInteger ( classindex , attributeflag , StringToInt ( value ), StringToFloat ( value )))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
else
{
if ( ! ClassModifyInteger ( classindex , attributeflag , StringToInt ( value )))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
}
case ClassDataType_Float :
{
if ( ! ClassModifyFloat ( classindex , attributeflag , StringToFloat ( value ), hasmultiplier ))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
case ClassDataType_String :
{
if ( ! ClassModifyString ( classindex , attributeflag , value ))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
}
}
}
else
{
// It's a single class.
classindex = ClassGetIndex ( classname );
// Validate classindex.
if ( ! ClassValidateIndex ( classindex ))
{
ReplyToCommand ( client , " Invalid class name specified. " );
return Plugin_Handled ;
}
switch ( attributetype )
{
case ClassDataType_Boolean :
{
if ( ! ClassModifyBoolean ( classindex , attributeflag , bool : StringToInt ( value )))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
case ClassDataType_Integer :
{
if ( hasmultiplier )
{
if ( ! ClassModifyInteger ( classindex , attributeflag , StringToInt ( value ), StringToFloat ( value )))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
else
{
if ( ! ClassModifyInteger ( classindex , attributeflag , StringToInt ( value )))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
}
case ClassDataType_Float :
{
if ( ! ClassModifyFloat ( classindex , attributeflag , StringToFloat ( value )), hasmultiplier )
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
case ClassDataType_String :
{
if ( ! ClassModifyString ( classindex , attributeflag , value ))
{
ReplyToCommand ( client , " Failed to set \" %s \" to \" %s \" in class \" %d \" . " , attributename , value , classindex );
}
}
}
}
return Plugin_Handled ;
}
2009-06-18 02:09:55 +02:00
/**
* Sets the multiplier on a class attribute .
*
* Syntax : zr_class_modify < class > < attribute > < value > [ is_multiplier ]
*
* class : The class to modify . Can be any class name , or one of the
* following team names ; " all " , " humans " , " zombies " or
* " admins " .
* attribute : The name of the class attribute .
* value : Value to set . Use quotes if value is a string .
* is_multiplier : Optional . specifies wether the original value should be
* multiplied by the specified value . Defaults to false .
*
* Note : Original values are retrieved from the original class cache , not the
* modified class cache .
*/
public Action : ClassSetMultiplierCommand ( client , argc )
{
decl String : syntax [ 320 ];
syntax [ 0 ] = 0 ;
if ( argc < 3 )
{
// Write syntax info.
2009-06-18 03:33:09 +02:00
StrCat ( syntax , sizeof ( syntax ), " Sets the multiplier on a class attribute. Usage: zr_class_set_multiplier < \" zombies \" | \" humans \" > <attribute> <value> \n \n " );
2009-06-18 02:09:55 +02:00
StrCat ( syntax , sizeof ( syntax ), " Valid attributes: \n ---------------------------------------- \n " );
StrCat ( syntax , sizeof ( syntax ), " napalm_time \n health \n health_regen_interval \n health_regen_amount \n health_infect_gain \n speed \n knockback \n jump_height \n jump_distance " );
ReplyToCommand ( client , syntax );
return Plugin_Handled ;
}
decl String : teamname [ 16 ];
decl String : attributename [ 32 ];
decl String : multiplier [ 32 ];
new teamid = - 1 ;
new ClassMultipliers : attribute ;
new Float : value ;
// Get arguments.
GetCmdArg ( 1 , teamname , sizeof ( teamname ));
GetCmdArg ( 2 , attributename , sizeof ( attributename ));
GetCmdArg ( 3 , multiplier , sizeof ( multiplier ));
// Get team id.
if ( StrEqual ( teamname , " zombies " , false ))
{
teamid = ZR_CLASS_TEAM_ZOMBIES ;
}
else if ( StrEqual ( teamname , " humans " , false ))
{
teamid = ZR_CLASS_TEAM_HUMANS ;
}
// Validate team id.
if ( teamid < 0 )
{
ReplyToCommand ( client , " Invalid team name: %s " , teamname );
return Plugin_Handled ;
}
// Get attribute type.
attribute = ClassAttributeNameToMultiplier ( attributename );
// Validate type.
if ( attribute == ClassM_Invalid )
{
ReplyToCommand ( client , " Attribute is invalid or not a multiplier: %s " , attributename );
}
// Get value.
value = StringToFloat ( multiplier );
// Set multiplier.
ClassMultiplierCache [ teamid ][ attribute ] = value ;
return Plugin_Handled ;
}
2009-06-18 03:33:09 +02:00
/**
* Command callback . ( zr_class_reload )
* Dumps class data at a specified index in the specified cache .
*
* @ param client The client index .
* @ param argc Argument count .
*/
public Action : ClassReloadCommand ( client , argc )
{
decl String : arg [ MAX_TARGET_LENGTH ];
decl String : targetname [ MAX_TARGET_LENGTH ];
new targetlist [ MAXPLAYERS + 1 ];
new targetcount ;
new bool : tn_is_ml ;
if ( argc < 1 )
{
// Write syntax info.
ReplyToCommand ( client , " Refreshes the player cache and reloads class attributes on one or more players. Usage: zr_class_reload <target> " );
return Plugin_Handled ;
}
// Get the target string.
GetCmdArg ( 1 , arg , sizeof ( arg ));
// Get target clients.
if (( targetcount = ProcessTargetString ( arg , client , targetlist , sizeof ( targetlist ), 0 , targetname , sizeof ( targetname ), tn_is_ml )) <= 0 )
{
// Failed to get targets.
ReplyToTargetError ( client , targetcount );
return Plugin_Handled ;
}
// Loop through each target.
for ( new target = 0 ; target < targetcount ; target ++ )
{
ClassReloadPlayer ( targetlist [ target ]);
}
// Check phrase format.
if ( tn_is_ml )
{
ReplyToCommand ( client , " Refreshed cache to %t. " , targetname );
}
else
{
ReplyToCommand ( client , " Refreshed cache to %s. " , targetname );
}
return Plugin_Handled ;
}
2009-05-10 18:49:47 +02:00
/**
* Modify class boolean attribute on a class .
*
* @ param classindex The class index .
* @ param attributeflag Attribute to modify ( a single attribute flag ) .
* @ param value New value to set .
* @ return True on success , false otherwise .
*/
2009-05-21 07:13:51 +02:00
stock bool : ClassModifyBoolean ( classindex , attributeflag , bool : value )
2009-05-10 18:49:47 +02:00
{
// Validate class index.
if ( ! ClassValidateIndex ( classindex ))
{
return false ;
}
switch ( attributeflag )
{
2009-06-22 01:09:51 +02:00
case ZR_CLASS_ENABLED :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_Enabled ] = bool : value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_NVGS :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_Nvgs ] = bool : value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_NO_FALL_DAMAGE :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_NoFallDamage ] = bool : value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_HAS_NAPALM :
2009-06-14 19:10:30 +02:00
{
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_HasNapalm ] = bool : value ;
2009-06-14 19:10:30 +02:00
return true ;
}
2009-05-10 18:49:47 +02:00
}
// Invalid flag or multiple flags combined.
return false ;
}
/**
* Modify class integer attribute on a class .
*
* @ param classindex The class index .
* @ param attributeflag Attribute to modify ( a single attribute flag ) .
* @ param value New value to set , or multiply with .
* @ param multiplier Optional . Use a multiplier instead of the value ,
* that multiplies with the original class value .
* Not all attributes support multipliers . 0.0 to
* disable . Value is ignored if this is non - zero .
* @ return True on success , false otherwise .
*/
2009-05-21 07:13:51 +02:00
stock ClassModifyInteger ( classindex , attributeflag , value , Float : multiplier = 0.0 )
2009-05-10 18:49:47 +02:00
{
// Validate class index.
if ( ! ClassValidateIndex ( classindex ))
{
return false ;
}
// Check if multiplier is specified.
new bool : ismultiplier = ( multiplier != 0.0 ) ? true : false ;
switch ( attributeflag )
{
2009-06-22 01:09:51 +02:00
case ZR_CLASS_FLAGS :
{
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_Flags ] = value ;
2009-06-22 01:09:51 +02:00
return true ;
}
case ZR_CLASS_ALPHA_INITIAL :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = RoundToNearest ( float ( ClassData [ classindex ][ Class_AlphaInitial ]) * multiplier );
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_AlphaInitial ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_ALPHA_DAMAGED :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = RoundToNearest ( float ( ClassData [ classindex ][ Class_AlphaDamaged ]) * multiplier );
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_AlphaDamaged ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_ALPHA_DAMAGE :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = RoundToNearest ( float ( ClassData [ classindex ][ Class_AlphaDamage ]) * multiplier );
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_AlphaDamage ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_FOV :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_Fov ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_IMMUNITY_MODE :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_ImmunityMode ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_HEALTH :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = RoundToNearest ( float ( ClassData [ classindex ][ Class_Health ]) * multiplier );
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_Health ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_HEALTH_REGEN_AMOUNT :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = RoundToNearest ( float ( ClassData [ classindex ][ Class_HealthRegenAmount ]) * multiplier );
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_HealthRegenAmount ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_HEALTH_INFECT_GAIN :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = RoundToNearest ( float ( ClassData [ classindex ][ Class_HealthInfectGain ]) * multiplier );
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_HealthInfectGain ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_KILL_BONUS :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = RoundToNearest ( float ( ClassData [ classindex ][ Class_KillBonus ]) * multiplier );
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_KillBonus ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
}
// Invalid flag or multiple flags combined.
return false ;
}
/**
* Modify class float attribute on a class .
*
* @ param classindex The class index .
* @ param attributeflag Attribute to modify ( a single attribute flag ) .
* @ param value New value to set , or multiply with .
2009-06-18 02:09:55 +02:00
* @ param ismultiplier Optional . Specifies wether to use value as a
* multiplier that is multiplied with the original
* class value . Unsupported attributes are ignored .
2009-05-10 18:49:47 +02:00
* @ return True on success , false otherwise .
*/
2009-05-21 07:13:51 +02:00
stock ClassModifyFloat ( classindex , attributeflag , Float : value , bool : ismultiplier = false )
2009-05-10 18:49:47 +02:00
{
// Validate class index.
if ( ! ClassValidateIndex ( classindex ))
{
return false ;
}
switch ( attributeflag )
{
2009-06-22 01:09:51 +02:00
case ZR_CLASS_NAPALM_TIME :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = ClassData [ classindex ][ Class_NapalmTime ] * value ;
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_NapalmTime ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_IMMUNITY_AMOUNT :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = ClassData [ classindex ][ Class_ImmunityAmount ] * value ;
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_ImmunityAmount ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_HEALTH_REGEN_INTERVAL :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = ClassData [ classindex ][ Class_HealthRegenInterval ] * value ;
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_HealthRegenInterval ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_SPEED :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = ClassData [ classindex ][ Class_Speed ] * value ;
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_Speed ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_KNOCKBACK :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = ClassData [ classindex ][ Class_KnockBack ] * value ;
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_KnockBack ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_JUMP_HEIGHT :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = ClassData [ classindex ][ Class_JumpHeight ] * value ;
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_JumpHeight ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_JUMP_DISTANCE :
2009-05-10 18:49:47 +02:00
{
if ( ismultiplier )
{
2009-08-13 18:31:21 +02:00
value = ClassData [ classindex ][ Class_JumpDistance ] * value ;
2009-05-10 18:49:47 +02:00
}
2009-08-13 18:31:21 +02:00
ClassDataCache [ classindex ][ Class_JumpDistance ] = value ;
2009-05-10 18:49:47 +02:00
return true ;
}
}
// Invalid flag or multiple flags combined.
return false ;
}
/**
* Modify class string attribute on a class .
*
* @ param classindex The class index .
* @ param attributeflag Attribute to modify ( a single attribute flag ) .
* @ param value New value to set .
* @ return True on success , false otherwise .
*/
2009-05-21 07:13:51 +02:00
stock ClassModifyString ( classindex , attributeflag , const String : value [])
2009-05-10 18:49:47 +02:00
{
// Validate class index.
if ( ! ClassValidateIndex ( classindex ))
{
return false ;
}
switch ( attributeflag )
{
2009-08-13 18:31:21 +02:00
case ZR_CLASS_GROUP :
{
strcopy ( ClassDataCache [ classindex ][ Class_Group ], 64 , value );
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_NAME :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
strcopy ( ClassDataCache [ classindex ][ Class_Name ], 64 , value );
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_DESCRIPTION :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
strcopy ( ClassDataCache [ classindex ][ Class_Description ], 256 , value );
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_MODEL_PATH :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
strcopy ( ClassDataCache [ classindex ][ Class_ModelPath ], PLATFORM_MAX_PATH , value );
2009-05-10 18:49:47 +02:00
return true ;
}
2009-06-22 01:09:51 +02:00
case ZR_CLASS_OVERLAY_PATH :
2009-05-10 18:49:47 +02:00
{
2009-08-13 18:31:21 +02:00
strcopy ( ClassDataCache [ classindex ][ Class_OverlayPath ], PLATFORM_MAX_PATH , value );
2009-05-10 18:49:47 +02:00
return true ;
}
}
// Invalid flag or multiple flags combined.
return false ;
}