DECORATE: Vertical spread on shotgunning enemies.

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
CaptainNurbles
Posts: 280
Joined: Sat Jan 27, 2018 9:12 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: The Deepest Reaches of Space
Contact:

DECORATE: Vertical spread on shotgunning enemies.

Post by CaptainNurbles »

Bad code warning, I'm an idiot with no formal programming training who's basically failed his way upwards into making a sorta okay Doom mod over the last three years lol. Tis just a hobby for me!

Tryin'a bullshit my way through adding realistic-ish bullet projectiles in my mod. Works perfectly cromulently for player weapons, and non-shotgun enemies work perfectly fine. Shotgunners, however, need vertical spread because shotgun, and by default I was getting no vertical spread.

Code: Select all

	Missile:
	  SPOS E 0 A_JumpIfInventory("12GPolShot",1,1) //If zombie has ammo, continue. Else jump to reload state.
	  Goto ZomRel
	  SPOS E 16 A_FaceTarget
	  SPOS F 0 A_TakeInventory("12GPolShot",1)
	  TNT1 E 0 A_SpawnProjectile("SmokeSpawner",32,random(-2,2))
	  TNT1 A 0 A_PlaySound("weapons/12gpolicefire",0,1,0,0.55)
	  TNT1 A 0 A_PlaySound("weapons/DistantCrack",0,1,0,ATTN_NONE)
	  TNT1 D 0 BRIGHT A_SpawnProjectile("Bullet12GPelletZom",32,0,(random(-420,420)/100.00),0,(random(-420,420)/100.00))
	  TNT1 D 0 BRIGHT A_SpawnProjectile("Bullet12GPelletZom",32,0,(random(-420,420)/100.00),0,(random(-420,420)/100.00))
	  TNT1 D 0 BRIGHT A_SpawnProjectile("Bullet12GPelletZom",32,0,(random(-420,420)/100.00),0,(random(-420,420)/100.00))
	  TNT1 D 0 BRIGHT A_SpawnProjectile("Bullet12GPelletZom",32,0,(random(-420,420)/100.00),0,(random(-420,420)/100.00))
	  TNT1 D 0 BRIGHT A_SpawnProjectile("Bullet12GPelletZom",32,0,(random(-420,420)/100.00),0,(random(-420,420)/100.00))
	  TNT1 D 0 BRIGHT A_SpawnProjectile("Bullet12GPelletZom",32,0,(random(-420,420)/100.00),0,(random(-420,420)/100.00))
	  SPOS F 10 BRIGHT A_SpawnProjectile("Bullet12GPelletZom",32,0,(random(-420,420)/100.00),0,(random(-420,420)/100.00))
	  SPOS E 0 A_SpawnProjectile("12GHull",32,10,random(260,280))
	  SPOS E 10 A_PlaySound("weapons/12GPolicepump")
	  Goto See
Adding the CMF_ABSOLUTEPITCH flag to the SpawnProjectile functions gave them vertical spread, but then they stopped being able to aim up or down at the player.

I figured I could have the zombie shoot a projectile, which itself would spawn the pellets while retaining the pitch that the zombie fired at the player, but so far I've seen everything from "How is he firing behind him with no vertical spread" to "stop shooting at the floor directly below you you undead twatgobbler." Probably a dead end.

I know there's got to be a way to keep the vertical spread while being able to aim up or down, with the projectiles retaining the needed pitch for that, but I'm struggling to figure this out. Any help would be appreciated! I'll post the bullet code below if that helps. I'd be using more ZScript if I could push my ADHD brain towards learning it instead of being stressed out every time I try lol

Code: Select all

