Jump to content

Stealings from others mod


Recommended Posts

I'm quite new to coding and I was wondering if anyone can help me, I want my mod to work the same way as how a frog works. When in battle with another player they drop the items similar to what a frog does, if anyone can help me with this, it'll be very much appreciated. Thank you!

Link to comment
Share on other sites

if you go to data/databundles unzip script.zip and you can view all the prefabs to see how they work.  quick glance at frog.lua shows
 

inst:AddComponent("thief")

inst.components.combat.onhitotherfn = OnHitOther

local function OnHitOther(inst, other, damage)
    inst.components.thief:StealItem(other)
end

I never done it before but I would imagine you add that to player_common.lua

if you want a weapon that does it you would probably use

inst:AddComponent("thief")

inst.components.weapon:SetOnAttack(OnAttack)

local function OnAttack(inst, owner, target)
    inst.components.thief:StealItem(target)
end

 

Edited by Wolf_EX
Link to comment
Share on other sites

On 06/06/2018 at 5:49 AM, Wolf_EX said:

if you go to data/databundles unzip script.zip and you can view all the prefabs to see how they work.  quick glance at frog.lua shows
 


inst:AddComponent("thief")

inst.components.combat.onhitotherfn = OnHitOther

local function OnHitOther(inst, other, damage)
    inst.components.thief:StealItem(other)
end

I never done it before but I would imagine you add that to player_common.lua

if you want a weapon that does it you would probably use


inst:AddComponent("thief")

inst.components.weapon:SetOnAttack(OnAttack)

local function OnAttack(inst, owner, target)
    inst.components.thief:StealItem(target)
end

 

Hello, it didn't work unfortunately :(

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...