1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Other Screen Overlay?

Discussion in 'Development' started by Business Radroach, Jun 2, 2019.

  1. Business Radroach

    Business Radroach Clockwork Customer

    Is there a way to make items cause a screen overlay? For example, if I wanted a drug item to cause the screen to be blurry for 5 minutes, would that be possible? Things like blurred vision, color tints, that sort of thing.
     
  2. vexus

    vexus ej rockwell's worst nightmare Staff Member Manager Legend Clockwork Customer

    • Informative Informative x 1
  3. Business Radroach

    Business Radroach Clockwork Customer

  4. Savvyge Investments

    Savvyge Investments Clockwork Customer

    Here is an example of the code to a DRUG mod. When you use a drug it changes your screenspace.

    However Im sure you can interpolate this into something.
    Basically your code will be like

    Function(player, EntityItem)
    onplayeruse(Enable screenspace effect for curtime 5 mins or something. I'm very nooby with coding but can interpret it okay.

    [​IMG]
     
  5. Business Radroach

    Business Radroach Clockwork Customer

    So I'm not entirely sure what to do with these values? I'm not very proficient with lua, so this is kind of a leap in difficulty for me.
     
  6. dead flag blues

    dead flag blues "...ours is a world of nuclear giants..." Clockwork Customer

    Look at the base alcohol scripts in your schema for an example?
     
    Last edited: Jun 3, 2019
  7. Business Radroach

    Business Radroach Clockwork Customer

    Code:
    function Clockwork:RenderScreenspaceEffects()
        if (IsValid(cwClient)) then
            local frameTime = FrameTime();
            local motionBlurs = {
                enabled = true,
                blurTable = {}
            };
            local color = 1;
            local isDrunk = cwPly:GetDrunk();
          
            if (!cwKernel:IsChoosingCharacter()) then
                if (cwLimb:IsActive() and cwEvent:CanRun("blur", "limb_damage")) then
                    local headDamage = cwLimb:GetDamage(HITGROUP_HEAD);
                    motionBlurs.blurTable["health"] = math.Clamp(1 - (headDamage * 0.01), 0, 1);
                elseif (cwClient:Health() <= 75) then
                    if (cwEvent:CanRun("blur", "health")) then
                        motionBlurs.blurTable["health"] = math.Clamp(
                            1 - ((cwClient:GetMaxHealth() - cwClient:Health()) * 0.01), 0, 1
                        );
                    end;
                end;
              
                if (cwClient:Alive()) then
                    color = math.Clamp(color - ((cwClient:GetMaxHealth() - cwClient:Health()) * 0.01), 0, color);
                else
                    color = 0;
                end;
              
                if (cwEvent:CanRun("blur", "isDrunk")) then
                    if (isDrunk and self.DrunkBlur) then
                        self.DrunkBlur = math.Clamp(self.DrunkBlur - (frameTime / 10), math.max(1 - (isDrunk / 8), 0.1), 1);                  
                        DrawMotionBlur(self.DrunkBlur, 1, 0);
                    elseif (self.DrunkBlur and self.DrunkBlur < 1) then
                        self.DrunkBlur = math.Clamp(self.DrunkBlur + (frameTime / 10), 0.1, 1);
                        motionBlurs.blurTable["isDrunk"] = self.DrunkBlur;
                    else
                        self.DrunkBlur = 1;
                    end;
                end;
            end;
          
            if (self.FishEyeTexture and cwClient:WaterLevel() > 2) then
                render.UpdateScreenEffectTexture();
                    self.FishEyeTexture:SetFloat("$envmap", 0);
                    self.FishEyeTexture:SetFloat("$envmaptint",    0);
                    self.FishEyeTexture:SetFloat("$refractamount", 0.1);
                    self.FishEyeTexture:SetInt("$ignorez", 1);
                render.SetMaterial(self.FishEyeTexture);
                render.DrawScreenQuad();
            end;
          
            self.ColorModify["$pp_colour_brightness"] = 0;
            self.ColorModify["$pp_colour_contrast"] = 1;
            self.ColorModify["$pp_colour_colour"] = color;
            self.ColorModify["$pp_colour_addr"] = 0;
            self.ColorModify["$pp_colour_addg"] = 0;
            self.ColorModify["$pp_colour_addb"] = 0;
            self.ColorModify["$pp_colour_mulr"] = 0;
            self.ColorModify["$pp_colour_mulg"] = 0;
            self.ColorModify["$pp_colour_mulb"] = 0;
          
            local systemTable = self.system:FindByID("Color Modify")
            local overrideColorMod = systemTable:GetModifyTable();
    
            if (overrideColorMod and overrideColorMod.enabled) then
                self.ColorModify["$pp_colour_brightness"] = overrideColorMod.brightness;
                self.ColorModify["$pp_colour_contrast"] = overrideColorMod.contrast;
                self.ColorModify["$pp_colour_colour"] = overrideColorMod.color;
                self.ColorModify["$pp_colour_addr"] = overrideColorMod.addr * 0.025;
                self.ColorModify["$pp_colour_addg"] = overrideColorMod.addg * 0.025;
                self.ColorModify["$pp_colour_addb"] = overrideColorMod.addg * 0.025;
                self.ColorModify["$pp_colour_mulr"] = overrideColorMod.mulr * 0.1;
                self.ColorModify["$pp_colour_mulg"] = overrideColorMod.mulg * 0.1;
                self.ColorModify["$pp_colour_mulb"] = overrideColorMod.mulb * 0.1;
            else
                cwPlugin:Call("PlayerSetDefaultColorModify", self.ColorModify);
            end;
          
            cwPlugin:Call("PlayerAdjustColorModify", self.ColorModify);
            cwPlugin:Call("PlayerAdjustMotionBlurs", motionBlurs);
          
            if (motionBlurs.enabled) then
                local addAlpha = nil;
              
                for k, v in pairs(motionBlurs.blurTable) do
                    if (!addAlpha or v < addAlpha) then
                        addAlpha = v;
                    end;
                end;
              
                if (addAlpha) then
                    DrawMotionBlur(math.Clamp(addAlpha, 0.1, 1), 1, 0);
                end;
            end;
          
            --[[
                Hotfix for ColorModify issues on OS X.
            --]]
            if (system.IsOSX()) then
                self.ColorModify["$pp_colour_brightness"] = 0;
                self.ColorModify["$pp_colour_contrast"] = 1;
            end;
          
            DrawColorModify(self.ColorModify);
        end;
    end;
    
    That's what I've found regarding alcohol, but it doesn't mean anything to me. If there's someone that's willing to sit down with me and help me out, that'd be appreciated.
     

Previous Readers (Total: 0)