Cone Shaped AOE

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.

Cone Shaped AOE

Postby 4page » Fri Oct 09, 2020 6:10 pm

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!
User avatar
4page
 
Joined: 06 Aug 2019

Re: Cone Shaped AOE

Postby Jarewill » Fri Oct 09, 2020 11:55 pm

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.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Cone Shaped AOE

Postby 4page » Sat Oct 10, 2020 12:15 am

But the bfg spray doesn't hit enemies behind other enemies does it?
User avatar
4page
 
Joined: 06 Aug 2019

Re: Cone Shaped AOE

Postby Jarewill » Sat Oct 10, 2020 12:53 am

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.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Cone Shaped AOE

Postby 4page » Sat Oct 10, 2020 12:57 am

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.
User avatar
4page
 
Joined: 06 Aug 2019

Re: Cone Shaped AOE

Postby 4page » Sat Oct 10, 2020 1:55 am

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?
User avatar
4page
 
Joined: 06 Aug 2019

Re: Cone Shaped AOE

Postby Jarewill » Sat Oct 10, 2020 7:52 am

If you store the pointer in the array it will work.
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.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Cone Shaped AOE

Postby 4page » Mon Oct 12, 2020 9:15 pm

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:
User avatar
4page
 
Joined: 06 Aug 2019


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests