Jump to content

Help With Rain/wetness Damage


Recommended Posts

I've been working on a DST character mod and One of their Cons is supposed to be Massive rain/wet damage (Taking damage from the rain/wetness, like 10 damage per second) Would anyone know what i'd have to put where. I tired searching for WX-78s Codes and stuff But I couldn't find them. Please help.

Link to comment
Share on other sites

That's how the 'speed bonus' is done for WX-78.

inst:DoPeriodicTask(1, onupdate, nil, 1)

OnUpdate function is called every second, and reduces 'overcharge counter' by 1.

As for your character, there is a built in 'components/moisture' component.

So in your case I would probably (that's if you modify an existing character tho):

AddPrefabPostInit("MyCharacter", AddMyCharacterPostInit)

get inst.components.wetness and then modify it in the following way:

local AddMyCharacterPostInit = function(inst)
  local old_on_update = inst.components.moisture.OnUpdate
  local new_on_update = function(inst, dt)
      old_on_update(inst,dt)
      -- .. your code here
      -- inst.moisture will give you current wetness level
  end
  inst.components.moisture.OnUpdate = new_on_update
end

 

Point is, you do not need to put any functions inside your very character, you just need to modify his moisture component. And only HIS moisture component :p

Edited by IvanX
Link to comment
Share on other sites

In exactly YOUR case, add the code into the master_postinit

local master_postinit = function(inst)  
  local old_on_update = inst.components.moisture.OnUpdate
  local new_on_update = function(inst, dt)
      old_on_update(inst,dt)
      -- .. your code here
      -- inst.moisture will give you current wetness level
  end
  inst.components.moisture.OnUpdate = new_on_update
end

 

Edited by IvanX
Link to comment
Share on other sites

4 hours ago, IvanX said:

In exactly YOUR case, add the code into the master_postinit


local master_postinit = function(inst)  
  local old_on_update = inst.components.moisture.OnUpdate
  local new_on_update = function(inst, dt)
      old_on_update(inst,dt)
      -- .. your code here
      -- inst.moisture will give you current wetness level
  end
  inst.components.moisture.OnUpdate = new_on_update
end

I really do appreciate the help, but I don't quite understand what you mean by "adding code into the master_oistinit"

Im a bit new to the whole coding stuff....

 

Link to comment
Share on other sites

your character prefab will have this function, because it's one of the functions required to actually create a prefab.

Look at the last line of "prefabs/wx78.lua" or any other character prefabs:

Quote

return MakePlayerCharacter("wx78", prefabs, assets, common_postinit, master_postinit)

Thus  i just brought up the piece of code required to modify moisture for your character, but master_postinit may still have 999 more modifications

 

P.S. Just knock me on steam, ivanxru, I'd rather keep the entire conversation in here as the reference, but I'm not sitting here all day refreshing every 1 min :) So you can just ask your question and knock-knock

Edited by IvanX
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...