Skip to content

Commit

Permalink
Power imp spell can be changed to spawn other units (#3581)
Browse files Browse the repository at this point in the history
- Not related to special digger property
- Can have multiple copies
  • Loading branch information
PieterVdc authored Oct 23, 2024
1 parent 4ddd6e9 commit be98486
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/fxdata/magic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,8 @@ PlayerState = PLAYER_STATE_CREATEDIGGER
ParentPower = NOPOWER
CastExpandFunc = do_not_expand
UseFunction = magic_use_power_imp
;only used with magic_use_power_imp, sets the type of unit spawned
CreatureType = IMP

[power3]
Name = POWER_OBEY
Expand Down
17 changes: 17 additions & 0 deletions src/config_magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const struct NamedCommand magic_power_commands[] = {
{"SPELL", 20},
{"EFFECT", 21},
{"USEFUNCTION", 22},
{"CREATURETYPE", 23},
{NULL, 0},
};

Expand Down Expand Up @@ -2206,6 +2207,22 @@ TbBool parse_magic_power_blocks(char *buf, long len, const char *config_textname
COMMAND_TEXT(cmd_num), blocknamelen, blockname, config_textname);
}
break;
case 23: //CREATURETYPE
if (get_conf_parameter_single(buf, &pos, len, word_buf, sizeof(word_buf)) > 0)
{
k = get_id(creature_desc,word_buf);
if (k >= 0)
{
powerst->creature_model = k;
n++;
}
}
if (n < 1)
{
CONFWRNLOG("Incorrect value of \"%s\" parameter in [%.*s] block of %s file.",
COMMAND_TEXT(cmd_num), blocknamelen, blockname, config_textname);
}
break;
case ccr_comment:
break;
case ccr_endOfFile:
Expand Down
1 change: 1 addition & 0 deletions src/config_magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ struct PowerConfigStats {
SpellKind spell_idx;
EffectOrEffElModel effect_id;
short magic_use_func_idx;
ThingModel creature_model;
};

/**
Expand Down
11 changes: 9 additions & 2 deletions src/creature_states_spdig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,9 +1020,16 @@ short imp_birth(struct Thing *thing)
{
// If the creature has flight ability, make sure it returns to flying state
restore_creature_flight_flag(thing);
if (!check_out_available_spdigger_drop_tasks(thing)) {
set_start_state(thing);
if (thing_is_creature_special_digger(thing))
{
if (!check_out_available_spdigger_drop_tasks(thing)) {
set_start_state(thing);
}
}
else
{
set_start_state(thing);
}
return 1;
}
long i = game.play_gameturn - thing->creation_turn;
Expand Down
2 changes: 1 addition & 1 deletion src/magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ static TbResult magic_use_power_imp(PowerKind power_kind, PlayerNumber plyr_idx,
pos.x.val = subtile_coord_center(stl_x);
pos.y.val = subtile_coord_center(stl_y);
pos.z.val = get_floor_height_at(&pos) + (heartng->clipbox_size_z >> 1);
thing = create_creature(&pos, get_players_special_digger_model(plyr_idx), plyr_idx);
thing = create_creature(&pos, powerst->creature_model, plyr_idx);
if (thing_is_invalid(thing))
{
ERRORLOG("There was place to create new creature, but creation failed");
Expand Down

0 comments on commit be98486

Please sign in to comment.