Jump to content

How to get/set water "dirty" flag?


blindcoder

Recommended Posts

Hi all.

 

Over the weekend I wanted to work on a water purification system (using water stills), but couldn't find any hint on how to get / set water giving you sickness or not.

 

What I want to achieve:

Pot water from toilet --> water in container marked "dirty" --> giving you sickness

Pot water from rainbarrel --> water in container has chance of being "dirty".

 

Pass water through still --> water marked "safe".

 

I was grepping through the lua code as good as I can but couldn't find anything.

 

Is that possible at all? If so, does anyone know how?

Link to comment
Share on other sites

You could maybe store the information as modData in the item which stores the water?

 

Yeah, that would be the obvious solution if it were only the rainbarrels, ignoring the toilets :)

 

You'll need to tweak the tile properties imo, to have a dirty flag, or either directly check the sprite name when drinking and then set your character Ill (like set a poison level from food)

 

Hmm, I thought drinking from toilets made you sick already, so I was hoping I could use that flag somehow.

Link to comment
Share on other sites

Why would you want to store the dirty flag in the toilet object?

 

Just check where the water is coming from and then save if that water is dirty in the pot / bottle / whatever item. No need to set any flags to the world objects.

 

At least that's how I would've tried to do it.

Link to comment
Share on other sites

Why would you want to store the dirty flag in the toilet object?

 

Just check where the water is coming from and then save if that water is dirty in the pot / bottle / whatever item. No need to set any flags to the world objects.

 

At least that's how I would've tried to do it.

 

I don't want to store it on the toilet :) I want to store it on the water bottle / kettle / bowl / etc.

 

 

Properties avoid that, you always have the properties, and no need to worry about MP sync compared to mod data, but it'll also work :)

 

I don't think the toilet water make you sick.. Or someone added it and I had no idea, mea culpa then :D

 

Hmm, I thought it would... or at least it did at some point and maybe got removed.

If it no longer does then I guess I can just extend/overwrite onTakeWaterAction (I think it's called that) to add the modData / property.

When the water is then consumed by a player, I'll check how to create sickness / foodpoisoning.

Link to comment
Share on other sites

I'm pretty much there now, already giving the player 5 points of food poisoning for every 1 unit of water s/he drinks from toilets, and also setting modData["dirtyWaterIsDirty"] = 1 on bottles and stuff.

 

Now, can I hook into the automatic drinking procedure somehow? Obviously, filling dirty water into a bottle shouldn't just magically make the water clean.

Link to comment
Share on other sites

Haha, I'm almost there :D

 

I can now poison the player when drinking from toilets / rain barrels (yes, I consider rain "dirty". acidic rain, anyone?) and I can record the state of bottled water and poison the player when s/he drinks from dirty bottled water automatically.

 

Now, remaining question: How much is a "noticable" FoodSickness level to add?

I would like to poison the player noticably, but not kill them outright.

Link to comment
Share on other sites

Okay, I'm using a value of 30 now for every drink action, no matter how much the player drinks. Drinking twice turns this into 60, but hey, it's good enough. It'll make the player queasy if he only drinks once, and will increase sickness if he continues to drink dirty bottled water.

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