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

Add NO_STEAL_HERO creature property #3603

Merged
merged 1 commit into from
Oct 29, 2024
Merged
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
4 changes: 2 additions & 2 deletions campgns/ami2019_crtr/avatar.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Name = AVATAR
Defence = 110
ThingSize = 256 512
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER LORD
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER LORD NO_STEAL_HERO

[experience]
Powers = SWING_WEAPON_SWORD ARMOUR WORD_OF_POWER HEAL NULL FREEZE LIGHTNING FIRE_BOMB INVISIBILITY SPEED
PowersLevelRequired = 1 2 3 4 0 6 7 8 9 10
ExperienceForHitting = 35

[jobs]
TrainingValue = 3
TrainingValue = 3
2 changes: 1 addition & 1 deletion campgns/ami2019_crtr/knight.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[attributes]
Name = KNIGHT
Defence = 30
Properties = BLEEDS HUMANOID_SKELETON
Properties = BLEEDS HUMANOID_SKELETON NO_STEAL_HERO
2 changes: 1 addition & 1 deletion campgns/dzjr06lv_crtr/avatar.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Recovery = 5
BaseSpeed = 32
Pay = 2500
DamageToBoulder = 20
Properties = BLEEDS HUMANOID_SKELETON ONE_OF_KIND
Properties = BLEEDS HUMANOID_SKELETON ONE_OF_KIND NO_STEAL_HERO

[attraction]
EntranceRoom = NULL BARRACKS NULL
Expand Down
2 changes: 1 addition & 1 deletion campgns/lqizgood_crtr/avatar.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

[attributes]
Name = AVATAR
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER ONE_OF_KIND
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER ONE_OF_KIND NO_STEAL_HERO
2 changes: 1 addition & 1 deletion campgns/lqizgood_crtr/knight.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[attributes]
Name = KNIGHT
Properties = BLEEDS HUMANOID_SKELETON
Properties = BLEEDS HUMANOID_SKELETON NO_STEAL_HERO

[attraction]
EntranceRoom = TRAINING BARRACKS NULL
Expand Down
2 changes: 1 addition & 1 deletion config/creatrs/avatar.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DamageToBoulder = 60
; Creature thing size - XY and Z, one cube is 256x256.
ThingSize = 256 590
LairObject = LAIR_AVATR
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER LORD ONE_OF_KIND
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER LORD ONE_OF_KIND NO_STEAL_HERO

[attraction]
EntranceRoom = LAIR TRAINING GARDEN
Expand Down
2 changes: 1 addition & 1 deletion config/creatrs/knight.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DamageToBoulder = 40
; Creature thing size - XY and Z, one cube is 256x256.
ThingSize = 256 560
LairObject = LAIR_KNGHT
Properties = BLEEDS HUMANOID_SKELETON LORD
Properties = BLEEDS HUMANOID_SKELETON LORD NO_STEAL_HERO

[attraction]
EntranceRoom = TRAINING NULL NULL
Expand Down
2 changes: 1 addition & 1 deletion levels/legacy_crtr/avatar.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FearWounded = 0
Defence = 110
Luck = 8
DamageToBoulder = 20
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER ONE_OF_KIND
Properties = BLEEDS HUMANOID_SKELETON NEVER_CHICKENS IMMUNE_TO_BOULDER ONE_OF_KIND NO_STEAL_HERO

