Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- function for transferring the damage done to the corpse onto the player
- local function transferDamage(ent, dmginfo)
- if ent.sid then -- check for nil value
- local ply = player.GetBySteamID(ent.sid)
- if IsValid(ply) and (ent == ply.fake_corpse) then
- if (dmginfo:GetDamage() < 0) then
- dmginfo:ScaleDamage(-1)
- end
- if (dmginfo:GetDamage() < 150) then -- if this blow is not lethal
- dmginfo:SetDamage(0) -- make sure it don't hurt
- end
- if (dmginfo:GetDamage() > 150) then -- if this blow is going to be lethal
- dmginfo:SetDamage(1000) -- make sure it actually kills him, weird things can happen
- ply:SetPos(ent:LocalToWorld(ent:OBBCenter()) + vector_up / 2) -- move the player back to the corpse
- ply:TakeDamageInfo(dmginfo)
- ply:SetNWBool("death_faked", false)
- ent:Remove() -- remove the fake corpse
- timer.Simple(0, function() -- make sure its really the next tick
- if ply:IsTerror() then
- ply:Kill() -- leaves an ugly death message but this is our last resort
- end
- end)
- else
- ply:TakeDamageInfo(dmginfo)
- end
- end
- end
- end
- hook.Add("EntityTakeDamage", "ttt-deathfaker-corpsedmgcheck", transferDamage)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement