Differences From
Artifact [a0e5424f99]:
72 72 pushPersona = function(self)
73 73 local s = userStore(self.entity)
74 74 s.write('persona', self.persona)
75 75 end;
76 76 uiColor = function(self) return lib.color {hue=238,sat=.5,lum=.5} end;
77 77 statDelta = function(self, stat, d, cause, abs)
78 78 local dt = self.persona.statDeltas
79 - local base
79 + local min, max, base = self:statRange(stat)
80 80 if abs then
81 - local min, max
82 - min, max, base = self:statRange(stat)
83 81 if d == true then d = max
84 82 elseif d == false then d = min end
85 83 end
86 84 if stat == 'health' then
87 85 self.entity:set_hp(abs and d or (self.entity:get_hp() + d), cause)
88 86 elseif stat == 'breath' then
89 87 self.entity:set_breath(abs and d or (self.entity:get_breath() + d))
90 88 else
91 89 if abs then
92 90 dt[stat] = d - base
93 91 else
94 92 dt[stat] = dt[stat] + d
95 93 end
94 +
95 + if dt[stat]+base > max then dt[stat] = max-base
96 + elseif dt[stat]+base < min then dt[stat] = min-base end
96 97 self:pushPersona()
97 98 end
99 +
100 +
98 101 self:updateHUD()
99 102 -- TODO trigger relevant animations?
100 103 end;
101 104 lookupSpecies = function(self)
102 105 return starlit.world.species.lookup(self.persona.species, self.persona.speciesVariant)
103 106 end;
104 107 phenoTrait = function(self, trait, dflt)
................................................................................
469 472
470 473 giveGifts('main', gifts.carry)
471 474
472 475 self:reconfigureSuit()
473 476
474 477 -- i feel like there has to be a better way
475 478 local cx = math.random(-500,500)
476 - local startPoint
479 + local iter, startPoint = 1
477 480 repeat local temp = -100
478 481 local cz = math.random(-500,500)
479 482 local cy = minetest.get_spawn_level(cx, cz)
480 483 if cy then
481 484 startPoint = vector.new(cx,cy,cz)
482 485 temp = starlit.world.climate.eval(startPoint,.5,.5).surfaceTemp
483 486 end
484 - if cx > 10000 then break end -- avoid infiniloop in pathological conditions
487 + iter = iter + 1
488 + if iter > 100 then break end -- avoid infiniloop in pathological conditions
485 489 until temp > -2
486 490 self.entity:set_pos(startPoint)
487 491 meta:set_string('starlit_spawn', startPoint:to_string())
488 492 end;
489 493 onDie = function(self, reason)
490 494 local inv = self.entity:get_inventory()
491 495 local where = self.entity:get_pos()
................................................................................
496 500 minetest.item_drop(o, self.entity, where)
497 501 end
498 502 end
499 503 inv:set_list(lst, {})
500 504 end
501 505 dropInv 'main'
502 506 dropInv 'starlit_suit'
503 - self:statDelta('psi', 0, 'death', true)
504 - self:statDelta('hunger', 0, 'death', true)
505 - self:statDelta('thirst', 0, 'death', true)
506 - self:statDelta('fatigue', 0, 'death', true)
507 - self:statDelta('stamina', 0, 'death', true)
507 + self:statDelta('psi', 0, 'death', true)
508 + self:statDelta('nutrition', 1500, 'death', true)
509 + self:statDelta('hydration', 2, 'death', true)
510 + self:statDelta('fatigue', 0, 'death', true)
511 + self:statDelta('stamina', 0, 'death', true)
508 512 self:updateSuit()
509 513 end;
510 514 onRespawn = function(self)
511 515 local meta = self.entity:get_meta()
512 516 self.entity:set_pos(vector.from_string(meta:get_string'starlit_spawn'))
513 517 self:updateSuit()
514 518 return true
................................................................................
840 844 local bmr = p:trait 'metabolism' * biointerval
841 845 -- TODO apply modifiers
842 846
843 847 local dehydration = p:trait 'dehydration' * biointerval
844 848 -- you dehydrate faster in higher temp
845 849 dehydration = dehydration * math.max(1, starlit.world.climate.temp(u.entity:get_pos()) / 10)
846 850
847 - u:statDelta('hunger', bmr)
848 - u:statDelta('thirst', dehydration)
851 + u:statDelta('nutrition', -bmr)
852 + u:statDelta('hydration', -dehydration)
853 +
854 + if u:effectiveStat 'nutrition' == 0 then
855 + -- starvation
856 + end
857 +
858 + if u:effectiveStat 'hydration' == 0 then
859 + -- dying of thirst
860 + end
861 +
862 + local rads = u:effectiveStat 'irradiation'
863 + if rads > 0 then
864 + u:statDelta('irradiation', -0.0001 * biointerval)
865 + end
866 +
849 867 end
850 868 end)
851 869
852 870 local cbit = {
853 871 up = 0x001;
854 872 down = 0x002;
855 873 left = 0x004;