[SOLVED][ZSCRIPT] Issue with A_Warp

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!)
Kan3x
Posts: 19
Joined: Tue Nov 08, 2022 4:19 pm

[SOLVED][ZSCRIPT] Issue with A_Warp

Post by Kan3x »

Hello

I'm having tons of troubles with A_Warp for unknown reasons.
Basically I want a monster to spawn a force shield in front of him and I want that shield to stay in position no matter where the monster goes or looks.
Easy, I thought, I simply call A_Warp every tic and that's it, but it doesn't work, the moment A_Warp gets called the shield parts "collapses" to the ground and at the monster's center, it's like it doesn't properly register the y and z coordinates I set in the function (the x coords work perfectly fine though...).

Here's the code for the shield parts:
Spoiler:
I tested (almost) every flag with no success at all.
Can you help me?
Last edited by Kan3x on Wed Jan 04, 2023 5:42 am, edited 1 time in total.
Magdiel012
Posts: 10
Joined: Wed Dec 21, 2022 10:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: [ZSCRIPT] Issue with A_Warp

Post by Magdiel012 »

Since you're already using ZScript, you can hold a reference to the shield in the monster class and set its position directly from there. You could also use TryMove() if you want it to be blocked by walls and other actors.
Kan3x
Posts: 19
Joined: Tue Nov 08, 2022 4:19 pm

Re: [ZSCRIPT] Issue with A_Warp

Post by Kan3x »

Magdiel012 wrote: Tue Jan 03, 2023 1:51 pm Since you're already using ZScript, you can hold a reference to the shield in the monster class and set its position directly from there. You could also use TryMove() if you want it to be blocked by walls and other actors.
Thanks for the help, but I just solved the issue. Apparently A_Warp doesn't properly work (?) on custom states in inherited classes, I just called the function from the Spawn state now and everything works fine.

Though at first I tried to look into TryMove(), but I didn't find much to learn from, can I ask you where I can find some documentation about these ZSCRIPT functions, variables and stuff? Cause I always feel like I'm missing a world of new possibilities.

EDIT: not true, I just forgot how inherited states work
Last edited by Kan3x on Wed Jan 04, 2023 2:05 pm, edited 1 time in total.
Magdiel012
Posts: 10
Joined: Wed Dec 21, 2022 10:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: [ZSCRIPT] Issue with A_Warp

Post by Magdiel012 »

Kan3x wrote: Wed Jan 04, 2023 5:41 am Though at first I tried to look into TryMove(), but I didn't find much to learn from, can I ask you where I can find some documentation about these ZSCRIPT functions, variables and stuff? Cause I always feel like I'm missing a world of new possibilities.
There is no one definitive place to find any of this stuff, you usually end up scrounging for bread crumbs from various sources. The wiki is a good place to start, followed by searching the forums to see if anyone else has asked about it already. After that I usually look through gzdoom.pk3 (file that comes with every GZDoom release) to see if any of the methods are described in comments (native ones usually aren't). If all else fails, I search through the GZDoom source for the native method and try to parse what the code is doing (my C++ comprehension isn't all that great though, to be honest).

Sometimes you have to get a little clever searching the wiki though. There's no page for TryMove(), for instance, but there is a page for CheckMove() that says:
ZDoom Wiki wrote:Unlike TryMove this function will not actually move the caller if the check passes.
Which must mean that TryMove() behaves like CheckMove(), except it also moves the caller if it does pass the check.
Last edited by Magdiel012 on Wed Jan 04, 2023 10:43 am, edited 1 time in total.
User avatar
inkoalawetrust
Posts: 46
Joined: Mon Aug 26, 2019 9:18 pm
Graphics Processor: nVidia with Vulkan support

Re: [ZSCRIPT] Issue with A_Warp

Post by inkoalawetrust »

Kan3x wrote: Wed Jan 04, 2023 5:41 am
Magdiel012 wrote: Tue Jan 03, 2023 1:51 pm Since you're already using ZScript, you can hold a reference to the shield in the monster class and set its position directly from there. You could also use TryMove() if you want it to be blocked by walls and other actors.
Thanks for the help, but I just solved the issue. Apparently A_Warp doesn't properly work (?) on custom states in inherited classes, I just called the function from the Spawn state now and everything works fine.

Though at first I tried to look into TryMove(), but I didn't find much to learn from, can I ask you where I can find some documentation about these ZSCRIPT functions, variables and stuff? Cause I always feel like I'm missing a world of new possibilities.
You can find this information on the ZDoom Wiki, on the DECORATE and ZScript reference pages. Which are basically a portal to bunch of other articles related to DECORATE and ZScript, like the list of ZScript actor functions and ZScript virtual functions. Most of the DECORATE information like Action functions, DECORATE expressions etc still apply to ZScript as well. But keep in mind that a ton of the ZScript stuff is still not documented, such as a lot of functions on the ZScript actor functions page.
Kan3x
Posts: 19
Joined: Tue Nov 08, 2022 4:19 pm

Re: [SOLVED][ZSCRIPT] Issue with A_Warp

Post by Kan3x »

Thank you both for the answers!
Magdiel012 wrote: Wed Jan 04, 2023 10:42 am There is no one definitive place to find any of this stuff, you usually end up scrounging for bread crumbs from various sources. The wiki is a good place to start, followed by searching the forums to see if anyone else has asked about it already. After that I usually look through gzdoom.pk3 (file that comes with every GZDoom release) to see if any of the methods are described in comments (native ones usually aren't). If all else fails, I search through the GZDoom source for the native method and try to parse what the code is doing (my C++ comprehension isn't all that great though, to be honest).

Sometimes you have to get a little clever searching the wiki though. There's no page for TryMove(), for instance, but there is a page for CheckMove() that says:
ZDoom Wiki wrote:Unlike TryMove this function will not actually move the caller if the check passes.
Which must mean that TryMove() behaves like CheckMove(), except it also moves the caller if it does pass the check.
inkoalawetrust wrote: Wed Jan 04, 2023 11:34 am You can find this information on the ZDoom Wiki, on the DECORATE and ZScript reference pages. Which are basically a portal to bunch of other articles related to DECORATE and ZScript, like the list of ZScript actor functions and ZScript virtual functions. Most of the DECORATE information like Action functions, DECORATE expressions etc still apply to ZScript as well.



Yeah, that's how I'm going forward in this world x) but my coding experience is near to none, so after having seen a bunch of questions on this forum about (in this case) TryMove and checked CheckMove on the wiki, I abandoned the idea of trying to figure this out in this way cause I didn't really know how to properly cast pointers, call the functions, the correct arguments etc. I need a lot more "studying" and tries yet.

inkoalawetrust wrote: Wed Jan 04, 2023 11:34 amBut keep in mind that a ton of the ZScript stuff is still not documented, such as a lot of functions on the ZScript actor functions page.
Speaking of which, dashing through the proper way to check for actor flags in anonymous functions, I stumbled on this https://github.com/jekyllgrim/ZScript_B ... /README.md. It looks like they're doing a very nice job :D

Return to “Scripting”