anybody have an idea to extend the repair range(shoot) of the toolgun?????
Extend Garry's Mod toolgun fire range?
Maybe use a raycast?
The hammer hooks don't trigger if the toolgun is too far away, so you might have to watch for mouse clicks and make your own system to handle them.
Give this a try, it uses a raycast as the others mentioned but it doesn't update the toolguns screen or shoot a beam.
private void OnPlayerInput(BasePlayer pl, InputState input)
{
if (pl == null)
return;
if (input.current.buttons == 0)
return;
if (input.IsDown(BUTTON.FIRE_PRIMARY))
{
if (input.IsDown(BUTTON.FIRE_PRIMARY) && !input.WasDown(BUTTON.FIRE_PRIMARY))
{
var item = pl.GetActiveItem();
if (item == null) return;
var dist = 10f;
var ent = EyeTraceToEntity(pl, dist);
var wep = item.GetHeldEntity();
if (ent == null || !(ent is BaseCombatEntity) || wep == null || !(wep is Toolgun)) return;
if (ent.Distance(pl.transform.position) < 2.24f) return; // use normal toolgun repair at shorter distances
BaseCombatEntity target = ent as BaseCombatEntity;
target.DoRepair(pl);
}
}
}
private BaseEntity EyeTraceToEntity(BasePlayer player, float distance)
{
RaycastHit hit;
return Physics.Raycast(new Ray(player.eyes.position, player.eyes.HeadForward()), out hit, distance) ? hit.GetEntity() : null;
} Thanks @Clearshot ill give it a test . but i was hoping to get beam and screen in play aswell....
NooBlet
Thanks @Clearshot ill give it a test . but i was hoping to get beam and screen in play aswell....
Maybe you can trick the toolgun with a fake object that only it can see.
ZugzwangMaybe you can trick the toolgun with a fake object that only it can see.
Or try sending the effect with EffectNetwork.Send or Effect.Run
The effect can definitely be fabricated. But I'm guessing that toolgun screen is client side and would require some shenanigans.