• Making a bullet do NO damage
    7 replies, posted
I have made a sentry entity thing, which will always hurt the player it target as long as it can see that player. I did this by using ent:TakeDamage() on the target, and shooting a bullet just for aesphetics. The bullet is set to do 0 damage ( bullet.Damage = 0 ), and it doesn't to players. But if the bullet shoots an obstructing entity between the target and the player, it does a small amount of damage. I have a barrier class that has a health display when you look at it, and if this gets shot by the bullet with "0" damage, it loses a small amount of HP. Also, if the bullet hits an NPC it damages them too. How do I make a bullet with absolutely zero damage?
I think you're gonna need the [url=http://wiki.garrysmod.com/?title=Gamemode.EntityTakeDamage]EntityTakeDamage hook[/url] to ignore the bullet damage.
[QUOTE=Overv;16920818]I think you're gonna need the [url=http://wiki.garrysmod.com/?title=Gamemode.EntityTakeDamage]EntityTakeDamage hook[/url] to ignore the bullet damage.[/QUOTE] Ok, good idea. I'll probably use the bullet hit callback to do it though, since my EntityTakeDamage is already quite cluttered, and it saves me from having to check that the damage was done by a sentry Edit: Didn't work :(. This is my code: [lua]local bullet = {} bullet.Src = self.Entity:GetPos() bullet.Attacker = self.Parent bullet.Dir = angle bullet.Spread = Vector( 0, 0, 0 ) bullet.Num = 1 bullet.Damage = 0 bullet.Force = 0 bullet.Tracer = 1 bullet.Callback = function( attacker, trace, dmg ) dmg:ScaleDamage( 0 ) end self.Entity:FireBullets( bullet )[/lua]
I used Msg on the dmg's GetDamage, and it returns 0. But it IS 100% hurting some entities.
Try the EntityTakeDamage way.
I think at the end since you have it as "scale damage" it is scaling the damage by a factor of a number you might have somewhere else in your code.
That may be stupid, but why don't you just shoot the bullet directly for applying damage instead of using TakeDamage? Try adding this at the end of your bullet callback: [lua]return {damage=false}[/lua]
I wanted to use takedamage so it would always hurt the target as long as the turret can see them. The bullet would sometimes be blocked by something if it just aimed for the middle of the target so takedamage ensured it would hit. I have changed it since then to have the bullet do the damage, but it scans around the target until it finds a point it can hit, and aims for there.
Sorry, you need to Log In to post a reply to this thread.