From 7acafbb7ce3884f6b4dfe4ce507cb7ce21fdd9a3 Mon Sep 17 00:00:00 2001 From: walter253 <130906143+walt253@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:45:08 +0100 Subject: [PATCH] TrapEffectTypeAcceptsNames --- config/fxdata/trapdoor.cfg | 16 +++++------ src/config_trapdoor.c | 55 +++++++++++++++++++++++++++++++------- src/lvl_script_commands.c | 53 ++++++++++++++++++++++++++++++++++-- 3 files changed, 105 insertions(+), 19 deletions(-) diff --git a/config/fxdata/trapdoor.cfg b/config/fxdata/trapdoor.cfg index aefc1b610f..82f31c133f 100644 --- a/config/fxdata/trapdoor.cfg +++ b/config/fxdata/trapdoor.cfg @@ -193,7 +193,7 @@ TriggerType = 0 ; 6: Spawns a creature, at level 1. ; 7: Keeper spell. ActivationType = 0 -; The shot/effect/slab number/creature number/keeper power, dependent on the Activation Type. +; The shot/effect/slab/creature/keeper power, based on the Activation Type. Accepts both names and numbers. EffectType = 0 ; Controls which things will be affected by the AreaDamage of the spell (1~8), see magic.cfg. HitType = 0 @@ -273,7 +273,7 @@ Shots = 1 TimeBetweenShots = 0 TriggerType = 1 ActivationType = 1 -EffectType = 15 +EffectType = SHOT_BOULDER HitType = 9 Hidden = 0 Slappable = 1 @@ -311,7 +311,7 @@ Shots = 12 TimeBetweenShots = 2000 TriggerType = 2 ActivationType = 3 -EffectType = 19 +EffectType = SHOT_ALARM HitType = 2 Hidden = 1 DetectInvisible = 1 @@ -351,7 +351,7 @@ Shots = 5 TimeBetweenShots = 200 TriggerType = 2 ActivationType = 2 -EffectType = 13 +EffectType = EFFECT_GAS_3 HitType = 4 Hidden = 1 DetectInvisible = 1 @@ -390,7 +390,7 @@ Shots = 6 TimeBetweenShots = 140 TriggerType = 2 ActivationType = 3 -EffectType = 29 +EffectType = SHOT_TRAP_LIGHTNING HitType = 4 Hidden = 1 DetectInvisible = 1 @@ -429,7 +429,7 @@ Shots = 3 TimeBetweenShots = 84 TriggerType = 2 ActivationType = 3 -EffectType = 31 +EffectType = SHOT_TRAP_WORD_OF_POWER HitType = 4 Hidden = 1 DetectInvisible = 1 @@ -468,7 +468,7 @@ Shots = 1 TimeBetweenShots = 0 TriggerType = 2 ActivationType = 4 -EffectType = 12 +EffectType = LAVA HitType = 4 Hidden = 1 DetectInvisible = 1 @@ -506,7 +506,7 @@ Shots = 1 TimeBetweenShots = 0 TriggerType = 0 ActivationType = 3 -EffectType = 32 +EffectType = SHOT_TRAP_TNT HitType = 9 Hidden = 0 Slappable = 1 diff --git a/src/config_trapdoor.c b/src/config_trapdoor.c index 717570fcb3..7620b313e9 100644 --- a/src/config_trapdoor.c +++ b/src/config_trapdoor.c @@ -491,19 +491,56 @@ TbBool parse_trapdoor_trap_blocks(char *buf, long len, const char *config_textna } break; case 15: // EFFECTTYPE - if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0) + if (get_conf_parameter_single(buf, &pos, len, word_buf, sizeof(word_buf)) > 0) { - k = atoi(word_buf); - if (k >= 0) - { - trapst->created_itm_model = k; - n++; - } + if (parameter_is_number(word_buf)) + { + k = atoi(word_buf); + } + else + { + switch (trapst->activation_type) + { + case TrpAcT_EffectonTrap: + { + k = get_id(effect_desc, word_buf); + break; + } + case TrpAcT_SlabChange: + { + k = get_id(slab_desc, word_buf); + break; + } + case TrpAcT_CreatureSpawn: + { + k = get_id(creature_desc, word_buf); + break; + } + case TrpAcT_Power: + { + k = get_id(power_desc, word_buf); + break; + } + case TrpAcT_HeadforTarget90: + case TrpAcT_ShotonTrap: + case TrpAcT_CreatureShot: + default: + { + k = get_id(shot_desc, word_buf); + break; + } + } + } + if (k >= 0) + { + trapst->created_itm_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); + CONFWRNLOG("Incorrect value of \"%s\" parameter in [%.*s] block of %s file.", + COMMAND_TEXT(cmd_num), blocknamelen, blockname, config_textname); } break; case 16: // ANIMATIONID diff --git a/src/lvl_script_commands.c b/src/lvl_script_commands.c index f92ce76e6a..a671d82f70 100644 --- a/src/lvl_script_commands.c +++ b/src/lvl_script_commands.c @@ -1076,7 +1076,56 @@ static void set_trap_configuration_check(const struct ScriptLine* scline) return; } } - else if (trapvar == 41) // DestroyedEffect + else if (trapvar == 17) // EffectType + { + if (parameter_is_number(valuestring)) + { + newvalue = atoi(valuestring); + } + else + { + struct TrapConfigStats *trapst = get_trap_model_stats(trap_id); + switch (trapst->activation_type) + { + case TrpAcT_EffectonTrap: + { + newvalue = get_id(effect_desc, valuestring); + break; + } + case TrpAcT_SlabChange: + { + newvalue = get_id(slab_desc, valuestring); + break; + } + case TrpAcT_CreatureSpawn: + { + newvalue = get_id(creature_desc, valuestring); + break; + } + case TrpAcT_Power: + { + newvalue = get_id(power_desc, valuestring); + break; + } + case TrpAcT_HeadforTarget90: + case TrpAcT_ShotonTrap: + case TrpAcT_CreatureShot: + default: + { + newvalue = get_id(shot_desc, valuestring); + break; + } + } + } + if ((newvalue > USHRT_MAX) || (newvalue < 0)) + { + SCRPTERRLOG("Value out of range: %ld", newvalue); + DEALLOCATE_SCRIPT_VALUE + return; + } + value->shorts[2] = newvalue; + } + else if (trapvar == 41) // DestroyedEffect { newvalue = effect_or_effect_element_id(valuestring); if ((newvalue == 0) && (!parameter_is_number(valuestring))) @@ -1087,7 +1136,7 @@ static void set_trap_configuration_check(const struct ScriptLine* scline) } value->ulongs[1] = newvalue; } - else if (trapvar == 46) //FlameAnimationOffset + else if (trapvar == 46) // FlameAnimationOffset { value->chars[8] = atoi(scline->tp[2]); value->chars[9] = scline->np[3];