Page 1 of 1
[0.11.x] Stamina (multiplayer compatible)
Posted: Mon Feb 02, 2015 11:04 pm
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 (87.07 KiB) Viewed 14484 times
Changes:
- 0.1.2 - added health drain for mining, and decreased health regen while walking
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Tue Feb 03, 2015 12:56 am
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.
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Tue Feb 03, 2015 2:00 am
by Degraine
That is an interesting idea. Pretty brutal motivation to get on top of automating stuff!
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Tue Feb 03, 2015 4:10 am
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)
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Tue Feb 03, 2015 4:50 am
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)
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Tue Feb 03, 2015 8:36 am
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.
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Tue Feb 03, 2015 6:35 pm
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.
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Fri Mar 06, 2015 10:47 pm
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.
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Sat Mar 07, 2015 2:00 pm
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
not enough, *snif*
Good mod sir!
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Sat Mar 07, 2015 2:12 pm
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
not enough, *snif*
Good mod sir!
Not enough?
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Sat Mar 07, 2015 2:15 pm
by Mr. Thunder_Tw
Smileys!
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Sat Mar 07, 2015 3:18 pm
by Schmendrick
Oh, I thought you wanted to hurt the character more.
Re: [0.11.x] Stamina (multiplayer compatible)
Posted: Tue Jul 28, 2015 8:50 pm
by Schmendrick
Updated for Factorio 0.12.x