Ramrodiger Posted August 18, 2015 Share Posted August 18, 2015 I'd like to reduce mighty hunger slightly and increase it just slightly when wimpy. I'm trying to make sense of the following code and am wondering if anyone has any quick tips. Would be greatly appreciated.local function applymightiness(inst) local percent = inst.components.hunger:GetPercent() local damage_mult = TUNING.WOLFGANG_ATTACKMULT_NORMAL local hunger_rate = TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL local health_max = TUNING.WOLFGANG_HEALTH_NORMAL local scale = 1 local mighty_scale = 2.5 local wimpy_scale = .9 if inst.strength == "mighty" then local mighty_start = (TUNING.WOLFGANG_START_MIGHTY_THRESH/TUNING.WOLFGANG_HUNGER) local mighty_percent = math.max(0, (percent - mighty_start) / (1 - mighty_start)) damage_mult = easing.linear(mighty_percent, TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MIN, TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MAX - TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MIN, 1) health_max = easing.linear(mighty_percent, TUNING.WOLFGANG_HEALTH_NORMAL, TUNING.WOLFGANG_HEALTH_MIGHTY - TUNING.WOLFGANG_HEALTH_NORMAL, 1) hunger_rate = easing.linear(mighty_percent, TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, TUNING.WOLFGANG_HUNGER_RATE_MULT_MIGHTY - TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, 1) scale = easing.linear(mighty_percent, 1, mighty_scale - 1, 1) elseif inst.strength == "wimpy" then local wimpy_start = (TUNING.WOLFGANG_START_WIMPY_THRESH/TUNING.WOLFGANG_HUNGER) local wimpy_percent = math.min(1, percent/wimpy_start ) damage_mult = easing.linear(wimpy_percent, TUNING.WOLFGANG_ATTACKMULT_WIMPY_MIN, TUNING.WOLFGANG_ATTACKMULT_WIMPY_MAX - TUNING.WOLFGANG_ATTACKMULT_WIMPY_MIN, 1) health_max = easing.linear(wimpy_percent, TUNING.WOLFGANG_HEALTH_WIMPY, TUNING.WOLFGANG_HEALTH_NORMAL - TUNING.WOLFGANG_HEALTH_WIMPY, 1) hunger_rate = easing.linear(wimpy_percent, TUNING.WOLFGANG_HUNGER_RATE_MULT_WIMPY, TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL - TUNING.WOLFGANG_HUNGER_RATE_MULT_WIMPY, 1) scale = easing.linear(wimpy_percent, wimpy_scale, 1 - wimpy_scale, 1) end Link to comment Share on other sites More sharing options...
DarkXero Posted August 18, 2015 Share Posted August 18, 2015 @Ramrodiger:TUNING values in tuning.lualinear eq in easing.lualocal function linear(t, b, c, d) return c * t / d + bendlocal percent = inst.components.hunger:GetPercent()percent belongs to (0, 1] rangeYour hunger percentlocal mighty_start = 225 / 300 = 0.75Threshold percentlocal mighty_percent = math.max(0, (percent - 0.75) / (1 - 0.75)) = max(0, (percent - 0.75) / 0.25)percent < 0.75 then m_p = 0; percent = 0.75 then m_p = 0; percent > 0.75 then m_p > 0; percent = 1.00 then m_p = 1Basically, how mighty you are, 1 mighty at 300 hunger, 0 mighty at 225, 0 mighty below 225hunger_rate = easing.linear(mighty_percent, TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, TUNING.WOLFGANG_HUNGER_RATE_MULT_MIGHTY - TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, 1)hunger_rate = easing.linear(mighty_percent, 1.5, 3 - 1.5, 1)hunger_rate = easing.linear(mighty_percent, 1.5, 1.5, 1)local function linear(mighty_percent, 1.5, 1.5, 1) return 1.5 * mighty_percent / 1 + 1.5endhunger_rate = 1.5 * mighty_percent + 1.5m_p = 0 then hunger_rate = 1.5m_p = 1 then hunger_rate = 3.0Linear equation.Slope by X plus axis intersection value. Then, for example:hunger_rate = mighty_percent + 1.5m_p = 0 then h_r = 1.5m_p = 1 then h_r = 2.5 Which is slightly less, right?(The equivalent to easing.linear(mighty_percent, 1.5, 1, 1)) Link to comment Share on other sites More sharing options...
Ramrodiger Posted August 18, 2015 Author Share Posted August 18, 2015 Wow thank you so much for your time!!! This has helped immensely. 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