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

Added hittype for own creatures #3507

Closed
wants to merge 1 commit into from
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
3 changes: 3 additions & 0 deletions config/fxdata/magic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ DamageType = None
;6 - Affect all things.
;7 - Affect only dungeon hearts.
;8 - Affect only not own dungeon hearts.
;9 - Affects shots, creatures and objects.
;10 - Affects all traps, not just destructible ones.
;11 - Affects only your own creatures.
HitType = 0
; For shots that can damage surrounding area - range, damage and blow.
; The damage and blow will be at its max only very near to the casting point at distance it will start decaying, until zero is reached at given range.
Expand Down
13 changes: 11 additions & 2 deletions src/creature_instances.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,16 @@ long instf_creature_fire_shot(struct Thing *creatng, long *param)
if (cctrl->targtng_idx == 0)
{
if ((creatng->alloc_flags & TAlF_IsControlled) == 0)
hittype = THit_CrtrsOnlyNotOwn;
{
if (creatng->owner == target->owner)
{
hittype = THit_CrtrsOnlyOwn;
}
else
{
hittype = THit_CrtrsOnlyNotOwn;
}
}
else
hittype = THit_CrtrsNObjcts;
}
Expand All @@ -499,7 +508,7 @@ long instf_creature_fire_shot(struct Thing *creatng, long *param)
else if (target->class_id == TCls_Trap)
hittype = THit_TrapsAll;
else if (target->owner == creatng->owner)
hittype = THit_CrtrsOnly;
hittype = THit_CrtrsOnlyOwn;
else
hittype = THit_CrtrsOnlyNotOwn;
}
Expand Down
13 changes: 11 additions & 2 deletions src/thing_creature.c
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ void creature_cast_spell_at_thing(struct Thing *castng, struct Thing *targetng,
hit_type = THit_CrtrsNObjctsNotOwn;
else
if (targetng->owner == castng->owner)
hit_type = THit_CrtrsOnly;
hit_type = THit_CrtrsOnlyOwn;
else
hit_type = THit_CrtrsOnlyNotOwn;
}
Expand Down Expand Up @@ -1805,7 +1805,16 @@ void creature_cast_spell(struct Thing *castng, SpellKind spl_idx, long shot_lvl,
if ((castng->alloc_flags & TAlF_IsControlled) != 0)
i = THit_CrtrsNObjcts;
else
i = THit_CrtrsOnlyNotOwn;
{
if (castng->owner == thing_get(cctrl->targtng_idx)->owner)
{
i = THit_CrtrsOnlyOwn;
}
else
{
i = THit_CrtrsOnlyNotOwn;
}
}
thing_fire_shot(castng, INVALID_THING, spconf->shot_model, shot_lvl, i);
}
// Check if the spell can be self-casted
Expand Down
1 change: 1 addition & 0 deletions src/thing_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum ThingHitTypes {
THit_HeartOnlyNotOwn, // Affect only not own dungeon hearts
THit_CrtrsNObjctsNShot, // Affect all creatures and all objects, also allow colliding with other shots
THit_TrapsAll, // Affect all traps, not just the ones that are destructable
THit_CrtrsOnlyOwn, // Affect only own creatures
THit_TypesCount, // Last item in enumeration, allows checking amount of valid types
};

Expand Down
6 changes: 4 additions & 2 deletions src/thing_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -3389,14 +3389,16 @@ HitTargetFlags hit_type_to_hit_targets(long hit_type)
HitTF_AnyFoodObjects|HitTF_AnyGoldPiles;
case THit_CrtrsOnly:
return HitTF_EnemyCreatures|HitTF_AlliedCreatures|HitTF_OwnedCreatures|HitTF_ArmourAffctdCreatrs;
case THit_CrtrsOnlyNotOwn:
return HitTF_EnemyCreatures | HitTF_AlliedCreatures | HitTF_ArmourAffctdCreatrs;
case THit_CrtrsOnlyOwn:
return HitTF_OwnedCreatures | HitTF_ArmourAffctdCreatrs;
case THit_CrtrsNObjctsNotOwn:
return HitTF_EnemyCreatures|HitTF_AlliedCreatures|HitTF_ArmourAffctdCreatrs|
HitTF_EnemySoulContainer|HitTF_AlliedSoulContainer|
HitTF_AnyWorkshopBoxes|HitTF_AnySpellbooks|HitTF_AnyDnSpecialBoxes|
HitTF_EnemyDestructibleTraps | HitTF_AlliedDestructibleTraps|
HitTF_AnyFoodObjects|HitTF_AnyGoldPiles;
case THit_CrtrsOnlyNotOwn:
return HitTF_EnemyCreatures|HitTF_AlliedCreatures|HitTF_ArmourAffctdCreatrs;
case THit_CrtrsNotArmourNotOwn:
return HitTF_EnemyCreatures|HitTF_AlliedCreatures;
case THit_HeartOnly:
Expand Down