Alkaiser Posted January 21, 2017 Share Posted January 21, 2017 (edited) Hey, everyone! I'm trying to figure out how to code a character trait that causes their attack multiplier to scale UP directly with their Wetness meter (to a maximum of 2x), while causing their damage reduction to scale DOWN (so they'd take double damage at max). The effect being similar to Wolfgang's strength percentage increasing directly relevant to his hunger percentage. As a side note, is there a way to make a light source that only shines in a cone? I'm trying to make a flashlight. (EDIT: Forget the flashlight, I just found a file on the forums that someone else looks to have put a lot of work in to create.) Edited January 21, 2017 by Alkaiser Link to comment Share on other sites More sharing options...
CarlZalph Posted January 21, 2017 Share Posted January 21, 2017 (edited) 1 hour ago, Alkaiser said: I'm trying to figure out how to code a character trait that causes their attack multiplier to scale UP directly with their Wetness meter (to a maximum of 2x), while causing their damage reduction to scale DOWN (so they'd take double damage at max). The effect being similar to Wolfgang's strength percentage increasing directly relevant to his hunger percentage. AddPrefabPostInit( "wilson", function(inst) if GLOBAL.TheWorld.ismastersim then if ( inst.components.health and inst.components.health.DoDelta and inst.components.combat and inst.components.moisture ) then local moisturePercent_Scaled = 1.0 inst:ListenForEvent( "moisturedelta", function(inst, data) moisturePercent_Scaled = 1.0 + inst.components.moisture.moisture/inst.components.moisture.maxmoisture inst.components.combat.damagemultiplier = moisturePercent_Scaled end ) local DoDelta_old = inst.components.health.DoDelta inst.components.health.DoDelta = function(self, amount, ...) DoDelta_old(self, moisturePercent_Scaled*amount, ...) end end end end ) Tested on both a full shard and listen server setups. 1 hour ago, Alkaiser said: As a side note, is there a way to make a light source that only shines in a cone? I'm trying to make a flashlight. (EDIT: Forget the flashlight, I just found a file on the forums that someone else looks to have put a lot of work in to create.) Behold, maths! Edited January 21, 2017 by CarlZalph Tested. Link to comment Share on other sites More sharing options...
Alkaiser Posted January 21, 2017 Author Share Posted January 21, 2017 Thank you, sir! 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