Jump to content

Recommended Posts

Hello!

I’ve been creating a custom character and recently got stuck at prefabs modding, because I’m new to this.

My character’s default damage multiplier is 1.5, and it becomes 2.0 for 10 seconds after he eats meat (including raw meat, cooked meat and all food made with meat, like meatball) EXCEPT MONSTER MEAT though.

I used whatsmynameagain’s code which works for cave banana. I edited the code, but nothing happend so far in game.

 

 

 

 

Here’s what I did so far:

above master_postinit:

Quote

local function onupdate(inst, dt)
inst.boost_time = inst.boost_time - dt    
if inst.boost_time <= 0 then         
if inst.boost_task ~= nil then             
inst.boost_task:Cancel()            
inst.boost_task = nil        
end        
inst.components.combat.damagemultiplier = 1.5
--change this to your char's default multiplier    
end
end

local function startmeatboost(inst, duration)    
inst.boost_time = 10 
--boost duration in seconds, change it to whatever you want    
if inst.boost_task == nil then        
inst.boost_task = inst:DoPeriodicTask(1, onupdate, nil, 1)
--arguments:(time, fn, delay, fnArguments)        
inst.components.combat.damagemultiplier = inst.boost_mult
--increase the multiplier         
onupdate(inst, 0)
--for avoiding a 1 second delay    
end
end

local function meat(inst, food)    
if inst.components.eater and food.components.edible and food.components.edible.foodtype == FOODTYPE.MEAT then
startmeatboost(inst)    
end
end

 

In master_postinit:

Quote

    -- Damage multiplier
    inst.components.combat.damagemultiplier = 1.5

Quote

    --remove inst.boost_time from here if you have it
    inst.boost_task = nil 
    --leave this nil 
    inst.boost_mult = 2
    --change this to the desired multiplier after eating meat
    inst.components.eater:SetOnEatFn(meat)

 

Any help would be much appreciated!

Edited by AVERY777
typo

I solved it myself somehow.

Quote

if inst.components.eater and food.components.edible and food.components.edible.foodtype == FOODTYPE.MEAT then

I just changed this part to:

Quote

if inst.components.eater and food.components.edible.foodtype == FOODTYPE.MEAT

and not food:HasTag("monstermeat") then

 

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...