Page 1 of 1

[solved]How to prevent projectle from shattering Ice Corpse?

Posted: Fri Nov 20, 2020 12:58 pm
by Lagi
how do i set some projectiles to not affect ice corpse? I cannot use damage type ice, because Im using different custom damage type.


when I freeze monsters they corpse are resistant to ice projectiles - thats fine.
problem is I have a "block/stun" projectile, that should not shatter ice corpse, as well.
Spoiler:

Re: How to prevent projectile from shattering Ice Corpse?

Posted: Sat Nov 21, 2020 2:26 am
by Kzer-Za
Maybe there is a simpler way, then someone will correct me, but I think that you could try overriding SpecialMissileHit in the stunner projectile class.

Something like this (untested):

Code: Select all

	override int SpecialMissileHit (Actor victim)
	{
		if (victim)
		{
			if (victim.InStateSequence(victim.CurState, victim.ResolveState("Ice")))
			{
				return 0;
			}
		}
		return -1;
	}

Re: How to prevent projectile from shattering Ice Corpse?

Posted: Sat Nov 21, 2020 4:40 am
by Lagi
thanks,

ehmm... it suppose to look like that?

Code: Select all

class blockstun : actor
{
		default
		{
		+NOBLOCKMAP;
		+NOGRAVITY ;
		+BLOODLESSIMPACT;
		+CAUSEPAIN;
		+DONTSPLASH;
		damagetype "stun";
		}

override int SpecialMissileHit (Actor victim)
   {
      if (victim)
      {
         if (victim.InStateSequence(victim.CurState, victim.ResolveState("Ice")))
         {
            return 0;
         }
      }
      return -1;
   }

}
above dont work any different, than decorate :D
Spoiler:
I make some research:
https://github.com/coelckers/gzdoom/blo ... red/ice.zs

the resistance of frozen corpse to ice damage, is coming from: A_FreezeDeath which give +IceCorpse flag

interaction with ice damage and icecorpse flag is here:
https://github.com/coelckers/gzdoom/blo ... action.cpp

Code: Select all

	if (target->health <= 0)
	{
		if (inflictor && mod == NAME_Ice && !(inflictor->flags7 & MF7_ICESHATTER))
		{
			return -1;
		}
		else if (target->flags & MF_ICECORPSE) // frozen
		{
			target->tics = 1;
			target->flags6 |= MF6_SHATTERING;
			target->Vel.Zero();
		}
		return -1;
	}
return -1, mean the damage is cancelled. Too bad if damage is 0 or lower, it will still shatter the ice.
if (damage < 0) damage = 0;

Re: How to prevent projectile from shattering Ice Corpse?

Posted: Sat Nov 21, 2020 5:10 am
by Graf Zahl
Kzer-Za wrote:Maybe there is a simpler way, then someone will correct me, but I think that you could try overriding SpecialMissileHit in the stunner projectile class.

Something like this (untested):

Code: Select all

	override int SpecialMissileHit (Actor victim)
	{
		if (victim)
		{
			if (victim.InStateSequence(victim.CurState, victim.ResolveState("Ice")))
			{
				return 0;
			}
		}
		return -1;
	}
That won't work. It completely misses the generic ice death case. The proper bit to check is bIceCorpse.

Re: How to prevent projectile from shattering Ice Corpse?

Posted: Sat Nov 21, 2020 6:35 am
by Kzer-Za
Then how about

Code: Select all

	override int SpecialMissileHit (Actor victim)
	{
		if (victim)
		{
			if (victim.bIceCorpse == true)
			{
				SetStateLabel("Death");
				return 1;
			}
		}
		return -1;
	}

Re: How to prevent projectile from shattering Ice Corpse?

Posted: Sat Nov 21, 2020 8:14 am
by Lagi
sorry, im using hitscan and puff. This probably mess with SpecialMIssileHit

TNT1 A 0 A_FireBullets(-50,0,-1,0, "blockstun", FBF_NORANDOM | FBF_EXPLICITANGLE, 140)

I would rewrite the code with A_FireProjectile

Re: How to prevent projectile from shattering Ice Corpse?

Posted: Sat Nov 21, 2020 8:55 am
by Kzer-Za
If it's hitscan, then I'm not sure what to do. We probably will have to wait until someone with a greater knolewdge of GZDoom than mine stops by.

Re: How to prevent projectile from shattering Ice Corpse?

Posted: Sat Nov 21, 2020 11:51 am
by Lagi
this work!

problem is: projectile has no limit to the range. So i can block attacks from other edge of map.

messy 1st part of code:

Code: Select all

class blockstun2 : actor
{
		default
		{
		+NOBLOCKMAP;
		+NOGRAVITY ;
		+BLOODLESSIMPACT;
		+CAUSEPAIN;
		+DONTSPLASH;
		damagetype "stun";
		
		Radius 10;
		  Height 20;
		  Speed 30 ;
		  Damage 0;
		  Projectile;
		  +THRUGHOST;
		  }
			  States
			  {
			  Spawn:
				DHFX A 2 Bright;
				DHFX B 2 Bright ;
				DHFX CDEFGH 2 Bright;
				Loop;
				
			  Death:
				
				FHFX STUVW 4;
				Stop;
			  }



   override int SpecialMissileHit (Actor victim)
   {
      if (victim)
      {
         if (victim.bIceCorpse == true)
         {
            return 0;
         }
      }
      return -1;
   }

}