mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-27 22:42:29 +00:00
- MBF21: added projectile group.
This commit is contained in:
parent
bca8d01ab3
commit
cc801a7efa
3 changed files with 45 additions and 1 deletions
|
@ -971,6 +971,13 @@ static int PatchThing (int thingy)
|
|||
}
|
||||
type->ActorInfo()->infighting_group = grp;
|
||||
}
|
||||
else if (linelen == 16 && stricmp(Line1, "projectile group") == 0)
|
||||
{
|
||||
stripwhite(Line2);
|
||||
int grp = atoi(Line2);
|
||||
if (grp < 0) grp = -1;
|
||||
type->ActorInfo()->projectile_group = grp;
|
||||
}
|
||||
|
||||
else if (linelen > 6)
|
||||
{
|
||||
|
|
|
@ -1157,6 +1157,29 @@ static bool CheckRipLevel(AActor *victim, AActor *projectile)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool P_ProjectileImmune(AActor* target, AActor* source)
|
||||
{
|
||||
// This one's directly taken from DSDA.
|
||||
auto targetgroup = target->GetClass()->ActorInfo()->projectile_group;
|
||||
auto sourcegroup = source->GetClass()->ActorInfo()->projectile_group;
|
||||
|
||||
return
|
||||
( // PG_GROUPLESS means no immunity, even to own species
|
||||
targetgroup != -1/*PG_GROUPLESS*/ ||
|
||||
target == source
|
||||
) &&
|
||||
(
|
||||
( // target type has default behaviour, and things are the same type
|
||||
targetgroup == 0/*PG_DEFAULT*/ &&
|
||||
(source->GetSpecies() == target->GetSpecies() && !(target->flags6 & MF6_DOHARMSPECIES))
|
||||
) ||
|
||||
( // target type has special behaviour, and things have the same group
|
||||
targetgroup != 0/*PG_DEFAULT*/ &&
|
||||
targetgroup == sourcegroup
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static bool CanAttackHurt(AActor *victim, AActor *shooter)
|
||||
{
|
||||
// players are never subject to infighting settings and are always allowed
|
||||
|
@ -1204,7 +1227,8 @@ static bool CanAttackHurt(AActor *victim, AActor *shooter)
|
|||
// [RH] Don't hurt monsters that hate the same victim as you do
|
||||
return false;
|
||||
}
|
||||
if (victim->GetSpecies() == shooter->GetSpecies() && !(victim->flags6 & MF6_DOHARMSPECIES))
|
||||
|
||||
if (P_ProjectileImmune(victim, shooter))
|
||||
{
|
||||
// Don't hurt same species or any relative -
|
||||
// but only if the target isn't one's hostile.
|
||||
|
|
|
@ -1038,6 +1038,19 @@ DEFINE_PROPERTY(infightinggroup, I, Actor)
|
|||
info->ActorInfo()->infighting_group = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
// MBF21
|
||||
//==========================================================================
|
||||
DEFINE_PROPERTY(projectilegroup, I, Actor)
|
||||
{
|
||||
PROP_INT_PARM(i, 0);
|
||||
if (i < -1)
|
||||
{
|
||||
I_Error("Projectile groups must be >= -1.");
|
||||
}
|
||||
info->ActorInfo()->projectile_group = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
// [BB]
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue