Accessing Actor Properties
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!)
Accessing Actor Properties
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
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:
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)
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
}
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)
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Accessing Actor Properties
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.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?
Re: Accessing Actor Properties
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.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)
Re: Accessing Actor Properties
Yeah, but you need to if you want keep track of it so you can refer to it in other scripts.