Skip to content
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

Flag for all spell immunities #2934

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion config/creatrs/avatar.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ DamageToBoulder = 60
; Creature thing size - XY and Z; one cube is 256x256
ThingSize = 256 512
LairObject = LAIR_AVATR
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER LORD ONE_OF_KIND
SpellImmunities = CHICKEN
Properties = BLEEDS HUMANOID_SKELETON IMMUNE_TO_BOULDER LORD ONE_OF_KIND

[attraction]
; Rooms required to attract the creature from entrance, and number of slabs which is needed (max 3 rooms)
Expand Down
3 changes: 2 additions & 1 deletion config/creatrs/bile_demon.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ DamageToBoulder = 50
; Creature thing size - XY and Z; one cube is 256x256
ThingSize = 256 512
LairObject = LAIR_BILDM
Properties = BLEEDS UNAFFECTED_BY_WIND IMMUNE_TO_GAS EVIL TREMBLING_FAT
SpellImmunities = GAS
Properties = BLEEDS UNAFFECTED_BY_WIND EVIL TREMBLING_FAT

[attraction]
; Rooms required to attract the creature from entrance, and number of slabs which is needed (max 3 rooms)
Expand Down
3 changes: 2 additions & 1 deletion config/creatrs/fairy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ DamageToBoulder = 15
; Creature thing size - XY and Z; one cube is 256x256
ThingSize = 256 512
LairObject = LAIR_FAIRY
Properties = BLEEDS IMMUNE_TO_GAS HUMANOID_SKELETON FLYING FEMALE
SpellImmunities = GAS
Properties = BLEEDS HUMANOID_SKELETON FLYING FEMALE

[attraction]
; Rooms required to attract the creature from entrance, and number of slabs which is needed (max 3 rooms)
Expand Down
3 changes: 2 additions & 1 deletion config/creatrs/ghost.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ DamageToBoulder = 20
; Creature thing size - XY and Z; one cube is 256x256
ThingSize = 256 512
LairObject = LAIR_GHOST
Properties = IMMUNE_TO_GAS FLYING SEE_INVISIBLE PASS_LOCKED_DOORS EVIL NO_CORPSE_ROTTING
SpellImmunities = GAS
Properties = FLYING SEE_INVISIBLE PASS_LOCKED_DOORS EVIL NO_CORPSE_ROTTING

[attraction]
; Rooms required to attract the creature from entrance, and number of slabs which is needed (max 3 rooms)
Expand Down
2 changes: 2 additions & 0 deletions config/creatrs/imp.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ DamageToBoulder = 30
ThingSize = 256 512
; The object the creature will create to use as a lair. Object needs to be configured correctly in objects.cfg too.
LairObject = LAIR_IMP
; Immunities: TODO
SpellImmunities =
; Creature properties:
; BLEEDS - the creature leaves blood when is hit, slapped, dying or being injured in any way.
; UNAFFECTED_BY_WIND - the creature isn't pushed back by Wind spell.
Expand Down
3 changes: 2 additions & 1 deletion config/creatrs/skeleton.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ DamageToBoulder = 20
; Creature thing size - XY and Z; one cube is 256x256
ThingSize = 256 512
LairObject = LAIR_SKELT
Properties = IMMUNE_TO_GAS HUMANOID_SKELETON EVIL
SpellImmunities = GAS
Properties = HUMANOID_SKELETON EVIL

[attraction]
; Rooms required to attract the creature from entrance, and number of slabs which is needed (max 3 rooms)
Expand Down
3 changes: 2 additions & 1 deletion config/creatrs/vampire.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ DamageToBoulder = 40
; Creature thing size - XY and Z; one cube is 256x256
ThingSize = 256 512
LairObject = LAIR_VAMP
Properties = BLEEDS IMMUNE_TO_GAS HUMANOID_SKELETON SEE_INVISIBLE EVIL ALLURING_SCVNGR
SpellImmunities = GAS
Properties = BLEEDS HUMANOID_SKELETON SEE_INVISIBLE EVIL ALLURING_SCVNGR

