Jump to content

Recommended Posts

 

 

 

I was using this code to give weaknesses to the character
But It broke so quickly.
I want to reduce the durability faster than other characters.

I'm sorry that I'm not good at English.
Please help me!

 

AddComponentPostInit("finiteuses", function(self)
self.inst:ListenForEvent("percentusedchange", function(inst, data)
local owner = nil
     if inst.components.inventoryitem then
        owner = inst.components.inventoryitem.owner
     end

     if owner and owner.prefab == "bubs" then
     if math.random() > 0.9 and data.percent > 0.8 then
        inst.components.finiteuses:SetUses(0)

     end

end

end)

end)

 

 

 

Edited by eeung

I'm not sure what exactly you were trying to do, as you set the uses to 0 if a random event occurs, which will break your tool.

If you want to make your character use for example 2 uses instead of one, you can use the component efficientuser.

You can add this to your master postinit of your character:

if inst.components.efficientuser == nil then
	inst:AddComponent("efficientuser")
end
inst.components.efficientuser:AddMultiplier(ACTIONS.CHOP,  2, inst)

This way you will use 2 uses of a axe instead of 1 when chopping. You can add for the other actions you want to make inefficient.

@Thomas Die inst is good there, as inst is defined in the listenforevent function. You could also use self.inst, but it wouldn't make a difference.

3 hours ago, Monti18 said:

무작위 이벤트가 발생하면 용도를 0으로 설정하여 도구가 손상될 수 있으므로 정확히 무엇을 하려고 했는지 잘 모르겠습니다.

예를 들어 캐릭터가 한 번 대신 두 번 사용하게 하려면 효율적인 사용자 컴포넌트를 사용할 수 있습니다.

이것을 캐릭터의 마스터 postinit에 추가할 수 있습니다.


  
  

이렇게 하면 도끼를 자를 때 1번 대신 2번 도끼를 사용하게 됩니다. 비효율적으로 만들려는 다른 작업을 추가할 수 있습니다.

@토마스 다이 inst가 listenforevent 함수에 정의되어 있으므로 inst가 좋습니다. self.inst를 사용할 수도 있지만 차이는 없습니다.

I tried to make a character that quickly cuts down the durability of the tool or breaks the tool well.
But the tool broke so easily that it was inconvenient.
So I wanted to make it twice as durable as others. Thank you for your help!

4 hours ago, Thomas Die said:

inst는 self.inst여야 한다고 생각합니다.

Thank you for your help!♡

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
×
  • Create New...