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.
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?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); } }
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
OnEntityTakeDamage also for structures and deployables
Discussion in 'Rust Development' started by ttrism, Apr 26, 2016.
-
Try to broadcast to chat in the OnEntityTakeDamage() and fire at a building to see if it triggers it.
-
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.
-
If you are the only one in the server you will be allright.
-
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 -
Guess thats the decay then.
-
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!
-
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. }
-
-
Code:if(entity is BasePlayer) // handle player damage else if (entity is BuildingBlock) // handle building block damage else // etc
Code:if(entity.LookupShortPrefabName() == "campfire.prefab") // handle campfire damage