Page 1 of 1
Accessing Actor Properties
Posted: Sun Nov 03, 2019 3:29 pm
by 4page
Is there a way in Decorate to access another Actor's properties using Pointers? Like if I wanted to find out an actor's X velocity, could I find that out using pointers, or is that something that can only be done from that specific actor's Decorate code?
Re: Accessing Actor Properties
Posted: Mon Nov 04, 2019 8:11 am
by LOZ_98
I don't know if it can be done using only DECORATE but a quick and dirty way I used to do this was using both DECORATE and ACS scripts and setting its activator to the pointer I want, giving it a UniqueTID and using GetActorVelX/Y/Z to get velocity for that TID
https://zdoom.org/wiki/SetActivator
https://zdoom.org/wiki/UniqueTID
https://zdoom.org/wiki/Thing_ChangeTID
https://zdoom.org/wiki/GetActorVelX
https://zdoom.org/wiki/GetActorVelY
https://zdoom.org/wiki/GetActorVelZ
Here's an example script, you can expand on it to have it do whatever else you want:
Code: Select all
//Map scopes outside of the script so we can access and modify it anywhere else in the currently imported library, use arrays if you want it to be used by multiple actors and give each their own variables.
int ActorTID; //TID of actor
int ActorVel; //Velocity of actor
script "util_uniquetargtid" (void) //Execute only once so it doesn't continue changing it
{
ActorTID = UniqueTID(); //Choose a unique TID that isn't used by other actors
SetActivator (0, AAPTR_TARGET); //Set the activator to be the target
Thing_ChangeTID(0, ActorTID); //Assign the unique TID to the activator, which is currently the target
}
script "util_checktargvel" (void)
{
ActorVel = GetActorVelX(ActorTID); //Check velocity of our activator / target
}
You should do this in a
Library and load it using
LOADACS lump before you can actually execute it. then you can execute the first once in DECORATE and have the second loop if you want to keep checking velocity or execute it only once. up to you.
https://zdoom.org/wiki/ACS_NamedExecuteAlways
Then you can do other actions based on the ActorVel variable (new scripts that check the variable, modifying existing scripts....etc)
Re: Accessing Actor Properties
Posted: Mon Nov 04, 2019 3:25 pm
by Void Weaver
4page wrote:Is there a way in Decorate to access another Actor's properties using Pointers? Like if I wanted to find out an actor's X velocity, could I find that out using pointers, or is that something that can only be done from that specific actor's Decorate code?
Apparently yes, but possibility of that strongly depends on kind of pointers relation. One of the best deco info transferring link proveds by AAPTR_MASTER + A_GiveToChildren.
Re: Accessing Actor Properties
Posted: Tue Nov 05, 2019 9:19 am
by Tartlman
LOZ_98 wrote:I don't know if it can be done using only DECORATE but a quick and dirty way I used to do this was using both DECORATE and ACS scripts and setting its activator to the pointer I want, giving it a UniqueTID and using GetActorVelX/Y/Z to get velocity for that TID... ...Then you can do other actions based on the ActorVel variable (new scripts that check the variable, modifying existing scripts....etc)
You don't need to give it a TID. For the most part, passing 0 as the TID in ACS scripts uses the actor that called the function.
Re: Accessing Actor Properties
Posted: Wed Nov 06, 2019 4:35 am
by LOZ_98
Yeah, but you need to if you want keep track of it so you can refer to it in other scripts.