Jump to content

Recommended Posts

Hello again, I am trying to make an edible prefab for an ale that doubles the amount of damage dealt by my character.

Unfortunately it crashes when my character eats it. It says something like: Can't use math problems on a nil value. (at least that was what I understood).

This is the 'problem' code:

 inst.components.edible.oneaten = function(inst, eater)
    if eater.prefab == "skyminer" then
       eater.components.hunger:DoDelta(7)
       eater.components.sanity:DoDelta(-5)
       eater.dwarvenaleresttime = 30 * 6.5
       eater.components.sanity.dapperness = eater.components.sanity.dapperness - TUNING.DAPPERNESS_MED
       eater.components.combat.damagemultiplier = eater.components.combat.damagemultiplier + TUNING.WILSON_DAMAGE_MULT
    end
   if eater.components.inventory ~= nil then
    local item = SpawnPrefab("woodenmug")
    eater.components.inventory:GiveItem(item)
    inst:Remove()
   end     
 end

 

I tried changing the mult into something else but I keep the same problem.

It's weird because the same code works fine within the Witcher Geralt mod.

If someone could tell me what I am doing wrong, that would be very helpful again :)

Many thanks.

 

 

Edited by Eremus007
4 hours ago, zUsername said:

First I didn't see the value of TUNING.WILSON_DAMAGE_MULT in tuning.lua.
Second have you set damagemultiplier and dapperness before Eaten execute ?

Oh, I don't know how I got on that, I set the damagemultiplier in the character prefab to 1 and then it worked.

Of course  if TUNING.WILSON_DAMAGE_MULT doesn't exist then the game can't multiply it...

Well, lesson learned:

Check the tuning file before you do something.

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