Kill projectiles if player dead?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
DonaldDuck
Posts: 69
Joined: Sat Jun 11, 2011 6:57 am

Kill projectiles if player dead?

Post by DonaldDuck »

I made a custom projectile that orbits the player:
Spoiler:
Now my question is:
Is it somehow possible to force the projectile to enter its deathstate once the player dies?
It should also work on a server with more then one player.

I thought i could do it with A_KillChildren but it just works on monsters.

How can i do that?
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Kill projectiles if player dead?

Post by Ed the Bat »

This might be a little roundabout, but perhaps give the player a token inventory during his death animation, then quickly take it away, and have the projectile look for it with A_JumpIfInTargetInventory? Something like...

Code: Select all

A_JumpIfInTargetInventory("DeathToken",1,"Death")
Does this do what you need it to?
User avatar
DonaldDuck
Posts: 69
Joined: Sat Jun 11, 2011 6:57 am

Re: Kill projectiles if player dead?

Post by DonaldDuck »

Ok i made this now:
Spoiler:
But it wont work.
I guess the problem is that the projectiles target is not the player. :(
User avatar
Xtyfe
Posts: 1490
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: Kill projectiles if player dead?

Post by Xtyfe »

Have it check the tracer field instead which would have the player targeted by default

A_JumpIfTargetInLOS ("DoomPlayer", 0, JLOSF_PROJECTILE)

This is not perfect, since it will only work with projectiles that can see the player, as well as projectiles that are shot at the player and not another monster from infighting
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Kill projectiles if player dead?

Post by Ed the Bat »

Yeah, I was a little concerned that it might not work since I didn't really know the method that spawned the projectile, so I wasn't sure if the player was their target...
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: Kill projectiles if player dead?

Post by NeuralStunner »

Xtyfe wrote:A_JumpIfTargetInLOS ("DoomPlayer", 0, JLOSF_PROJECTILE)

This is not perfect, since it will only work with projectiles that can see the player, as well as projectiles that are shot at the player and not another monster from infighting
Um, no. That's not what the "projectile" flag does at all. That's related to seeker missiles and entirely useless for tracking the firer whatsoever. (Unless by some hackery the missile is seeking its firer, but that'd require knowledge of pointers enough to make it moot.)
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Re: Kill projectiles if player dead?

Post by FDARI »

When an actor has been spawned by a missile function, it will normally assign the firing actor (player, in this case) to its TARGET-pointer. The projectile should then be able to check for a living player like this:

Code: Select all

somestate:
MISL ABAB 2
// the next line is the one that checks target situation
MISL A 0 a_jumpIfTargetInLOS("somestate", JLOSF_NOSIGHT|JLOSF_DEADNOJUMP)
death:
(...)
Nosight: Jump even if the target is not in sight. Deadnojump: Don't jump if the target is dead. So it jumps as long as the target is alive, returning to "somestate". Make sure that some time (at least 1 tick) passes between the "somestate"-label and the jump command, since there will otherwise be a 0-tick infinite loop.
User avatar
DonaldDuck
Posts: 69
Joined: Sat Jun 11, 2011 6:57 am

Re: Kill projectiles if player dead?

Post by DonaldDuck »

Hey thanks guys it worked!

But the only problem now:
When the projectile orbits the player, it orbits its viewheight and its annoying (can barely see something).
I tried to lower the orbit height by lowering the spawnheight of A_FireCustomMissile to -32, but it goes back to the viewheight!

Next thing i tried was to lower the pitch in A_CustomMissile, so the it would be forced to keep a certain. But it keeps going back to the viewheight AGAIN.

How do i keep the projectile on a certain height? (e.g.: always 16 below the viewheight.)
User avatar
Xtyfe
Posts: 1490
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: Kill projectiles if player dead?

Post by Xtyfe »

The viewheight of the player is chest level, and by default that is where the projectile would spawn. I think thats whats happening
Locked

Return to “Editing (Archive)”