Regarding projectiles spawned from a projectile

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Doomedarchviledemon
Posts: 31
Joined: Tue Jul 05, 2011 9:17 pm

Regarding projectiles spawned from a projectile

Post by Doomedarchviledemon »

Hello, I am trying to make a Snow based magic weapon and am running into an issue with snow falls. This issue is that the snow particles are hurting the player and I do not want them too. Currently I have it set up to where the weapon spawns an invisible projectile that travels up and when it hits the ceiling it will go into its death state and leave behind the actual snow spawner. (Trying to figure out how to make it go into its death state when hitting a non-ceiling like the skybox but that's for later) This Snow Spawner is what spawns the snow particles as well as clouds that will fill a large area in the sky.

So the player spawns the Starter, the Starter spawns the Snow Spawner, and the Snow Spawn spawns the Snow and Clouds. That's three levels of spawning because that's how I know how to do it.

I tried putting that SXF_SETMASTER flag on pretty much everything to see if that did anything but nothing changed. The player still gets hurt. First starting off with just adding it to the first call upon firing the weapon, then also adding it to the SnowStart's, and so on and so forth. I've tried the master child thing before but I couldn't, and still can't, seem to really understand how to work it properly.

I would greatly appreciate any help with this. Thank you.

Code: Select all

Actor SnowTest : Weapon  //Rename this!!!
{
  Scale 0.75
  Obituary "%o was splattered by %k pistol"
  Radius 20
  Height 16
  AttackSound "Weapon/PistolFire"
  Inventory.pickupmessage "You got the Pistol"
  Weapon.SelectionOrder 400
  Weapon.SlotNumber 2
  Weapon.kickback 100
  Weapon.ammotype "CLIP"
  Weapon.ammouse 1 
  Weapon.ammogive 25
  States
  {
  Spawn:
    2PIS E -1
    Loop
  Ready:
    2PIS A 2 A_WeaponReady
    Loop
  Deselect:
    2PIS D 1 A_Lower
    Loop
  Select:
    2PIS F 1 A_Raise
    Loop
  Fire:
    2PIS A 1    
    2PIS B 4 bright A_SpawnItemEx("SnowStart",0,0,0,0,0,10,0,SXF_SETMASTER)
    2PIS C 4 
    2PIS F 4
    2PIS D 4 A_ReFire
    Goto Ready
  AltFire:
	2PIS A 1    
    2PIS B 4 bright A_SpawnItemEx("Snowcloud",0,0,0,0,0,5)
    2PIS C 4 
    2PIS F 4
    2PIS D 4 A_ReFire
	Goto Ready
  }
} 

Actor SnowStart
{
	Radius 1
	Height 1
	Speed 5
	RenderStyle Translucent
	Alpha 0.0
	Scale 0.6
	Projectile
	+MISSILE 
	+NOBLOCKMAP
	+NOGRAVITY
	States
	{
	Spawn:
		SNOW A 1 A_CheckCeiling("Death")
		loop
		Death:
		SNOW A 1
		TNT1 AAAAAAAAAA 0 A_SpawnItemEx("SnowSpawner",0,0,0,0,0,0,0,SXF_SETMASTER)
		Stop
	}
}

Actor SnowParticle
{
	Radius 1
	Height 1
	Damage 1
	DamageType Ice
	RenderStyle Translucent
	Alpha 0
	Scale 0.6
	Projectile
	+MISSILE 
	+NOBLOCKMAP
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SetScale(frandom(0.3, 0.6))
		SNOW AAAAAAA 2 A_FadeIn(0.1)
		SNOW A 3
		loop
		Death:
		SNOW A 1 A_FadeOut(0.05)
		loop
	}
}

Actor SnowSpawner
{
	Radius 1
	Height 1

	+NOBLOCKMAP
	+NOGRAVITY
	+NOSECTOR
	+NOINTERACTION
	+NOCLIP
	-SOLID
	+SPAWNCEILING
	States
	{
	Spawn:
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx ("Snowcloud", Random(-300, 300), Random(-300, 300), -30, 0, 0, 0, 0, 0, 0)
		TNT1 AAAAAAAAAAAAAAAAAAAA 5 A_SpawnItemEx ("SnowParticle", Random(-300, 300), Random(-300, 300), 0, frandom(-1.0, 1.0), frandom(-1.0, 1.0), frandom(-1.0, -3.0), 0, SXF_SETMASTER, 0)
		Stop
		}
}

Actor Snowcloud
{
 Radius 0
 Height 0
 RenderStyle Translucent
 Alpha 0.0 
 Scale 1
 +NoGravity
 +NoBlockmap
 +NoInteraction
 -Solid
 States
   {
   Spawn:
      SNCL ABCDEABCDE 7 A_FadeIn(0.1)  //fades from 0% to 100%
      SNCL ABCDEABCDEABCDE 7
      SNCL ABCDEABCDE 7 A_FadeOut(0.1)  //fades from 100% to 0%
      Stop
   }
}
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

Re: Regarding projectiles spawned from a projectile

Post by gwHero »

