So, this is silly but I came up with an enemy that shoots a projectile which in turn shoots projectiles at the target while it's traveling through the air. Problem is, due to the mechanic where the shooter is considered the projectile's target, the projectile fires at its own creator.
I tried clearing the target. I tried using the transfer pointers command to change its target pointer to the target pointer by its originator. I tried using A_SpawnItemEX instead of A_SpawnProjectile so I could use the flag to transfer pointers to the new actor, and didn't activate the MISSILE flag until after, but it still treats its originator as the target. Weirdly enough A_FaceTarget faces the originator's foe, but the projectiles are fired at the originator and not the target.
Any idea how to fix this?
Projectile that fires projectiles?
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!)
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!)
-
Heisanevilgenius
- Posts: 123
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
-
phantombeta
- Posts: 2218
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Projectile that fires projectiles?
A_SpawnProjectile's ptr parameter should work for this
Of course, you'll need to make sure tracer is set to something somehow. Since it's for an enemy, you want to have the enemy pass its target to the initial projectile. Something like this:
[edit] Here's a full working sample:
Code: Select all
A_SpawnProjectile ("DoomImpBall", spawnheight: 0, flags: CMF_TRACKOWNER, ptr: AAPTR_TRACER);
Code: Select all
let proj = A_SpawnProjectile (/* [...] */);
if (proj)
proj.tracer = target;
Code: Select all
class DoomImp2 : DoomImp replaces DoomImp {
void A_NewTroopAttack () {
let targ = target;
if (targ == null)
return;
if (CheckMeleeRange ()) {
A_StartSound ("imp/melee", CHAN_WEAPON);
let damage = random [pr_troopattack] (1, 8) * 3;
let newdam = targ.DamageMobj (self, self, damage, "Melee");
targ.TraceBleed (newdam > 0 ? newdam : damage, self);
} else {
let proj = A_SpawnProjectile ("DoomImpBall2");
if (proj != null)
proj.tracer = target;
}
}
states {
Melee:
Missile:
TROO EF 8 A_FaceTarget;
TROO G 6 A_NewTroopAttack;
goto See;
}
}
class DoomImpBall2 : DoomImpBall {
states {
Spawn:
BAL1 A 4 bright {
if (tracer != null)
A_SpawnProjectile ("DoomImpBallSmall", spawnHeight: 0, flags: CMF_TRACKOWNER, ptr: AAPTR_TRACER);
}
BAL1 BAB 4 bright;
loop;
}
}
class DoomImpBallSmall : DoomImpBall {
default {
Radius 4;
Height 4;
Speed 20;
FastSpeed 30;
DamageFunction random (3, 8);
Scale .75;
}
states {
Spawn:
BAL2 AB 4 bright;
loop;
Death:
BAL2 CDE 6 bright;
stop;
}
}-
Heisanevilgenius
- Posts: 123
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: Projectile that fires projectiles?
Thank you so much! I did a lot of tweaking to get the results I wanted but now it works perfectly 