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?
A problem with Thing_Projectile and Spawn
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.
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.
- Caligari87
- Admin
- Posts: 6243
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
A problem with Thing_Projectile and Spawn
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?

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

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.
- Caligari87
- Admin
- Posts: 6243
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
I fixed the script. It was just a math issue with the z value, but here it is anyway.
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.
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.

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);
}
}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
}
}