Jump to content

Looking for scripting help for character mod.


Recommended Posts

Hey everybody, I created this character mod based on the DST Extended Template Character.

 

http://steamcommunity.com/sharedfiles/filedetails/?id=487896774

 

Because I'm more of an artist I don't really understand a lot how LUA works even after reading the tutorials about it.

 

What I want to implement something like this:

 

If health <= 80% then attack = x1.1

elseif health <= 60% then attack = x1.2

elseif health <= 40% then attack = x1.3 AND 

elseif health <= 20% then attack = x1.4 AND (a bright blue glow around him so that he can survive nighttime without a torch or fire)

end

 

Thank you for reading this and for helping me if you have time.

Link to comment
Share on other sites

Hey everybody, I created this character mod based on the DST Extended Template Character.

 

http://steamcommunity.com/sharedfiles/filedetails/?id=487896774

 

Because I'm more of an artist I don't really understand a lot how LUA works even after reading the tutorials about it.

 

What I want to implement something like this:

 

If health <= 80% then attack = x1.1

elseif health <= 60% then attack = x1.2

elseif health <= 40% then attack = x1.3 AND 

elseif health <= 20% then attack = x1.4 AND (a bright blue glow around him so that he can survive nighttime without a torch or fire)

end

 

Thank you for reading this and for helping me if you have time.

 

Also I thought about having a progressively higher sanity loss to even the gain out.

 

I'm sorry if this is complicated. Thanks again for reading.

Link to comment
Share on other sites

@Akiru,

-- over master_postinit and common_postinitlocal function FlipLight(inst)	if inst._light:value() then		inst.Light:SetFalloff(0.7)		inst.Light:SetIntensity(0.5)		inst.Light:SetRadius(7)		inst.Light:SetColour(169/255, 231/255, 245/255)		inst.Light:Enable(true)	else		inst.Light:Enable(false)	endendlocal function HealthFlux(inst, data)    local hp = data.newpercent    if 0.8 < hp then        inst.components.sanity.custom_rate_fn = function(inst) return 0 end        inst.components.combat.damagemultiplier = 1        inst._light:set(false)    elseif 0.6 < hp and hp <= 0.8 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.01 end        inst.components.combat.damagemultiplier = 1.1        inst._light:set(false)    elseif 0.4 < hp and hp <= 0.6 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.02 end        inst.components.combat.damagemultiplier = 1.2        inst._light:set(false)    elseif 0.2 < hp and hp <= 0.4 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.05 end        inst.components.combat.damagemultiplier = 1.3        inst._light:set(false)    elseif hp <= 0.2 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.1 end        inst.components.combat.damagemultiplier = 1.4		inst._light:set(true)    endend    -- inside common_postinit    inst:ListenForEvent("fliplight", FlipLight)    inst._light = net_bool(inst.GUID, "player._light", "fliplight")    inst._light:set_local(false)     -- inside master_postinit    inst:ListenForEvent("healthdelta", HealthFlux)
Edited by DarkXero
Link to comment
Share on other sites

@Akiru,

-- over master_postinit and common_postinitlocal function FlipLight(inst)	if inst._light:value() then		inst.Light:SetFalloff(0.7)		inst.Light:SetIntensity(0.5)		inst.Light:SetRadius(7)		inst.Light:SetColour(169/255, 231/255, 245/255)		inst.Light:Enable(true)	else		inst.Light:Enable(false)	endendlocal function HealthFlux(inst, data)    local hp = data.newpercent    if 0.6 < hp and hp <= 0.8 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.01 end        inst.components.combat.damagemultiplier = 1.1        inst._light:set(false)    elseif 0.4 < hp and hp <= 0.6 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.02 end        inst.components.combat.damagemultiplier = 1.2        inst._light:set(false)    elseif 0.2 < hp and hp <= 0.4 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.05 end        inst.components.combat.damagemultiplier = 1.3        inst._light:set(false)    elseif hp <= 0.2 then        inst.components.sanity.custom_rate_fn = function(inst) return -0.1 end        inst.components.combat.damagemultiplier = 1.4		inst._light:set(true)    endend    -- inside common_postinit    inst:ListenForEvent("fliplight", FlipLight)    inst._light = net_bool(inst.GUID, "player._light", "fliplight")    inst._light:set_local(false)     -- inside master_postinit    inst:ListenForEvent("healthdelta", HealthFlux)

Incredible. I will try this code out as soon as I get back home again. Thank you so much for spending time on my request.

I will give you credit on my character page. If you want something in return, (Art related like an Icon or a Portrait for a mod or anything) tell me so I can return the favor.

Link to comment
Share on other sites

@Akiru,

I was rereading my post and noticed that I missed the first case, when health is over 80 percent. I included it now.

 

Omitting it would make you never leave the -0.01 sanity rate debuff. Or any other one, when you heal yourself a lot.

 

I think that should do it.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...