Spoiler:Code: Select all
Actor InfraredReplacer : CustomInventory replaces Infrared { var int user_Item; +INVENTORY.ALWAYSPICKUP +INVENTORY.QUIET -COUNTITEM Inventory.Amount 0 States { Spawn: TNT1 A 0 TNT1 A 0 A_SetUserVar("user_Item",(ACS_NamedExecuteWithResult("InfraredReplacement",0,0,0))) TNT1 A 0 A_JumpIf(user_Item==1,"Stimpack") TNT1 A 0 A_JumpIf(user_Item==2,"Medikit") TNT1 A 0 A_JumpIf(user_Item==3,"Berserk") TNT1 A 0 A_JumpIf(user_Item==4,"Soulsphere") TNT1 A 0 A_JumpIf(user_Item==5,"Megasphere") TNT1 A 0 A_JumpIf(user_Item==6,"ArmorBonus") TNT1 A 0 A_JumpIf(user_Item==7,"GreenArmor") TNT1 A 0 A_JumpIf(user_Item==8,"BlueArmor") TNT1 A 0 A_JumpIf(user_Item==9,"BlurSphere") TNT1 A 0 A_JumpIf(user_Item==10,"InvulnerabilitySphere") TNT1 A 0 A_JumpIf(user_Item==11,"RadSuit") TNT1 A 0 A_JumpIf(user_Item==12,"Infrared") TNT1 A 0 A_JumpIf(user_Item==13,"Allmap") TNT1 A 0 A_JumpIf(user_Item==14,"DemonicDagger") TNT1 A 0 A_JumpIf(user_Item==15,"SkullChest") TNT1 A 0 A_JumpIf(user_Item==16,"EvilSceptre") TNT1 A 0 A_JumpIf(user_Item==17,"UnholyBible") Goto HealthBonus HealthBonus: TNT1 A 0 A_SpawnItem("HealthBonus2") Goto End Stimpack: TNT1 A 0 A_SpawnItem("Stimpack2") Goto End Medikit: TNT1 A 0 A_SpawnItem("Medikit2") Goto End Berserk: TNT1 A 0 A_SpawnItem("Berserk2") Goto End Soulsphere: TNT1 A 0 A_SpawnItem("Soulsphere2") Goto End Megasphere: TNT1 A 0 A_SpawnItem("Megasphere2") Goto End ArmorBonus: TNT1 A 0 A_SpawnItem("ArmorBonus2") Goto End GreenArmor: TNT1 A 0 A_SpawnItem("GreenArmor2") Goto End BlueArmor: TNT1 A 0 A_SpawnItem("BlueArmor2") Goto End BlurSphere: TNT1 A 0 A_SpawnItem("BlurSphere2") Goto End InvulnerabilitySphere: TNT1 A 0 A_SpawnItem("InvulnerabilitySphere2") Goto End RadSuit: TNT1 A 0 A_SpawnItem("RadSuit2") Goto End Infrared: TNT1 A 0 A_SpawnItem("Infrared2") Goto End Allmap: TNT1 A 0 A_SpawnItem("Allmap2") Goto End DemonicDagger: TNT1 A 0 A_SpawnItem("DemonicDagger") Goto End SkullChest: TNT1 A 0 A_SpawnItem("SkullChest") Goto End EvilSceptre: TNT1 A 0 A_SpawnItem("EvilSceptre") Goto End UnholyBible: TNT1 A 0 A_SpawnItem("UnholyBible") Goto End End: TNT1 A -1 Loop } }
Self Pointer used in ambiguous Context
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!)
- Doomguy 2000
- Posts: 178
- Joined: Tue Oct 12, 2010 3:30 pm
- Location: Undisclosed Location, United States
- Contact:
Self Pointer used in ambiguous Context
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:
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Self Pointer used in ambiguous Context
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)
- Doomguy 2000
- Posts: 178
- Joined: Tue Oct 12, 2010 3:30 pm
- Location: Undisclosed Location, United States
- Contact:
Re: Self Pointer used in ambiguous Context
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.
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.
Re: Self Pointer used in ambiguous Context
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
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)
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 all
TNT1 A 0 A_JumpIf(invoker.user_Item==8,"BlueArmor")
- Doomguy 2000
- Posts: 178
- Joined: Tue Oct 12, 2010 3:30 pm
- Location: Undisclosed Location, United States
- Contact:
Re: Self Pointer used in ambiguous Context
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:
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:
Re: Self Pointer used in ambiguous Context
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: viewtopic.php?f=122&t=70725
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: viewtopic.php?f=122&t=70725
- Doomguy 2000
- Posts: 178
- Joined: Tue Oct 12, 2010 3:30 pm
- Location: Undisclosed Location, United States
- Contact:
Re: Self Pointer used in ambiguous Context
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.
The code in question that I'm now only concerned about:
Code: Select all
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
Code: Select all
TNT1 A 0 A_SetUserVar("user_Monster",(ACS_NamedExecuteWithResult("ZombiemanReplacement",0,0,0)));
Re: Self Pointer used in ambiguous Context
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
into
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: [wiki]ACS_NamedExecuteWithResult[/wiki] notes aliases for this function for DECORATE and ZScript, so it might be useful to you
Code: Select all
TNT1 A 0 A_SetUserVar("user_Monster",(ACS_NamedExecuteWithResult("ZombiemanReplacement",0,0,0)));
Code: Select all
TNT1 A 0 { user_monser = ACS_NamedExecuteWithResult("ZombiemanReplacement",0,0,0);}
PS: [wiki]ACS_NamedExecuteWithResult[/wiki] notes aliases for this function for DECORATE and ZScript, so it might be useful to you
- Doomguy 2000
- Posts: 178
- Joined: Tue Oct 12, 2010 3:30 pm
- Location: Undisclosed Location, United States
- Contact:
Re: Self Pointer used in ambiguous Context
Thanks I appreciate your help with this, Virathas. Shouldn't be too hard to convert the rest of the necessary code to Zscript.
- Dan_The_Noob
- Posts: 880
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Self Pointer used in ambiguous Context
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.
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.
- Doomguy 2000
- Posts: 178
- Joined: Tue Oct 12, 2010 3:30 pm
- Location: Undisclosed Location, United States
- Contact:
Re: Self Pointer used in ambiguous Context
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.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.
this is an example of how much more efficient my idea is in place of a randomspawner:
Code: Select all
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;
- Dan_The_Noob
- Posts: 880
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Self Pointer used in ambiguous Context
well, that example is more involved than the item one in the first post.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: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.Code: Select all
<stuffgoeshere>