Trigger script with weapon attack?
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!)
Trigger script with weapon attack?
Hello. According to the wiki, ACS_NamedExecute should be usable in DECORATE but I can't find any examples of how to do this. Let's say I want to trigger a script every time I punch/fire with "ACTOR Fist : Weapon", how would I do that? Or maybe I could make an ACS script that does this without changing the actor somehow? Or maybe I could add an AltFire attack to fist that doesn't do anything except triggering the script? Any ideas?
- Player701
-
- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Trigger script with weapon attack?
You just call it like any other action function:
The above example uses an anonymous function, which is equivalent to the following code:
Please note, however, that unless you're aiming for Zandronum compatibility, a ZScript-based solution would likely be a better way to solve your problem, although it depends on what exactly you intend to accomplish. In modern GZDoom, ACS should generally be used for map events only, with very few exceptions like SetAmmoCapacity.
Code: Select all
actor MyFist : Fist
{
States
{
Fire:
PUNG B 4
PUNG C 4
{
A_Punch;
ACS_NamedExecute("MyScript", 0);
}
PUNG D 5
PUNG C 4
PUNG B 5 A_ReFire
Goto Ready
}
}
Code: Select all
PUNG C 4 A_Punch
TNT1 A 0 ACS_NamedExecute("MyScript", 0)
Re: Trigger script with weapon attack?
Code: Select all
actor MyFist : Fist
{
States
{
Fire:
PUNG B 4
PUNG C 4
{
A_Punch;
ACS_NamedExecute("MyScript", 0);
}
PUNG D 5
PUNG C 4
PUNG B 5 A_ReFire
Goto Ready
}
}
Script error, "THate.pk3:decorate.txt" line 8:
Sprite names must be exactly 4 characters
I'm very new to doom scripting so I'm probably missing something obvious but could you please explain in detail how to do this. I do need Zandronum compatibility btw.
- Player701
-
- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Trigger script with weapon attack?
Zandronum probably does not support anonymous functions (though I haven't used it in a very long time, so can't be sure). Try replacing this part of the code
with the second example from my previous post.
Code: Select all
PUNG C 4
{
A_Punch;
ACS_NamedExecute("MyScript", 0);
}
Re: Trigger script with weapon attack?
Yeah, that worked. Thanks!