1. I am using Weapon Damage Scaler for Rust | Oxide by Shady to also scale up melee weapons for my medieval server. It works fine on wooden doors but not on foundations, walls or high external walls etc.

    Here is a snippet taken from the plugin.

    Code:
    void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
            {
                if (entity == null || hitInfo == null || hitInfo?.Initiator == null) return;            if (hitInfo?.Initiator is BasePlayer)
                {
                    if ((bool)Config["UseGlobalDamageScaler"])
                    {
                        hitInfo.damageTypes.ScaleAll(float.Parse(Config["GlobalDamageScaler"].ToString()));
                        return;
                    }
                    if ((bool)Config["PlayersOnly"])
                    {
                        if (entity is BasePlayer)
                            if (entity as BasePlayer != null || hitInfo != null)
                                ScaleDealtDamage(hitInfo);
                        return;
                    }
                    else ScaleDealtDamage(hitInfo);
                }
            }private void ScaleDealtDamage(HitInfo hitInfo)
            {
                string bodypart = StringPool.Get(hitInfo.HitBone) ?? string.Empty;
                if (string.IsNullOrEmpty(bodypart)) return;            float ammoMod = 1.0f;            BaseProjectile heldWeapon = hitInfo?.Weapon?.GetItem()?.GetHeldEntity() as BaseProjectile ?? null;
                if (heldWeapon != null)
                    if (weaponData.AmmoTypes.ContainsKey(heldWeapon.primaryMagazine?.ammoType?.shortname))
                        ammoMod = weaponData.AmmoTypes[heldWeapon.primaryMagazine?.ammoType?.shortname];            string weapon = hitInfo?.Weapon?.GetItem()?.info?.shortname ?? string.Empty;
                if (string.IsNullOrEmpty(weapon)) return;            if (InList(weapon, bodypart))
                {
                    float globalMod = weaponData.Weapons[weapon].GlobalModifier;
                    float individualMod = weaponData.Weapons[weapon].IndividualParts[bodypart];
                    float totalMod = (globalMod + individualMod + ammoMod) / 3;
                    if (totalMod != 1.0f)
                        hitInfo.damageTypes.ScaleAll(totalMod);
                }
            }
    I think the OnEntityTakeDamage() method does not count for structures like foundations, walls or deployables like high externals. Is there a hook to fix this?

    edit: I added ScaleDealtDamage() because actually the else statement "else ScaleDealtDamage(hitInfo);" is triggered since in my config "UseGlobalDamageScaler" and "PlayersOnly" is false

    edit2: Problem seems to be in ScaleDealtDamage() at

    string bodypart = StringPool.Get(hitInfo.HitBone) ?? string.Empty;
    if (string.IsNullOrEmpty(bodypart)) return;

    Strangely the wooden door is treated as a bone, thats why the damage scales. But walls and such obviously does not count as Bone. So is there something like hitInfo.HitEntity or hitInfo.HitStructure
     
    Last edited by a moderator: Apr 26, 2016
  2. Try to broadcast to chat in the OnEntityTakeDamage() and fire at a building to see if it triggers it.
     
  3. If you have a empty onentitytakedamage with a broadcast it will fire like a hundred times a second lol. It does catch everything but you need to filter for what you want.
     
  4. If you are the only one in the server you will be allright.
     
  5. It fires constantly on my test server and I'm the only one on there. You need to filter for a player doing the damage ,just check for hitinfo.Initiator is BasePlayer and you'll be fine
     
    Last edited by a moderator: Apr 26, 2016
  6. Guess thats the decay then.
     
  7. I'll take a look into this, shouldn't be hard to change/fix. For future reference, since you seem to be specifically talking about the plugin, you should probably try posting in it's thread!
     
  8. I did entitys like this:
    Code:
    BuildingBlock buildingBlock = entity.GetComponent<BuildingBlock>();
    if(hitinfo.Initiator is BasePlayer && entity == buildingBlock)
    {
    Do stuff if it is a building block(wall, foundation, ceiling, etc)
    }
    else
    {
    Do stuff if not a building block.
    }
    This should work with most objects.
     
  9. would be awesome! I know, but I figured here in the forums there are more people contributing (and faster) as when I post it in the plugin thread
     
  10. The BaseCombatEntity entity passed into OnEntityTakeDamage is the entity which is receiving damage - you don't need to get it from the HitInfo. You can check its type with conditions such as:
    Code:
    if(entity is BasePlayer)
        // handle player damage
    else if (entity is BuildingBlock)
        // handle building block damage
    else
        // etc
    Or you can even check for specific items by using prefab ID:
    Code:
    if(entity.LookupShortPrefabName() == "campfire.prefab")
        // handle campfire damage