Page 1 of 1

Projectile Cloning Itself After Death?

PostPosted: Mon Oct 04, 2021 1:45 am
by RastaManGames
Trying to make grenade launcher with two fire modes. First (default one) is firing with "RG6Projectile" and everything is OK. I see nice explosion and some fragmentations around. But another one (with timing and bouncing projectile named "RG6Timed") are acting kinda strange. If it hits enemy actor, then it dies (death state with explosion sprites), but after that spawning another "RG6Timed" projectile and continues bouncing without any loss of momentum. Sometimes (several first tests) it spawned few projectiles at once after hitting enemy actor. Here is the code of usual projectile and timed one. Where is the cruel error, that turns timed projectile into cluster bomb?

Code: Select allExpand view
ACTOR RG6Projectile
{
   Projectile
   Radius 4
   Height 8
   Damage 20
   Speed 40
   BounceSound "misc/grenade_bounce"
   DeathSound "boom/rg6"
   +GrenadeTrail
   +ZDoomTrans
   -NoGravity
   Decal "Scorch"
   +Randomize
   +DehExplosion
   Scale 0.5
   States
   {
   Spawn:
      RG6P O 3 Bright
      RG6P O 0 A_CountDown
      Loop
   Death:
      STX1 A 1 Bright A_NoGravity
      STX1 B 1 Bright A_Explode
      STX1 C 1 Bright
      STX1 D 1 Bright
      STX1 E 1 Bright
      STX1 F 1 Bright
      STX1 G 1 Bright
      STX1 H 1 Bright A_SpawnItemEx("RG6Frags",0,0,2.0,velx,vely,velz,0,SXF_TRANSFERPOINTERS)
      STX2 A 1 Bright
      STX2 B 1 Bright
      STX2 C 1 Bright
      STX2 D 1 Bright
      STX2 E 1 Bright
      STX2 F 1 Bright
      STX2 G 1 Bright
      STX2 H 1 Bright
      STX3 A 1 Bright
      STX3 B 1 Bright
      STX3 C 1 Bright
      STX3 D 1 Bright
      STX3 E 1 Bright
      STX3 F 1 Bright
      STX3 G 1 Bright
      STX3 H 1 Bright
      STX4 A 1 Bright
      STX4 B 1 Bright
      STX4 C 1 Bright
      STX4 D 1 Bright
      STX4 E 1 Bright
      STX4 F 1 Bright
      STX4 G 1 Bright
      STX4 H 1 Bright
      Stop
   }
}

ACTOR RG6Timed : RG6Projectile
{
   ReactionTime 25
   Damage 1
   +BounceOnFloors
   +BounceOnWalls
   +BounceOnCeilings
   +ExtremeDeath
   +CanBounceWater
}

Re: Projectile Cloning Itself After Death?

PostPosted: Thu Oct 14, 2021 1:58 am
by Player701
I don't see anything weird here, so the problem might be elsewhere. Please post the code for RG6Frags and all related actors.

Re: Projectile Cloning Itself After Death?

PostPosted: Mon Oct 18, 2021 8:45 am
by RastaManGames
Here is fragmentations, that are spawning by grenade explosion:
Spoiler: "RG6Frags"


Here is a custom puff, that spawning by frags:
Spoiler: "STInvisPuff"


Here is weapon itself, that spawning timed projectile, which cloning itself several times after hitting enemy actor:
Spoiler: "RG6"

Re: Projectile Cloning Itself After Death?

PostPosted: Tue Oct 19, 2021 4:11 am
by Player701
Sorry for the late reply. I think the problem is with your weapon code, in particular, with this line:

RastaManGames wrote:
Code: Select allExpand view
TNT1 AAAAAAAA 0 A_FireProjectile("RG6Timed ",0,0,0,0,FPF_NOAUTOAIM,0)

This spawns not one projectile but eight (8) of them, which all follow the same path. However, when they hit an enemy, the engine has to process the damage for one projectile at a time. If at some point during this processing the enemy takes enough damage and dies, then the processing stops and the rest of the projectiles continue on their path, which may indeed look as if the projectile has "cloned" itself.

To fix this, simply do not spawn more than one projectile during an attack. If spawning 8 projectiles is not a mistake on your part, then I suggest you find another way to achieve the desired effect.