Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made IsEnemy/FriendlyEntityName more efficient #808

Merged
merged 1 commit into from Sep 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 15 additions & 32 deletions garrysmod/lua/includes/util.lua
Expand Up @@ -14,7 +14,7 @@ Format = string.format
-----------------------------------------------------------]]
function IsTableOfEntitiesValid( tab )

if (!tab) then return false end
if ( !tab ) then return false end

for k, v in pairs( tab ) do
if ( !IsValid( v ) ) then return false end
Expand Down Expand Up @@ -309,47 +309,30 @@ end
--[[---------------------------------------------------------
IsEnemyEntityName
-----------------------------------------------------------]]
function IsEnemyEntityName( victimtype )
local EnemyNames = {
npc_antlion = true, npc_antlionguard = true, npc_breen = true, npc_combine_s = true,
npc_cscanner = true, npc_fastzombie = true, npc_fastzombie_torso = true, npc_gman = true,
npc_headcrab = true, npc_headcrab_fast = true, npc_headcrab_poison = true, npc_hunter = true,
npc_manhack = true, npc_poisonzombie = true, npc_zombie = true, npc_zombie_torso = true
}

if ( victimtype == "npc_combine_s" ) then return true; end
if ( victimtype == "npc_cscanner" ) then return true; end
if ( victimtype == "npc_manhack" ) then return true; end
if ( victimtype == "npc_hunter" ) then return true; end
if ( victimtype == "npc_antlion" ) then return true; end
if ( victimtype == "npc_antlionguard" ) then return true; end
if ( victimtype == "npc_antlion_worker" ) then return true; end
if ( victimtype == "npc_fastzombie_torso" ) then return true; end
if ( victimtype == "npc_fastzombie" ) then return true; end
if ( victimtype == "npc_headcrab" ) then return true; end
if ( victimtype == "npc_headcrab_fast" ) then return true; end
if ( victimtype == "npc_poisonzombie" ) then return true; end
if ( victimtype == "npc_headcrab_poison" ) then return true; end
if ( victimtype == "npc_zombie" ) then return true; end
if ( victimtype == "npc_zombie_torso" ) then return true; end
if ( victimtype == "npc_zombine" ) then return true; end
if ( victimtype == "npc_gman" ) then return true; end
if ( victimtype == "npc_breen" ) then return true; end
function IsEnemyEntityName( victimtype )

return false
return EnemyNames[ victimtype ] or false

end

--[[---------------------------------------------------------
IsFriendEntityName
-----------------------------------------------------------]]
function IsFriendEntityName( victimtype )
local FriendlyNames = {
npc_alyx = true, npc_barney = true, npc_citizen = true, npc_eli = true, npc_kleiner = true,
npc_magnusson = true, npc_monk = true, npc_mossman = true, npc_vortigaunt = true
}

if ( victimtype == "npc_monk" ) then return true; end
if ( victimtype == "npc_alyx" ) then return true; end
if ( victimtype == "npc_barney" ) then return true; end
if ( victimtype == "npc_citizen" ) then return true; end
if ( victimtype == "npc_kleiner" ) then return true; end
if ( victimtype == "npc_magnusson" ) then return true; end
if ( victimtype == "npc_eli" ) then return true; end
if ( victimtype == "npc_mossman" ) then return true; end
if ( victimtype == "npc_vortigaunt" ) then return true; end
function IsFriendEntityName( victimtype )

return false
return FriendlyNames[ victimtype ] or false

end

Expand Down