• A weapon that deals more damage against one npc, less damage against others?
    1 replies, posted
Howdy folks! I'd like to know whether its possible or not to create a gun that deals more damage against, say, antlions, but less damage on combine. If so, how can I achieve such an effect?
[url]http://wiki.garrysmod.com/page/Hooks/Base/EntityTakeDamage[/url] You should use that hook [url]http://wiki.garrysmod.com/page/Classes/CTakeDamageInfo[/url] That will allow you go grab information and you could do something like [lua] local function ChangeDamage( ent, dmginfo ) local att = dmginfo:GetAttacker() if IsValid( ent ) and IsValid( att ) and att:IsPlayer() then if att:GetActiveWeapon():GetClass() == "YOUR WEAPON" and ent:GetClass() == "npc_antlion" then dmginfo:ScaleDamage( 2 ) -- doubles damage given to the antlion end end end hook.Add( "EntityTakeDamage", "ChangeDamage", ChangeDamage ) [/lua] P.s. Thanks randomscript for this ;D
Sorry, you need to Log In to post a reply to this thread.