RustTip

OnCatapultFireForce

OxideCarbonPrimitive

Called when catapult fire force occurs.

object OnCatapultFireForce(Catapult catapult, BasePlayer shooter, object l1 => l1)
Works — the game method in this build is the one the hook was written for.

Parameters

catapult
Catapult
shooter
BasePlayer
l1 => l1
object

Return value

objectThe returned value modifies the result, the game continues.

Example

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

private object OnCatapultFireForce(Catapult catapult, BasePlayer shooter, object l1 => l1)
{
    Puts("OnCatapultFireForce");

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

    // to affect the game:
    // return default(float); // your value instead of the game result
}

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

Injection point

Rust.opj (Oxide)
bool Catapult.Fire(BasePlayer, float)

Passes: Catapult catapult, BasePlayer shooter, object l1 => l1

WorksReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (this,a0,l1 => l1)Assembly-CSharp.dll

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

public bool Fire(BasePlayer shooter, float force)
{
	FireRecoil();
	float num = Mathf.Lerp(2f, 1f, Mathf.Clamp01(force));
	float num2 = Mathf.Lerp(0.5f, 1f, Mathf.Clamp01(force));
	bool flag = true;
	Vector3 firingPos = muzzle.position;
	BasePlayer passenger = GetPassenger();
	Interface.CallHook("OnCatapultFireForce", this, shooter, l1 => l1);
	if (passenger != null)
	{
		passenger.ServerPosition = muzzle.transform.position;
		passenger.Ragdoll(muzzle.transform.forward * (20f * num2) + Vector3.up * (2.5f * num), matchPlayerGravity: false, flailInAir: true, dieOnImpact: true, this);
		return true;
	}
	if (GamePhysics.CheckSphere(muzzle.position, 1f, 1236994833, QueryTriggerInteraction.Ignore))
	{
// …

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.