Skip to content

Commit

Permalink
Merge branch 'master' into rightshiftoneclick
Browse files Browse the repository at this point in the history
  • Loading branch information
Loobinex committed Aug 19, 2024
2 parents ec0e653 + c8b5153 commit 6b615f2
Show file tree
Hide file tree
Showing 15 changed files with 213 additions and 110 deletions.
9 changes: 8 additions & 1 deletion config/fxdata/objects.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ LightUnaffected = 0
LightIntensity = 0
; The range of the light in subtiles. 0~255.
LightRadius = 0
; Unknown light properties. Possible flag values 0~255, where powers of 2 are unique properties.
LightFlags = 0
; The type of light. 0: disabled, 1: enabled.
LightIsDynamic = 0
; The icon that represents the icon on the map. -1 is used for custom.
Expand Down Expand Up @@ -98,6 +100,7 @@ FallAcceleration = 0
LightUnaffected = 1
LightIntensity = 50
LightRadius = 6
LightFlags = 5
LightIsDynamic = 0
AmbienceSound = 78
RandomStartFrame = 1
Expand Down Expand Up @@ -151,6 +154,7 @@ FallAcceleration = 20
LightUnaffected = 1
LightIntensity = 47
LightRadius = 7
LightFlags = 5
LightIsDynamic = 0
AmbienceSound = 78
RandomStartFrame = 0
Expand Down Expand Up @@ -181,6 +185,7 @@ LightUnaffected = 0
MapIcon = 512
LightIntensity = 36
LightRadius = 14
LightFlags = 5
LightIsDynamic = 1
RandomStartFrame = 0
DrawClass = 2
Expand Down Expand Up @@ -737,6 +742,7 @@ FallAcceleration = 0
LightUnaffected = 1
LightIntensity = 46
LightRadius = 6
LightFlags = 5
LightIsDynamic = 0
AmbienceSound = 78
RandomStartFrame = 1
Expand Down Expand Up @@ -1221,7 +1227,7 @@ UpdateFunction = NULL

[object49]
Name = HERO_GATE
Genre = FURNITURE
Genre = HEROGATE
AnimationID = 776
AnimationSpeed = 256
Size_XY = 0
Expand All @@ -1234,6 +1240,7 @@ FallAcceleration = 0
LightUnaffected = 1
LightIntensity = 40
LightRadius = 10
LightFlags = 5
LightIsDynamic = 0
AmbienceSound = 973
RandomStartFrame = 0
Expand Down
25 changes: 16 additions & 9 deletions src/config_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const struct NamedCommand objects_object_commands[] = {
{"FLAMEANIMATIONSIZE", 35},
{"FLAMEANIMATIONOFFSET", 36},
{"FLAMETRANSPARENCYFLAGS", 37},
{"LIGHTFLAGS", 38},
{NULL, 0},
};

Expand Down Expand Up @@ -110,6 +111,7 @@ const struct NamedCommand objects_genres_desc[] = {
{"POWER", OCtg_Power},
{"LAIR_TOTEM", OCtg_LairTotem},
{"EFFECT", OCtg_Effect},
{"HEROGATE", OCtg_HeroGate},
{NULL, 0},
};

Expand Down Expand Up @@ -762,6 +764,20 @@ TbBool parse_objects_object_blocks(char *buf, long len, const char *config_textn
CONFWRNLOG("Incorrect value of \"%s\" parameter in [%s] block of %s file.",
COMMAND_TEXT(cmd_num), block_buf, config_textname);
}
break;
case 38: // LIGHTFLAGS
if (get_conf_parameter_single(buf, &pos, len, word_buf, sizeof(word_buf)) > 0)
{
k = atoi(word_buf);
objst->ilght.flags = k;
n++;
}
if (n <= 0)
{
CONFWRNLOG("Incorrect value of \"%s\" parameter in [%s] block of %s file.",
COMMAND_TEXT(cmd_num), block_buf, config_textname);
}
break;
case 0: // comment
break;
case -1: // end of buffer
Expand Down Expand Up @@ -960,15 +976,6 @@ int get_required_room_capacity_for_object(RoomRole room_role, ThingModel objmode
return 0;
}

void init_objects(void)
{
game.conf.object_conf.object_cfgstats[ObjMdl_Torch].ilght.flags = 5;
game.conf.object_conf.object_cfgstats[ObjMdl_HeroGate].ilght.flags = 5;
game.conf.object_conf.object_cfgstats[ObjMdl_StatueLit].ilght.flags = 5;
game.conf.object_conf.object_cfgstats[ObjMdl_SoulCountainer].ilght.flags = 5;
game.conf.object_conf.object_cfgstats[ObjMdl_Candlestick].ilght.flags = 5;
}

