starlit  Diff

Differences From Artifact [3944fdb227]:

To Artifact [642ae8f101]:


    14     14   
    15     15   -- constants
    16     16   local animationFrameRate = 60
    17     17   
    18     18   local species = {
    19     19   	human = {
    20     20   		name = 'Human';
    21         -		desc = 'The weeds of the galactic flowerbed. Humans are one of the Lesser Races, excluded from the ranks of the Greatest Races by souls that lack, in normal circumstances, external psionic channels. Their mastery of the universe cut unexpectedly short, forever locked out of FTL travel, short-lived without augments, and alternately pitied or scorned by the lowest of the low, humans flourish nonetheless due to a capacity for adaptation unmatched among the Thinking Few, terrifyingly rapid reproductive cycles -- and a keen facility for bribery. While the lack of human psions remains a sensitive topic, humans (unlike the bitter and emotional Kruthandi) are practical enough to hire the talent they cannot possess, and have even built a small number of symbiotic civilizations with the more indulging of the Powers. In a galaxy where nearly all sophont life is specialized to a fault, humans have found the unique niche of occupying no particular niche.';
           21  +		desc = 'The weeds of the galactic flowerbed. Humans are one of the Lesser Races, excluded from the ranks of the Starlit by souls that lack, in normal circumstances, external psionic channels. Their mastery of the universe cut unexpectedly short, forever locked out of FTL travel, short-lived without augments, and alternately pitied or scorned by the lowest of the low, humans flourish nonetheless due to a capacity for adaptation unmatched among the Thinking Few, terrifyingly rapid reproductive cycles -- and a keen facility for bribery. While the lack of human psions remains a sensitive topic, humans (unlike the bitter and emotional Kruthandi) are practical enough to hire the talent they cannot possess, and have even built a small number of symbiotic civilizations with the more indulging of the Powers. In a galaxy where nearly all sophont life is specialized to a fault, humans have found the unique niche of occupying no particular niche.';
    22     22   		scale = 1.0;
    23     23   		params = {
    24     24   			{'eyeColor',  'Eye Color',  'tone', {hue=327, sat=0, lum=0}};
    25     25   			{'hairColor', 'Hair Color', 'tone', {hue=100, sat=0, lum=0}};
    26     26   			{'skinTone',  'Skin Tone',  'tone', {hue=  0, sat=0, lum=0}};
    27     27   		};
    28     28   		tempRange = {
................................................................................
    55     55   					morale = 0.8; -- you are not She-Bear Grylls
    56     56   				};
    57     57   				traits = {
    58     58   					health = 400;
    59     59   					lungCapacity = .6;
    60     60   					irradiation = 0.8; -- you are smaller, so it takes less rads to kill ya
    61     61   					sturdiness = 0; -- women are more fragile and thus susceptible to blunt force trauma
    62         -					metabolism = 1800; --Cal
           62  +					metabolism = 1800e3 / 24 / 60 / 60; --kCal/s
    63     63   					painTolerance = 0.4;
           64  +					dehydration = 3; -- mL/s
    64     65   				};
    65     66   			};
    66     67   			male = {
    67     68   				name = 'Human Male';
    68     69   				eyeHeight = 1.6;
    69     70   				stats = {
    70     71   					psiRegen = 1.0;
    71     72   					psiPower = 1.0;
    72     73   					psi = 1.0;
    73     74   					hunger = 1.0;
           75  +					thirst = 1.0;
    74     76   					staminaRegen = .7; -- men are strong but have inferior endurance
    75     77   				};
    76     78   				traits = {
    77     79   					health = 500;
    78     80   					painTolerance = 1.0;
    79     81   					lungCapacity = 1.0;
    80     82   					sturdiness = 0.3;
    81         -					metabolism = 2200; --Cal
           83  +					metabolism = 2200e3 / 24 / 60 / 60; --Cal/s
           84  +					dehydration = 5; -- mL/s
    82     85   				};
    83     86   			};
    84     87   		};
    85     88   		traits = {};
    86     89   	};
    87     90   }
           91  +
    88     92   
    89     93   starlit.world.species = {
    90     94   	index = species;
    91     95   	paramTypes = paramTypes;
    92     96   }
           97  +
           98  +starlit.world.species.pheno = lib.class {
           99  +	name = 'starlit:species.pheno';
          100  +	construct = function(pSp, pVar)
          101  +		local sp, var = starlit.world.species.lookup(pSp, pVar)
          102  +		return {
          103  +			species = sp, variant = var;
          104  +			pSpecies = pSp, pVariant = pVar;
          105  +		};
          106  +	end;
          107  +	__index = {
          108  +		trait = function(me, st, dflt)
          109  +			local v = me.variant.traits[st] or me.species.traits[st]
          110  +			return v or dflt
          111  +		end;
          112  +	};
          113  +}
    93    114   
    94    115   function starlit.world.species.mkDefaultParamsTable(pSpecies, pVariant)
    95    116   	local sp = species[pSpecies]
    96    117   	local var = sp.variants[pVariant]
    97    118   	local vpd = var.defaults or {}
    98    119   	local tbl = {}
    99    120   	for _, p in pairs(sp.params) do
................................................................................
   108    129   	return {
   109    130   		species = pSpecies;
   110    131   		speciesVariant = pVariant;
   111    132   		bodyParams = starlit.world.species.paramsFromTable(pSpecies,
   112    133   			starlit.world.species.mkDefaultParamsTable(pSpecies, pVariant)
   113    134   		);
   114    135   		statDeltas = {};
          136  +		facts = {};
   115    137   	}
   116    138   end
   117    139   
   118    140   local function spLookup(pSpecies, pVariant)
   119    141   	local sp = species[pSpecies]
   120    142   	local var = sp.variants[pVariant or next(sp.variants)]
   121    143   	return sp, var
................................................................................
   160    182   		local delta = max - min
   161    183   		return min + delta*p
   162    184   	end
   163    185   	local ps = starlit.world.species.mkPersonaFor(pSpecies,pVariant)
   164    186   	local startingHP = pct('health', 1.0)
   165    187   	if circumstances.injured    then startingHP = pct('health', circumstances.injured) end
   166    188   	if circumstances.psiCharged then ps.statDeltas.psi = pct('psi', circumstances.psiCharged) end
          189  +	for k,v in pairs(starlit.world.stats) do ps.statDeltas[k] = 0 end
   167    190   	ps.statDeltas.warmth = 20 -- don't instantly start dying of frostbite
   168    191   
   169    192   	entity:set_properties{hp_max = var.traits.health or sp.traits.health}
   170    193   	entity:set_hp(startingHP, 'initial hp')
   171    194   	return ps
   172    195   end
   173    196