CBuizel Posted June 22, 2015 Share Posted June 22, 2015 I'm trying to create a character (not a robot) that, in contrast to WX78, gains health from rain rather than lose it. I've looked into WX78's lua, but I'm not certain with what I should be looking for. I figured it would be the rainsparks function, but it didn't seem like the one... local function dorainsparks(inst, dt)local mitigates_rain = falsefor k,v in pairs (inst.components.inventory.equipslots) doif v.components.dapperness thenif v.components.dapperness.mitigates_rain thenmitigates_rain = trueendendendif GetSeasonManager() and GetSeasonManager():IsRaining() and not mitigates_rain theninst.spark_time = inst.spark_time - dtif inst.spark_time <= 0 then--GetClock():DoLightningLighting()inst.spark_time = 3+math.random()*2inst.components.health:DoDelta(-.5, false, "rain")local pos = Vector3(inst.Transform:GetWorldPosition())pos.y = pos.y + 1 + math.random()*1.5local spark = SpawnPrefab("sparks")spark.Transform:SetPosition(pos:Get())endendend Basically, what would I have to use to make my character love the rain (gain health from it)? Link to comment https://forums.kleientertainment.com/forums/topic/55567-custom-character-gain-health-while-raining-or-wet/ Share on other sites More sharing options...
Amalleus Posted June 22, 2015 Share Posted June 22, 2015 (edited) One question... Don't you see keywords in the text-code which you attached? =(You want robot to gain health, 154 string does lower health DoDelta(-.5, false, "rain")1. -.5 means lose health by 0.5.2. false as i remember defined to godmod3. why he lost health - because of "rain"What time needed to lose health - read conditions before Edited June 22, 2015 by Amalleus Link to comment https://forums.kleientertainment.com/forums/topic/55567-custom-character-gain-health-while-raining-or-wet/#findComment-649134 Share on other sites More sharing options...
CBuizel Posted June 22, 2015 Author Share Posted June 22, 2015 One question... Don't you see keywords in the text-code which you attached? =(You want robot to gain health, 154 string does lower health DoDelta(-.5, false, "rain")1. -.5 means lose health by 0.5.2. false as i remember defined to godmod3. why he lost health - because of "rain"What time needed to lose health - read conditions beforeOh wow, I need to get a stronger prescription for my glasses xD Thank you for pointing that out, I will test this out... Link to comment https://forums.kleientertainment.com/forums/topic/55567-custom-character-gain-health-while-raining-or-wet/#findComment-649148 Share on other sites More sharing options...
CBuizel Posted June 23, 2015 Author Share Posted June 23, 2015 Actually, I tried inst.components.health:DoDelta(-.5, false, "rain")-- Also tried the belowinst.components.health:DoDelta(-.5, true, "rain")Both did not work. My character didn't care that it was raining at all. No damage taken. There has to be much more code to it than this single line. I'll have to dig deeper... unless somebody can help me out if they know what I should do. Ultimately, I want to also set the movement speed to something greater while raining as well. But first I want to restore health when raining. Link to comment https://forums.kleientertainment.com/forums/topic/55567-custom-character-gain-health-while-raining-or-wet/#findComment-649252 Share on other sites More sharing options...
Amalleus Posted June 23, 2015 Share Posted June 23, 2015 (edited) I didn't tell you that only this string will make your character to always regen or degen health if it is raining. Dude, learn programming, mostly about how code works and about "if else" conditionsAs i told earlier i may repeatinst.components.health:DoDelta(-.5, false, "rain")this string only makes manipulation with health. Right in this one: lower current health of "inst" by -0.5there is no conditions to repeat it again so it will do it once after game starts (if it is not in repeated events) Edited June 23, 2015 by Amalleus Link to comment https://forums.kleientertainment.com/forums/topic/55567-custom-character-gain-health-while-raining-or-wet/#findComment-649316 Share on other sites More sharing options...
CBuizel Posted June 24, 2015 Author Share Posted June 24, 2015 Thanks. I am learning programming; I'm not the best, but I'm learning.I've gotten it to work now and it won't have any visual effects. It'll just regenerate health every second or two while raining.In the charactermod.lua: local function dorainheal(inst, dt) local mitigates_rain = false for k,v in pairs (inst.components.inventory.equipslots) do if v.components.dapperness then if v.components.dapperness.mitigates_rain then mitigates_rain = true end end end if GetSeasonManager() and GetSeasonManager():IsRaining() and not mitigates_rain then inst.heal_time = inst.heal_time - dt if inst.heal_time <= 0 then inst.heal_time = 3+math.random()*2 inst.components.health:DoDelta(0.5, false, "rain") -- Adjust health regen in rain local pos = Vector3(inst.Transform:GetWorldPosition()) pos.y = pos.y + 1 + math.random()*1.5 end endendIn the charactermod.lua, within the "local fn = function(inst)", add these linesinst.heal_time = 3inst:DoPeriodicTask(1/10, function() dorainheal(inst, 1/10) end) Link to comment https://forums.kleientertainment.com/forums/topic/55567-custom-character-gain-health-while-raining-or-wet/#findComment-649446 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