class BulletBase : FastProjectile
{
	Default
	{
	Radius 0.1;
	Height 1;
	MissileHeight 8;
	Scale 0.1;
	Speed 240; //
	DamageFunction (18);
	Projectile;
	+RANDOMIZE
	+ZDOOMTRANS
	+NOEXTREMEDEATH
	+BLOODSPLATTER
	-PIERCEARMOR
	AttackSound "puff/bulletwall";
	Decal "BulletChip";
	}
	States
	{
	Spawn: //Do not edit this Spawn state. This universally adds visible tracers to all bullets. (Actually not working yet, but I have bigger fish to fry)
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.01*vel.x)/-35.0,-(0.01*vel.y)/-35.0,0+(0.01*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION); // Visual tracer so that you can more easily see incoming gunfire.
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.1*vel.x)/-35.0,-(0.1*vel.y)/-35.0,0+(0.1*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.2*vel.x)/-35.0,-(0.2*vel.y)/-35.0,0+(0.2*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.3*vel.x)/-35.0,-(0.3*vel.y)/-35.0,0+(0.3*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.4*vel.x)/-35.0,-(0.4*vel.y)/-35.0,0+(0.4*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.5*vel.x)/-35.0,-(0.5*vel.y)/-35.0,0+(0.5*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.6*vel.x)/-35.0,-(0.6*vel.y)/-35.0,0+(0.6*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.7*vel.x)/-35.0,-(0.7*vel.y)/-35.0,0+(0.7*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.8*vel.x)/-35.0,-(0.8*vel.y)/-35.0,0+(0.8*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(0.9*vel.x)/-35.0,-(0.9*vel.y)/-35.0,0+(0.9*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(1.0*vel.x)/-35.0,-(1.0*vel.y)/-35.0,0+(1.0*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(1.1*vel.x)/-35.0,-(1.1*vel.y)/-35.0,0+(1.1*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(1.2*vel.x)/-35.0,-(1.2*vel.y)/-35.0,0+(1.2*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(1.3*vel.x)/-35.0,-(1.3*vel.y)/-35.0,0+(1.3*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(1.4*vel.x)/-35.0,-(1.4*vel.y)/-35.0,0+(1.4*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 Bright A_SpawnItemEx("BulletTracer",(1.5*vel.x)/-35.0,-(1.5*vel.y)/-35.0,0+(1.5*vel.z)/-35.0,0,0,0,0,SXF_ABSOLUTEANGLE|SXF_NOCHECKPOSITION);
	  TNT1 A 0 A_GiveInventory("BulletDropCounter",1); //This gives the bullet a Counter for every tic that it displays tracers.
	  Goto BulletDropper;
	BulletDropper: //Bullet drop. Each bullet actor needs its own BulletDropper state to determine its flatness - how many tics it travels for before falling down some due to gravity.
	  BULT A 1 Bright; //One frame of visibility.
	  BULT A 0 A_JumpIfInventory("BulletDropCounter",5,1); //If the bullet has X number of this counter, it'll drop a little bit to simulate gravity.
	  Goto Spawn;
	  BULT A 0 Bright ThrustThingZ(0,1,1,1);
	  Goto Spawn;
	Death:
	  TNT1 A 0 A_StartSound("puff/bulletwall",0);
	  PUFF A 0 A_SetScale(1);
	  TNT1 A 0 A_SpawnItemEx("ChipSpawner",-2,0,0);
      PUFF ABCD 4;
      Stop;
	XDeath:
	  TNT1 A 0 A_StartSound("puff/bulletflesh",0);
	  TNT1 A 0 A_SetScale(1);
      Stop;
	Crash:
	  TNT1 A 0 A_StartSound("puff/bulletwall",0);
	  PUFF A 0 A_SetScale(1);
	  TNT1 A 0 A_SpawnItemEx("ChipSpawner",-2,0,0);
      PUFF ABCD 4;
      Stop;
	}
}

class Bullet12GPelletZom : BulletBase
{
	Default
	{
	Speed 230;
	DamageFunction (10*GetCVAR("SC_PlayerDamageTaken"));
	DamageType "Pellet";
	}
	States
	{
	BulletDropper:
	  BULT A 1 Bright;
	  BULT A 0 A_JumpIfInventory("BulletDropCounter",4,1);
	  Goto Spawn;
	  BULT A 0 Bright ThrustThingZ(0,1,1,1);
	  Goto Spawn;
	}
}
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: DECORATE: Vertical spread on shotgunning enemies.

Post by Gez »

CaptainNurbles wrote: Mon Feb 19, 2024 1:34 pm Adding the CMF_ABSOLUTEPITCH flag to the SpawnProjectile functions gave them vertical spread, but then they stopped being able to aim up or down at the player.
I think the one you want here is CMF_OFFSETPITCH. Did you try it?
CaptainNurbles
Posts: 280
Joined: Sat Jan 27, 2018 9:12 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: The Deepest Reaches of Space
Contact:

Re: DECORATE: Vertical spread on shotgunning enemies.

Post by CaptainNurbles »

Just did, seems to be working so far. No idea how I missed that on the ZDoom wiki x.x
Post Reply

Return to “Scripting”