Need a plugin that prevents the train (workcart entity) from being damaged by anything.
Prevent Train (workcart) From Damage...
Very possible, should be easy enough. :)
Not sure if this is of interest to you, but I developed plugin earlier this month on request, called Workcart Safe Zones. It is currently pending approval on uMod. It allows selectively adding a safe zone to specific workcarts, or automatically adding safe zones to all workcarts. It also prevents damage to those workcarts.
Well.. To fulfill the requested plugin you just need this:
namespace Oxide.Plugins
{
[Info("NoCartDamage", "ThibmoRozier", "1.0.0")]
[Description("Fully disables freightcart damage.")]
public class NoCartDamage : RustPlugin
{
object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
if (entity.ShortPrefabName.Equals("workcart.entity")) // Negate any cart damage
return 0;
return null; // Default behaviour for anything else
}
}
} FYI: Returning a number in that hook does not scale the damage to that number. If you want to scale damage, use something like this (this snippet might have incorrect capitalization): hitInfo.damageTypes.ScaleAll(n).
However, when scaling to 0, you should generally return non-null to prevent the game from processing the hit further, or it will consider the entity attacked and prevent repair (though not exactly an issue here since all damage is prevented so there's nothing to repair).
Also, returning a different non-null value than other plugins will unfortunately result in a hook conflict which will complain in the logs despite the result being the same (Oxide limitation), so the standard is to return true, especially for this hook.
To summarize, simply return true instead of 0.
WhiteThunder
To summarize, simply return true instead of 0.
Ah yes, true, been a while since I tinkered with Oxide/uMod. :D