OnEntityMarkHostile
OxideCarbonEntityCalled when entity mark hostile occurs.
object OnEntityMarkHostile(BaseCombatEntity baseCombatEntity, float duration)
object OnEntityMarkHostile(BasePlayer basePlayer, float duration)Works — the game method in this build is the one the hook was written for.
Parameters
- baseCombatEntity
- BaseCombatEntity
- duration
- float
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnEntityMarkHostile(BaseCombatEntity baseCombatEntity, float duration)
{
Puts("OnEntityMarkHostile");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void BaseCombatEntity.MarkHostileFor(float)
Passes: BaseCombatEntity baseCombatEntity, float duration
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll
Where it is called (this branch's game code)
public virtual void MarkHostileFor(float duration = 60f)
{
if (Interface.CallHook("OnEntityMarkHostile", this, duration) != null)
{
return;
}
float b = Time.realtimeSinceStartup + duration;
unHostileTime = Mathf.Max(unHostileTime, b);
}Injection point 2
Rust.opj (Oxide)
void BasePlayer.MarkHostileFor(float)
Passes: BasePlayer basePlayer, float duration
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll
Where it is called (this branch's game code)
public override void MarkHostileFor(float duration = 60f)
{
if (Interface.CallHook("OnEntityMarkHostile", this, duration) != null)
{
return;
}
if (!IsHostilePaused() && !InSafeCombatZone())
{
duration = Mathf.Max(duration, (float)(State.unHostileTimestamp - TimeEx.currentTimestamp));
SetHostileDuration(duration);
}
// …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.