mumuking Posted October 1, 2024 Share Posted October 1, 2024 is there any possibility that can make a character have an ability like bone armor "every x second block damage". Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/ Share on other sites More sharing options...
yanecc Posted October 1, 2024 Share Posted October 1, 2024 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. 1 Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751447 Share on other sites More sharing options...
mumuking Posted October 2, 2024 Author Share Posted October 2, 2024 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 Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751468 Share on other sites More sharing options...
mumuking Posted October 2, 2024 Author Share Posted October 2, 2024 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? Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751469 Share on other sites More sharing options...
mumuking Posted October 2, 2024 Author Share Posted October 2, 2024 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? Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751472 Share on other sites More sharing options...
mumuking Posted October 2, 2024 Author Share Posted October 2, 2024 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 Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751474 Share on other sites More sharing options...
yanecc Posted October 2, 2024 Share Posted October 2, 2024 (edited) 将其放入角色的 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 October 2, 2024 by yanecc 1 Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751494 Share on other sites More sharing options...
mumuking Posted October 2, 2024 Author Share Posted October 2, 2024 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 Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751559 Share on other sites More sharing options...
yanecc Posted October 2, 2024 Share Posted October 2, 2024 8 minutes ago, mumuking 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 Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751563 Share on other sites More sharing options...
mumuking Posted October 2, 2024 Author Share Posted October 2, 2024 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 1 Link to comment https://forums.kleientertainment.com/forums/topic/160036-need-help-looking-for-how-to-make-a-character-has-a-perk-like-bone-armor-function/#findComment-1751568 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now