Hi, I want players to only take damage above 500 radiation. So far I've got this:
The damage you take form radiation starts beforehand therefore player.health = player.health doesn't work seem to work. Anyone has any suggestions what could work instead of this line?Code:void OnRunPlayerMetabolism(PlayerMetabolism metabolism) { BasePlayer player = (BasePlayer) metabolism.GetComponent("BasePlayer"); if (metabolism.radiation_poison.value < 500 && metabolism.radiation_poison.value > 1) { player.health = player.health; } }
I've also tried looking at OnEntityTakeDamage. Managed to check which if a player got damaged and tried to determine the damagetype but this doesn't seem to work either. The DamageType always seems to be "Generic". Perhaps anyone has a solution to this?
[DOUBLEPOST=1433328694,1433167347][/DOUBLEPOST]Fixed it! Found http://oxidemod.org/plugins/realistic-fall-damage.855/ as example code. Works great!Code:void OnEntityTakeDamage(BaseEntity entity, HitInfo info) { if (entity.name == "player/player") { foreach (DamageType dt in info.damageTypes.types) { if (dt == DamageType.RadiationExposure) { ConsoleSystem.Broadcast("chat.add", 0, "Radiation Damage"); } } }
Code:void OnEntityTakeDamage(BaseEntity entity, HitInfo info) { BasePlayer player = entity.GetComponent<BasePlayer>(); if (player == null) { return; } if(info.damageTypes.Total() <= 0) { return; } DamageType majorDamagetype = info.damageTypes.GetMajorityDamageType(); if (majorDamagetype == DamageType.Radiation) { float newDamage; if (player.metabolism.radiation_poison.value >= 40) { newDamage = 0.05f; } else { newDamage = 0; } info.damageTypes.Set(majorDamagetype, newDamage); } }
Solved Adjust health to radiation level
Discussion in 'Rust Development' started by DroneFW, Jun 3, 2015.
-
Can you make standalone plugins for this ?
-
Yea, you can. It's pretty easy actually!
-
starting to looking for plugins ^^ will see that !