RustTip

OnSiegeWeaponFire

OxidePrimitive
object OnSiegeWeaponFire(Catapult catapult, BasePlayer basePlayer)
object OnSiegeWeaponFire(BatteringRam batteringRam, BasePlayer basePlayer)
Works — the game method in this build is the one the hook was written for.

Parameters

catapult
Catapult
basePlayer
BasePlayer

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 OnSiegeWeaponFire(Catapult catapult, BasePlayer basePlayer)
{
    Puts("OnSiegeWeaponFire");

    // 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 1

Rust.opj (Oxide)
void Catapult.SERVER_WantsFire(BaseEntity.RPCMessage)

Passes: Catapult catapult, BasePlayer basePlayer

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

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

[RPC_Server]
[RPC_Server.MaxDistance(3f)]
public void SERVER_WantsFire(RPCMessage msg)
{
	BasePlayer player = msg.player;
	if (CanFire())
	{
		if (Interface.CallHook("OnSiegeWeaponFire", this, player) != null)
		{
			return;
		}
		float force = reloadProgress;
		Fire(player, force);
		reloadProgress = 0f;
		timeSinceLastFire = 0f;
		FireAnimation();
// …

Injection point 2

Rust.opj (Oxide)
void BatteringRam.SERVER_WantsAttack(BaseEntity.RPCMessage)

Passes: BatteringRam batteringRam, BasePlayer basePlayer

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

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

// …
public void SERVER_WantsAttack(RPCMessage msg)
{
	BasePlayer player = msg.player;
	BasePlayer driver = GetDriver();
	if (driver == null || player == null || driver != player || !CanAttack() || driver.InSafeZone())
	{
		return;
	}
	if (Interface.CallHook("OnSiegeWeaponFire", this, player) != null)
	{
		return;
	}
	ClientRPC(RpcTarget.NetworkGroup("CLIENT_Attack"));
	Invoke(() =>
	{
		ScanEntities(driver);
	}, SwingDelay(2f));
// …

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.