Skip to content

Commit c56493d

Browse files
authored
Extra ADD_CREATURE_TO_LEVEL param to determine spawn method (#3841)
1 parent a388650 commit c56493d

13 files changed

+115
-61
lines changed

src/config_creature.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,21 @@ const struct NamedCommand instance_range_desc[] = {
202202
{NULL, -1},
203203
};
204204

205+
const struct NamedCommand spawn_type_desc[] = {
206+
{"NONE", SpwnT_None },
207+
{"0", SpwnT_None },
208+
{"DEFAULT", SpwnT_Default },
209+
{"1", SpwnT_Default },
210+
{"JUMP", SpwnT_Jump },
211+
{"2", SpwnT_Jump },
212+
{"FALL", SpwnT_Fall },
213+
{"3", SpwnT_Fall },
214+
{"INIT", SpwnT_Initialize },
215+
{"INITIALIZE", SpwnT_Initialize },
216+
{"4", SpwnT_Initialize },
217+
{NULL, -1 },
218+
};
219+
205220
/******************************************************************************/
206221
struct NamedCommand creature_desc[CREATURE_TYPES_MAX];
207222
struct NamedCommand instance_desc[INSTANCE_TYPES_MAX];

src/config_creature.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ enum CreatureAttackType {
169169
AttckT_Ranged,
170170
};
171171

172+
enum CreatureSpawnType {
173+
SpwnT_None = 0,
174+
SpwnT_Default,
175+
SpwnT_Jump,
176+
SpwnT_Fall,
177+
SpwnT_Initialize
178+
};
179+
172180
/******************************************************************************/
173181
#pragma pack(1)
174182

@@ -278,6 +286,7 @@ extern const struct NamedCommand creatmodel_experience_commands[];
278286
extern const struct NamedCommand creatmodel_senses_commands[];
279287
extern const struct NamedCommand creatmodel_appearance_commands[];
280288
extern const struct NamedCommand creature_deathkind_desc[];
289+
extern const struct NamedCommand spawn_type_desc[];
281290
extern Creature_Job_Player_Check_Func creature_job_player_check_func_list[];
282291
/******************************************************************************/
283292
struct CreatureStats *creature_stats_get(ThingModel crstat_idx);

src/creature_groups.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ struct Thing *script_process_new_party(struct Party *party, PlayerNumber plyr_id
903903
break;
904904
}
905905
struct PartyMember* member = &(party->members[k]);
906-
struct Thing* thing = script_create_new_creature(plyr_idx, member->crtr_kind, location, member->carried_gold, member->crtr_level);
906+
struct Thing* thing = script_create_new_creature(plyr_idx, member->crtr_kind, location, member->carried_gold, member->crtr_level, SpwnT_Default);
907907
if (!thing_is_invalid(thing))
908908
{
909909
struct CreatureControl* cctrl = creature_control_get_from_thing(thing);

src/creature_states_hero.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ TbBool script_support_send_tunneller_to_appropriate_dungeon(struct Thing *creatn
13021302
struct Thing *script_process_new_tunneler(unsigned char plyr_idx, TbMapLocation location, TbMapLocation heading, unsigned char crtr_level, unsigned long carried_gold)
13031303
{
13041304
ThingModel diggerkind = get_players_special_digger_model(plyr_idx);
1305-
struct Thing* creatng = script_create_creature_at_location(plyr_idx, diggerkind, location);
1305+
struct Thing* creatng = script_create_creature_at_location(plyr_idx, diggerkind, location, SpwnT_Default);
13061306
if (thing_is_invalid(creatng))
13071307
return INVALID_THING;
13081308
creatng->creature.gold_carried = carried_gold;

src/keeperfx.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void draw_gold_total(PlayerNumber plyr_idx, long scr_x, long scr_y, long units_p
263263
void draw_mini_things_in_hand(long x, long y);
264264
TbBool screen_to_map(struct Camera *camera, long screen_x, long screen_y, struct Coord3d *mappos);
265265
void update_creatr_model_activities_list(void);
266-
void find_map_location_coords(long location, long *x, long *y, int plyr_idx, const char *func_name);
266+
void find_map_location_coords(TbMapLocation location, long *x, long *y, int plyr_idx, const char *func_name);
267267
TbBool any_player_close_enough_to_see(const struct Coord3d *pos);
268268
void affect_nearby_stuff_with_vortex(struct Thing *thing);
269269
void affect_nearby_friends_with_alarm(struct Thing *thing);
@@ -282,10 +282,10 @@ short winning_player_quitting(struct PlayerInfo *player, long *plyr_count);
282282
short lose_level(struct PlayerInfo *player);
283283
short resign_level(struct PlayerInfo *player);
284284
short complete_level(struct PlayerInfo *player);
285-
void set_general_information(long msg_id, long target, long x, long y);
286-
void set_quick_information(long msg_id, long target, long x, long y);
287-
void process_objective(const char *msg_text, long target, long x, long y);
288-
void set_general_objective(long msg_id, long target, long x, long y);
285+
void set_general_information(long msg_id, TbMapLocation target, long x, long y);
286+
void set_quick_information(long msg_id, TbMapLocation target, long x, long y);
287+
void process_objective(const char *msg_text, TbMapLocation target, long x, long y);
288+
void set_general_objective(long msg_id, TbMapLocation target, long x, long y);
289289
void turn_off_power_sight_of_evil(PlayerNumber plridx);
290290
void turn_off_power_obey(PlayerNumber plyr_idx);
291291

src/lvl_script.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,7 @@ static void process_party(struct PartyTrigger* pr_trig)
12531253
break;
12541254
case TrgF_CREATE_CREATURE:
12551255
SCRIPTDBG(6, "Adding creature %ld", n);
1256-
script_process_new_creatures(pr_trig->plyr_idx, n, pr_trig->location,
1257-
pr_trig->ncopies, pr_trig->carried_gold, pr_trig->crtr_level);
1256+
script_process_new_creatures(pr_trig->plyr_idx, n, pr_trig->location, pr_trig->ncopies, pr_trig->carried_gold, pr_trig->crtr_level, pr_trig->spawn_type);
12581257
break;
12591258
}
12601259
}

src/lvl_script.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ struct PartyTrigger {
9797
};
9898
union
9999
{
100-
unsigned long location;
100+
TbMapLocation location;
101101
unsigned long countdown;
102102
};
103+
char spawn_type;
103104
unsigned char crtr_level;
104105
unsigned short carried_gold;
105106
union

src/lvl_script_commands.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7483,7 +7483,7 @@ const struct CommandDesc command_desc[] = {
74837483
{"ADD_TO_PARTY", "ACNNAN ", Cmd_ADD_TO_PARTY, &add_to_party_check, NULL},
74847484
{"DELETE_FROM_PARTY", "ACN ", Cmd_DELETE_FROM_PARTY, &delete_from_party_check, NULL},
74857485
{"ADD_PARTY_TO_LEVEL", "PAAN ", Cmd_ADD_PARTY_TO_LEVEL, NULL, NULL},
7486-
{"ADD_CREATURE_TO_LEVEL", "PCANNN ", Cmd_ADD_CREATURE_TO_LEVEL, NULL, NULL},
7486+
{"ADD_CREATURE_TO_LEVEL", "PCANNNa ", Cmd_ADD_CREATURE_TO_LEVEL, NULL, NULL},
74877487
{"ADD_OBJECT_TO_LEVEL", "AANpa ", Cmd_ADD_OBJECT_TO_LEVEL, &add_object_to_level_check, &add_object_to_level_process},
74887488
{"IF", "PAOAa ", Cmd_IF, &if_check, NULL},
74897489
{"IF_ACTION_POINT", "NP ", Cmd_IF_ACTION_POINT, NULL, NULL},

src/lvl_script_commands_old.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static void command_add_party_to_level(long plr_range_id, const char *prtname, c
119119
}
120120
}
121121

122-
static void command_add_creature_to_level(long plr_range_id, const char *crtr_name, const char *locname, long ncopies, long crtr_level, long carried_gold)
122+
static void command_add_creature_to_level(long plr_range_id, const char *crtr_name, const char *locname, long ncopies, long crtr_level, long carried_gold, const char *spawn_type)
123123
{
124124
TbMapLocation location;
125125
if ((crtr_level < 1) || (crtr_level > CREATURE_MAX_LEVEL))
@@ -147,6 +147,20 @@ static void command_add_creature_to_level(long plr_range_id, const char *crtr_na
147147
SCRPTERRLOG("Unknown creature, '%s'", crtr_name);
148148
return;
149149
}
150+
long spawn_type_id;
151+
if ((strcmp(spawn_type, "") == 0))
152+
{
153+
spawn_type_id = SpwnT_Default;
154+
}
155+
else
156+
{
157+
spawn_type_id = get_rid(spawn_type_desc, spawn_type);
158+
}
159+
if (spawn_type_id == -1)
160+
{
161+
SCRPTERRLOG("Unknown spawn type, '%s'", spawn_type);
162+
return;
163+
}
150164
// Verify player
151165
long plr_id = get_players_range_single(plr_range_id);
152166
if (plr_id < 0) {
@@ -158,7 +172,7 @@ static void command_add_creature_to_level(long plr_range_id, const char *crtr_na
158172
return;
159173
if (get_script_current_condition() == CONDITION_ALWAYS)
160174
{
161-
script_process_new_creatures(plr_id, crtr_id, location, ncopies, carried_gold, crtr_level-1);
175+
script_process_new_creatures(plr_id, crtr_id, location, ncopies, carried_gold, crtr_level-1, spawn_type_id);
162176
} else
163177
{
164178
struct PartyTrigger* pr_trig = &gameadd.script.party_triggers[gameadd.script.party_triggers_num % PARTY_TRIGGERS_COUNT];
@@ -171,6 +185,7 @@ static void command_add_creature_to_level(long plr_range_id, const char *crtr_na
171185
pr_trig->carried_gold = carried_gold;
172186
pr_trig->location = location;
173187
pr_trig->ncopies = ncopies;
188+
pr_trig->spawn_type = spawn_type_id;
174189
pr_trig->condit_idx = get_script_current_condition();
175190
gameadd.script.party_triggers_num++;
176191
}
@@ -1319,7 +1334,7 @@ void script_add_command(const struct CommandDesc *cmd_desc, const struct ScriptL
13191334
command_add_party_to_level(scline->np[0], scline->tp[1], scline->tp[2], scline->np[3]);
13201335
break;
13211336
case Cmd_ADD_CREATURE_TO_LEVEL:
1322-
command_add_creature_to_level(scline->np[0], scline->tp[1], scline->tp[2], scline->np[3], scline->np[4], scline->np[5]);
1337+
command_add_creature_to_level(scline->np[0], scline->tp[1], scline->tp[2], scline->np[3], scline->np[4], scline->np[5], scline->tp[6]);
13231338
break;
13241339
case Cmd_ENDIF:
13251340
pop_condition();

src/lvl_script_value.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ TbResult script_use_spell_on_creature(PlayerNumber plyr_idx, ThingModel crmodel,
207207
* @param destination: The desitination of the disk task.
208208
* @return TbResult whether the spell was successfully cast
209209
*/
210-
TbResult script_computer_dig_to_location(long plyr_idx, long origin, long destination)
210+
TbResult script_computer_dig_to_location(long plyr_idx, TbMapLocation origin, TbMapLocation destination)
211211
{
212212
struct Computer2* comp = get_computer_player(plyr_idx);
213213
long orig_x, orig_y = 0;

0 commit comments

Comments
 (0)