Jump to content

Recommended Posts

Hello fellow gamers

I've been trying to make a custom character that can generate an invuln shield like thulecite crown with a chance on being hit, below is my code

local function OnAttacked(inst, data)
    if math.random(1,100)<=30 then
        local fx = SpawnPrefab("forcefieldfx")
        fx.entity:SetParent(inst.entity)
        fx.Transform:SetPosition(0, 0.2, 0)
        local fx_hitanim = function()
            fx.AnimState:PlayAnimation("hit")
            fx.AnimState:PushAnimation("idle_loop")
        end
        fx:ListenForEvent("blocked", fx_hitanim, inst)

        if not inst.components.health:IsDead() then
        inst.components.health:SetInvincible(true)
        end

        inst.active = true

        inst:DoTaskInTime(--[[Duration]] TUNING.ARMOR_RUINSHAT_DURATION, function()
            fx:RemoveEventCallback("blocked", fx_hitanim, inst)
            fx.kill_fx(fx)
        inst.components.health:SetInvincible(false)
            if inst:IsValid() then
                inst.active=false
            end
        end)
    end
end

This currently doens't work in game based on my tests, can any modders figure out what is wrong?

Link to comment
https://forums.kleientertainment.com/forums/topic/171572-dst-modding-question/
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
×
  • Create New...