Jump to content

Recommended Posts

local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
    end
end

Hope this helps.

  • Like 1
5 hours ago, yanecc said:
local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
    end
end

Hope this helps.

omg omg tyty

5 hours ago, yanecc said:
local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
    end
end

Hope this helps.

one more question, is this have any visual effect like bone armor shield effect?

5 hours ago, yanecc said:
local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
    end
end

Hope this helps.

one more question, is this have any visual effect like bone armor shield effect?

 

6 hours ago, yanecc said:
local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
    end
end

Hope this helps.

and btw should I just put this into the text directly? like, copy and paste? 

6 hours ago, yanecc said:
local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
    end
end

Hope this helps.

hi i just copy and paste those codes into my character's prefabs lua. the game just crashed, I have no idea how to do this lol

将其放入角色的 master_postinit 函数中

local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
        -- armorskeleton_fx
        local fx = SpawnPrefab("shadow_shield"..tostring(math.random() < .5 and 6 or 3))
        fx.entity:SetParent(self.inst)
        return false
    end
end

 

Edited by yanecc
  • Like 1
13 hours ago, yanecc said:

将其放入角色的 master_postinit 函数中

local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
        -- armorskeleton_fx
        local fx = SpawnPrefab("shadow_shield"..tostring(math.random() < .5 and 6 or 3))
        fx.entity:SetParent(self.inst)
        return false
    end
end

 

:(

 

QQ20241002-145237.png

8 minutes ago, mumuking said:

:(

 

QQ20241002-145237.png

local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
        -- armorskeleton_fx
        local fx = SpawnPrefab("shadow_shield" .. tostring(math.random() < .5 and 6 or 3))
        fx.entity:SetParent(self.inst.entity)
        return false
    end
end

Add .entity

25 minutes ago, yanecc said:
local _GetAttacked = inst.components.combat.GetAttacked
inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, stimuli, spdamage)
    if GetTime() - self.lastwasattackedtime < 5 then
        return _GetAttacked(self, attacker, damage, weapon, stimuli, spdamage)
    else
        self.lastwasattackedtime = GetTime()
        self.inst:PushEvent("blocked", { attacker = attacker })
        -- armorskeleton_fx
        local fx = SpawnPrefab("shadow_shield" .. tostring(math.random() < .5 and 6 or 3))
        fx.entity:SetParent(self.inst.entity)
        return false
    end
end

Add .entity

u r my hero

  • GL Happy 1

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