Skip to content
Closed
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
2 changes: 2 additions & 0 deletions config/fxdata/trapdoor.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ Unsellable = 0
PlaceSound = 0
; Index of the sound to play when trap is triggered.
TriggerSound = 0
; Index of the sound to play on repeat while trap is recharging.
RechargeSound = 0
; Function that should be executed to update the object.
; follows the template in fxdata/lua/config-api/trapdoor-templates.lua
UpdateFunction =
Expand Down
1 change: 1 addition & 0 deletions src/config_trapdoor.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ const struct NamedField trapdoor_trap_named_fields[] = {
{"SHOTORIGIN", 2, field(game.conf.trapdoor_conf.trap_cfgstats[0].shot_shift_z), 0, LONG_MIN, ULONG_MAX, NULL, value_default, assign_default},
{"PLACESOUND", 0, field(game.conf.trapdoor_conf.trap_cfgstats[0].place_sound_idx), 117, LONG_MIN, ULONG_MAX, NULL, value_default, assign_default},
{"TRIGGERSOUND", 0, field(game.conf.trapdoor_conf.trap_cfgstats[0].trigger_sound_idx), 176, LONG_MIN, ULONG_MAX, NULL, value_default, assign_default},
{"RECHARGESOUND", 0, field(game.conf.trapdoor_conf.trap_cfgstats[0].recharge_sound_idx), 0, LONG_MIN, ULONG_MAX, NULL, value_default, assign_default},
{"DESTROYEDEFFECT", 0, field(game.conf.trapdoor_conf.trap_cfgstats[0].destroyed_effect), -TngEffElm_Blast2, LONG_MIN, ULONG_MAX, NULL, value_effOrEffEl, assign_default},
{"INITIALDELAY", 0, field(game.conf.trapdoor_conf.trap_cfgstats[0].initial_delay), 0, LONG_MIN, ULONG_MAX, NULL, value_default, assign_default},
{"PLACEONSUBTILE", 0, field(game.conf.trapdoor_conf.trap_cfgstats[0].place_on_subtile), 0, LONG_MIN, ULONG_MAX, NULL, value_default, assign_default},
Expand Down
1 change: 1 addition & 0 deletions src/config_trapdoor.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ struct TrapConfigStats {
TbBool unsellable;
short place_sound_idx;
short trigger_sound_idx;
short recharge_sound_idx;
FuncIdx updatefn_idx;
};

Expand Down
17 changes: 15 additions & 2 deletions src/thing_traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,10 @@ void activate_trap(struct Thing *traptng, struct Thing *creatng)
{
event_create_event(traptng->mappos.x.val, traptng->mappos.y.val, EvKind_AlarmTriggered, traptng->owner, 0);
}
thing_play_sample(traptng, trapst->trigger_sound_idx, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
if (trapst->trigger_sound_idx > 0)
{
thing_play_sample(traptng, trapst->trigger_sound_idx, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
}
switch (trapst->activation_type)
{
case TrpAcT_HeadforTarget90:
Expand Down Expand Up @@ -657,7 +660,10 @@ void activate_trap_by_slap(struct PlayerInfo *player, struct Thing* traptng)
{
event_create_event(traptng->mappos.x.val, traptng->mappos.y.val, EvKind_AlarmTriggered, traptng->owner, 0);
}
thing_play_sample(traptng, trapst->trigger_sound_idx, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
if (trapst->trigger_sound_idx > 0)
{
thing_play_sample(traptng, trapst->trigger_sound_idx, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
}

switch (trapst->activation_type)
{
Expand Down Expand Up @@ -957,6 +963,13 @@ TngUpdateRet update_trap(struct Thing *traptng)
traptng->anim_speed = trapst->anim_speed;
}
traptng->max_frames = keepersprite_frames(traptng->anim_sprite);
//Optionally play a recharge sound while recharging, without overlap.
if (trapst->recharge_sound_idx > 0)
{
if (!S3DEmitterIsPlayingSample(traptng->snd_emitter_id, trapst->recharge_sound_idx, 0)) {
thing_play_sample(traptng, trapst->recharge_sound_idx, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS);
}
}
}
}
if (trapst->activation_type == TrpAcT_CreatureShot)
Expand Down