Skip to content

Multiple Sleep Experience configs #3989

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
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/creatrs/sorceror.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ PowersLevelRequired = 1 2 3 4 5 6 7 8 9 0
LevelsTrainValues = 1000 3500 5000 6500 8500 10500 13000 16000 20000
GrowUp = 0 NULL 0
SleepExperience = GOLD 200
SleepExperience2 = DENSE_GOLD 300
SleepExperience3 = GEMS 50
ExperienceForHitting = 12

[jobs]
Expand Down
17 changes: 12 additions & 5 deletions src/config_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,13 @@ void check_and_auto_fix_stats(void)
ERRORLOG("Creature model %d (%s) HungerRate > 0 & Hunger Fill = 0 - Fixing", (int)model, creature_code_name(model));
crstat->hunger_fill = 1;
}
if ( (crstat->sleep_exp_slab != 0) && (crstat->sleep_experience == 0) )
for (unsigned int i = 0; i < SLEEP_XP_COUNT; i++)
{
ERRORLOG("Creature model %d (%s) SleepSlab set but SleepExperience = 0 - Fixing", (int)model, creature_code_name(model));
crstat->sleep_exp_slab = 0;
if ( (crstat->sleep_exp_slab[i] != 0) && (crstat->sleep_experience[i] == 0) )
{
ERRORLOG("Creature model %d (%s) SleepSlab set but SleepExperience = 0 - Fixing", (int)model, creature_code_name(model));
crstat->sleep_exp_slab[i] = 0;
}
}
if ((crstat->grow_up >= game.conf.crtr_conf.model_count) && !(crstat->grow_up == CREATURE_NOT_A_DIGGER))
{
Expand Down Expand Up @@ -518,8 +521,12 @@ void init_creature_model_stats(void)
}
crstat->grow_up = 0;
crstat->grow_up_level = 0;
crstat->sleep_exp_slab = 0;
crstat->sleep_experience = 0;
crstat->sleep_exp_slab[0] = 0;
crstat->sleep_experience[0] = 0;
crstat->sleep_exp_slab[1] = 0;
crstat->sleep_experience[1] = 0;
crstat->sleep_exp_slab[2] = 0;
crstat->sleep_experience[2] = 0;
crstat->exp_for_hitting = 0;
crstat->rebirth = 0;
// Jobs block.
Expand Down
21 changes: 14 additions & 7 deletions src/config_crtrmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ const struct NamedCommand creatmodel_experience_commands[] = {
{"LEVELSTRAINVALUES", 3},
{"GROWUP", 4},
{"SLEEPEXPERIENCE", 5},
{"EXPERIENCEFORHITTING", 6},
{"REBIRTH", 7},
{"SLEEPEXPERIENCE2", 6},
{"SLEEPEXPERIENCE3", 7},
{"EXPERIENCEFORHITTING", 8},
{"REBIRTH", 9},
{NULL, 0},
};

Expand Down Expand Up @@ -1884,22 +1886,26 @@ TbBool parse_creaturemodel_experience_blocks(long crtr_model,char *buf,long len,
}
break;
case 5: // SLEEPEXPERIENCE
case 6: // SLEEPEXPERIENCE2
case 7: // SLEEPEXPERIENCE3
{
unsigned int index = cmd_num - 5;
if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
{
k = get_id(slab_desc, word_buf);
if (k >= 0)
{
crstat->sleep_exp_slab = k;
crstat->sleep_exp_slab[index] = k;
n++;
} else
{
crstat->sleep_exp_slab = 0;
crstat->sleep_exp_slab[index] = 0;
}
}
if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
{
k = atoi(word_buf);
crstat->sleep_experience = k;
crstat->sleep_experience[index] = k;
n++;
}
if (n < 2)
Expand All @@ -1908,7 +1914,8 @@ TbBool parse_creaturemodel_experience_blocks(long crtr_model,char *buf,long len,
COMMAND_TEXT(cmd_num),block_buf,config_textname);
}
break;
case 6: // EXPERIENCEFORHITTING
}
case 8: // EXPERIENCEFORHITTING
if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
{
k = atoi(word_buf);
Expand All @@ -1921,7 +1928,7 @@ TbBool parse_creaturemodel_experience_blocks(long crtr_model,char *buf,long len,
COMMAND_TEXT(cmd_num),block_buf,config_textname);
}
break;
case 7: // REBIRTH
case 9: // REBIRTH
if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0)
{
k = atoi(word_buf);
Expand Down
5 changes: 3 additions & 2 deletions src/creature_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extern "C" {
#define ENTRANCE_ROOMS_COUNT 3
#define INSTANCE_TYPES_MAX 2000
#define LAIR_ENEMY_MAX 5
#define SLEEP_XP_COUNT 3

#define INVALID_CRTR_CONTROL (game.persons.cctrl_lookup[0])
/******************************************************************************/
Expand Down Expand Up @@ -433,8 +434,8 @@ struct CreatureStats { // These stats are not compatible with original DK - they
unsigned short annoy_level;
unsigned char lair_size;
unsigned char hurt_by_lava;
unsigned char sleep_exp_slab;
short sleep_experience;
SlabKind sleep_exp_slab[SLEEP_XP_COUNT];
short sleep_experience[SLEEP_XP_COUNT];
short exp_for_hitting;
short gold_hold;
short training_cost;
Expand Down
13 changes: 8 additions & 5 deletions src/creature_states_lair.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,15 @@ short creature_sleep(struct Thing *thing)
dungeon->lvstats.backs_stabbed++;
}
}
if (crstat->sleep_exp_slab != SlbT_ROCK)
{ // To think about: Should SlbT_ROCK be ignored? Settings the experience gain to 0 is enough to disable the feature.
if (creature_can_gain_experience(thing) && room_has_slab_adjacent(room, crstat->sleep_exp_slab))
for (unsigned int i = 0; i < SLEEP_XP_COUNT; i++)
{
if (crstat->sleep_experience[i] != 0)
{
cctrl->exp_points += crstat->sleep_experience;
check_experience_upgrade(thing);
if (creature_can_gain_experience(thing) && room_has_slab_adjacent(room, crstat->sleep_exp_slab[i]))
{
cctrl->exp_points += crstat->sleep_experience[i];
check_experience_upgrade(thing);
}
}
}
{
Expand Down
11 changes: 7 additions & 4 deletions src/lvl_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2802,17 +2802,20 @@ static void set_creature_configuration_process(struct ScriptContext* context)
break;
}
case 5: // SLEEPEXPERIENCE
case 6: // SLEEPEXPERIENCE2
case 7: // SLEEPEXPERIENCE3
{
crstat->sleep_exp_slab = value;
crstat->sleep_experience = value2;
unsigned int index = creature_variable - 5;
crstat->sleep_exp_slab[index] = value;
crstat->sleep_experience[index] = value2;
break;
}
case 6: // EXPERIENCEFORHITTING
case 8: // EXPERIENCEFORHITTING
{
crstat->exp_for_hitting = value;
break;
}
case 7: // REBIRTH
case 9: // REBIRTH
{
crstat->rebirth = value;
break;
Expand Down