Oh looks like it is time to clean up the code used for ability triggers rofl. Well the good news is at this point I think I will be getting pretty close to standardizing and fully optimizing all the standard code methodology used for every single race soon. (means future coding is much much faster b/c all the optimization has already been done correctly to begin with (also easier to read and edit code))
Example:
Before:
Code:
public OnAbilityCommand( client, ability, bool:pressed )
{
//Plant
if( War3_GetRace( client ) == thisRaceID && ability == 0 && pressed && IsPlayerAlive( client ) )
{
new skill_level = War3_GetSkillLevel( client, thisRaceID, SKILL_WARD );
if( skill_level > 0 )
{
if( !Silenced( client ) )
{
}
}
}
//Activate
if( War3_GetRace( client ) == thisRaceID && ability == 1 && pressed && IsPlayerAlive( client ) )
{
}
}
After:
Code:
public OnAbilityCommand( client, ability, bool:pressed )
{
if(War3_GetRace(client) == thisRaceID && IsPlayerAlive(client))
{
//Plant
if(ability == 0 && pressed)
{
new skill_level = skill_level_item[client];
if(skill_level > 0 && !Silenced(client))
{
}
}
//Activate
if(ability == 1 && pressed)
{
new skill_level = skill_level_item[client];
if(skill_level > 0 && !Silenced(client))
{
}
}
}
}
Notice that redundant duplicate code was eliminated allowing for better permanence reduced possibility of errors and increased readability. Rather than keep rechecking the same dam thing multiple times it is done once. In this case it is further optimized by moving the skill level check to its own statement as well (but this could be for 2 different abilities and you logically would test those individually within the defined statement. Also I will be testing with an else if b/c it appears this method is called on a case by case basis and so there can be some benefit to not running unnecessary code. In fact a switch statement might be passable as well to improve optimization to the highest possible degree.