[0.11.x] Stamina (multiplayer compatible)

Topics and discussion about specific mods
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

[0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

You should probably automate more things.

Stamina is a small mod that causes hand crafting items to slowly drain your health. 1 second of crafting costs 1 health (the vanilla player's max health is 100). So you might want to rethink hand crafting that level 3 module...
stamina.jpg
stamina.jpg (87.07 KiB) Viewed 14485 times
Changes:
  • 0.1.2 - added health drain for mining, and decreased health regen while walking
Attachments
Stamina_0.1.2.zip
(1.37 KiB) Downloaded 396 times
Stamina_0.1.0.zip
(1.02 KiB) Downloaded 208 times
Last edited by Schmendrick on Fri Mar 06, 2015 10:49 pm, edited 2 times in total.
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

Update: there seem to be a bug or two with multiplayer.

One: if you log out of a MP server while crafting, your character will continue to lose health while offline and when you log back in you may be dead.
Two (discovered while testing the above after realizing it might be an issue): desyncs happen. Not sure why. Sometimes causes a loop.

Will work on fixing these soon.
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
Degraine
Filter Inserter
Filter Inserter
Posts: 282
Joined: Wed Aug 13, 2014 10:49 am
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Degraine »

That is an interesting idea. Pretty brutal motivation to get on top of automating stuff!
User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by FreeER »

nice mod idea :)
Schmendrick wrote:One: if you log out of a MP server while crafting, your character will continue to lose health while offline and when you log back in you may be dead.
How is that a bug? Isn't it kind of the point that if you keep crafting you will die? lol. Beyond that it's probably because MP players aren't removed until game.removeofflineplayers() is called
Schmendrick wrote:Two (discovered while testing the above after realizing it might be an issue): desyncs happen. Not sure why. Sometimes causes a loop.
I know there was a desync bug with using hash tables (non-numeric tables, aka using pairs) due to the non-deterministic data retrieval, not certain if that's been fixed yet. Perhaps try using ipairs? Or maybe the floating point arithmetic causing issues, though I thought the devs did something to correct for that... Just wild guesses here since I don't have a clue and can't actually test :)

btw this code should do the same as what you have uploaded (well, unless damage considers armor...which it probably does lol):

Code: Select all

require "defines"
game.onevent(defines.events.ontick, function(event)
  if event.tick % 3 == 0 then
    for _, p in ipairs(game.players) do
      if p.character and p.craftingqueuesize > 0 then
        if p.character.health < 18 then
          -- assuming the character.die() line was due to negative health or something?
          -- damage will kill the player if health drops to (or below) 0
          p.character.damage(0.08, p.force)
        else
          -- assuming setting health is to avoid the obvious red overlay that damage causes
          p.character.health = p.character.health - 0.08
        end
      end
    end
  end
end)
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

I assume it's a bug, because I assume the player stops crafting when offline - either way it's a nasty gotcha. If an offline player's crafting queue continues to process, then I'll have to address that, somehow. However, if that assumption is correct, I have a fix (probably!) for both problems, but I'm waiting to test it out before I "publish" it.

The mod avoids dealing damage to the character for two reasons: one, as you presumed, to avoid the red "being damaged" screen highlight, and, two, to circumvent armor or similar effects from mitigating the damage.

I use locals and avoid using modulo arithmetic because it is faster.

Here is the update, pre-release 0.1.1. Once it's tested and confirmed I'll move it to the OP (if offline crafting is a thing, I'll worry about that in 0.1.2)
Attachments
Stamina_0.1.1.zip
(1.1 KiB) Downloaded 184 times
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
dee-
Filter Inserter
Filter Inserter
Posts: 416
Joined: Mon Jan 19, 2015 9:21 am
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by dee- »

Nice idea ^^

But isn't this the same as just saying every item that needs a longer buildung time as X can only be build in factories and modify their recipe accordingly?
Sure, it would be less spectacular but the "ceiling" effect would be the same. Stamina adds to this that you have to pause between builds because your health is still drained.
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

dee- wrote:But isn't this the same as just saying every item that needs a longer buildung time as X can only be build in factories and modify their recipe accordingly?
Mostly, yes, but I feel this application is more interesting. Instead of simply restricting certain recipes outright, it gives you a choice. It makes automation "feel" better in a direct, in-game way. An assembling machine 1 may craft half as fast as the player, but it costs no health. You'll always hand craft your first few Science Pack 1's, but with stamina it feels draining (because it is) and makes that first automated setup feel like it's really doing something other than just saving you time. If you know you're not leaving the base any time soon, it's safe to craft a large item by hand, and if you only need one, you may very well choose not to bother setting up the automation. On the other hand, most big items cost a fair amount of crafting time's worth of intermediate items, and this gives you a reason to keep some of them on hand (crafting a roboport from its ingredients won't kill you, but crafting one from scratch certainly will). Alternately, you can eat fish to extend your effective crafting stamina. How often do most players use fish at the moment?

Stamina also encourages you to maintain (probably factory created and maintained) stockpiles of all your military equipment, or else face a decision about crafting new ammo in the middle of a fight.

A good game is about interesting decisions.
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

0.1.2 update.

Mining now drains health.
Walking now drains health, but at a rate less than natural health regeneration - so if you're not crafting, walking won't "hurt" you, it will just slow your regen.
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
User avatar
Mr. Thunder_Tw
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Mon Sep 29, 2014 2:15 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Mr. Thunder_Tw »

I like this mod, a lot. So thanks a lot Schmendrick!
There ain't enough smileys to express how i feel except :cry: not enough, *snif* :D :D :D Good mod sir!
my Mod: ThunderGui
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

Mr. Thunder_Tw wrote:I like this mod, a lot. So thanks a lot Schmendrick!
There ain't enough smileys to express how i feel except :cry: not enough, *snif* :D :D :D Good mod sir!
Not enough?
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
User avatar
Mr. Thunder_Tw
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Mon Sep 29, 2014 2:15 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Mr. Thunder_Tw »

Smileys! :lol:
my Mod: ThunderGui
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

Oh, I thought you wanted to hurt the character more. :P
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
Schmendrick
Fast Inserter
Fast Inserter
Posts: 223
Joined: Wed Apr 30, 2014 11:17 pm
Contact:

Re: [0.11.x] Stamina (multiplayer compatible)

Post by Schmendrick »

Updated for Factorio 0.12.x
Like my mods? Check out another! Or see older, pre-0.12.0 mods.
Post Reply

Return to “Mods”