ACS Controlled Bullet Spread

Discuss all aspects related to modding Zandronum here.
Post Reply
Lollipop
Zandrone
Posts: 1116
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

ACS Controlled Bullet Spread

#1

Post by Lollipop » Fri Jul 12, 2019 3:03 pm

What it says on the tin.
I want, when firing a weapon, that this weapon's spread is calculated through ACS as a function of the player's velocity. However, I have problems with a lack of fractionality in the result.
Since I want to calculate the result in ACS, and only once, I need to store the result in some fashion that the weapon definition has access to. To this end I have tried to use a user variable (a big nope I learned) and the accuracy actor property of the player.
Using the accuracy property allowed me to get the result I needed, however it only allows me to use integer values for the angles, and hence angles of 0.5 were not possible, as would be if writing the value directly into the decorate source.

At this point I'm at my wit's end. I even tried reading zan source code to no avail, as I couldn't find the code for the behaviors involved.
I will appreciate any and all help.
Spoiler: Snippets (Open)
I want to use ACS to control bullet spread, so I use something that looks like this:

Code: Select all

PISG B 0 A_FireBullets (accuracy, accuracy, -1, 4, "BulletPuff")
Where I set the actor property through ACS in this fashion:

Code: Select all

script 7891 (int result)
{
	log(d:result);
	SetActorProperty(0, APROP_ACCURACY, result);
}
Though what I have learned is that this method only works for integer spread angles and cannot emulate things like:

Code: Select all

PISG B 0 A_FireBullets (0.5, 0.5, -1, 4, "BulletPuff")

User avatar
TDRR
Forum Regular
Posts: 111
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: ACS Controlled Bullet Spread

#2

Post by TDRR » Fri Jul 12, 2019 5:50 pm

Heh, what a coincidence i was messing with manipulating properties a couple days ago.

You can use MeleeRange instead, which takes floats as input.
No Gucci, no Prada, no Supreme, but my sadness got an ending, my smile shining like bling-bling, i'm so blessed feeling like a king!

Lollipop
Zandrone
Posts: 1116
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

Re: ACS Controlled Bullet Spread

#3

Post by Lollipop » Fri Jul 12, 2019 6:56 pm

I have in fact tried the meleerange property, which I should have remembered to add. However, you made me realize that it would be a good idea to just try all those properties one at a time to see if any of them did what I wanted.
I have found out by logging the meleerange property before changing it and puking the script multiple times to see that setting the property in fact does nothing at all. However, the alpha value can be set and, as far as I can see in my chasecam, doesn't alter the appearance of the player in any way, so it might be what I should go for. It shouldn't matter in any case as I will be calculating and using it in a sequence of 0-tick states.

Thank you for helping me out, I will do some more extensive testing and report the results here.

User avatar
Empyre
Zandrone
Posts: 1282
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Re: ACS Controlled Bullet Spread

#4

Post by Empyre » Sat Jul 13, 2019 3:55 pm

How about making a second script to fire the weapon, and using ACS variables set by the first script?
"For the world is hollow, and I have touched the sky."

Ænima
Addicted to Zandronum
Posts: 3470
Joined: Tue Jun 05, 2012 6:12 pm
Location: Shpongleland

Re: ACS Controlled Bullet Spread

#5

Post by Ænima » Mon Jul 15, 2019 8:35 pm

do it the hacky old-fashioned way and use inventory items and lots of state jumps :v

never fails
Image ­ ­
­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­
Doom64: Unabsolved: Doom64 and Diablo2 had a baby


ZandroSkins
: a pack made by our community
Squad Radio: a WASD-powered chat menu, add your own sounds
AeniPuffs: neat blood and puff effects

User avatar
TDRR
Forum Regular
Posts: 111
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: ACS Controlled Bullet Spread

#6

Post by TDRR » Mon Jul 15, 2019 11:40 pm

Ænima wrote:
Mon Jul 15, 2019 8:35 pm
do it the hacky old-fashioned way and use inventory items and lots of state jumps :v

never fails
Eh, i'm all for hacky workarounds when i'm restricted on Zandronum, but if there's a cleaner alternative with way shorter code then i rather use that. But maybe using inventory items is faster performance-wise and in netplay.
No Gucci, no Prada, no Supreme, but my sadness got an ending, my smile shining like bling-bling, i'm so blessed feeling like a king!

Lollipop
Zandrone
Posts: 1116
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

Re: ACS Controlled Bullet Spread

#7

Post by Lollipop » Thu Jul 18, 2019 12:42 pm

