Get overlay id from overlay itself

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
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Get overlay id from overlay itself

Post by Apeirogon »

How overlay can check what exactly id it have from weapon state? Or how correctly name it?

Problem is, I have same reload sequences for two different overlays, and I want so that they, overlays, decide on its own in what state they should jump after reloading, overlay_1_ready for one overlay and overlay_ready_2 for another.
Problem is, to get overlay id it need to know overlays number, which is same as knowing overlays id. Vicious circle.
There are psprites pointer in player pawn struct, but it point only at "first" overlay, which is an overlay with the smallest number of layer. I can store them all, but, again, there are no any way to check is it specific psprite IS psrite from which I iterate through them all.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Get overlay id from overlay itself

Post by Apeirogon »

Turns out stateinfo struct have mPSPIndex field, which exactly what I needed.
https://github.com/coelckers/gzdoom/blo ... ts.zs#L884

Code: Select all

class weapon
{
states
{
    ready:
        SPRT A 1
        {
            player.findpsprite(mStateInfo.mPSPIndex).setstate(state here);
        }
    loop;
}

}
Post Reply

Return to “Scripting”