Doomedarchviledemon wrote:This issue is that the snow particles are hurting the player and I do not want them too.
Define SnowParticle Damage 0 instead of 1.
User avatar
Doomedarchviledemon
Posts: 31
Joined: Tue Jul 05, 2011 9:17 pm

Re: Regarding projectiles spawned from a projectile

Post by Doomedarchviledemon »

gwHero wrote:
Doomedarchviledemon wrote:This issue is that the snow particles are hurting the player and I do not want them too.
Define SnowParticle Damage 0 instead of 1.
This will make it so that it will not harm enemies either. I'd like the snow to harm the enemies, but not the player. This is meant to be a large AoE kind of attack. Not too strong to take down any major baddies, but enough to gradually lower their health over time.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Regarding projectiles spawned from a projectile

Post by Matt »

when spawning SnowSpawner use SXF_SETTARGET, then for spawning the snow use SXF_TRANSFERPOINTERS.

That way the final resulting snow will have the shooter be its target (which is how a projectile identifies its owner).
User avatar
Doomedarchviledemon
Posts: 31
Joined: Tue Jul 05, 2011 9:17 pm

Re: Regarding projectiles spawned from a projectile

Post by Doomedarchviledemon »

Matt wrote:when spawning SnowSpawner use SXF_SETTARGET, then for spawning the snow use SXF_TRANSFERPOINTERS.

That way the final resulting snow will have the shooter be its target (which is how a projectile identifies its owner).
Oh that works perfectly! Thank you very much!

I am still a little confused as to how this all works though. I've also tried this sort of thing with monsters and it never worked out correctly. My understanding is that anything that is spawned with A_SpawnItemEx with the SXF_SETMASTER, the one who spawned whatever item is the master and the spawned item is the child, thus should act as a 'friendly' actor to the master. Thus, anything spawned from the child should also be 'friendly' towards the master? So far that isn't the case in my tests. For example, an orbiting item that orbits around the master and shoots out projectiles should shoot towards the player, but instead just shoots back at the master.

These SETTARGET and TRANSFERPOINTERS, are they necessary for a Master and Child relation in general? If so how do I tell which to put where and why? I've read over the wiki on the A_SpawnItemEx time and time again and I just can't seem to grasp how it all works together for whatever reason. Maybe I'm just not understanding the descriptions. For SETTARGET the description is "Sets the calling actor to be the spawning actor's target", which to me translates to the master targeting the calling actor to attack it or something like that. Is that not it at all or what?
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: Regarding projectiles spawned from a projectile

Post by Gez »

The [wiki]actor pointers[/wiki] are not necessarily coherent in their use because when they were originally coded, they did what they were needed for and no more. Monsters needed a target pointer for who they attack; projectiles didn't need a target pointer but they needed to know who shot them so that they wouldn't collide with it, let's use the target pointer for that because it exists and projectiles don't have a use for it otherwise.

Then when they added seeker missiles for the revenant in Doom II, they had to add the tracer pointer... (The tracer pointer isn't present in vanilla Heretic or Hexen.)


Anyway, monsters and projectiles have different uses for the same pointers.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Regarding projectiles spawned from a projectile

Post by Graf Zahl »

Gez wrote: (The tracer pointer isn't present in vanilla Heretic or Hexen.)

... which caused Raven to place the relevant info for their seeker missiles into the integer variable 'special1'. Fortunately ZDoom never implemented this particular bit of insanity.
And in case you ask, why SXF_TRANSFERPOINTERS? Only think one moment about how this community abuses glitches. It took no time for the first mods to appear that built on the faulty logic and this stuff is still around, lile the monster resource WAD's Afrit.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Regarding projectiles spawned from a projectile

Post by Matt »

Doomedarchviledemon wrote:These SETTARGET and TRANSFERPOINTERS, are they necessary for a Master and Child relation in general? If so how do I tell which to put where and why? I've read over the wiki on the A_SpawnItemEx time and time again and I just can't seem to grasp how it all works together for whatever reason. Maybe I'm just not understanding the descriptions. For SETTARGET the description is "Sets the calling actor to be the spawning actor's target", which to me translates to the master targeting the calling actor to attack it or something like that. Is that not it at all or what?
I may be oversimplifying in this, but:

Each actor has the following pointers (among others but let's ignore those):
Target
Master
Tracer

We'll call the thing that calls A_SpawnItemEx the spawner and the thing spawned the spawnee.

If you don't specify any flags:
If the spawnee is a projectile the spawnee's target will be the spawner.
No other pointers will be set.

If you specify SXF_TRANSFERPOINTERS, the spawnee's target, master and tracer will be the spawner's target, master and tracer, subject to any of the other flags.

If you specify SXF_SETMASTER, the spawnee's master will be the spawner. This has priority of SXF_TRANSFERPOINTERS. Same go for SXF_SETTARGET and SXF_SETTRACER.

If you specify SXF_ISMASTER, the spawner's master will be the spawnee. This has priority of SXF_TRANSFERPOINTERS. Same go for SXF_ISTARGET and SXF_ISTRACER.

I've never used SXF_ORIGINATOR so I can't explain that. (Is that actually supposed to say "master" in the wiki description? o_O)
Post Reply

Return to “Scripting”