Page 1 of 1

ACS Controlled Bullet Spread

Posted: Fri Jul 12, 2019 3:03 pm
by Lollipop
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")

Re: ACS Controlled Bullet Spread

Posted: Fri Jul 12, 2019 5:50 pm
by TDRR
Heh, what a coincidence i was messing with manipulating properties a couple days ago.

You can use MeleeRange instead, which takes floats as input.

Re: ACS Controlled Bullet Spread

Posted: Fri Jul 12, 2019 6:56 pm
by Lollipop
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.

Re: ACS Controlled Bullet Spread

Posted: Sat Jul 13, 2019 3:55 pm
by Empyre
How about making a second script to fire the weapon, and using ACS variables set by the first script?

Re: ACS Controlled Bullet Spread

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

never fails

Re: ACS Controlled Bullet Spread

Posted: Mon Jul 15, 2019 11:40 pm
by TDRR
Æ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.

Re: ACS Controlled Bullet Spread

Posted: Thu Jul 18, 2019 12:42 pm
by Lollipop
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.

Re: ACS Controlled Bullet Spread

Posted: Fri Jul 19, 2019 4:46 am
by TDRR
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.

Re: ACS Controlled Bullet Spread

Posted: Fri Jul 19, 2019 7:59 am
by Lollipop
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

Re: ACS Controlled Bullet Spread

Posted: Sat Jul 20, 2019 4:55 pm
by Empyre
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.

Re: ACS Controlled Bullet Spread

Posted: Sun Sep 08, 2019 6:21 pm
by TDRR
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.

Re: ACS Controlled Bullet Spread

Posted: Wed Sep 11, 2019 2:19 am
by Empyre
DECORATE has a much shorter alias for ACS_NamedExecuteWithresult, CallACS.
https://zdoom.org/wiki/ACS_NamedExecuteWithResult

Re: ACS Controlled Bullet Spread

Posted: Wed Sep 11, 2019 7:29 pm
by TDRR
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.