starlit  Diff

Differences From Artifact [1469667980]:

To Artifact [7816834c67]:


    19     19   	sprint = {
    20     20   		id = 'sprint';
    21     21   		name = 'Sprint';
    22     22   		desc = 'Put on a short burst of speed at the cost of some stamina';
    23     23   		img = 'starlit-ui-icon-ability-sprint.png';
    24     24   		powerKind = 'maneuver';
    25     25   		run = function(user, ctx)
           26  +			local cost = 10
           27  +			-- unfortunately stat writes are very expensive, so can't draw from stamina
           28  +			-- every single frame
           29  +			local function halt()
           30  +				if user.action.prog.sprint then
           31  +					user:statDelta('stamina', -user.action.prog.sprint.cb)
           32  +					user:deleteOverlay(user.action.prog.sprint.id)
           33  +					user.action.prog.sprint = nil
           34  +				end
           35  +			end
           36  +
           37  +			if ctx.how.state == 'init' then
           38  +				halt()
           39  +				if user:effectiveStat 'stamina' > 0 then
           40  +					user.action.prog.sprint = {
           41  +						cb = 0;
           42  +						id = user:overlay(function(phys) phys.speed = phys.speed * 2 end)
           43  +					}
           44  +				end
           45  +			elseif ctx.how.state == 'prog' then
           46  +				local d = ctx.how.delta
           47  +				local p = user.action.prog.sprint
           48  +				-- is the player currently holding any of WASD
           49  +				local isMoving = bit.band(0x0f, user.entity:get_player_control_bits()) ~= 0
           50  +				if p and isMoving then
           51  +					p.cb = p.cb + cost*d
           52  +					if p.cb >= 10 then
           53  +						user:statDelta('stamina', -10)
           54  +						if user:effectiveStat 'stamina' < 10 then halt() end
           55  +					end
           56  +				end
           57  +			elseif ctx.how.state == 'halt' then
           58  +				halt()
           59  +			end
    26     60   		end;
    27     61   	};
    28     62   }
    29     63   
    30     64   local species = {
    31     65   	human = {
    32     66   		name = 'Human';
................................................................................
    59     93   				end;
    60     94   				stats = {
    61     95   					psiRegen = 1.3;
    62     96   					psiPower = 1.2;
    63     97   					psi = 1.2;
    64     98   					nutrition = .8; -- women have smaller stomachs
    65     99   					hydration = .8;
    66         -					staminaRegen = 1.0;
    67    100   					morale = 0.8; -- you are not She-Bear Grylls
    68    101   				};
    69    102   				traits = {
    70    103   					health = 400;
    71    104   					lungCapacity = .6;
    72    105   					irradiation = 0.8; -- you are smaller, so it takes less rads to kill ya
    73    106   					sturdiness = 0; -- women are more fragile and thus susceptible to blunt force trauma
    74    107   					metabolism = .150; -- kCal/s
    75    108   					painTolerance = 0.4;
    76    109   					dehydration = 10e-4; -- L/s
    77    110   					speed = 1.1;
          111  +					staminaRegen = 30.0;
    78    112   				};
    79    113   			};
    80    114   			male = {
    81    115   				name = 'Human Male';
    82    116   				eyeHeight = 1.6;
    83    117   				stats = {
    84    118   					psiRegen = 1.0;
    85    119   					psiPower = 1.0;
    86    120   					psi = 1.0;
    87    121   					nutrition = 1.0;
    88    122   					hydration = 1.0;
    89         -					staminaRegen = .7; -- men are strong but have inferior endurance
          123  +					staminaRegen = 20; -- men are strong but have inferior endurance
    90    124   				};
    91    125   				traits = {
    92    126   					health = 500;
    93    127   					painTolerance = 1.0;
    94    128   					lungCapacity = 1.0;
    95    129   					sturdiness = 0.3;
    96    130   					metabolism = .150; -- kCal/s