Projectile Cloning Itself After Death?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Projectile Cloning Itself After Death?

Postby RastaManGames » Mon Oct 04, 2021 1:45 am

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
}
User avatar
RastaManGames
Syberian Doom Fan
 
Joined: 13 Mar 2014
Location: Russian Federation, Krasnoyarsk
Discord: ℝ𝕒𝕀π•₯π•’π•„π•’π•Ÿπ”Ύπ•’π•žπ•–π•€#4168
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Projectile Cloning Itself After Death?

Postby Player701 » Thu Oct 14, 2021 1:58 am

I don't see anything weird here, so the problem might be elsewhere. Please post the code for RG6Frags and all related actors.
User avatar
Player701
Β 
Β 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Projectile Cloning Itself After Death?

Postby RastaManGames » Mon Oct 18, 2021 8:45 am

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"
User avatar
RastaManGames
Syberian Doom Fan
 
Joined: 13 Mar 2014
Location: Russian Federation, Krasnoyarsk
Discord: ℝ𝕒𝕀π•₯π•’π•„π•’π•Ÿπ”Ύπ•’π•žπ•–π•€#4168
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Projectile Cloning Itself After Death?

Postby Player701 » Tue Oct 19, 2021 4:11 am

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.
User avatar
Player701
Β 
Β 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests