Cone Shaped AOE
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!)
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!)
Cone Shaped AOE
I'm trying to figure out a good way to do a cone shaped area of effect attack from the player, which will hit all the enemies in the area only once. I've done this in DECORATE (a VERY hacky way involving a RadiusGive, checking the position of the enemy relative to the player with the given item, then affecting the enemy based on that), but I'm updating to ZScript and want a more reliable way to do it, and hopefully learn some new things in the process. Any help is appreciated!
Re: Cone Shaped AOE
I recommend looking at how A_BFGSpray function works here.
That's personally what I used as a base for all my cone shaped detection functions.
That's personally what I used as a base for all my cone shaped detection functions.
Re: Cone Shaped AOE
But the bfg spray doesn't hit enemies behind other enemies does it?
Re: Cone Shaped AOE
Right, that slipped my mind.
What you could probably do is send another LineAttack / LineTrace when it hits an enemy at the same angle with a subtracted distance with Distance2D / 3D.
I don't have any examples at hand currently, but if there's any problems I'll try to make one later today.
What you could probably do is send another LineAttack / LineTrace when it hits an enemy at the same angle with a subtracted distance with Distance2D / 3D.
I don't have any examples at hand currently, but if there's any problems I'll try to make one later today.
Re: Cone Shaped AOE
I'll keep that in mind and try to puzzle it out. I'm really new to zscript and kinda just stumbling my way through it.
Re: Cone Shaped AOE
Would it maybe be doable if I do kinda what the BFG spray does, but when it hits an enemy, turns off their SHOOTABLE flag, then fires the line tracer again in the same direction up to the distance? Then at the end of it set all the flags back on. Maybe have a sort of recursive function in order to store all the hit enemies. So it starts from the left side going right and instead of having a loop in the function making it increment, the top function starts a recursive function chain and each time it hits an enemy makes them not shootable, then at the end resolves everything backwards. Would that work do you think? Or would the pointers to the enemies not be stored properly?
Re: Cone Shaped AOE
If you store the pointer in the array it will work.
In fact, I used your idea in this example:
Please tell me if there are any errors.
In fact, I used your idea in this example:
Spoiler:This is an edited version of my powerup's DoEffect() override, that I tried to turn into a weapon function, because I didn't know when you will call it.
Please tell me if there are any errors.
Re: Cone Shaped AOE
Your function works absolutely fine, just need to make sure to put a way to damage enemies in, maybe a lineattack() under the do stuff area. (I say this for future reference in case others wonder why it's not damaging enemies) But I guess I shouldn't really have asked for a cone shaped attack in the first place. What I really wanted was a fan shape, which I guess this would also do with a ver = 0. I decided to come up with my own, though. Here it is for future reference:
Spoiler: