Self Pointer used in ambiguous Context

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!)

Self Pointer used in ambiguous Context

Postby Doomguy 2000 » Sun Nov 14, 2021 11:41 pm

When I used a more recent version of GZDoom, I get this error in a couple of my wads that I run it with. My Doom Debug Menu now gets tons of these specific errors and I don't know how to address the error itself. Here is an image of the amount of console errors that I get when I load wads that have my specific coding.

Spoiler:
User avatar
Doomguy 2000
Τηε Λεγενδ
 
Joined: 12 Oct 2010
Location: Undisclosed Location, United States

Re: Self Pointer used in ambiguous Context

Postby Matt » Tue Nov 16, 2021 6:05 pm

Can you describe the intended result of this code? I think this is long overdue for a complete rewrite. (This is a lot less daunting than it sounds - and likely a lot less daunting than fixing this, the new code is likely going to be much more compact than this)
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Self Pointer used in ambiguous Context

Postby Doomguy 2000 » Tue Nov 16, 2021 8:29 pm

https://www.doomguy2000.com/uploads/2/7 ... ugdoom.zip

Something I made 7 years ago and the intent behind was to be able to choose what to replace the monsters with the one you want and same for items, keys, etc within the game. When I use older versions of GZDoom I don't get console errors that I've described. It still works and does what it's intended to do on recent versions of GZDoom, but get these errors regardless. To me it's more of an annoyance and could be playable in future versions of the source port. Written in Decorate also requires Cvarinfo, menudef, and acs in order for this idea to work. The errors occur in lines with TNT1 A 0 A_JumpIf(user_example==1,"namedstate") as an example I described in the code.
User avatar
Doomguy 2000
Τηε Λεγενδ
 
Joined: 12 Oct 2010
Location: Undisclosed Location, United States

Re: Self Pointer used in ambiguous Context

Postby Virathas » Wed Nov 17, 2021 8:20 am

I am by no means expert about this, but I believe i can shed light about why this warning appears:

In an inventory or weapon, the self pointers are "ambiguous". In inventory, "self" can either refer to the item itself OR the player/actor holding it, and since self is implied, it will have the "ambiguous" context. Not sure if this is available in DECORATE (actually i doubt it) you'd have to use invoker pointer. For example
Code: Select allExpand view
TNT1 A 0 A_JumpIf(invoker.user_Item==8,"BlueArmor")

If full decorate is required, you could try to hijack some built in variables of the inventory class (Again, not exactly sure DECORATE grants enough access for that, ZScript is simply so much superior to it)
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: Self Pointer used in ambiguous Context

Postby Doomguy 2000 » Wed Nov 17, 2021 11:20 pm

Yeah this is going to take me awhile to figure out how to use ZScript since now I've converted an example of my decorate to ZScript. Hopefully I can fix it and convert the rest of my code to this format.

I'm trying to figure out how to convert my idea in to Zscript and seem to get these errors:

Spoiler:


An example of what I'm trying to convert to Zscript:

Spoiler:
User avatar
Doomguy 2000
Τηε Λεγενδ
 
Joined: 12 Oct 2010
Location: Undisclosed Location, United States

Re: Self Pointer used in ambiguous Context

Postby Virathas » Thu Nov 18, 2021 4:08 pm

In this particular case the error is pretty straightforward. All the jumps you use are comparing integer values, and the variable you have declared is not an integer, but a pointer to a CVAR. You could simply change it to an "int" and this particular place should work.

Also note the operators you are using in the jump functions - "=" sets the variable on the left to the value on the right. "==" is a logical comparator.

And, lastly just a warning/reminder - if you forcibly spawn a different monster (or item) while removing the original object, some maps will become broken, including doom2's MAP07. This is the reason why Randomspawners tend to be used. I personally worked on a randomspawner that uses special conditions for spawning so it might be of use to you, though the code is not simple at all: https://forum.zdoom.org/viewtopic.php?f=122&t=70725
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: Self Pointer used in ambiguous Context

Postby Doomguy 2000 » Fri Nov 19, 2021 12:14 am

I got the wad to load successfully and can still do what I want it to do but I'm also interested in fixing this specific error that I got saying that A_SetUserVar - deprecated since 2.3.0 and can't seem to figure out how to solve this problem.

Code: Select allExpand view
Script warning, "DBugDoomU.pk3:zscript" line 22:
Accessing deprecated function A_SetUserVar - deprecated since 2.3.0, User variables are deprecated in ZScript. Actor variables are directly accessible


The code in question that I'm now only concerned about:
Code: Select allExpand view
TNT1 A 0 A_SetUserVar("user_Monster",(ACS_NamedExecuteWithResult("ZombiemanReplacement",0,0,0)));
User avatar
Doomguy 2000
Τηε Λεγενδ
 
Joined: 12 Oct 2010
Location: Undisclosed Location, United States

Re: Self Pointer used in ambiguous Context

Postby Virathas » Fri Nov 19, 2021 12:37 am

Again, this is fairly simple. Since ZScript is so awesome, you don't need dedicated functions to change values. While i do not use ACS in Zscript (since pretty much everthing ACS offers can be done in ZScript), i belive simply changing
Code: Select allExpand view
TNT1 A 0 A_SetUserVar("user_Monster",(ACS_NamedExecuteWithResult("ZombiemanReplacement",0,0,0)));

into
Code: Select allExpand view
TNT1 A 0 { user_monser = ACS_NamedExecuteWithResult("ZombiemanReplacement",0,0,0);}

A bit of context: Just as the warning message tells, user variables are no longer useful since you can access most variables in the classes. You could change health of an item, directly change position, and even easily change velocity. It all, and more is directly accessible with simple "health = newvalue". And likewise, you can simply add new properties just by having something like "int NewValue" or "string TextData" or even "actor AdditionalTargetPointer".

