-
Notifications
You must be signed in to change notification settings - Fork 459
add: новые дебаффы голодания #7025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
syndicatecat
wants to merge
16
commits into
ss220-space:master220
Choose a base branch
from
syndicatecat:hunger
base: master220
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
088b75e
miaylodanie
syndicatecat 4a34e02
!
syndicatecat a1ceb09
Merge branch 'master220' into hunger
syndicatecat 3fb043c
Update hunger_effects.dm
syndicatecat da5d5a1
12
syndicatecat 5b1938f
Update paradise.dme
syndicatecat 5ea43a7
Update hunger_effects.dm
syndicatecat 800d8a5
Update hunger_effects.dm
syndicatecat f6b5139
Update human.dm
syndicatecat 077547f
!!!!!!!!!
syndicatecat b67a92f
блин
syndicatecat ce75752
Merge branch 'master220' into hunger
syndicatecat 4df14c3
!
syndicatecat fa9d93c
Merge branch 'hunger' of https://github.com/syndicatecat/Paradise int…
syndicatecat 0957c9e
)
syndicatecat a0890ff
Merge branch 'master220' into hunger
syndicatecat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#define COMSIG_CARBON_NUTRITION_UPDATE "carbon_nutrition_update" | ||
/datum/component/hunger_effects | ||
var/datum/hunger_level/current_level | ||
|
||
/datum/component/hunger_effects/Initialize() | ||
if(!ishuman(parent)) | ||
return COMPONENT_INCOMPATIBLE | ||
RegisterSignal(parent, COMSIG_CARBON_NUTRITION_UPDATE, PROC_REF(update_hunger_effects)) | ||
RegisterSignal(parent, COMSIG_LIVING_LIFE, PROC_REF(on_life)) | ||
update_hunger_effects() | ||
return ..() | ||
|
||
/datum/component/hunger_effects/proc/update_hunger_effects() | ||
var/mob/living/carbon/human/target = parent | ||
if(!istype(target)) | ||
return | ||
var/current_nutrition = target.nutrition | ||
var/datum/hunger_level/new_level = find_hunger_level(current_nutrition) | ||
current_level = new_level | ||
apply_hunger_effects(target) | ||
|
||
/datum/component/hunger_effects/proc/find_hunger_level(nutrition) | ||
var/list/valid_levels = list() | ||
for(var/level_type in GLOB.hunger_levels) | ||
var/datum/hunger_level/level = GLOB.hunger_levels[level_type] | ||
valid_levels += level | ||
sortTim(valid_levels, /proc/hunger_levels_update) | ||
for(var/datum/hunger_level/level in valid_levels) | ||
if(nutrition >= level.min_nutrition) | ||
return level | ||
return GLOB.hunger_levels[/datum/hunger_level/starving] | ||
|
||
/proc/hunger_levels_update(datum/hunger_level/A, datum/hunger_level/B) | ||
return B.min_nutrition - A.min_nutrition | ||
|
||
/datum/component/hunger_effects/proc/apply_hunger_effects(mob/living/carbon/human/target) | ||
target.remove_movespeed_modifier(/datum/movespeed_modifier/hunger) | ||
target.remove_actionspeed_modifier(/datum/actionspeed_modifier/species_tool_mod) | ||
if(!isnull(current_level?.move_mod) && current_level.move_mod != 0) | ||
target.add_or_update_variable_movespeed_modifier( | ||
/datum/movespeed_modifier/hunger, | ||
multiplicative_slowdown = current_level.move_mod | ||
) | ||
var/base_toolspeed = target.dna.species.toolspeedmod | ||
var/new_toolspeed = base_toolspeed + (current_level?.tool_mod || 0) | ||
if(new_toolspeed != base_toolspeed) | ||
target.add_or_update_variable_actionspeed_modifier( | ||
/datum/actionspeed_modifier/species_tool_mod, | ||
multiplicative_slowdown = new_toolspeed | ||
) | ||
else | ||
target.remove_actionspeed_modifier(/datum/actionspeed_modifier/species_tool_mod) | ||
target.sound_environment_override = current_level?.sound_env || SOUND_ENVIRONMENT_NONE | ||
if(!isnull(current_level?.stamina_max)) | ||
target.set_stamina_max(current_level.stamina_max) | ||
|
||
/datum/component/hunger_effects/proc/on_life() | ||
var/mob/living/carbon/human/target = parent | ||
if(!istype(target) || !current_level) | ||
return | ||
if(current_level.regen_stamina && target.getStaminaLoss() > 0) | ||
target.adjustStaminaLoss(-0.5, TRUE) | ||
if(current_level.regen_blood) | ||
target.blood_volume = min(target.blood_volume + 0.2, BLOOD_VOLUME_NORMAL) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
GLOBAL_LIST_EMPTY(hunger_levels) | ||
/datum/hunger_level | ||
var/above = null | ||
var/below = null | ||
var/min_nutrition = 0 | ||
var/move_mod = 0 | ||
var/tool_mod = 0 | ||
var/stamina_max = MAX_STAMINA_LOSS | ||
var/sound_env = SOUND_ENVIRONMENT_NONE | ||
var/regen_stamina = FALSE | ||
var/regen_blood = FALSE | ||
|
||
/datum/hunger_level/starving | ||
min_nutrition = 0 | ||
move_mod = 2 | ||
tool_mod = 0.5 | ||
stamina_max = MAX_STAMINA_LOSS - 10 | ||
sound_env = SOUND_ENVIRONMENT_DRUGGED | ||
above = /datum/hunger_level/hungry | ||
below = null | ||
|
||
/datum/hunger_level/hungry | ||
min_nutrition = NUTRITION_LEVEL_HYPOGLYCEMIA + 1 | ||
move_mod = 1 | ||
tool_mod = 0.25 | ||
stamina_max = MAX_STAMINA_LOSS - 5 | ||
sound_env = SOUND_ENVIRONMENT_NONE | ||
above = /datum/hunger_level/normal | ||
below = /datum/hunger_level/starving | ||
|
||
/datum/hunger_level/normal | ||
min_nutrition = NUTRITION_LEVEL_HUNGRY + 1 | ||
move_mod = 0 | ||
tool_mod = 0 | ||
stamina_max = MAX_STAMINA_LOSS | ||
sound_env = SOUND_ENVIRONMENT_NONE | ||
above = /datum/hunger_level/fed | ||
below = /datum/hunger_level/hungry | ||
|
||
/datum/hunger_level/fed | ||
min_nutrition = NUTRITION_LEVEL_FED + 1 | ||
move_mod = 0 | ||
tool_mod = 0 | ||
stamina_max = MAX_STAMINA_LOSS + 5 | ||
sound_env = SOUND_ENVIRONMENT_NONE | ||
above = /datum/hunger_level/full | ||
below = /datum/hunger_level/normal | ||
|
||
/datum/hunger_level/full | ||
min_nutrition = NUTRITION_LEVEL_WELL_FED + 1 | ||
move_mod = 0 | ||
tool_mod = 0 | ||
stamina_max = MAX_STAMINA_LOSS + 10 | ||
sound_env = SOUND_ENVIRONMENT_NONE | ||
regen_stamina = TRUE | ||
regen_blood = TRUE | ||
above = null | ||
below = /datum/hunger_level/fed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это не нужно. У тебя есть порог у текущего уровня голода. Если текущий голод ниже min_nutrition текущего уровня, то с помощью below(если тот туществует) получай голод ниже из глобального списка. above-у сделай тип /datum/hunger_level. Тогда ты сможешь статически получить значения даже из типа, а не из объекта типа. Сравнивай текущее насыщение с min_nutrition из above, и если он выше, то получай так же из списка, но уже через above