RustTip

IOnBaseCombatEntityHurt

OxideEntity
object IOnBaseCombatEntityHurt(BaseCombatEntity baseCombatEntity, HitInfo info)
Works — the game method in this build is the one the hook was written for.

Parameters

baseCombatEntity
BaseCombatEntity
info
HitInfo

Return value

objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.

Example

object — you can affect the game: return a value to change or cancel the action.

private object IOnBaseCombatEntityHurt(BaseCombatEntity baseCombatEntity, HitInfo info)
{
    Puts("IOnBaseCombatEntityHurt");

    // change nothing — the game continues as usual
    return null;

    // to affect the game:
    // return null; // null — the game continues as usual
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
void BaseCombatEntity.Hurt(HitInfo)

Passes: BaseCombatEntity baseCombatEntity, HitInfo info

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a0)Assembly-CSharp.dll

Where it is called (this branch's game code)

// …
		num2 = ((!num3 || !(flag | flag2)) ? ConVar.Server.paintballstandarddamage : (30f * ConVar.Server.paintballoverallsdamage));
	}
	else
	{
		num2 = 0f;
	}
	info.damageTypes.Scale(DamageType.Paintball, num2);
}
if (Interface.CallHook("IOnBaseCombatEntityHurt", this, info) != null)
{
	return;
}
DebugHurt(info);
float num4 = info.damageTypes.Total();
health = num - num4;
SendNetworkUpdate();
LogEntry(RustLog.EntryType.Combat, 2, "hurt {0}/{1} - {2} health left", info.damageTypes.GetMajorityDamageType(), num4, health);
// …

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.