Getting / Setting Player Status
2 2

11 posts in this topic

Recommended Posts

I'm trying to piece together how things like bandages and pills work, but there seems to be quite a bit handled on the Java side.  For instance, pills:

 

self.character:getBodyDamage():JustTookPill(self.item);

 

I see through Status and BodyDamage you can manipulate a few things:

 

 
player:getStats():setStress(0.5);
player:getStats():setPanic(50);

player:getStats():setFatigue(50);

 

Also found to work:

 

player:getStats():setDrunkenness(100);

 

or 

 

self.character:getBodyDamage():setBoredomLevel(0);

player:getBodyDamage():setWetness(10);

 

OK, Pain was easy to guess:

 

player:getStats():setPain(50);

 

But Pain seems to be correlated to other factors (ie injury, etc) - so setting this manually seems futile at the moment, it just resets back.

 

Anyone know the methods for things like Injury and Fever? I see the Wounded/Bitten/etc in Bandage/HealthUI code, but only getters.

 

Is there anything like a percent chance of infection?

Share this post


Link to post
Share on other sites

percent change of infection is a hardcoded thing at the moment :(

for the fever and other bodydamaging thing look into BodyDamage... forgot how to access that but it should be something like player:getBodyDamage() and then use some functions on it ( for example getBodyPart() wiche gives you a bodypart of your body back. )

not sure what functions there are in there, but that java class is where the functions you can call from lua are defined in.

zombie/charachters/BodyDamage/BodyDamage.class and others

the is a option to see your cold level so sickness is in the BodyDamage too

Share this post


Link to post
Share on other sites

I recommend using jd-gui. It's very helpful.

 

AndroChef continues jd-gui for Java 7, though it costs a bit and handles only single files outside of jars.

I'd recommend collapsing everything in notepad, so you only have to view the terrifying number of functions and class variables before delving into the massive amounts of functions.

Share this post


Link to post
Share on other sites

Thanks.  So it looks like Injuries/Damage is something comprised from the various parts.  That makes sense.  A lot of things can be manipulated, but things like Pain or Fever will likely diminish quickly without the normal reasons for their existence.

 

So these:

player:getStats():setStress(0.5);player:getStats():setPanic(50);player:getStats():setFatigue(50);player:getStats():setDrunkenness(100);player:getBodyDamage():setBoredomLevel(0);player:getBodyDamage():setWetness(10);
Effect the player directly, more or less as expected.
 
Or if you wanted to kill the player really, really fast:
local bodyParts = getPlayer():getBodyDamage():getBodyParts();for i=0,BodyPartType.ToIndex(BodyPartType.MAX) - 1 do  local bodyPart = bodyParts:get(i);  bodyPart:SetBitten(true);end

But without those injuries, setting something like Pain will just vanish quickly.  Same with the Fever moodlet, it doesn't do anything unless the player is sick, infected or "fake infected"  But you can control those factors to adjust the fever.

 

Thanks guys!

 

 

Still seeing if I can make the PC spontaneously combust....

Share this post


Link to post
Share on other sites

All of this is handled on the "Java side", afaik - this talk of "Java side" and "Lua side" seems to be a misconception, except that some small parts of code, like the timed action queuing, are handled in the Lua-files in the media/lua directory.

 

From my investigations into some of this:

 

50 for fatigue seems to be overkill - from what I remember, the fatigue and endurance values are small. I usually set the fatigue levels in increments of +0.04 for a moderate amount of work(like hauling away a body) and that will often induce the "getting drowsy" icon very quickly. For endurance, you need to subtract from the current value(the value will decrease towards 0 through exertion). Another peculiarity of exertion is that it stops decreasing during combat. I think some of the other endurance values might take over at that point, but I never investigated this.

 

To infect a player, simply call getBodyDamage():setInf(true); To control infection level, use getBodyDamage():setInfectionLevel(infLevel). This value goes from 0(no infection), to 100(dead). Somewhere in the middle of this, you reach the "zombified" state. The infection status will sometimes go away if the infection level is low, so make sure this is set at least above 15 if you want to make sure the infection progresses. You can also set the infection rate through another function.

 

To add chance of infection, simply use the Lua-function ZombRand(max) to draw a random number between 0 and (not including) max, or use one of the standard Java-functions(ZombRand is just a wrapper for these).

Share this post


Link to post
Share on other sites

I'm looking at the opposite - giving better chances against infection and death (but not a cure).  But man, this game really wants to kill people.  After a scratch - I was thinking I was going overboard with:

        getPlayer():getBodyDamage():setInf(false);	getPlayer():getBodyDamage():setInfectionLevel(0);	getPlayer():getStats():setSickness(0);	bodyPart:SetCortorised(true);	

Nope:  Still get  Sickness.  Fever.  Death.

 

Update - though there is something in RestoreFullHealth() which works.  Odd. 

Share this post


Link to post
Share on other sites

There's no reason you shouldn't with those, they won't disable the infection mechanism. What you need to do is simply make your own infection mechanism and keep the old one in check. If you don't want a cure, you could use setInfectionGrowthRate() and setInfectionHealthReductionAmmount().

Share this post


Link to post
Share on other sites

After restoring health, it's also necessary to set the rate at which infection increases to 0, if memory serves. It should be a variable in IsoPlayer -- but is it accessible from Lua? Erm.

It's been a while.

Share this post


Link to post
Share on other sites

Well the issue seems to have been that I was modifying the infection in bodyDamage but not the bodyPart - and I think the infection update obviously checks the whole enchilada.  

Share this post


Link to post
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
2 2