Jump to content

Recommended Posts

I'm currently modding a character into the game, and I can't seem to find much on this topic, so here I am, requesting help from the scripting gods ( you! ).

The character in question needs to move faster the lower its health goes.

I'd also like to know if it's possible to reverse night/day sanity loss and make it so daytime induces sanity loss, as opposed to night. And perhaps night could make it -regain- sanity to a very small degree?

( The character has night vision, and I'd rather make it a night-based character, as odd as it sounds. )

And one last thing-- the character is a carnivore, and I'd like to know if there's a way to prevent sanity loss from eating raw meats.

Note: I successfully implemented night vision and carnivore, so no need to help me with those.

Thanks in advance!

I'm currently modding a character into the game, and I can't seem to find much on this topic, so here I am, requesting help from the scripting gods ( you! ).

The character in question needs to move faster the lower its health goes.

I'd also like to know if it's possible to reverse night/day sanity loss and make it so daytime induces sanity loss, as opposed to night. And perhaps night could make it -regain- sanity to a very small degree?

( The character has night vision, and I'd rather make it a night-based character, as odd as it sounds. )

And one last thing-- the character is a carnivore, and I'd like to know if there's a way to prevent sanity loss from eating raw meats.

Note: I successfully implemented night vision and carnivore, so no need to help me with those.

Thanks in advance!

 

 

You are going to want to look at William Danninghar, he has a custom ability that mimics what you want for speed.

 

Check out Isis for the no meat damage AND reversed sanity loss.

Sorry for the double post. Seems there's no edit button.

Couldn't find anything I was looking for in these mods-- or I just can't seem to get them to work, one or the other. I have terrible difficulty with coding/scripting/thingamajigs, ...

If anyone could show me how, it'd be greatly appreciated, because borrowing from other mods doesn't seem to work for me.

You are going to want to look at William Danninghar, he has a custom ability that mimics what you want for speed.

 

Check out Isis for the no meat damage AND reversed sanity loss.

that depends on what Sannom wants. If they want it so just the lower the character's sanity is, the faster they run, William does not do that. He just goes into his nightmare form when his sanity is below 40ish. Warwick http://forums.kleientertainment.com/files/file/455-warwick/ becomes slower as his sanity goes down, so I'm sure you could look in his coding to see how that's done.

that depends on what Sannom wants. If they want it so just the lower the character's sanity is, the faster they run, William does not do that. He just goes into his nightmare form when his sanity is below 40ish. Warwick http://forums.kleientertainment.com/files/file/455-warwick/ becomes slower as his sanity goes down, so I'm sure you could look in his coding to see how that's done.

Thank you for correcting me. I thought I had seen in it one of the better mods.

Would you happen to have any idea how to use a similar code with health rather than sanity? I'm really not the best at coding and whatnot, as you can already tell. Beginner steps, I'd never touched any of that stuff before, ... three days ago!

Edit: This is what I tried, but it crashes the game after loading a save;
 

local function healthcheck(inst) local healthcurr = inst.components.health.healthcurrent        if healthcurr >= 90 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1)        elseif healthcurr >= 70 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2)        inst.components.combat.damagemultiplier = 1.2        elseif healthcurr >= 50 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.3)        inst.components.combat.damagemultiplier = 1.4        elseif healthcurr >= 40 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.4)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)        inst.components.combat.damagemultiplier = 1.6        elseif healthcurr >= 25 then            inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5)           inst.components.combat.damagemultiplier = 2        else        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5)        inst.components.combat.damagemultiplier = 2        endend

I also added the "Inst:ListenForEvent("healthdelta", healthcheck)" under "local fn = function(inst)", but... no good.

I'm stumped.

Edited by Sannom

Bumping this... Sorry in advance.

Why the heck does it work with inst.components.sanity.current, but not with inst.components.health.healthcurrent?

 

Can anyone help? I've been trying to fix this for a whole day, without success.

Edited by Sannom

Not saying I can help.. but 'no one' can really help with what you posted.  IE: you forgot to zip up and upload your mod folder so someone can look at it and see whats wrong.  Also when you posted that it crashed you didnt post the -exact- crash message. The message itself is designed to tell you where the problem is and would be useful in debugging

Edited by seronis

Would you happen to have any idea how to use a similar code with health rather than sanity? I'm really not the best at coding and whatnot, as you can already tell. Beginner steps, I'd never touched any of that stuff before, ... three days ago!

Edit: This is what I tried, but it crashes the game after loading a save;

 

local function healthcheck(inst) local healthcurr = inst.components.health.healthcurrent        if healthcurr >= 90 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1)        elseif healthcurr >= 70 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2)        inst.components.combat.damagemultiplier = 1.2        elseif healthcurr >= 50 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.3)        inst.components.combat.damagemultiplier = 1.4        elseif healthcurr >= 40 then        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.4)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4)        inst.components.combat.damagemultiplier = 1.6        elseif healthcurr >= 25 then            inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5)           inst.components.combat.damagemultiplier = 2        else        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5)        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5)        inst.components.combat.damagemultiplier = 2        endend

I also added the "Inst:ListenForEvent("healthdelta", healthcheck)" under "local fn = function(inst)", but... no good.

I'm stumped.

 

In your logic code (specifically the elseif statements) it should read like this:

elseif healthcurrent >= 70 then

 

you forgot the "ent" of most of those lines.

Can we get a final opinion on this?

I'd really like to make a character that changes based on health. Thanks guys.

The variable is currenthealth, not healthcurrent. Look at components/health.lua.

 

The line should be:

local healthcurr = inst.components.health.currenthealth
or you could use the GetPercent function instead:

local percenthealth = inst.components.health:GetPercent()-- less than 50% healthif percenthealth < .5 then  -- do stuffend
Edited by squeek

The variable is currenthealth, not healthcurrent. Look at components/health.lua.

 

The line should be:

local healthcurr = inst.components.health.currenthealth
or you could use the GetPercent function instead:

local percenthealth = inst.components.health:GetPercent()-- less than 50% healthif percenthealth < .5 then  -- do stuffend

 

local percenthealth = inst.components.health:GetPercent()if percenthealth < .2 thensoundmanager.loop "f***ing annoying incessant beeping.wav"end

[snickers]

Yes, I know that code is total bull. It's a joke. In case you can't tell.

local percenthealth = inst.components.health:GetPercent()if percenthealth < .2 thensoundmanager.loop "f***ing annoying incessant beeping.wav"end
[snickers]

Yes, I know that code is total bull. It's a joke. In case you can't tell.

I am familiar with that beeping.

http://youtu.be/0M7IINwTFVw?t=13m34s

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
×
  • Create New...