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