Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No effect hit types, shots do damage #3310

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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: 1 addition & 1 deletion config/fxdata/creature.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 29 additions & 4 deletions config/fxdata/magic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -577,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
Expand All @@ -586,6 +582,7 @@ Size_XY = 128
Size_Z = 128
Health = 40
Damage = 0
AreaDamage = 5 120 0
DamageType =
HitType = 2
Speed = 180
Expand Down Expand Up @@ -1270,6 +1267,7 @@ AnimationSize = 0
AnimationTransparency = 0
Health = 1
Damage = 0
ExplosionEffects = 14 0 0 0
DamageType = Magical
HitType = 3
AreaDamage = 5 150 128
Expand Down Expand Up @@ -1330,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]
Expand Down
1 change: 0 additions & 1 deletion src/config_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/config_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct EffectConfigStats {
unsigned char always_generate;
struct InitLight ilght;
unsigned char affected_by_wind;
ThingHitType effect_hit_type;
};

struct EffectGeneratorConfigStats {
Expand Down
26 changes: 1 addition & 25 deletions src/config_magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions src/config_magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
11 changes: 0 additions & 11 deletions src/thing_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/thing_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ struct Thing {
//TCls_Effect
struct {
char unused;
short unused2;
ThingModel parent_shot_model;
unsigned char hit_type;
} shot_effect;
struct {
Expand Down
16 changes: 5 additions & 11 deletions src/thing_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1167,16 +1166,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;
}
Expand Down Expand Up @@ -1530,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);
Expand Down
10 changes: 7 additions & 3 deletions src/thing_shots.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -925,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))
{
Expand All @@ -949,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;
}
}
}
Expand Down