Jump to content

[SOLVED] Custom blowdart weapon | Infinite uses


Recommended Posts

Hey.

(I have created a few question-topics today. I hope that's ok).

I'm working on making the blowdart into just the tube, which requires ammo to be used. I imagine it is going to be like this:

- On attack > If has ammo > do attack

else do nothing

Problem is that I've been looking through the blowdart.lua file for a while now and I haven't been able to find the thing that removes it on use. Do you know what makes it finite use, and how I could change it into infinite uses?

EDIT:

Making progress. Removing all references to the "projectile" component makes it so the blowdart is not destroyed on use. So now I know where to look.

Next question is: How do I check the player, holding the blowdart,'s inventory for an item?

EDIT2:

I have created the following script

local function pipeattack(inst, attacker, target)
    if not target:IsValid() then
        --target killed or removed in combat damage phase
        return
    end

    if GetPlayer().components.inventory:Has("stinger", 1) then
        if target.components.combat then
            inst.components.weapon:SetDamage(TUNING.PIPE_DART_DAMAGE)
            target.components.combat:SuggestTarget(attacker)
            GetPlayer().components.inventory:RemoveItem("stinger", false)
        end
    else
        inst.components.weapon:SetDamage(0)
        print("No ammo")
    end
end

However, the console says I shouldn't use GetPlayer(). Instead I should use ThePlayer.

When I use ThePlayer it doesn't let me attack any creature at all. When I use GetPlayer() it crashes, saying something went wrong in inventory.lua

The error it gives me is: "848: attempt to index field 'components' (a nil value)". I'm not sure what it means but it seems like it found an item that isn't nil and wants to do something with it. Not sure what I can do to prevent this crash. I am probably doing something wrong with the RemoveItem function.

EDIT3:

I have solved the whole thing. I am using fueled.lua to give the blowdart stingers as ammo.

Link to comment
Share on other sites

3 minutes ago, Soto8969 said:

i dont really know about modding, but i thing the speargun from Shipwreck is a good model for your idea.

Ah, I don't have that DLC :/

However, I'm mostly interested in knowing what makes the blowdart prefab a finite-use prefab.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...