So I have done more thorough testing and it seems that the only four of those properties (unless the names are inconsistent and that is why it didn't work) can be accessed from within a decorate weapon definition. Meleerange is apparently immune to modification in this manner, ScaleX and ScaleY scales the player's sprite as one would expect and Alpha does seemingly nothing for some reason, making it ideal for transferring fixed point values from ACS to decorate with a value needs to be used multiple times.

So Alpha is the only value that can be used without side effects out of the three that work.

User avatar
TDRR
Forum Regular
Posts: 111
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: ACS Controlled Bullet Spread

#8

Post by TDRR » Fri Jul 19, 2019 4:46 am

Lollipop wrote:
Thu Jul 18, 2019 12:42 pm
So I have done more thorough testing and it seems that the only four of those properties (unless the names are inconsistent and that is why it didn't work) can be accessed from within a decorate weapon definition. Meleerange is apparently immune to modification in this manner, ScaleX and ScaleY scales the player's sprite as one would expect and Alpha does seemingly nothing for some reason, making it ideal for transferring fixed point values from ACS to decorate with a value needs to be used multiple times.

So Alpha is the only value that can be used without side effects out of the three that work.
Don't think it doesn't have side effects, because if you used it while on a transparency powerup, then yes your transparency would indeed be changed. Make sure you store the value and reset it to the previous one once you are done with your scripting.
No Gucci, no Prada, no Supreme, but my sadness got an ending, my smile shining like bling-bling, i'm so blessed feeling like a king!

Lollipop
Zandrone
Posts: 1116
Joined: Tue Jul 24, 2012 10:34 am
Location: Denmark

Re: ACS Controlled Bullet Spread

#9

Post by Lollipop » Fri Jul 19, 2019 7:59 am

That is worth noting. I will keep it in mind. However, I will have to shelf what I'm working on to work on something else entirely so I will probably forget by then. :P

User avatar
Empyre
Zandrone
Posts: 1282
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Re: ACS Controlled Bullet Spread

#10

Post by Empyre » Sat Jul 20, 2019 4:55 pm

Lollipop wrote:
Fri Jul 19, 2019 7:59 am
That is worth noting. I will keep it in mind. However, I will have to shelf what I'm working on to work on something else entirely so I will probably forget by then. :P
Then put it in a txt file on your desktop. I have such a txt file for each project I am working on, or might work on in the future.
"For the world is hollow, and I have touched the sky."

User avatar
TDRR
Forum Regular
Posts: 111
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: ACS Controlled Bullet Spread

#11

Post by TDRR » Sun Sep 08, 2019 6:21 pm

Here's an even better fix:
Use ACS_NamedExecuteWithResult as a parameter. The result value, set with SetResultValue(value) will be put as the argument you put the function in. So for example:

A_Jump(ACS_NamedExecuteWithResult("lolz"), "Null") would set the chance (first argument) to whatever the ACS script returns.
No Gucci, no Prada, no Supreme, but my sadness got an ending, my smile shining like bling-bling, i'm so blessed feeling like a king!

User avatar
Empyre
Zandrone
Posts: 1282
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Re: ACS Controlled Bullet Spread

#12

Post by Empyre » Wed Sep 11, 2019 2:19 am

DECORATE has a much shorter alias for ACS_NamedExecuteWithresult, CallACS.
https://zdoom.org/wiki/ACS_NamedExecuteWithResult
"For the world is hollow, and I have touched the sky."

User avatar
TDRR
Forum Regular
Posts: 111
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: ACS Controlled Bullet Spread

#13

Post by TDRR » Wed Sep 11, 2019 7:29 pm

Empyre wrote:
Wed Sep 11, 2019 2:19 am
DECORATE has a much shorter alias for ACS_NamedExecuteWithresult, CallACS.
https://zdoom.org/wiki/ACS_NamedExecuteWithResult
IIRC that doesn't work in Zandronum nor in GZDoom 1.8.6. We can't use it if it's for Zandro.
No Gucci, no Prada, no Supreme, but my sadness got an ending, my smile shining like bling-bling, i'm so blessed feeling like a king!

User avatar
Empyre
Zandrone
Posts: 1282
Joined: Sun Jul 08, 2012 6:41 am
Location: Garland, TX, USA

Re: ACS Controlled Bullet Spread

#14

Post by Empyre » Tue Sep 17, 2019 4:06 pm

I have used CallACS successfully in Zandronum.
"For the world is hollow, and I have touched the sky."

Post Reply