Projectile Executing Script(ACS)

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.

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!)
Post Reply
andreboomer
Posts: 21
Joined: Wed Feb 16, 2022 9:04 pm
Graphics Processor: nVidia with Vulkan support

Projectile Executing Script(ACS)

Post by andreboomer »

How could I make a projectile execute a script? From zscript/decorate.
So it would do ACS_NamedExecute. It works with monsters, but the projectiles itself can't call it.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Projectile Executing Script(ACS)

Post by Player701 »

andreboomer wrote: Wed Sep 14, 2022 6:31 pm It works with monsters, but the projectiles itself can't call it.
Yes they can:

Code: Select all

actor MyRocket : Rocket
{
    States
    {
        Death:
            MISL B 8 Bright A_Explode
            MISL C 6 Bright ACS_NamedExecute("MyScript")
            MISL D 4 Bright
            Stop
    }
}
Note that the projectile itself is considered the activator of the script. If your script includes calls like GiveInventory, then you first have to call SetActivatorToTarget to change the activator to the actor who fired the projectile (e.g. the player). But most of the time (and also if you want your script to do something with the victim instead of the shooter), ZScript is prefered over ACS. If you could clarify what exactly you'd like to achieve with your scripting, I might be able to provide a more extensive example.
andreboomer
Posts: 21
Joined: Wed Feb 16, 2022 9:04 pm
Graphics Processor: nVidia with Vulkan support

Re: Projectile Executing Script(ACS)

Post by andreboomer »

Player701 wrote: Wed Sep 14, 2022 11:57 pm
andreboomer wrote: Wed Sep 14, 2022 6:31 pm It works with monsters, but the projectiles itself can't call it.
Yes they can:

Code: Select all

actor MyRocket : Rocket
{
    States
    {
        Death:
            MISL B 8 Bright A_Explode
            MISL C 6 Bright ACS_NamedExecute("MyScript")
            MISL D 4 Bright
            Stop
    }
}
Note that the projectile itself is considered the activator of the script. If your script includes calls like GiveInventory, then you first have to call SetActivatorToTarget to change the activator to the actor who fired the projectile (e.g. the player). But most of the time (and also if you want your script to do something with the victim instead of the shooter), ZScript is prefered over ACS. If you could clarify what exactly you'd like to achieve with your scripting, I might be able to provide a more extensive example.
I'm gonna check out SetActivator, thanks. If it doesnt work, I might go in more depth of my question.
Thanks
Post Reply

Return to “Scripting”