From 7727c10924bf18c642f9eb4bfbd2b3c2c8e0d2b1 Mon Sep 17 00:00:00 2001 From: Loobinex Date: Sun, 16 Jun 2024 01:19:47 +0200 Subject: [PATCH 1/4] Delete spell casting effect --- config/fxdata/magic.cfg | 3 --- src/config_magic.c | 26 +------------------------- src/config_magic.h | 2 -- src/thing_creature.c | 11 ----------- 4 files changed, 1 insertion(+), 41 deletions(-) diff --git a/config/fxdata/magic.cfg b/config/fxdata/magic.cfg index c345c64884..0c98b95476 100644 --- a/config/fxdata/magic.cfg +++ b/config/fxdata/magic.cfg @@ -19,8 +19,6 @@ Name = NOSPELL ; Whether the spell can target a thing or not. CastAtThing = 0 ShotModel = NOSHOT -; Effect or Effect element that is created as the spell. -EffectModel = 0 ; The [power] the spell is taking the stats from. SpellPower = NOPOWER ; Spell effects the target will be affected by. Powers of 2 for unique effects, add them up to combine. @@ -231,7 +229,6 @@ SymbolSprites = 384 442 Name = SPELL_WORD_OF_POWER CastAtThing = 0 ShotModel = SHOT_WORD_OF_POWER -EffectModel = EFFECT_WORD_OF_POWER Duration = 0 SymbolSprites = 386 444 diff --git a/src/config_magic.c b/src/config_magic.c index 1c5fa81561..61558a06a3 100644 --- a/src/config_magic.c +++ b/src/config_magic.c @@ -568,7 +568,6 @@ TbBool parse_magic_spell_blocks(char *buf, long len, const char *config_textname spconf->caster_affect_sound = 0; spconf->cast_at_thing = 0; spconf->shot_model = 0; - spconf->cast_effect_model = 0; spconf->bigsym_sprite_idx = 0; spconf->medsym_sprite_idx = 0; spconf->crtr_summon_model = 0; @@ -691,30 +690,7 @@ TbBool parse_magic_spell_blocks(char *buf, long len, const char *config_textname } break; case 6: // EFFECTMODEL - if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0) - { - k = get_id(effect_desc, word_buf); - if (k < 0) - { - if (parameter_is_number(word_buf)) - { - k = atoi(word_buf); - spconf->cast_effect_model = k; - n++; - } - } else - { - spconf->cast_effect_model = k; - n++; - } - } - if (n < 1) - { - CONFWRNLOG("Incorrect effect model \"%s\" in [%s] block of %s file.", - word_buf,block_buf,config_textname); - break; - } - break; + break; //todo delete case 7: // SYMBOLSPRITES if (get_conf_parameter_single(buf,&pos,len,word_buf,sizeof(word_buf)) > 0) { diff --git a/src/config_magic.h b/src/config_magic.h index d7c086409c..c434a982ee 100644 --- a/src/config_magic.h +++ b/src/config_magic.h @@ -384,8 +384,6 @@ struct SpellConfig { ThingModel shot_model; /** Informs if caster is affected by the spell. */ unsigned char caster_affected; - /** Effect model created while casting. */ - EffectOrEffElModel cast_effect_model; /** If caster is affected by the spell, indicates sound sample to be played. */ unsigned short caster_affect_sound; /** Sprite index of big symbol icon representing the spell. */ diff --git a/src/thing_creature.c b/src/thing_creature.c index 819f445100..9bf24ba4d1 100644 --- a/src/thing_creature.c +++ b/src/thing_creature.c @@ -1749,17 +1749,6 @@ void creature_cast_spell(struct Thing *castng, long spl_idx, long shot_lvl, long { thing_summon_temporary_creature(castng, spconf->crtr_summon_model, spconf->crtr_summon_level, spconf->crtr_summon_amount, spconf->duration); } - // Check if the spell has an effect associated - if (spconf->cast_effect_model != 0) - { - struct Thing* efthing = create_used_effect_or_element(&castng->mappos, spconf->cast_effect_model, castng->owner); - if (!thing_is_invalid(efthing)) - { - struct ShotConfigStats* shotst = get_shot_model_stats(spconf->shot_model); - efthing->shot_effect.hit_type = shotst->area_hit_type; - efthing->parent_idx = castng->index; - } - } } void update_creature_count(struct Thing *creatng) From 39178b8bcc85525b1671c23137dc065ae983bd8e Mon Sep 17 00:00:00 2001 From: Loobinex Date: Sun, 16 Jun 2024 01:23:42 +0200 Subject: [PATCH 2/4] word of power now directly uses the shot --- config/fxdata/magic.cfg | 1 + src/thing_data.h | 2 +- src/thing_effects.c | 12 +++--------- src/thing_shots.c | 3 ++- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/config/fxdata/magic.cfg b/config/fxdata/magic.cfg index 0c98b95476..0def148f0d 100644 --- a/config/fxdata/magic.cfg +++ b/config/fxdata/magic.cfg @@ -1267,6 +1267,7 @@ AnimationSize = 0 AnimationTransparency = 0 Health = 1 Damage = 0 +ExplosionEffects = 14 0 0 0 DamageType = Magical HitType = 3 AreaDamage = 5 150 128 diff --git a/src/thing_data.h b/src/thing_data.h index 8f2046444b..652b3e6c4b 100644 --- a/src/thing_data.h +++ b/src/thing_data.h @@ -212,7 +212,7 @@ struct Thing { //TCls_Effect struct { char unused; - short unused2; + ThingModel parent_shot_model; unsigned char hit_type; } shot_effect; struct { diff --git a/src/thing_effects.c b/src/thing_effects.c index 6a70a0bb99..f5ea2d11d0 100644 --- a/src/thing_effects.c +++ b/src/thing_effects.c @@ -1167,16 +1167,10 @@ void word_of_power_affecting_area(struct Thing *efftng, struct Thing *tngsrc, st if (efftng->creation_turn != game.play_gameturn) { return; } - struct ShotConfigStats* shotst; - if (thing_is_deployed_trap(tngsrc)) - { - shotst = get_shot_model_stats(ShM_TrapWordOfPower); - } - else + + struct ShotConfigStats* shotst = get_shot_model_stats(efftng->shot_effect.parent_shot_model); + if ((shotst->area_range <= 0) || ((shotst->area_damage == 0) && (shotst->area_blow == 0))) { - shotst = get_shot_model_stats(ShM_WordOfPower); - } - if ((shotst->area_range <= 0) || ((shotst->area_damage == 0) && (shotst->area_blow == 0))) { ERRORLOG("Word of power shot configuration does not include area influence."); return; } diff --git a/src/thing_shots.c b/src/thing_shots.c index c5b02e5955..14acf510b5 100644 --- a/src/thing_shots.c +++ b/src/thing_shots.c @@ -127,7 +127,8 @@ TbBool detonate_shot(struct Thing *shotng, TbBool destroy) HitTargetFlags hit_targets = hit_type_to_hit_targets(shotst->area_hit_type); explosion_affecting_area(shotng, &shotng->mappos, dist, damage, shotst->area_blow, hit_targets, shotst->damage_type); } - create_used_effect_or_element(&shotng->mappos, shotst->explode.effect1_model, shotng->owner); + struct Thing* efftng = create_used_effect_or_element(&shotng->mappos, shotst->explode.effect1_model, shotng->owner); + efftng->shot_effect.parent_shot_model = shotng->model; create_used_effect_or_element(&shotng->mappos, shotst->explode.effect2_model, shotng->owner); if (shotst->explode.around_effect1_model != 0) { From fcb7f673e061aa5157bceda8aa01e15e6d2c07fd Mon Sep 17 00:00:00 2001 From: Loobinex Date: Sun, 16 Jun 2024 01:40:25 +0200 Subject: [PATCH 3/4] handle gas too --- src/config_effects.c | 1 - src/config_effects.h | 1 - src/thing_effects.c | 1 - src/thing_shots.c | 7 +++++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config_effects.c b/src/config_effects.c index 1107942420..47de014b0a 100644 --- a/src/config_effects.c +++ b/src/config_effects.c @@ -100,7 +100,6 @@ static void load_effects(VALUE *value, unsigned short flags) CONDITIONAL_ASSIGN_INT(section,"LightFlags" ,effcst->ilght.flags ); CONDITIONAL_ASSIGN_INT(section,"ElementsCount" ,effcst->elements_count ); CONDITIONAL_ASSIGN_INT(section,"AlwaysGenerate",effcst->always_generate ); - CONDITIONAL_ASSIGN_INT(section,"HitType",effcst->effect_hit_type); } } } diff --git a/src/config_effects.h b/src/config_effects.h index e016c4a211..15f1522508 100644 --- a/src/config_effects.h +++ b/src/config_effects.h @@ -55,7 +55,6 @@ struct EffectConfigStats { unsigned char always_generate; struct InitLight ilght; unsigned char affected_by_wind; - ThingHitType effect_hit_type; }; struct EffectGeneratorConfigStats { diff --git a/src/thing_effects.c b/src/thing_effects.c index f5ea2d11d0..eaeb8a5745 100644 --- a/src/thing_effects.c +++ b/src/thing_effects.c @@ -891,7 +891,6 @@ struct Thing *create_effect(const struct Coord3d *pos, ThingModel effmodel, Play thing->inertia_air = 0; thing->rendering_flags |= TRF_Unknown01; thing->health = effcst->start_health; - thing->shot_effect.hit_type = effcst->effect_hit_type; if (effcst->ilght.radius != 0) { struct InitLight ilght; diff --git a/src/thing_shots.c b/src/thing_shots.c index 14acf510b5..619de64869 100644 --- a/src/thing_shots.c +++ b/src/thing_shots.c @@ -926,11 +926,13 @@ long project_damage_of_melee_shot(long shot_dexterity, long shot_damage, const s void create_relevant_effect_for_shot_hitting_thing(struct Thing *shotng, struct Thing *target) { struct ShotConfigStats* shotst = get_shot_model_stats(shotng->model); + struct Thing* efftng; if (target->class_id == TCls_Creature) { thing_play_sample(target, shotst->hit_creature.sndsample_idx, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS); if (shotst->hit_creature.effect_model != 0) { - create_used_effect_or_element(&shotng->mappos, shotst->hit_creature.effect_model, shotng->owner); + efftng = create_used_effect_or_element(&shotng->mappos, shotst->hit_creature.effect_model, shotng->owner); + efftng->shot_effect.hit_type = shotst->area_hit_type; } if (creature_affected_by_spell(target, SplK_Freeze)) { @@ -950,7 +952,8 @@ void create_relevant_effect_for_shot_hitting_thing(struct Thing *shotng, struct // TODO for a later PR: introduces trap/object hit, for now it uses the on hit creature sound and effect. thing_play_sample(target, shotst->hit_creature.sndsample_idx, NORMAL_PITCH, 0, 3, 0, 2, FULL_LOUDNESS); if (shotst->hit_creature.effect_model != 0) { - create_used_effect_or_element(&shotng->mappos, shotst->hit_creature.effect_model, shotng->owner); + efftng = create_used_effect_or_element(&shotng->mappos, shotst->hit_creature.effect_model, shotng->owner); + efftng->shot_effect.hit_type = shotst->area_hit_type; } } } From 2ccdae3612afa43d728a8ec63a5159308a286b9d Mon Sep 17 00:00:00 2001 From: Loobinex Date: Sun, 16 Jun 2024 01:57:44 +0200 Subject: [PATCH 4/4] Gas also configurable --- config/fxdata/creature.cfg | 2 +- config/fxdata/magic.cfg | 29 ++++++++++++++++++++++++++++- src/thing_effects.c | 3 ++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/config/fxdata/creature.cfg b/config/fxdata/creature.cfg index 6b4f0e14ba..dca16eacc4 100644 --- a/config/fxdata/creature.cfg +++ b/config/fxdata/creature.cfg @@ -610,7 +610,7 @@ RangeMin = MIN RangeMax = 284 PrimaryTarget = 3 Properties = MELEE_ATTACK -Function = creature_fart 0 0 +Function = creature_cast_spell SPELL_CRAZY_GAS 0 [instance30] Name = DIG diff --git a/config/fxdata/magic.cfg b/config/fxdata/magic.cfg index 0def148f0d..4e71f23b89 100644 --- a/config/fxdata/magic.cfg +++ b/config/fxdata/magic.cfg @@ -574,7 +574,6 @@ EffectModel = EFFECTELEMENT_ELECTRIC_BALL3 EffectSpacing = 96 [shot5] -; Poison Cloud gas shot doesn't do area damage, instead it creates an effect which applies the area damage. Name = SHOT_POISON_CLOUD Animation = 928 AnimationSize = 128 @@ -583,6 +582,7 @@ Size_XY = 128 Size_Z = 128 Health = 40 Damage = 0 +AreaDamage = 5 120 0 DamageType = HitType = 2 Speed = 180 @@ -1328,6 +1328,33 @@ WithstandHitAgainst = WALL DOOR Properties = NO_HIT REBOUND_IMMUNE WIND_IMMUNE EXPLODE_FLESH NO_STUN UpdateLogic = 7 +[shot33] +Name = SHOT_POISON_CLOUD +Animation = 0 +AnimationSize = 0 +AnimationTransparency = 2 +Size_XY = 128 +Size_Z = 128 +Health = 1 +Damage = 0 +AreaDamage = 5 120 0 +DamageType = +HitType = 4 +Speed = 180 +BaseExperienceGain = 256 +DestroyOnHit = 1 +TargetHitstopTurns = 6 +FiringSound = 46 +ShotSound = 43 +ShotSoundPriority = 1 +Unshaded = 1 +HitCreatureEffect = 13 +HitCreatureSound = 137 1 +HitWallEffect = 13 +HitDoorEffect = 13 +HitWaterEffect = 19 +HitWaterSound = 36 1 + ; Powers types. [power0] diff --git a/src/thing_effects.c b/src/thing_effects.c index eaeb8a5745..06542f7780 100644 --- a/src/thing_effects.c +++ b/src/thing_effects.c @@ -1523,13 +1523,14 @@ TngUpdateRet update_effect(struct Thing *efftng) effect_generate_effect_elements(efftng); } // Let the effect affect area + struct ShotConfigStats* shotst = get_shot_model_stats(efftng->shot_effect.parent_shot_model); switch (effcst->area_affect_type) { case AAffT_GasDamage: case AAffT_GasSlow: case AAffT_GasSlowDamage: case AAffT_GasDisease: - poison_cloud_affecting_area(efftng, &efftng->mappos, 5*COORD_PER_STL, 120, effcst->area_affect_type); + poison_cloud_affecting_area(efftng, &efftng->mappos, shotst->area_range*COORD_PER_STL, shotst->area_damage, effcst->area_affect_type); break; case AAffT_WOPDamage: word_of_power_affecting_area(efftng, subtng, &efftng->mappos);