[ZSCRIPT] Mikk's Dumb Questions

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ZSCRIPT] Mikk's Dumb Questions

Re: [ZSCRIPT] Mikk's Dumb Questions

by Mikk- » Sat Dec 16, 2017 7:49 am

Oh, okay! I didn't want to clog up the editing forums, that's all.

Re: [ZSCRIPT] Mikk's Dumb Questions

by Blue Shadow » Fri Dec 15, 2017 8:11 pm

Mikk- wrote:Okay so I'm just gonna turn this thread into a (possibly) dumb questions thread about various ZScript features and other such stuff.
It's better to create a separate thread for each problem, instead of piling them up in a single thread. There's a reason, after all, for the editing forum organization that took place recently.

Re: [ZSCRIPT] Mikk's Dumb Questions

by Mikk- » Fri Dec 15, 2017 5:20 pm

Okay so I'm just gonna turn this thread into a (possibly) dumb questions thread about various ZScript features and other such stuff.

In light of this; is it possible to create a GLSL shader that looks similar to the Black Phantoms of Dark Souls?
Spoiler:
I don't know much about shaders, I do however know that they can do some cool shit like that FillSpectre shader - which is actually what gave me the idea.

Re: [ZSCRIPT] Variables reset upon respawn

by Nash » Fri Dec 15, 2017 10:54 am

Good job! Hope you have fun learning ZScript. It's not as scary as some people make it out to be. :D

Re: [ZSCRIPT] Variables reset upon respawn

by Mikk- » Fri Dec 15, 2017 7:45 am

Thank you so so much Nash! This will help me immensely! Regarding your challenge, I think I've come up with a neat solution (I think) :P

Code: Select all

class Souls_Player : ClericPlayer
    {
    default
        {
        Player.StartItem "Souls_PlayerInfo";
        }
        
    int GetSoulInfo(int variable)
        {
        let pVar = Souls_PlayerInfo(FindInventory("Souls_PlayerInfo"));

        if (pVar)
            {
            switch(variable)
                {
                case LAST_BONFIRE_NUM:
                    return pVar.souls_lastbonfire[0];
                    
                case LAST_BONFIRE_MAP:
                    return pVar.souls_lastbonfire[1];
                    
                case PLAYER_RETURNING: 
                    return pVar.souls_returning;
                
                }
            }
        return 0;
        }
    
    void SetSoulInfo(int variable, int amount)
        {
        let pVar = Souls_PlayerInfo(FindInventory("Souls_PlayerInfo"));

        if (pVar)
            {
            switch(variable)
                {        
                case LAST_BONFIRE_NUM:
                    pVar.souls_lastbonfire[0] = amount;
                    break;
                    
                case LAST_BONFIRE_MAP:
                    pVar.souls_lastbonfire[1] = amount;
                    break;
                    
                case PLAYER_RETURNING: 
                    pVar.souls_returning = amount;
                    break;
                    
                }
            }
        }
    }

class Souls_PlayerInfo : Inventory
{
    int souls_lastbonfire[2];
    int souls_returning;

    Default
    {
        Inventory.MaxAmount 1;
        +INVENTORY.UNDROPPABLE;
        +INVENTORY.HUBPOWER;
        +INVENTORY.UNTOSSABLE;
    }
}
 

Re: [ZSCRIPT] Variables reset upon respawn

by Nash » Fri Dec 15, 2017 1:20 am

Hey sorry for the late reply. Here I show you how to access your variables from an Event Handler.
Attachments
player variable 2.pk3
(3.95 KiB) Downloaded 78 times

Re: [ZSCRIPT] Variables reset upon respawn

by Mikk- » Thu Dec 14, 2017 12:35 pm

Brilliant! thanks Nash! Now I've hit another roadblock... How can I access these variables through an Event Handler? Specifically PlayerEntered, PlayerDied and PlayerRespawned. Event handlers are like black magic.

So far I have:

Code: Select all

class Souls_Player : ClericPlayer
    {
    default
        {
        Player.StartItem "Souls_BonfireInfo";
        }
    }

class Souls_BonfireInfo : Inventory
{
    int souls_lastbonfire[2];
    int souls_returning;

    Default
    {
        Inventory.MaxAmount 1;
        +INVENTORY.UNDROPPABLE;
        +INVENTORY.HUBPOWER;
        +INVENTORY.UNTOSSABLE;
    }
}

// Very basic and non-functional event handler 
// l o l 
class Souls_Handler : EventHandler
    {
    override void PlayerEntered(PlayerEvent e)
        {
        if(e.IsReturn)
            {
            }
        }
    override void PlayerDied(PlayerEvent e)
        {
        }
    Override void PlayerRespawned(PlayerEvent e)
        {
        }
    } 
What I want this handler to do is:

Code: Select all

    1. Upon death, set player "Souls_Returning" to true
    2. Upon Respawn, Teleport_NewMap to "Souls_LastBonfire[1]"
    3. Upon Entry (& e.IsReturn) to clear the Souls_Returning value
    4. Teleport the player to "Souls_LastBonfire[0]"

Re: [ZSCRIPT] Variables reset upon respawn

by Nash » Thu Dec 14, 2017 8:37 am

Try this.
Attachments
player variable.pk3
(3.53 KiB) Downloaded 72 times

Re: [ZSCRIPT] Variables reset upon respawn

by Mikk- » Thu Dec 14, 2017 8:29 am

That sounds like it could work, but I don't really know how to store and access variables on an inventory item - ZScript is all so very new and confusing to me! :oops:

Re: [ZSCRIPT] Variables reset upon respawn

by Nash » Thu Dec 14, 2017 8:22 am

Would storing the variables on an undepletable inventory inside the player work?

Re: [ZSCRIPT] Variables reset upon respawn

by Mikk- » Thu Dec 14, 2017 7:10 am

Graf Zahl wrote:The player which respawns is a completely new actor which will not get the values of the previous version transferred to it.
Ah, I was worried it was as such. Is there any workaround, or some such way to transfer the values to the newly spawned player actor?

Re: [ZSCRIPT] Variables reset upon respawn

by Graf Zahl » Sat Dec 09, 2017 2:40 pm

The player which respawns is a completely new actor which will not get the values of the previous version transferred to it.

Re: [ZSCRIPT] Variables reset upon respawn

by Mikk- » Sat Dec 09, 2017 11:25 am

The player is actually respawning, the maps have allowrespawn enabled in MAPINFO

Re: [ZSCRIPT] Variables reset upon respawn

by AFADoomer » Sat Dec 09, 2017 11:21 am

Possibly dumb question: Is the player actually respawning (as you would in DM/Coop), or is the game restoring from the autosave that gets generated when you start a level?

[ZSCRIPT] Mikk's Dumb Questions

by Mikk- » Fri Dec 08, 2017 3:25 pm

Hi! I've encountered a slight problem with something I'm working on, I've noticed that upon death ZScript Variables defined on a player are reset upon respawn. Is there any way to solve this? Or do I have to revert to Global variables...

Say for example my player has one 1D array and one variable defined, these are read and manipulated by ACS' [wiki]GetUserVariable[/wiki] & [wiki]SetUserVariable[/wiki]. In this case, the player can rest at a certain points in a level (in a hub, I should add), the current levelnum and id of the rest point are stored in the player's lastbonfire array, however, these variables are cleared upon respawn which makes this system arguably useless...

Top