Jump to content

Recommended Posts

24 minutes ago, CarlZalph said:

Listen for the onequip/onunequip events from the hat and then apply the colour cube to the owner if it's a player.

You can find pretty much all of this code with the moggles hat alone.

Quote

local SHOOTVISION_COLOURCUBES =
{
    day = "images/colour_cubes/shooting_goggles_cc.tex",
    dusk = "images/colour_cubes/shooting_goggles_cc.tex",
    night = "images/colour_cubes/shooting_goggles_cc.tex",
    full_moon = "images/colour_cubes/purple_moon_cc",
}

local function SetShootVision(inst, enable)
    if enable then
        --inst.components.playervision:ForceNightVision(true)
        inst.components.playervision:SetCustomCCTable(SHOOTVISION_COLOURCUBES)
    else
        --inst.components.playervision:ForceNightVision(false)
        inst.components.playervision:SetCustomCCTable(nil)
    end
end

local function onequip(inst, owner)
    SetShootVision(owner, true)
    goggletalk(inst)
    owner.AnimState:OverrideSymbol("swap_hat", "hat_gogglesshoot", "swap_hat")
    owner.AnimState:Show("HAT")
    --if TheWorld and TheWorld.components.colourcube then
        --TheWorld.components.colourcube:SetOverrideColourCube("images/colour_cubes/shooting_goggles_cc.tex", .25)
    --end

    if owner:HasTag("wagstaff_inventor") then
        inst.components.weapon:CanRangedAttack(function() return true end)
        --inst.components.weapon:SetProjectile("fryfocals_charge")
    else
        --inst.components.weapon:SetProjectile()
       inst.components.weapon:CanRangedAttack(function() return false end)
    end
end

local function onunequip(inst, owner)
    SetShootVision(owner, false)
    owner.AnimState:ClearOverrideSymbol("swap_hat")
    owner.AnimState:Hide("HAT")
    --if TheWorld and TheWorld.components.colourcube then
        --TheWorld.components.colourcubemanager:SetOverrideColourCube(nil, .5)
    --end        
end

I have this code but whenever I equip said item I freeze and crash instantly.
 

Quote

[00:01:42]: Assert failure 'dest != INVALID_RESOURCE_HANDLE' at ..\source\game\components\PostProcessorComponent.cpp(31): Trace follows...

This is what I find in the client_log.txt, what does it mean?

I meant that "Trace follows..." it said, but apparently the trace didn't follow xD

That's where it broke. What I wanted to know was the stacktrace. Which function was fired tracing all the way to the call that caused the crash. But apparently, we can't have nice things.

I don't know enough about the engine to solve that one.

2 hours ago, Ultroman said:

That's where it broke. What I wanted to know was the stacktrace. Which function was fired tracing all the way to the call that caused the crash. But apparently, we can't have nice things.

I don't know enough about the engine to solve that one.

I think this is caused from the mod not having the image loaded into its assets and the game trying to use said asset as if it were loaded already.

 

@Omaremad74

I see you have "images/colour_cubes/purple_moon_cc" in there without the ".tex" at the end.  Perhaps this is the culprit, as every other colourcube in the playervision component also has the ".tex" suffix for all of its images.

Just now, CarlZalph said:

I think this is caused from the mod not having the image loaded into its assets and the game trying to use said asset as if it were loaded already.

 

@Omaremad74

I see you have "images/colour_cubes/purple_moon_cc" in there without the ".tex" at the end.  Perhaps this is the culprit, as every other colourcube in the playervision component also has the ".tex" suffix for all of its images.

I tried it but it's still the same error.

2 minutes ago, Omaremad74 said:

I tried it but it's still the same error.

Well, to limit to see whether or not it's the custom colourcube images not being loaded properly, could you try re-using some base game colourcube paths?

local SHOOTVISION_COLOURCUBES =
{
    day = "images/colour_cubes/mole_vision_off_cc.tex",
    dusk = "images/colour_cubes/mole_vision_on_cc.tex",
    night = "images/colour_cubes/mole_vision_on_cc.tex",
    full_moon = "images/colour_cubes/mole_vision_off_cc.tex",
}

 

Just now, CarlZalph said:

Well, to limit to see whether or not it's the custom colourcube images not being loaded properly, could you try re-using some base game colourcube paths?


local SHOOTVISION_COLOURCUBES =
{
    day = "images/colour_cubes/mole_vision_off_cc.tex",
    dusk = "images/colour_cubes/mole_vision_on_cc.tex",
    night = "images/colour_cubes/mole_vision_on_cc.tex",
    full_moon = "images/colour_cubes/mole_vision_off_cc.tex",
}

 

Hmm so it's something with the custom colour cubes...

Screenshot (63).png
I will see what I can do to fix the colour cubes.

1 minute ago, CarlZalph said:

[snip[

This is the code used in DS for it
 

Quote

local function shoot_onequip(inst, owner)
        onequip(inst, owner)
        if GetWorld() and GetWorld().components.colourcubemanager then
            GetWorld().components.colourcubemanager:SetOverrideColourCube("images/colour_cubes/shooting_goggles_cc.tex", .25)
        end

        if owner:HasTag("wagstaff_inventor") then
            inst.components.weapon:SetCanAttack(function() return true end)
            --inst.components.weapon:SetProjectile("fryfocals_charge")
        else
            --inst.components.weapon:SetProjectile()
            inst.components.weapon:SetCanAttack(function() return false end)
        end
    end

But ofc colourcubemanager doesn't exist and theres no function called SetOverrideColourCube in the colourcube component. Although Now im wondering is there a function that does almost this Or Do I have to do something completely different?

Edited by Omaremad74
16 minutes ago, Omaremad74 said:

But ofc colourcubemanager doesn't exist and theres no function called SetOverrideColourCube in the colourcube component. Although Now im wondering is there a function that does almost this Or Do I have to do something completely different?

Ultimately the functions go to using: PostProcessor:SetColourCubeData

After doing a small test I'm thinking the colourcube images are only loaded from the game's core directory rather than from mods to have the PostProcessor able to use them.

The SetOverrideColourCube is just a workaround Klei used to force a specific colourcube that doesn't change by normal game behaviour like the time of day and such.

You can simulate it by hooking this PostProcessor function and then having it return your static if the goggles are on or to use the default if they are not.

For an example on how to do something like this, see (hook getmetatable(PostProcessor).__index.SetColourCubeData):

 

Good luck to you with your port here, I'm going to get some rest.

Edited by CarlZalph

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