rons0n Posted January 31, 2016 Share Posted January 31, 2016 (edited) How can I make it so if my character has a specific tag to make him immune to any type of healing? Sleeping won't heal HP, Eating won't heal HP, absolutely everything about healing will not effect him whatsoever. *Cough*Then maybe another tag that can heal but only half from the original value. Anything is appreciated! Thank you! Edited January 31, 2016 by rons0n Link to comment Share on other sites More sharing options...
DarkXero Posted January 31, 2016 Share Posted January 31, 2016 1 hour ago, rons0n said: Anything is appreciated! local _DoDelta = inst.components.health.DoDelta inst.components.health.DoDelta = function(self, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) if amount > 0 then if self.inst:HasTag("nohealz") then amount = 0 elseif self.inst:HasTag("halfhealz") then amount = amount * 0.5 end end _DoDelta(self, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) end inside master_postinit. Link to comment Share on other sites More sharing options...
rons0n Posted February 1, 2016 Author Share Posted February 1, 2016 1 hour ago, DarkXero said: local _DoDelta = inst.components.health.DoDelta inst.components.health.DoDelta = function(self, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) if amount > 0 then if self.inst:HasTag("nohealz") then amount = 0 elseif self.inst:HasTag("halfhealz") then amount = amount * 0.5 end end _DoDelta(self, amount, overtime, cause, ignore_invincible, afflicter, ignore_absorb) end inside master_postinit. Much thanks! I wish I knew how mention works with this upgrade to the fourms so I don't have to quote all this. I may have more questions sometine in the future but for now I appreciate all the help! Link to comment Share on other sites More sharing options...
DarkXero Posted February 1, 2016 Share Posted February 1, 2016 14 minutes ago, rons0n said: I wish I knew how mention works with this upgrade to the fourms so I don't have to quote all this. Type the @ then write the name of the guy you want. @rons0n it autocompletes and shows people to click, you don't have to introduce the full name. Link to comment Share on other sites More sharing options...
rons0n Posted February 1, 2016 Author Share Posted February 1, 2016 I felt like my second question doesn't warrant another thread so I decided to post it here: My character transforms by a keyhandler creayed by Kzisor but I don't want people to transform back and fourth freely. Is there a way to give it a time limit? For example: If CharA presses the transform button to be CharB than he must wait atleast 5 days before pressing the transform button to go back to CharA and vice versa. --Transformation Section GLOBAL.TUNING.FRISK = {} GLOBAL.TUNING.FRISK.KEY = GetModConfigData("charakey") or 122 local function CharaFn(inst) if inst:HasTag("playerghost") then return end if inst.transformed then inst.AnimState:SetBuild("frisk") inst.components.locomotor:SetExternalSpeedMultiplier(inst, "frisk_speed_mod", 1.35) inst.components.health.absorb = 0.1 inst.components.combat.damagemultiplier = 0.75 STRINGS.CHARACTERS.FRISK = require "speech_frisk" inst:AddTag("frisk") inst:AddTag("doublehealz") inst:RemoveTag("nohealz") inst:RemoveTag("chara") inst:RemoveTag("scarytoprey") inst:RemoveTag("monster") local x, y, z = inst.Transform:GetWorldPosition() local fx = SpawnPrefab("groundpoundring_fx") fx.Transform:SetPosition(x, y, z) SpawnPrefab("chester_transform_fx").Transform:SetPosition(inst:GetPosition():Get()) else inst.AnimState:SetBuild("chara") inst.components.locomotor:SetExternalSpeedMultiplier(inst, "frisk_speed_mod", 1.35) inst.components.health.absorb = 0.85 inst.components.combat.damagemultiplier = 1.75 STRINGS.CHARACTERS.FRISK = require "speech_chara" inst:RemoveTag("frisk") inst:RemoveTag("doublehealz") inst:AddTag("nohealz") inst:AddTag("chara") inst:AddTag("scarytoprey") inst:AddTag("monster") local x, y, z = inst.Transform:GetWorldPosition() local fx = SpawnPrefab("firering_fx") fx.Transform:SetPosition(x, y, z) SpawnPrefab("statue_transition_2").Transform:SetPosition(inst:GetPosition():Get()) end inst.transformed = not inst.transformed -- inst.components.health:SetCurrentHealth(1) -- inst.components.health:DoDelta(0) return true end AddModRPCHandler("frisk", "CHARA", CharaFn) I joined the Undertale hype a bit late :) Thank you for reading! Link to comment Share on other sites More sharing options...
DarkXero Posted February 1, 2016 Share Posted February 1, 2016 @rons0n local function CharaFn(inst) if inst:HasTag("playerghost") then return end if inst.transform_delay then return end inst.transform_task = inst:DoTaskInTime(inst._cooldown, inst.ResetDelay) inst.transform_delay = GLOBAL.GetTime() + inst._cooldown -- ... end with this, as you transform, you schedule a task for the following 5 days. You also save the time where this task will be performed, which is the current sim time plus the task wait time. As transform_delay holds a value, the if conditional will make the function return and not transform. After 5 days, the ResetDelay makes transform_delay a nil, so you can transform again. After this we only need to setup some functions in the prefab: local function ResetDelay(inst) inst.transform_delay = nil end local function OnSave(inst, data) data.transform_delay = inst.transform_delay end local function OnLoad(inst, data) if data then if data.transform_delay then local time_left = GetTime() - data.transform_delay inst.transform_task = inst:DoTaskInTime(time_left, inst.ResetDelay) inst.transform_delay = data.transform_delay end end end local function master_postinit(inst) inst._cooldown = 5 * TUNING.TOTAL_DAY_TIME inst.ResetDelay = ResetDelay inst.OnSave = OnSave inst.OnLoad = OnLoad end ResetDelay, which makes inst.transform_delay a nil value, so we can transform again. OnSave, which saves the simulation time where the cooldown restarts. OnLoad, which loads the sim time we saved, compares the present sim time with the old one, and restarts the task. inst._cooldown holds the cooldown value, also makes the cooldown accessible from outside the prefab. inst.ResetDelay makes ResetDelay accessible from outside the prefab. Link to comment Share on other sites More sharing options...
rons0n Posted February 1, 2016 Author Share Posted February 1, 2016 (edited) @DarkXero Thanks! Everything seems to be in order! (Hopefully anyway, I tend to botch up the code placement...). Though time seems to reset when you relogin. Dunno where I messed up~ Unrelated, do you know why speeding up time by console won't do anything like it used to? Before, If I had a mod that messed with time, I would do LongUpdate and do my thing respectively. But now it seems like i'm always on Day1 or something even if i go to day 200. Regardless I'm absolutely joyous this character is close to coming into the workshop. I appreciate you speeding up the process! Edited February 1, 2016 by rons0n Link to comment Share on other sites More sharing options...
DarkXero Posted February 1, 2016 Share Posted February 1, 2016 8 hours ago, rons0n said: Unrelated, do you know why speeding up time by console won't do anything like it used to? Before, If I had a mod that messed with time, I would do LongUpdate and do my thing respectively. But now it seems like i'm always on Day1 or something even if i go to day 200. Works fine to me. If you are a client of a dedicated server, remember to have admin privileges and have "Remote: " enabled. If you are a ghost, then you won't age. Link to comment Share on other sites More sharing options...
rons0n Posted February 1, 2016 Author Share Posted February 1, 2016 Yeah I totally forgot that Kzisor's keyhandler component messes with time, my bad.Thanks! Link to comment Share on other sites More sharing options...
rons0n Posted February 1, 2016 Author Share Posted February 1, 2016 (edited) I HAVE NO IDEA HOW THE FORUMS WORK ANYMORE HOW DO YOU USE SPOILER? I'm using pastebin for pasting my code. So lost right now. Basically I used this: http://pastebin.com/vQAqSWw9 And that worked for a good amount. It's suppose to make you 'invisible' until you provoke something but now it doesn't seem to work at all? Or atleast a completely random matter. It's hard to explain. Can someone explain what I did to make this bit of code all finnicky? It worked just fine before. modmain: http://pastebin.com/KMqGHx8P character prefab: http://pastebin.com/M6WMAMZy It looks like I had to add the tags directly into the common postinit to work properly. Which is weird because I didnt have to do that before. Ah well. Edited February 2, 2016 by rons0n Link to comment 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