Skip to content

Commit

Permalink
first prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
Loobinex committed Nov 15, 2024
1 parent 8bfa30e commit ed81a64
Showing 1 changed file with 43 additions and 11 deletions.
54 changes: 43 additions & 11 deletions src/thing_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,11 +981,17 @@ TbBool destroy_effect_thing(struct Thing *efftng)
* @note If the function returns true, the effect might have caused death of the target.
*/
TbBool explosion_affecting_thing(struct Thing *tngsrc, struct Thing *tngdst, const struct Coord3d *pos,
MapCoordDelta max_dist, HitPoints max_damage, long blow_strength, DamageType damage_type, PlayerNumber owner, unsigned long shot_model_flags)
MapCoordDelta max_dist, struct ShotConfigStats* shotst)
{
HitPoints max_damage = shotst->area_damage;
long blow_strength = shotst->area_blow;
DamageType damage_type = shotst->damage_type;
unsigned long shot_model_flags = shotst->model_flags;
PlayerNumber owner = tngsrc->owner;

if (thing_is_deployed_door(tngdst))
{
return explosion_affecting_door(tngsrc, tngdst, pos, max_dist, max_damage, blow_strength, damage_type, owner);
return explosion_affecting_door(tngsrc, tngdst, pos, max_dist, max_damage, blow_strength, damage_type, owner);
}
TbBool affected = false;
SYNCDBG(17,"Starting for %s, max damage %d, max blow %d, owner %d",thing_model_name(tngdst),(int)max_damage,(int)blow_strength,(int)owner);
Expand Down Expand Up @@ -1014,7 +1020,7 @@ TbBool explosion_affecting_thing(struct Thing *tngsrc, struct Thing *tngdst, con
struct CreatureBattle* battle = creature_battle_get_from_thing(origtng);
CrDeathFlags dieflags = (!creature_battle_invalid(battle)) ? CrDed_DiedInBattle : CrDed_Default;
// Explosions kill rather than only stun friendly creatures when imprison is on
if ((players_creatures_tolerate_each_other(tngsrc->owner,tngdst->owner) &! (game.conf.rules.game.classic_bugs_flags & ClscBug_FriendlyFaint)) || (shot_model_flags & ShMF_NoStun) )
if ((players_creatures_tolerate_each_other(tngsrc->owner,tngdst->owner) &! (flag_is_set(game.conf.rules.game.classic_bugs_flags,ClscBug_FriendlyFaint))) || (shot_model_flags & ShMF_NoStun) )
{
dieflags |= CrDed_NoUnconscious;
}
Expand All @@ -1025,6 +1031,31 @@ TbBool explosion_affecting_thing(struct Thing *tngsrc, struct Thing *tngdst, con
kill_creature(tngdst, origtng, -1, dieflags);
affected = true;
}
else
{
if (shotst->cast_spell_kind != 0)
{
//origtng
struct Thing* shooter = INVALID_THING;
if (tngsrc->parent_idx != tngsrc->index) {
shooter = thing_get(tngsrc->parent_idx);
}
short n;
struct CreatureControl* cctrl = creature_control_get_from_thing(tngdst);
struct CreatureControl* scctrl = creature_control_get_from_thing(shooter);
if (!creature_control_invalid(scctrl)) {
n = scctrl->explevel;
}
else {
n = 0;
}
if (shotst->cast_spell_kind == SplK_Disease)
{
cctrl->disease_caster_plyridx = tngsrc->owner;
}
apply_spell_effect_to_thing(tngdst, shotst->cast_spell_kind, n);
}
}
}
if (thing_is_dungeon_heart(tngdst))
{
Expand Down Expand Up @@ -1113,12 +1144,13 @@ TbBool explosion_affecting_door(struct Thing *tngsrc, struct Thing *tngdst, cons
* @param mapblk Map block on which all targets are to be affected by the spell.
* @param max_dist Range of the spell on map, used to compute damage decaying with distance; in map coordinates.
* @param max_damage Damage at epicenter of the explosion.
* @param blow_strength The strength of hitwave blowing creatures out of affected area.
* @param damage_type Type of the damage inflicted.
* @param shotst the shot information used to determine damage, bow and spell effects
*/
long explosion_effect_affecting_map_block(struct Thing *efftng, struct Thing *tngsrc, struct Map *mapblk,
MapCoordDelta max_dist, HitPoints max_damage, long blow_strength, DamageType damage_type, unsigned long shot_model_flags)
MapCoordDelta max_dist, struct ShotConfigStats* shotst)
{
long blow_strength = shotst->area_blow;
DamageType damage_type = shotst->damage_type;
PlayerNumber owner;
if (!thing_is_invalid(tngsrc))
owner = tngsrc->owner;
Expand All @@ -1140,14 +1172,14 @@ long explosion_effect_affecting_map_block(struct Thing *efftng, struct Thing *tn
// Per thing processing block
if ((thing->class_id == TCls_Door) && (efftng->shot_effect.hit_type != THit_CrtrsOnlyNotOwn)) //TODO: Find pretty way to say that WoP traps should not destroy doors. And make it configurable through configs.
{
if (explosion_affecting_door(tngsrc, thing, &efftng->mappos, max_dist, max_damage, blow_strength, damage_type, owner))
if (explosion_affecting_door(tngsrc, thing, &efftng->mappos, max_dist, shotst->area_damage, blow_strength, damage_type, owner))
{
num_affected++;
}
} else
if (effect_can_affect_thing(efftng, thing))
{
if (explosion_affecting_thing(tngsrc, thing, &efftng->mappos, max_dist, max_damage, blow_strength, damage_type, owner, shot_model_flags))
if (explosion_affecting_thing(tngsrc, thing, &efftng->mappos, max_dist, shotst))
{
num_affected++;
}
Expand Down Expand Up @@ -1234,8 +1266,7 @@ void word_of_power_affecting_area(struct Thing *efftng, struct Thing *tngsrc, st
for (long stl_x = stl_xmin; stl_x <= stl_xmax; stl_x++)
{
struct Map* mapblk = get_map_block_at(stl_x, stl_y);
explosion_effect_affecting_map_block(efftng, tngsrc, mapblk, max_dist,
shotst->area_damage, shotst->area_blow, shotst->damage_type, shotst->model_flags);
explosion_effect_affecting_map_block(efftng, tngsrc, mapblk, max_dist, shotst);
}
}
}
Expand Down Expand Up @@ -1267,6 +1298,7 @@ TbBool area_effect_can_affect_thing(const struct Thing *thing, HitTargetFlags hi
* @param hit_targets Defines which things are affected.
* @param damage_type Type of the damage inflicted.
*/
// not explosion_effect_affecting_map_block
long explosion_affecting_map_block(struct Thing *tngsrc, const struct Map *mapblk, const struct Coord3d *pos,
MapCoord max_dist, HitPoints max_damage, long blow_strength, HitTargetFlags hit_targets, DamageType damage_type)
{
Expand Down Expand Up @@ -1298,7 +1330,7 @@ long explosion_affecting_map_block(struct Thing *tngsrc, const struct Map *mapbl
if (area_effect_can_affect_thing(thing, hit_targets, owner))
{
struct ShotConfigStats* shotst = get_shot_model_stats(tngsrc->model);
if (explosion_affecting_thing(tngsrc, thing, pos, max_dist, max_damage, blow_strength, damage_type, owner, shotst->model_flags))
if (explosion_affecting_thing(tngsrc, thing, pos, max_dist, shotst))
num_affected++;
}
// Per thing processing block ends
Expand Down

0 comments on commit ed81a64

Please sign in to comment.