/******************************************************************************/
#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion src/config_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum ObjectCategoryIndex {
OCtg_Power, //< Object is a keeper power effect, ie. hand of evil or keeper spell
OCtg_LairTotem, //< Object is a creature lair
OCtg_Effect, //< Object is some kind of effect which has influence on things or on terrain
OCtg_HeroGate, //< Object functions as a hero gate
};

enum ObjectModelFlags {
Expand Down Expand Up @@ -134,7 +135,6 @@ ThingClass crate_to_workshop_item_class(ThingModel tngmodel);
ThingModel crate_to_workshop_item_model(ThingModel tngmodel);
ThingClass crate_thing_to_workshop_item_class(const struct Thing *thing);
ThingModel crate_thing_to_workshop_item_model(const struct Thing *thing);
void init_objects(void);
int get_required_room_capacity_for_object(RoomRole room_role, ThingModel objmodel, ThingModel relmodel);
void update_all_object_stats();
/******************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions src/creature_states_hero.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ short good_leave_through_exit_door(struct Thing *thing)
erstat_inc(ESE_BadCreatrState);
return false;
}
struct Thing* tmptng = find_base_thing_on_mapwho(TCls_Object, ObjMdl_HeroGate, thing->mappos.x.stl.num, thing->mappos.y.stl.num); //49 = hero gate
struct Thing* tmptng = find_object_of_genre_on_mapwho(OCtg_HeroGate, thing->mappos.x.stl.num, thing->mappos.y.stl.num);
if (thing_is_invalid(tmptng))
{
return 0;
Expand Down Expand Up @@ -1123,7 +1123,7 @@ short good_wait_in_exit_door(struct Thing *thing)
cctrl->countdown_282--;
if (cctrl->countdown_282 == 0)
{
struct Thing* tmptng = find_base_thing_on_mapwho(TCls_Object, ObjMdl_HeroGate, thing->mappos.x.stl.num, thing->mappos.y.stl.num);
struct Thing* tmptng = find_object_of_genre_on_mapwho(OCtg_HeroGate, thing->mappos.x.stl.num, thing->mappos.y.stl.num);
if (!thing_is_invalid(tmptng))
{
if (cctrl->hero.hero_gate_creation_turn == tmptng->creation_turn)
Expand Down
5 changes: 0 additions & 5 deletions src/lvl_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,6 @@ static void process_party(struct PartyTrigger* pr_trig)
case TrgF_DELETE_FROM_PARTY:
delete_member_from_party(pr_trig->party_id, pr_trig->creatr_id, pr_trig->crtr_level);
break;
case TrgF_CREATE_OBJECT:
n |= ((pr_trig->crtr_level & 7) << 7);
SYNCDBG(6, "Adding object %d at location %d", (int)n, (int)pr_trig->location);
script_process_new_object(n, pr_trig->location, pr_trig->carried_gold, pr_trig->plyr_idx);
break;
case TrgF_CREATE_EFFECT_GENERATOR:
SYNCDBG(6, "Adding effect generator %d at location %d", pr_trig->crtr_level, (int)pr_trig->location);
script_process_new_effectgen(pr_trig->crtr_level, pr_trig->location, pr_trig->carried_gold);
Expand Down
119 changes: 110 additions & 9 deletions src/lvl_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ static void move_creature_process(struct ScriptContext* context)
}

struct Coord3d pos;
if(!get_coords_at_location(&pos,location)) {
if(!get_coords_at_location(&pos,location,false)) {
SYNCDBG(5,"No valid coords for location",(int)location);
return;
}
Expand Down Expand Up @@ -2339,7 +2339,7 @@ static void set_door_configuration_process(struct ScriptContext *context)
}
}

static void create_effect_process(struct ScriptContext *context)
static void create_effect_at_pos_process(struct ScriptContext* context)
{
struct Coord3d pos;
set_coords_to_subtile_center(&pos, context->value->shorts[1], context->value->shorts[2], 0);
Expand Down Expand Up @@ -2367,6 +2367,36 @@ static void create_effect_process(struct ScriptContext *context)
}
}

static void create_effect_process(struct ScriptContext *context)
{
struct Coord3d pos;
if (!get_coords_at_location(&pos, context->value->uarg1,true))
{
SCRPTWRNLOG("Could not find location %d to create effect", context->value->uarg1);
}
TbBool Price = (context->value->shorts[0] == -(TngEffElm_Price));
if (Price)
{
pos.z.val += 128;
}
else
{
pos.z.val += context->value->arg2;
}
struct Thing* efftng = create_used_effect_or_element(&pos, context->value->shorts[0], game.neutral_player_num);
if (!thing_is_invalid(efftng))
{
if (thing_in_wall_at(efftng, &efftng->mappos))
{
move_creature_to_nearest_valid_position(efftng);
}
if (Price)
{
efftng->price_effect.number = context->value->arg2;
}
}
}

static void set_heart_health_check(const struct ScriptLine *scline)
{
ALLOCATE_SCRIPT_VALUE(scline->command, 0);
Expand Down Expand Up @@ -3452,11 +3482,7 @@ static void create_effect_check(const struct ScriptLine *scline)
{
return;
}
long stl_x;
long stl_y;
find_map_location_coords(location, &stl_x, &stl_y, 0, __func__);
value->shorts[1] = stl_x;
value->shorts[2] = stl_y;
value->uarg1 = location;
value->arg2 = scline->np[2];
PROCESS_SCRIPT_VALUE(scline->command);
}
Expand Down Expand Up @@ -5971,6 +5997,80 @@ static void computer_player_check(const struct ScriptLine* scline)
}
}

static void add_object_to_level_at_pos_check(const struct ScriptLine* scline)
{
ALLOCATE_SCRIPT_VALUE(scline->command, 0);
short tngmodel = get_rid(object_desc, scline->tp[0]);
if (tngmodel == -1)
{
SCRPTERRLOG("Unknown object: %s", scline->tp[0]);
DEALLOCATE_SCRIPT_VALUE
return;
}
value->shorts[0] = tngmodel;
if (!subtile_coords_invalid(scline->np[1], scline->np[2]))
{
value->shorts[1] = scline->np[1];
value->shorts[2] = scline->np[2];
}
else
{
SCRPTERRLOG("Invalid subtile co-ordinates: %ld, %ld", scline->np[1], scline->np[2]);
DEALLOCATE_SCRIPT_VALUE
return;
}
value->arg2 = scline->np[3];
PlayerNumber plyr_idx = get_rid(player_desc, scline->tp[4]);
if ((plyr_idx == -1) || (plyr_idx == ALL_PLAYERS))
{
plyr_idx = PLAYER_NEUTRAL;
}
value->chars[6] = plyr_idx;
PROCESS_SCRIPT_VALUE(scline->command);
}

static void add_object_to_level_check(const struct ScriptLine* scline)
{
ALLOCATE_SCRIPT_VALUE(scline->command, 0);
short obj_id = get_rid(object_desc, scline->tp[0]);
if (obj_id == -1)
{
SCRPTERRLOG("Unknown object, '%s'", scline->tp[0]);
DEALLOCATE_SCRIPT_VALUE
return;
}
value->shorts[0] = obj_id;
TbMapLocation location;
if (!get_map_location_id(scline->tp[1], &location))
{
DEALLOCATE_SCRIPT_VALUE
return;
}
value->uarg1 = location;
value->arg2 = scline->np[2];
PlayerNumber plyr_idx = get_rid(player_desc, scline->tp[3]);
if ((plyr_idx == -1) || (plyr_idx == ALL_PLAYERS))
{
plyr_idx = PLAYER_NEUTRAL;
}
value->chars[2] = plyr_idx;
PROCESS_SCRIPT_VALUE(scline->command);
}

static void add_object_to_level_process(struct ScriptContext* context)
{
struct Coord3d pos;
if (get_coords_at_location(&pos,context->value->uarg1,true))
{
script_process_new_object(context->value->shorts[0], pos.x.stl.num, pos.y.stl.num, context->value->arg2, context->value->chars[2]);
}
}

static void add_object_to_level_at_pos_process(struct ScriptContext* context)
{
script_process_new_object(context->value->shorts[0], context->value->shorts[1], context->value->shorts[2], context->value->arg2, context->value->chars[6]);
}

/**
* Descriptions of script commands for parser.
* Arguments are: A-string, N-integer, C-creature model, P- player, R- room kind, L- location, O- operator, S- slab kind
Expand All @@ -5982,7 +6082,7 @@ const struct CommandDesc command_desc[] = {
{"DELETE_FROM_PARTY", "ACN ", Cmd_DELETE_FROM_PARTY, &delete_from_party_check, NULL},
{"ADD_PARTY_TO_LEVEL", "PAAN ", Cmd_ADD_PARTY_TO_LEVEL, NULL, NULL},
{"ADD_CREATURE_TO_LEVEL", "PCANNN ", Cmd_ADD_CREATURE_TO_LEVEL, NULL, NULL},
{"ADD_OBJECT_TO_LEVEL", "AANp ", Cmd_ADD_OBJECT_TO_LEVEL, NULL, NULL},
{"ADD_OBJECT_TO_LEVEL", "AANp ", Cmd_ADD_OBJECT_TO_LEVEL, &add_object_to_level_check, &add_object_to_level_process},
{"IF", "PAOAa ", Cmd_IF, &if_check, NULL},
{"IF_ACTION_POINT", "NP ", Cmd_IF_ACTION_POINT, NULL, NULL},
{"ENDIF", " ", Cmd_ENDIF, NULL, NULL},
Expand Down Expand Up @@ -6102,7 +6202,7 @@ const struct CommandDesc command_desc[] = {
{"HIDE_TIMER", " ", Cmd_HIDE_TIMER, &cmd_no_param_check, &hide_timer_process},
{"HIDE_VARIABLE", " ", Cmd_HIDE_VARIABLE, &cmd_no_param_check, &hide_variable_process},
{"CREATE_EFFECT", "AAn ", Cmd_CREATE_EFFECT, &create_effect_check, &create_effect_process},
{"CREATE_EFFECT_AT_POS", "ANNn ", Cmd_CREATE_EFFECT_AT_POS, &create_effect_at_pos_check, &create_effect_process},
{"CREATE_EFFECT_AT_POS", "ANNn ", Cmd_CREATE_EFFECT_AT_POS, &create_effect_at_pos_check, &create_effect_at_pos_process},
{"HEART_LOST_QUICK_OBJECTIVE", "NAl ", Cmd_HEART_LOST_QUICK_OBJECTIVE, &heart_lost_quick_objective_check, &heart_lost_quick_objective_process},
{"HEART_LOST_OBJECTIVE", "Nl ", Cmd_HEART_LOST_OBJECTIVE, &heart_lost_objective_check, &heart_lost_objective_process},
{"SET_DOOR", "ANN ", Cmd_SET_DOOR, &set_door_check, &set_door_process},
Expand All @@ -6128,6 +6228,7 @@ const struct CommandDesc command_desc[] = {
{"SET_PLAYER_MODIFIER", "PAN ", Cmd_SET_PLAYER_MODIFIER, &set_player_modifier_check, &set_player_modifier_process},
{"ADD_TO_PLAYER_MODIFIER", "PAN ", Cmd_ADD_TO_PLAYER_MODIFIER, &add_to_player_modifier_check, &add_to_player_modifier_process},
{"CHANGE_SLAB_TEXTURE", "NNAa ", Cmd_CHANGE_SLAB_TEXTURE , &change_slab_texture_check, &change_slab_texture_process},
{"ADD_OBJECT_TO_LEVEL_AT_POS", "ANNNp ", Cmd_ADD_OBJECT_TO_LEVEL_AT_POS, &add_object_to_level_at_pos_check, &add_object_to_level_at_pos_process},
{NULL, " ", Cmd_NONE, NULL, NULL},
};

Expand Down
46 changes: 0 additions & 46 deletions src/lvl_script_commands_old.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,49 +118,6 @@ static void command_add_party_to_level(long plr_range_id, const char *prtname, c
}
}

static void command_add_object_to_level(const char *obj_name, const char *locname, long arg, const char* playername)
{
TbMapLocation location;
long obj_id = get_rid(object_desc, obj_name);
if (obj_id == -1)
{
SCRPTERRLOG("Unknown object, '%s'", obj_name);
return;
}
if (gameadd.script.party_triggers_num >= PARTY_TRIGGERS_COUNT)
{
SCRPTERRLOG("Too many ADD_CREATURE commands in script");
return;
}
long plr_id = get_rid(player_desc, playername);

if ((plr_id == -1) || (plr_id == ALL_PLAYERS))
{
plr_id = PLAYER_NEUTRAL;
}

// Recognize place where party is created
if (!get_map_location_id(locname, &location))
return;
if (get_script_current_condition() == CONDITION_ALWAYS)
{
script_process_new_object(obj_id, location, arg, plr_id);
} else
{
struct PartyTrigger* pr_trig = &gameadd.script.party_triggers[gameadd.script.party_triggers_num % PARTY_TRIGGERS_COUNT];
pr_trig->flags = TrgF_CREATE_OBJECT;
pr_trig->flags |= next_command_reusable?TrgF_REUSABLE:0;
pr_trig->plyr_idx = plr_id;
pr_trig->creatr_id = obj_id & 0x7F;
pr_trig->crtr_level = ((obj_id >> 7) & 7); // No more than 1023 different classes of objects :)
pr_trig->carried_gold = arg;
pr_trig->location = location;
pr_trig->ncopies = 1;
pr_trig->condit_idx = get_script_current_condition();
gameadd.script.party_triggers_num++;
}
}

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)
{
TbMapLocation location;
Expand Down Expand Up @@ -1521,9 +1478,6 @@ void script_add_command(const struct CommandDesc *cmd_desc, const struct ScriptL
case Cmd_ADD_CREATURE_TO_LEVEL:
command_add_creature_to_level(scline->np[0], scline->tp[1], scline->tp[2], scline->np[3], scline->np[4], scline->np[5]);
break;
case Cmd_ADD_OBJECT_TO_LEVEL:
command_add_object_to_level(scline->tp[0], scline->tp[1], scline->np[2], scline->tp[3]);
break;
case Cmd_ENDIF:
pop_condition();
break;
Expand Down
Loading

0 comments on commit 6b615f2

Please sign in to comment.