[attraction]
; Rooms required to attract the creature from entrance, and number of slabs which is needed (max 3 rooms)
Expand Down
3 changes: 2 additions & 1 deletion config/creatrs/wizard.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ DamageToBoulder = 30
; Creature thing size - XY and Z; one cube is 256x256
ThingSize = 256 512
LairObject = LAIR_WIZRD
Properties = BLEEDS IMMUNE_TO_GAS HUMANOID_SKELETON
SpellImmunities = GAS
Properties = BLEEDS HUMANOID_SKELETON

[attraction]
; Rooms required to attract the creature from entrance, and number of slabs which is needed (max 3 rooms)
Expand Down
7 changes: 7 additions & 0 deletions src/config_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,13 @@ unsigned long get_creature_model_flags(const struct Thing *thing)
return game.conf.crtr_conf.model[thing->model].model_flags;
}

unsigned long get_creature_immunity_flags(const struct Thing* thing)
{
if ((thing->model < 1) || (thing->model >= game.conf.crtr_conf.model_count))
return 0;
return game.conf.crtr_conf.model[thing->model].immunity_flags;
}

ThingModel get_creature_model_with_model_flags(unsigned long needflags)
{
for (ThingModel crmodel = 0; crmodel < game.conf.crtr_conf.model_count; crmodel++)
Expand Down
4 changes: 2 additions & 2 deletions src/config_creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ enum CreatureModelFlags {
CMF_IsLordOTLand = 0x0008, // simply, Knight
CMF_IsSpectator = 0x0010, // simply, Floating spirit
CMF_IsEvil = 0x0020, // All evil creatures
CMF_NeverChickens = 0x0040, // Cannot be affected by Chicken (for Avatar)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this one replaced with a dummied out property instead?
disease is ok to be removed cause is at end of list but for that one there is a hole now or I'm misunderstanding it 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, will add some comments there sure

CMF_ImmuneToBoulder = 0x0080, // Boulder traps are destroyed at the moment they touch the creature
CMF_NoCorpseRotting = 0x0100, // Corpse cannot rot in graveyard
CMF_NoEnmHeartAttack = 0x0200, // Creature will not attack enemy heart on sight
Expand All @@ -56,7 +55,6 @@ enum CreatureModelFlags {
CMF_Insect = 0x1000, // Creature is kind of insect
CMF_OneOfKind = 0x2000, // Only one creature of that kind may exist on one level. Unit name is type name.
CMF_NoImprisonment = 0x4000, // Creature will not faint.
CMF_NeverSick = 0x8000, // Creature will not get disease.
};

enum CreatureJobFlags {
Expand Down Expand Up @@ -223,6 +221,7 @@ struct CreatureModelConfig {
char name[COMMAND_WORD_LEN];
long namestr_idx;
unsigned long model_flags;
unsigned long immunity_flags;
};

/**
Expand Down Expand Up @@ -293,6 +292,7 @@ TbBool is_creature_model_wildcard(ThingModel crmodel);
TbBool load_creaturetypes_config(const char *conf_fname, unsigned short flags);
/******************************************************************************/
unsigned long get_creature_model_flags(const struct Thing *thing);
unsigned long get_creature_immunity_flags(const struct Thing* thing);
TbBool set_creature_available(PlayerNumber plyr_idx, ThingModel crtr_model, long can_be_avail, long force_avail);
ThingModel get_players_special_digger_model(PlayerNumber plyr_idx);
ThingModel get_players_spectator_model(PlayerNumber plyr_idx);
Expand Down
37 changes: 34 additions & 3 deletions src/config_crtrmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const struct NamedCommand creatmodel_attributes_commands[] = {
{"CORPSEVANISHEFFECT", 32},
{"FOOTSTEPPITCH", 33},
{"LAIROBJECT", 34},
{"SPELLIMMUNITIES", 35},
{NULL, 0},
};

Expand Down Expand Up @@ -117,6 +118,27 @@ const struct NamedCommand creatmodel_properties_commands[] = {
{NULL, 0},
};

const struct NamedCommand creatmodel_spell_immunity_commands[] = {
{"SLOW", CSAfF_Slow},
{"SPEED", CSAfF_Speed},
{"ARMOUR", CSAfF_Armour},
{"REBOUND", CSAfF_Rebound},
{"FLYING", CSAfF_Flying},
{"INVISIBILITY", CSAfF_Invisibility},
{"SIGHT", CSAfF_Sight},
{"LIGHT", CSAfF_Light},
{"DISEASE", CSAfF_Disease},
{"CHICKEN", CSAfF_Chicken},
{"GAS", CSAfF_PoisonCloud},
{"CALL_TO_ARMS", CSAfF_CalledToArms},
{"MAD_PSYCHO", CSAfF_MadKilling},
{"FALLING", CSAfF_MagicFall},
{"LEVELUP", CSAfF_ExpLevelUp},
{"GROUNDED", CSAfF_Grounded},
{"TIMEBOMB", CSAfF_Timebomb},
{NULL, 0},
};

const struct NamedCommand creatmodel_attraction_commands[] = {
{"ENTRANCEROOM", 1},
{"ROOMSLABSREQUIRED", 2},
Expand Down Expand Up @@ -273,6 +295,7 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
crstat->can_go_locked_doors = false;
crconf->namestr_idx = 0;
crconf->model_flags = 0;
crconf->immunity_flags = 0;
}
// Find the block
char block_buf[COMMAND_WORD_LEN];
Expand Down Expand Up @@ -645,7 +668,7 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
n++;
break;
case 3: // IMMUNE_TO_GAS
crstat->immune_to_gas = true;
set_flag(crconf->immunity_flags, CSAfF_PoisonCloud); // legacy, used to be a model flag
n++;
break;
case 4: // HUMANOID_SKELETON
Expand Down Expand Up @@ -693,7 +716,7 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
n++;
break;
case 16: // NEVER_CHICKENS
crconf->model_flags |= CMF_NeverChickens;
set_flag(crconf->immunity_flags, CSAfF_Chicken); // legacy, used to be a model flag
n++;
break;
case 17: // IMMUNE_TO_BOULDER
Expand Down Expand Up @@ -729,7 +752,7 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
n++;
break;
case 25: // IMMUNE_TO_DISEASE
crconf->model_flags |= CMF_NeverSick;
set_flag(crconf->immunity_flags, CSAfF_Disease); // legacy, used to be a model flag
n++;
break;
case 26: // ILLUMINATED
Expand Down Expand Up @@ -805,6 +828,14 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
COMMAND_TEXT(cmd_num), block_buf, config_textname);
}
break;
case 35: // SPELL_IMMUNITIES
crconf->immunity_flags = 0;
while (get_conf_parameter_single(buf, &pos, len, word_buf, sizeof(word_buf)) > 0)
{
k = get_id(creatmodel_spell_immunity_commands, word_buf);
set_flag(crconf->immunity_flags, k);
}
break;
case 0: // comment
break;
case -1: // end of buffer
Expand Down
17 changes: 10 additions & 7 deletions src/lvl_script_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,10 @@ TbResult script_use_spell_on_creature(PlayerNumber plyr_idx, long crmodel, long
const struct SpellConfig* spconf = get_spell_config(spkind);

if (spconf->caster_affected ||
(spkind == SplK_Freeze) || (spkind == SplK_Slow) || // These four should be also marked at configs somehow
( (spkind == SplK_Disease) && ((get_creature_model_flags(thing) & CMF_NeverSick) == 0) ) ||
( (spkind == SplK_Chicken) && ((get_creature_model_flags(thing) & CMF_NeverChickens) == 0) ) )
( (spkind == SplK_Freeze) ) || // This one should be also marked at configs somehow
( (spkind == SplK_Disease) && (!flag_is_set(get_creature_model_flags(thing), CSAfF_Disease)) ) ||
( (spkind == SplK_Slow) && (!flag_is_set(get_creature_model_flags(thing), CSAfF_Slow )) ) ||
( (spkind == SplK_Chicken) && (!flag_is_set(get_creature_model_flags(thing), CSAfF_Chicken)) ) )
{
if (thing_is_picked_up(thing))
{
Expand Down Expand Up @@ -691,11 +692,12 @@ void script_process_value(unsigned long var_index, unsigned long plr_range_id, l
case 16: // NEVER_CHICKENS
if (val4 >= 1)
{
crconf->model_flags |= CMF_NeverChickens;
//legacy, used to be model_flags
set_flag(crconf->immunity_flags, CSAfF_Chicken);
}
else
{
crconf->model_flags ^= CMF_NeverChickens;
clear_flag(crconf->immunity_flags, CSAfF_Chicken);
}
break;
case 17: // IMMUNE_TO_BOULDER
Expand Down Expand Up @@ -781,11 +783,12 @@ void script_process_value(unsigned long var_index, unsigned long plr_range_id, l
case 25: // NEVER_SICK
if (val4 >= 1)
{
crconf->model_flags |= CMF_NeverSick;
//legacy, used to be model_flags
set_flag(crconf->immunity_flags, CSAfF_Disease);
}
else
{
crconf->model_flags ^= CMF_NeverSick;
clear_flag(crconf->immunity_flags, CSAfF_Disease);
}
break;
case 26: // ILLUMINATED
Expand Down
4 changes: 2 additions & 2 deletions src/magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ TbResult magic_use_power_chicken(PlayerNumber plyr_idx, struct Thing *thing, Map
}
}
// Check if the creature kind isn't affected by that spell
if ((get_creature_model_flags(thing) & CMF_NeverChickens) != 0)
if (flag_is_set(get_creature_immunity_flags(thing), CSAfF_Chicken))
{
thing_play_sample(thing, 58, 20, 0, 3, 0, 2, 128);
return Lb_SUCCESS;
Expand All @@ -1110,7 +1110,7 @@ TbResult magic_use_power_disease(PlayerNumber plyr_idx, struct Thing *thing, Map
}
}
// Check if the creature kind isn't affected by that spell
if ((get_creature_model_flags(thing) & CMF_NeverSick) != 0)
if (flag_is_set(get_creature_immunity_flags(thing), CSAfF_Disease))
{
thing_play_sample(thing, 58, 20, 0, 3, 0, 2, 128);
return Lb_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion src/power_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void process_disease(struct Thing *creatng)
}
i = thing->next_on_mapblk;
// Per thing code
if (thing_is_creature(thing) && ((get_creature_model_flags(thing) & CMF_IsSpecDigger) == 0) && ((get_creature_model_flags(thing) & CMF_NeverSick) == 0)
if (thing_is_creature(thing) && ((get_creature_model_flags(thing) & CMF_IsSpecDigger) == 0) && ((get_creature_immunity_flags(thing) & CSAfF_Disease) == 0)
&& (thing->owner != cctrl->disease_caster_plyridx) && !creature_affected_by_spell(thing, SplK_Disease) && (cctrl->disease_caster_plyridx != game.neutral_player_num))
{
struct CreatureControl* tngcctrl = creature_control_get_from_thing(thing);
Expand Down
4 changes: 2 additions & 2 deletions src/thing_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ void first_apply_spell_effect_to_thing(struct Thing *thing, SpellKind spell_idx,
} else
if (spell_idx == SplK_Disease)
{
if ((get_creature_model_flags(thing) & CMF_NeverSick) == 0)
if ((get_creature_immunity_flags(thing) & CSAfF_Disease) == 0)
{
if (i != -1)
{
Expand Down Expand Up @@ -1003,7 +1003,7 @@ void first_apply_spell_effect_to_thing(struct Thing *thing, SpellKind spell_idx,
} else
if (spell_idx == SplK_Chicken)
{
if ((get_creature_model_flags(thing) & CMF_NeverChickens) == 0)
if (!flag_is_set(get_creature_immunity_flags(thing), CSAfF_Chicken))
{
if (i != -1)
{
Expand Down