1. Calytic

    Calytic Community Admin Community Mod

    Alrighty guys, I'm working on a fairly extensive skill system and now I'm at First Aid, or the Medicine skill.

    I currently have 3 problems.

    Firstly, I discovered it was possible to use a Syringe or Bandage on another player and I do not know how to read the target data to attribute a healing bonus.

    Secondly, I am currently intercepting syringe/bandage usage through OnPlayerInput. This is very expensive given the OnPlayerInput tick rate.

    Given the second problem, I cannot detect when a syringe is used, only when it is attempted. With a stack server this means that using a single syringe consumes it from the actionbar and the remaining syringe cannot be used until I switch away and then back to that actionbar item.

    Thanks!
     
  2. Have you had a try with the 'OnConsumableUse(Item item)' hook? Can't check right now if it able to capture the syringe/bandage effect and not entirely sure if it triggers you can get both the user & target. If that doesn't do the trick we could look into adding a hook for this but not sure when exactly I'll be able to do that.

    Can't really give an answer to the second problem regarding the stacks, I'd have to look at the Assembly-CSharp to see if I can find something for that.
     
  3. Calytic

    Calytic Community Admin Community Mod

    I can fix the problem regarding stacks provided I can auto re-equip the item.

    I have figured out how to UNEQUIP using the following code:

    Code:
    healingitem.item.GetHeldEntity().GetComponent("HeldEntity").SetHeld(false);
    How do I RE-EQUIP?
    [DOUBLEPOST=1430909106][/DOUBLEPOST]OnConsumableUse(Item item) does not intercept Syringes or Bandages AFAIK.
    [DOUBLEPOST=1430909342][/DOUBLEPOST]
    The target appears to be a passthru variable in SyringeWeapon : BaseMelee @ InjectedSelf(RPCMessage) /InjectedOther(RPCMessage) / GiveEffectsTo(BasePlayer). I do not see any hook related code.
     
  4. Did you try SetHeld(true)? :)

    I've added OnHealingItemUse as a hook to the attached Assembly-CSharp.dll, I still need to run some tests (currently unable to do so) but it should trigger on a bandage/syringe being used.
    Code:
    OnHealingItemUse(HeldEntity ent, BasePlayer target)
    Returning anything else than null will cancel the normal behavior.
     
  5. Calytic

    Calytic Community Admin Community Mod

    Yes, that does nothing. I assume that is because when I SetHeld false that the item is no longer available through GetHeldEntity. I have not confirmed that and have yet to find any way to do it. It is not a problem anymore as simply un-equiping was enough. I am now tracking the amounts of syringes/bandages in the stack and only applying bonuses when the amounts change.

    Thank you so much! This is a great addition to oxide.
     
  6. I still have to add the hook to Oxide itself though. Haven't had the time for it yet.