Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hatemap = { }
- local function OnNPCKilled( npc, attacker, inflictor )
- local a, b, k, v, d
- a = npc:GetClass( )
- b = attacker:GetClass( )
- hatemap[ a ] = hatemap[ a ] or { }
- hatemap[ a ][ b ] = hatemap[ a ][ b ] or 0
- hatemap[ b ] = hatemap[ b ] or { }
- hatemap[ b ][ a ] = hatemap[ b ][ a ] or 0
- hatemap[ a ][ b ] = hatemap[ a ][ b ] - 100
- hatemap[ b ][ a ] = hatemap[ b ][ a ] + 100
- d = hatemap[ a ][ b ]
- for k, v in ents.FindByClass( a ) do
- v:AddRelationship( string.format( "%s %s %d", b, d > 0 and "D_LI" or "D_HT", math.abs( d ) ) )
- if d > 0 then
- v:AddRelationship( string.format( "%s D_HT 0", b ) )
- end
- end
- d = hatemap[ b ][ a ]
- for k, v in ents.FindByClass( b ) do
- v:AddRelationship( string.format( "%s %s %d", b, d > 0 and "D_LI" or "D_HT", math.abs( d ) )
- if d > 0 then
- v:AddRelationship( string.format( "%s D_HT 0", b ) )
- end
- end
- end
- local function EntityTakeDamage( ent, inflictor, attacker, amount, info )
- local a, b
- if not ( ent:IsPlayer( ) or ent:IsNPC( ) ) then
- return
- end
- a = ent:GetClass( )
- b = attacker:GetClass( )
- hatemap[ a ] = hatemap[ a ] or { }
- hatemap[ a ][ b ] = hatemap[ a ][ b ] or 0
- hatemap[ b ] = hatemap[ b ] or { }
- hatemap[ b ][ a ] = hatemap[ b ][ a ] or 0
- hatemap[ a ][ b ] = hatemap[ a ][ b ] - amount
- hatemap[ b ][ a ] = hatemap[ b ][ a ] + amount
- d = hatemap[ a ][ b ]
- for k, v in ents.FindByClass( a ) do
- v:AddRelationship( string.format( "%s %s %d", b, d > 0 and "D_LI" or "D_HT", math.abs( d ) ) )
- if d > 0 then
- v:AddRelationship( string.format( "%s D_HT 0", b ) )
- end
- end
- d = hatemap[ b ][ a ]
- for k, v in ents.FindByClass( b ) do
- v:AddRelationship( string.format( "%s %s %d", b, d > 0 and "D_LI" or "D_HT", math.abs( d ) )
- if d > 0 then
- v:AddRelationship( string.format( "%s D_HT 0", b ) )
- end
- end
- end
- local function OnEntityCreated( ent )
- local a, k, v
- a = ent:GetClass( )
- if hatemap[ a ] and ent:IsNPC( ) then
- for k, v in pairs( hatemap[ a ] ) do
- ent:AddRelationship( string.format( "%s %s %d", k, v > 0 and "D_LI" or "D_HT", v ) )
- end
- end
- end
- hook.Add( "OnNPCKilled", "Hatemap.OnNPCKilled", OnNPCKilled )
- hook.Add( "EntityTakeDamage", "Hatemap.EntityTakeDamage", EntityTakeDamage )
- hook.Add( "OnEntityCreated", "Hatemap.OnEntityCreated", OnEntityCreated )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement