A problem with Thing_Projectile and Spawn

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
Caligari87
Admin
Posts: 6243
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

A problem with Thing_Projectile and Spawn

Post by Caligari87 »

I'm working on a "bullet shells" weapons mod that ejects shells from your weapon when you fire. I had it working for a while, with a thing_projectile script that threw shells out onto the ground when the weapon fired. However, there was a problem: the shells spawned at the player's feet, so I decided to get the player's x,y,z and spawn a mapspot at the player's height +40 or so, and then launch the shells and remove the mapspot until the next loop. However, now the shells just fall straight to the ground in the center of the player's sprite. I know the script works, just btw, so no need to ask for it. Is there any way to thing_projectile relative to the player's height???

Also, I want the shells to fly out at a 90-degree angle to the player's view. Is there any way to get the player's angle also?

8-)
User avatar
Caligari87
Admin
Posts: 6243
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Post by Caligari87 »

Please, people. If you don't care, just say so, don't leave me hanging.

8-)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

Give the shell the NOCLIP flag. If you spawn it inside the player it can't move anywhere.
User avatar
Caligari87
Admin
Posts: 6243
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Post by Caligari87 »

If I use NOCLIP, it'll go through walls. I want it to bounce. And before, I was spawning it at the player's tid, and it worked fine, apart from being too low.

EDIT: I tried offseting the spawned mapspot outside the player and it did the same thing. When it does work though, it's a cool effect. I'm making a Halo weapons mod to go with this also.

8-)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

Post your script. Maybe it's just a stupid little error...
User avatar
Caligari87
Admin
Posts: 6243
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Post by Caligari87 »

I fixed the script. It was just a math issue with the z value, but here it is anyway.

Code: Select all

script 1 enter	{
	Thing_ChangeTID(0,500);
	int ammo1,ammo2;
	int x,y,z;
	while(1==1)	{
		ammo2=ammo1;
		ammo1=CheckInventory("Clip");
		if(ammo1<ammo2)	{
			x=GetActorX(500);
			y=GetActorY(500);
			z=GetActorZ(500);			
			Spawn("MapSpot",x,y,28*65536+z,501,0);	
			Thing_projectilegravity(501,random(254,255),0,random(8,15),random(8,15));
			Thing_Remove(501);
		}
		delay(1);
	}
}
The real problem is the code for the bullet shell. It works fine now, but it doesn't bounce, and the death is obviously jury-rigged. If I set it to be a projectile type, or +MISSILE then it "dies" whenever I spawn it, because the player is right nearby.

Code: Select all

Actor shell1 20001	{
	spawnid 255
	speed 10
	radius 1
	height 2
	mass 100
	scale .1
	deathsound "shell1"
	+teleport
	+doombounce
	+floorclip
	States
	{
	Spawn:
		PBUL A 35
		goto death
	Death:
		PBUL B 250 A_Scream
		Stop
	}
}
Also, to repeat an earlier question, is there any way to get the player's angle beyond rough speed checking? That's just not precise enough for my purposes.

8-)
Locked

Return to “Editing (Archive)”