Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TEAM_RESISTANCE = {
- [TEAM_THIEF] = {
- DMG_POISON,
- },
- }
- hook.Add("EntityTakeDamage", "resistance stuff", function(pPlayer, CDmgInfo)
- local tResistance = TEAM_RESISTANCE[pPlayer:Team()] -- Get their resistance stuffs
- if not tResistance then return end -- The index doesn't exist
- local iDmgType = CDmgInfo:GetDamageType() -- Returns a bitflag, explained below
- for k,v in ipairs(tResistance) do -- lets iterate cause cool
- if (bit.band(iDmgType, v) == 0) then -- iirc this is how you do it in glua, not certain though
- return false
- end
- end
- end)
- --[[ BIT FLAGS
- A bit flag is a 1 or a 0 in a binary number, for example
- In this example we'll use recipes ig
- 0001
- The first bit here may represent whether or not the food needs to be put in the oven
- 0010
- This may represent whether or not it needs to be mixed
- 0100
- This may represent whether or not it is dairy
- 1000
- This may represent whether or not it is halal
- Just like above, if I wanted to check if my recipe was halal, I would check if the last bit (1000) is set to 1, if it is, then it is halal.
- If I wanted to check if it was halal AND dairy, then I would check if the two bits (1000) and (1100) are set to 1.
- That's pretty much it ig
- ]]--
Advertisement
Add Comment
Please, Sign In to add comment