Jump to content

Need help with custom character abilities.


Recommended Posts

Hello! I am making a mod for Chat Noir from Miraculous Ladybug, and I've finished all of the art and coding aside from specific character abilities. If somebody could, would you be awfully kind in helping me figure out how to make him weak to rain, see in the dark(if possible?), and able to poison, similar to the sans mod here? https://steamcommunity.com/sharedfiles/filedetails/?id=559804807

Link to comment
Share on other sites

local function SetBeaverVision(inst, enable) if enable then inst.components.playervision:ForceNightVision(true) inst.components.playervision:SetCustomCCTable(BEAVERVISION_COLOURCUBES) else inst.components.playervision:ForceNightVision(false) inst.components.playervision:SetCustomCCTable(nil) end end
 
How would this be changed(if this is the correct sequence) to be able to incorporate night vision into a character ability?
 
Link to comment
Share on other sites

Is there anything calling those functions? Before you can worry about whats in them, you have to find a way to call them when its dark/bright respectively so they will run. Where are those functions from? Can you figure out what's calling them?

Maybe you could use an event listener to call them. I happen to remember an event listener I used in one of my old mods for a character when entering the dark.

inst:ListenForEvent("enterdark", function(inst) 
	--you can put the code you want to run in here--
	inst.entity:AddLight()  --like probably this, 
	--and the rest of whatever was in that function
end)

You can put that in the master_postinit of your character. Whatever is inside of it will run every time your character enters full darkness.

I remember that "enterdark" is the event name for entering darkness, but I don't remember the event name for leaving darkness. I'm sure there is one though.

Link to comment
Share on other sites

Nightvision has to be run inside of common_postinit.

local NIGHTVISION_COLOURCUBES =
{
    day = "images/colour_cubes/ruins_light_cc.tex",
    dusk = "images/colour_cubes/ruins_dim_cc.tex",
    night = "images/colour_cubes/purple_moon_cc.tex",
    full_moon = "images/colour_cubes/purple_moon_cc.tex",
}

local function SetNightVision(inst, enable) --This should be obvious
    if TheWorld.state.isnight or TheWorld:HasTag("cave") then
        inst.components.playervision:ForceNightVision(true)
        inst.components.playervision:SetCustomCCTable(NIGHTVISION_COLOURCUBES)
    else
        inst.components.playervision:ForceNightVision(false)
        inst.components.playervision:SetCustomCCTable(nil)
    end
end

--In common_postinit
	inst:WatchWorldState( "isday", function() SetNightVision(inst) end)
  	inst:WatchWorldState( "isdusk", function() SetNightVision(inst) end)
  	inst:WatchWorldState( "isnight", function() SetNightVision(inst)  end)
	inst:WatchWorldState( "iscaveday", function() SetNightVision(inst) end)
  	inst:WatchWorldState( "iscavedusk", function() SetNightVision(inst) end)
  	inst:WatchWorldState( "iscavenight", function() SetNightVision(inst)  end)
	
	SetNightVision(inst) --This is here to make sure the NightVision is enabled when a player rejoins.

This is the code I use in my mod. I'm sure theres a better way to WatchWorldState bit, but it'll work.

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