Pop Guy Posted January 22 Share Posted January 22 I've tried everything, but there's no way to stop Wilson from doing 100% of his damage to walls every time. I don't understand why they seem to completely ignore any attempts to equip them with armor; I'm exhausted, 3 hours of inconclusive attempts. Here's the latest version of the code I tried to implement in the mod's modmain, if any kind soul can tell me what I'm doing wrong... --========================= -- WALLS ARMOR --========================= local REDUCTION = 0.75 local REMAIN = 1 - REDUCTION local function IsWall(inst) return inst ~= nil and inst:HasTag("wall") end AddComponentPostInit("health", function(self) if self.inst == nil or not IsWall(self.inst) then return end if not TheWorld.ismastersim then return end local oldDoDelta = self.DoDelta function self:DoDelta(delta, ...) if delta < 0 then delta = delta * REMAIN end return oldDoDelta(self, delta, ...) end end) AddComponentPostInit("workable", function(self) if self.inst == nil or not IsWall(self.inst) then return end if not TheWorld.ismastersim then return end local oldWorkedBy = self.WorkedBy function self:WorkedBy(worker, work, ...) return oldWorkedBy(self, worker, work * REMAIN, ...) end end) Link to comment https://forums.kleientertainment.com/forums/topic/169595-how-do-you-give-walls-in-the-game-natural-armor-that-absorbs-75-of-incoming-damage/ Share on other sites More sharing options...
Jakepeng99 Posted January 22 Share Posted January 22 22 minutes ago, Pop Guy said: I've tried everything, but there's no way to stop Wilson from doing 100% of his damage to walls every time. I don't understand why they seem to completely ignore any attempts to equip them with armor; I'm exhausted, 3 hours of inconclusive attempts. Here's the latest version of the code I tried to implement in the mod's modmain, if any kind soul can tell me what I'm doing wrong... --========================= -- WALLS ARMOR --========================= local REDUCTION = 0.75 local REMAIN = 1 - REDUCTION local function IsWall(inst) return inst ~= nil and inst:HasTag("wall") end AddComponentPostInit("health", function(self) if self.inst == nil or not IsWall(self.inst) then return end if not TheWorld.ismastersim then return end local oldDoDelta = self.DoDelta function self:DoDelta(delta, ...) if delta < 0 then delta = delta * REMAIN end return oldDoDelta(self, delta, ...) end end) AddComponentPostInit("workable", function(self) if self.inst == nil or not IsWall(self.inst) then return end if not TheWorld.ismastersim then return end local oldWorkedBy = self.WorkedBy function self:WorkedBy(worker, work, ...) return oldWorkedBy(self, worker, work * REMAIN, ...) end end) I don’t know anything about the dst code, but look at the moon stone walls. They have damage reduction specifically against players. Link to comment https://forums.kleientertainment.com/forums/topic/169595-how-do-you-give-walls-in-the-game-natural-armor-that-absorbs-75-of-incoming-damage/#findComment-1849684 Share on other sites More sharing options...
wormwood123 Posted January 22 Share Posted January 22 43 minutes ago, Jakepeng99 said: They have damage reduction specifically against players. That explains a lot… Link to comment https://forums.kleientertainment.com/forums/topic/169595-how-do-you-give-walls-in-the-game-natural-armor-that-absorbs-75-of-incoming-damage/#findComment-1849688 Share on other sites More sharing options...
Pop Guy Posted January 23 Author Share Posted January 23 Update: I tried increasing the health of the walls instead of giving them armor, but now the game gets stuck in an infinite launch and the log fails to give me any information about the problem, damn it! --========================= -- WALLS ARMOR --========================= local MOD_WALLDATA = { { name = "wall_hay", maxhealth = 400, maxwork = 3, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 4, }, { name = "wall_wood", maxhealth = 800, maxwork = 4, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 4, }, { name = "wall_stone", maxhealth = 1600, maxwork = 5, playerdamagemod = TUNING.MOONROCKWALL_PLAYERDAMAGEMOD, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 4, }, { name = "wall_stone_2", maxhealth = 1600, maxwork = 5, playerdamagemod = TUNING.MOONROCKWALL_PLAYERDAMAGEMOD, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 4, }, { name = "wall_moonrock", maxhealth = 3200, maxwork = 6, playerdamagemod = TUNING.MOONROCKWALL_PLAYERDAMAGEMOD, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 5.3, }, { name = "wall_scrap", maxhealth = 3200, maxwork = 6, playerdamagemod = TUNING.SCRAPWALL_PLAYERDAMAGEMOD, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 5.3, }, { name = "wall_ruins", maxhealth = 6400, maxwork = 7, playerdamagemod = TUNING.DREADSTONEWALL_PLAYERDAMAGEMOD, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 8, }, { name = "wall_ruins_2", maxhealth = 6400, maxwork = 7, playerdamagemod = TUNING.DREADSTONEWALL_PLAYERDAMAGEMOD, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 8, }, { name = "wall_dreadstone", maxhealth = 12800, maxwork = 8, playerdamagemod = TUNING.DREADSTONEWALL_PLAYERDAMAGEMOD, repairhealth = TUNING.REPAIR_DREADSTONE_HEALTH * 16, }, } local function ApplyModWallData(inst, data) if not TheWorld.ismastersim then return end if inst.custom_walldata_applied then return end inst:DoTaskInTime(0.05, function() local ok, err = pcall(function() inst.custom_walldata_applied = true -- HEALTH if data.maxhealth and inst.components.health then inst.components.health:SetMaxHealth(data.maxhealth) if inst.components.health.currenthealth == inst.components.health.maxhealth then inst.components.health:SetCurrentHealth(data.maxhealth * 0.5) end end -- WORKABLE (hammer) if data.maxwork and inst.components.workable then inst.components.workable:SetWorkLeft(data.maxwork) end -- REPAIR VALUE if data.repairhealth and inst.components.repairable then inst.components.repairable.healthrepairvalue = data.repairhealth end end) end) end for _, v in ipairs(MOD_WALLDATA) do AddPrefabPostInit(v.name, function(inst) ApplyModWallData(inst, v) end) end Link to comment https://forums.kleientertainment.com/forums/topic/169595-how-do-you-give-walls-in-the-game-natural-armor-that-absorbs-75-of-incoming-damage/#findComment-1849790 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