[attraction]
EntranceRoom = NULL NULL NULL
Expand Down
47 changes: 24 additions & 23 deletions src/config_creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,36 @@
extern "C" {
#endif

#define CREATURE_NONE 255
#define CREATURE_ANY 254
#define CREATURE_NOT_A_DIGGER 253
#define CREATURE_DIGGER 252
#define CREATURE_NONE 255
#define CREATURE_ANY 254
#define CREATURE_NOT_A_DIGGER 253
#define CREATURE_DIGGER 252

/** Percentage of creature parameter increase for every experience level.
* Used as default value, should be replaced in config file. */
#define CREATURE_PROPERTY_INCREASE_ON_EXP 35
/******************************************************************************/
enum CreatureModelFlags {
CMF_IsSpecDigger = 0x00001, // Imp and Tunneller.
CMF_IsArachnid = 0x00002, // simply, Spider.
CMF_IsDiptera = 0x00004, // simply, Fly.
CMF_IsLordOTLand = 0x00008, // simply, Knight.
CMF_IsSpectator = 0x00010, // simply, Floating Spirit.
CMF_IsEvil = 0x00020, // All evil creatures.
CMF_NeverChickens = 0x00040, // Cannot be affected by Chicken (for Avatar).
CMF_ImmuneToBoulder = 0x00080, // Boulder traps are destroyed at the moment they touch the creature.
CMF_NoCorpseRotting = 0x00100, // Corpse cannot rot in graveyard.
CMF_NoEnmHeartAttack = 0x00200, // Creature will not attack enemy heart on sight.
CMF_Trembling = 0x00400, // Creature causes ground to tremble when dropped.
CMF_Female = 0x00800, // Creature is female.
CMF_Insect = 0x01000, // Creature is kind of insect.
CMF_OneOfKind = 0x02000, // Only one creature of that kind may exist on one level. Unit name is type name.
CMF_NoImprisonment = 0x04000, // Creature will not faint.
CMF_NeverSick = 0x08000, // Creature will not get disease.
CMF_NoResurrect = 0x10000, // Creature will not resurrect.
CMF_NoTransfer = 0x20000, // Creature cannot be transferred.
CMF_Fat = 0x40000, // Creature to fat too walk a full animation
CMF_IsSpecDigger = 0x000001, // Imp and Tunneller.
CMF_IsArachnid = 0x000002, // Simply, Spider.
CMF_IsDiptera = 0x000004, // Simply, Fly.
CMF_IsLordOTLand = 0x000008, // Simply, Knight and Avatar.
CMF_IsSpectator = 0x000010, // Simply, Floating Spirit.
CMF_IsEvil = 0x000020, // All evil creatures.
CMF_NeverChickens = 0x000040, // Cannot be affected by Chicken (for Avatar).
CMF_ImmuneToBoulder = 0x000080, // Boulder traps are destroyed at the moment they touch the creature.
CMF_NoCorpseRotting = 0x000100, // Corpse cannot rot in graveyard.
CMF_NoEnmHeartAttack = 0x000200, // Creature will not attack enemy heart on sight.
CMF_Trembling = 0x000400, // Creature causes ground to tremble when dropped.
CMF_Female = 0x000800, // Creature is female.
CMF_Insect = 0x001000, // Creature is kind of insect.
CMF_OneOfKind = 0x002000, // Only one creature of that kind may exist on one level. Unit name is type name.
CMF_NoImprisonment = 0x004000, // Creature will not faint.
CMF_NeverSick = 0x008000, // Creature will not get disease.
CMF_NoResurrect = 0x010000, // Creature will not resurrect.
CMF_NoTransfer = 0x020000, // Creature cannot be transferred.
CMF_Fat = 0x040000, // Creature to fat too walk a full animation.
CMF_NoStealHero = 0x080000, // Prevent the creature from being stolen with the Steal Hero special.
};

enum CreatureJobFlags {
Expand Down
5 changes: 5 additions & 0 deletions src/config_crtrmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const struct NamedCommand creatmodel_properties_commands[] = {
{"NO_TRANSFER", 29},
{"TREMBLING", 30},
{"FAT", 31},
{"NO_STEAL_HERO", 32},
{NULL, 0},
};

Expand Down Expand Up @@ -764,6 +765,10 @@ TbBool parse_creaturemodel_attributes_blocks(long crtr_model,char *buf,long len,
crconf->model_flags |= CMF_Fat;
n++;
break;
case 32: // NO_STEAL_HERO
crconf->model_flags |= CMF_NoStealHero;
n++;
break;
default:
CONFWRNLOG("Incorrect value of \"%s\" parameter \"%s\" in [%s] block of %s %s file.",
COMMAND_TEXT(cmd_num),word_buf,block_buf, creature_code_name(crtr_model), config_textname);
Expand Down
10 changes: 10 additions & 0 deletions src/lvl_script_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,16 @@ void script_process_value(unsigned long var_index, unsigned long plr_range_id, l
clear_flag(crconf->model_flags,CMF_Fat);
}
break;
case 32: // NO_STEAL_HERO
if (val4 >= 1)
{
set_flag(crconf->model_flags,CMF_NoStealHero);
}
else
{
clear_flag(crconf->model_flags,CMF_NoStealHero);
}
break;
default:
SCRPTERRLOG("Unknown creature property '%d'", val3);
break;
Expand Down
35 changes: 11 additions & 24 deletions src/power_specials.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,32 +193,28 @@ void increase_level(struct PlayerInfo *player, int count)

TbBool steal_hero(struct PlayerInfo *player, struct Coord3d *pos)
{
//TODO CONFIG creature models dependency; put them in config files
static ThingModel skip_steal_models[] = {6, 7};//6 = KNIGHT, 7 = AVATAR
static ThingModel prefer_steal_models[] = {3, 12};//3 = ARCHER, 12 = THIEF
// TODO CONFIG creature models dependency put them in config files.
static ThingModel prefer_steal_models[] = {3, 12}; // 3 = ARCHER, 12 = THIEF.
struct Thing* herotng = INVALID_THING;
int heronum;
ThingIndex tng_idx;
SYNCDBG(8,"Starting");

SYNCDBG(8, "Starting");
int rand_offset = GAME_RANDOM(PLAYERS_COUNT);

for (size_t j = 0; j < PLAYERS_COUNT; j++)
{
PlayerNumber roam_plr_idx = (j + rand_offset) % PLAYERS_COUNT;
if(!player_is_roaming(roam_plr_idx))
continue;

struct Dungeon* herodngn = get_players_num_dungeon(roam_plr_idx);
unsigned long k = 0;
if (herodngn->num_active_creatrs > 0) {
heronum = PLAYER_RANDOM(roam_plr_idx, herodngn->num_active_creatrs);
tng_idx = herodngn->creatr_list_start;
SYNCDBG(4,"Selecting random creature %d out of %d heroes",(int)heronum,(int)herodngn->num_active_creatrs);
SYNCDBG(4, "Selecting random creature %d out of %d heroes", (int)heronum, (int)herodngn->num_active_creatrs);
} else {
heronum = 0;
tng_idx = 0;
SYNCDBG(4,"No heroes on map, skipping selection");
SYNCDBG(4, "No heroes on map, skipping selection");
}
while (tng_idx != 0)
{
Expand All @@ -231,26 +227,19 @@ TbBool steal_hero(struct PlayerInfo *player, struct Coord3d *pos)
break;
}
tng_idx = cctrl->players_next_creature_idx;
// Thing list loop body
TbBool heroallow = true;
for (ThingModel skipidx = 0; skipidx < sizeof(skip_steal_models) / sizeof(skip_steal_models[0]); skipidx++)
{
if (thing->model == skip_steal_models[skipidx]) {
heroallow = false;
}
}
if (heroallow) {
// Thing list loop body.
if (!flag_is_set(get_creature_model_flags(thing), CMF_NoStealHero)) {
herotng = thing;
}
// If we've reached requested hero number, return either current hero on previously selected one
// If we've reached requested hero number, return either current hero on previously selected one.
if ((heronum <= 0) && thing_is_creature(herotng)) {
break;
}
heronum--;
if (tng_idx == 0) {
tng_idx = herodngn->creatr_list_start;
}
// Thing list loop body ends
// Thing list loop body ends.
k++;
if (k > CREATURES_COUNT)
{
Expand All @@ -259,14 +248,12 @@ TbBool steal_hero(struct PlayerInfo *player, struct Coord3d *pos)
}
}
}


if (!thing_is_invalid(herotng))
{
move_thing_in_map(herotng, pos);
reset_interpolation_of_thing(herotng);
change_creature_owner(herotng, player->id_number);
SYNCDBG(3,"Converted %s to owner %d",thing_model_name(herotng),(int)player->id_number);
SYNCDBG(3, "Converted %s to owner %d", thing_model_name(herotng), (int)player->id_number);
}
else
{
Expand All @@ -279,7 +266,7 @@ TbBool steal_hero(struct PlayerInfo *player, struct Coord3d *pos)
struct Thing* creatng = create_creature(pos, prefer_steal_models[steal_idx], player->id_number);
if (thing_is_invalid(creatng))
return false;
SYNCDBG(3,"Created %s owner %d",thing_model_name(creatng),(int)player->id_number);
SYNCDBG(3, "Created %s owner %d", thing_model_name(creatng), (int)player->id_number);
}
return true;
}
Expand Down
Loading