PS: ACS_NamedExecuteWithResult notes aliases for this function for DECORATE and ZScript, so it might be useful to you
User avatar
Virathas
 
Joined: 10 Aug 2017

Re: Self Pointer used in ambiguous Context

Postby Doomguy 2000 » Fri Nov 19, 2021 1:06 am

Thanks I appreciate your help with this, Virathas. Shouldn't be too hard to convert the rest of the necessary code to Zscript.
User avatar
Doomguy 2000
Τηε Λεγενδ
 
Joined: 12 Oct 2010
Location: Undisclosed Location, United States

Re: Self Pointer used in ambiguous Context

Postby Dan_The_Noob » Sun Nov 21, 2021 5:58 pm

wouldn't this just be easier with a random spawner?
it seems like that's what you're trying to make, with extra steps.

--edit--
this is less of a suggestion and more me inquiring to why you wouldn't use a randomspawner in this case.
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Self Pointer used in ambiguous Context

Postby Doomguy 2000 » Tue Nov 23, 2021 10:15 pm

Dan_The_Noob wrote:wouldn't this just be easier with a random spawner?
it seems like that's what you're trying to make, with extra steps.

--edit--
this is less of a suggestion and more me inquiring to why you wouldn't use a randomspawner in this case.


Because for this idea to to work I would need to use this complex coding in order for it to work. I the case of a randomsapwner, I would be more limited in what I could do and would have to create new difficulties in place of choosing what I would want to do with what I want to replace something in the options menu instead of starting a new game. It's more complicated for sure, but worth the payout at the end of the day if you wanted to do gamemodes in place of just adding more difficulty settings.

this is an example of how much more efficient my idea is in place of a randomspawner:
Code: Select allExpand view
Class ZombieManReplacer : Actor replaces Zombieman
{
    int user_Mode;
    int user_Character;
   Default
{
    Monster;
    Health 0x7FFFFFFF;
   Radius 0;
   Height 0;
   +NOCLIP
   -SOLID
    +NORADIUSDMG
   +NOBLOOD
   -COUNTKILL
   +BOSSDEATH
   +CANTSEEK
   +NEVERTARGET
   }
   States
   {
   Spawn:
     TNT1 A 0;
     TNT1 A 0 {user_Mode = ACS_NamedExecuteWithResult("GameModes",0,0,0);}
     TNT1 A 0 A_JumpIf(user_Mode==1,"Custom War");
          Goto Classicgame;
    Classicgame:
     TNT1 A 0 A_Jump(256,"CW01","CW02","CW03");
   CW01:   
     TNT1 A 0 A_SpawnItemEx("Character1",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERAMBUSHFLAG);   
     Goto Waiting;
   CW02:   
     TNT1 A 0 A_SpawnItemEx("Character2",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERAMBUSHFLAG);   
     Goto Waiting;
   CW03:   
     TNT1 A 0 A_SpawnItemEx("Character3",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERAMBUSHFLAG);   
     Goto Waiting;
    "Custom War":
     TNT1 A 0 {user_Character = ACS_NamedExecuteWithResult("ZombiemanReplacement",0,0,0);}
     TNT1 A 0 A_JumpIf(user_Character==1,"Zombieman");
     TNT1 A 0 A_JumpIf(user_Character==2,"Shotgunguy");
     Goto Demon;
   Demon:   
     TNT1 A 0 A_SpawnItemEx("Demon",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERAMBUSHFLAG);   
     Goto Waiting;
   Zombieman:   
     TNT1 A 0 A_SpawnItemEx("Zombieman",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERAMBUSHFLAG);   
     Goto Waiting;
   Shotgunguy:   
     TNT1 A 0 A_SpawnItemEx("Shotgunguy",0,0,0,0,0,0,0,SXF_SETMASTER|SXF_NOCHECKPOSITION|SXF_TRANSFERAMBUSHFLAG);   
     Goto Waiting;
       Waiting:
     TNT1 A 70 Bright;
     Loop;
   Death:
     TNT1 A 3 A_BossDeath;
     Stop;
   End:
     TNT1 A 1;
     Stop;


It's mostly similar to the decorate coding years ago I've done with a few differences like adding ; after almost every line of code with some differences like adding { } to more complex coding that needs it and figuring out ways to replace the deprecated flags and states that the console tell you upon loading the wad among other things of note.
User avatar
Doomguy 2000
Τηε Λεγενδ
 
Joined: 12 Oct 2010
Location: Undisclosed Location, United States

Re: Self Pointer used in ambiguous Context

Postby Dan_The_Noob » Wed Nov 24, 2021 1:31 am

Doomguy 2000 wrote:
Because for this idea to to work I would need to use this complex coding in order for it to work. I the case of a randomsapwner, I would be more limited in what I could do and would have to create new difficulties in place of choosing what I would want to do with what I want to replace something in the options menu instead of starting a new game. It's more complicated for sure, but worth the payout at the end of the day if you wanted to do gamemodes in place of just adding more difficulty settings.

this is an example of how much more efficient my idea is in place of a randomspawner:
Code: Select allExpand view
<stuffgoeshere>

It's mostly similar to the decorate coding years ago I've done with a few differences like adding ; after almost every line of code with some differences like adding { } to more complex coding that needs it and figuring out ways to replace the deprecated flags and states that the console tell you upon loading the wad among other things of note.


well, that example is more involved than the item one in the first post.
User avatar
Dan_The_Noob
 
Joined: 07 May 2019
Twitch ID: Dan_The_Noob
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest