Worm-like actor (projectile with fixed-length trail)

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
Jekyll Grim Payne
Global Moderator
Posts: 1120
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Worm-like actor (projectile with fixed-length trail)

Post by Jekyll Grim Payne »

Hi. I was having this idea about a worm-like projectile (for the lack of the better term; at least I don't know a better one). It's like a regular projectile with trail that we all like, but with regular projectiles the length of the trail is regulated simply by the amount of time the trail actor is present, i.e. it disappears (for example, fades out) after a short time, and thus the trail's length is limited.

I however need to make a trail that will simply have a limited number of actors, say, 10. The moment a new one spawns, the trail-actor at the end has to despawn, BUT they have to NOT despawn by themselves. I.e. when the projectile for some reason stops showing those animation where the trail is spawned, the trail behind it stays. So I need a trail that has fixed length and doesn't disappear but doesn't become longer. That's why I call it worm-like -- it looks like a worm. May be even used to create a sort of worm monster.

I'm asking because I believe that somebody must have tried this and may already know an effective method to implement it, so I wouldn't like to waste lots of time reinventing the wheel.
RaveYard
Posts: 198
Joined: Fri Apr 12, 2013 10:51 am

Re: Worm-like actor (projectile with fixed-length trail)

Post by RaveYard »

Something like this?

https://www.youtube.com/watch?v=MRGqNVC2fn4

I made it in few minutes and it's a still work in progress, because the trail is supposed to disappear when the projectile dies and now I can have only one projectile at a 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: Worm-like actor (projectile with fixed-length trail)

Post by Matt »

Is it workable to have a bunch of actors defined, each on spawn spawning the next with SXF_SETMASTER|SXF_TRANSFERPOINTERS, then each one except the very first constantly call A_Warp?

(If there's a way to confirm whether an actor's master is dead,* then each of those actors could then constantly check that as well, and if its master is dead it can start moving autonomously.)

*EDIT: [wiki]A_JumpIfTargetInLOS[/wiki] works, ignore anything else I might have said in previous versions of this EDIT: paragraph.
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1120
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: Worm-like actor (projectile with fixed-length trail)

Post by Jekyll Grim Payne »

RaveYard wrote:Something like this?

https://www.youtube.com/watch?v=MRGqNVC2fn4

I made it in few minutes and it's a still work in progress, because the trail is supposed to disappear when the projectile dies and now I can have only one projectile at a time.
Well, more or less like that, yes. Could you reveal the code? :)
RaveYard
Posts: 198
Joined: Fri Apr 12, 2013 10:51 am

Re: Worm-like actor (projectile with fixed-length trail)

Post by RaveYard »

I have rewritten the whole thing and now it doesn't require ACS to work.

Code: Select all

actor WormCounter : Inventory {
	inventory.maxamount 0x7FFFFFFF
}

actor ImprovedWorm : Rocket {
	States {
		Spawn:
			MISL A 0
			MISL A 0 A_SpawnItemEx("ImprovedWormTrail",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_ORIGINATOR)
			MISL A 0 A_GiveToChildren("WormCounter",1)
			MISL A 1 bright
			loop
		Death:
			MISL A 0
			MISL A 0 A_GiveToChildren("WormCounter",10)
			goto Super::Death //Goes to rocket's death
	}
}

actor ImprovedWormTrail {
	States {
		Spawn:
			PLSS AB 2 A_JumpIfInventory("WormCounter",10,"Limit")
			loop
		Limit:
			TNT1 A 0
			stop
	}
}
User avatar
Jekyll Grim Payne
Global Moderator
Posts: 1120
Joined: Mon Jul 21, 2008 4:08 am
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Contact:

Re: Worm-like actor (projectile with fixed-length trail)

Post by Jekyll Grim Payne »

RaveYard wrote:I have rewritten the whole thing and now it doesn't require ACS to work.
Love it! I knew giving items to children should work, but couldn't figure out that the giving process should be repeated, so that the further the trail actor is in the trail, the more items it'd have. Thanks :)
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Worm-like actor (projectile with fixed-length trail)

Post by edward850 »

RaveYard wrote:I have rewritten the whole thing and now it doesn't require ACS to work.
You have some redundant frames, and a couple of things just seemed out of place. Here's a cleaned up version:

Code: Select all

actor WormCounter : Inventory
{
   inventory.maxamount 0x7FFFFFFF
}

actor ImprovedWorm : Rocket
{
   States
   {
      Spawn:
         MISL A 0 nodelay A_SpawnItemEx("ImprovedWormTrail",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_ORIGINATOR)
         MISL A 1 bright A_GiveToChildren("WormCounter",1)
         loop
      Death:
         MISL A 0 A_GiveToChildren("WormCounter",10)
         goto Super::Death //Goes to rocket's death
   }
}

actor ImprovedWormTrail
{
   States
   {
      Spawn:
         PLSS AB 2 nodelay A_JumpIfInventory("WormCounter",10,"Limit")
         loop
      Limit:
         TNT1 A 0
         stop
   }
}
RaveYard
Posts: 198
Joined: Fri Apr 12, 2013 10:51 am

Re: Worm-like actor (projectile with fixed-length trail)

Post by RaveYard »

edward850 wrote: You have some redundant frames, and a couple of things just seemed out of place. Here's a cleaned up version:
Nitpicking! (Just kidding ofcourse) :D
To be serious, one thing I didn't realize was: that there was need for nodelay in ImprovedWormTrail
Also, I have the habit of keeping the { } like in Java, even in C++ :?
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Worm-like actor (projectile with fixed-length trail)

Post by edward850 »

There wasn't overall, but habits are habits. :P
Locked

Return to “Editing (Archive)”