[2.4.1] User variables in weapons have inconsistent owners.

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Guest

[2.4.1] User variables in weapons have inconsistent owners.

Post by Guest »

I was recently working on a decorate weapon that use a user variables, namely one named "user_entropic". I tried using the weapon, but whenever I fired the weapon, ZDoom would tell me "user_entropic is not a user variable in class DoomPlayer"

Figuring that when you pick up a weapon, the decorate code for user variables must transfer their target to the player, I created a new player class that had the same user variables as the weapon definition. However, the weapon still didn't work. In particular, this line was causing me problems:

Code: Select all

SPEL A 0 A_JumpIfInventory("DynamicMana",user_dynamic,"CheckStatic")
I had, earlier in my decorate code, set user_dynamic to be 7. However, no matter how much DynamicMana I had, it still wouldn't make the jump.

After looking at A_JumpIfInventory, I had the hunch that user_dynamic might be considered 0, because if it was, I would need to have my max mana before I made the jump. I tried deleting the line "var int user_dynamic;" from my weapon definition (but left the variable in my player class definition) and sure enough, upon starting Zdoom, it told me, "Script error, "MyWad.pk3:spelcast.txt" line 51: Unknown identifier 'user_dynamic'", where line 51 is the one that calls A_JumpIfInventory.

In short, it appears as though a user variable in a weapon references the variable of the player when writing a variable, but the user variable of the weapon when reading the variable. This is awfully inconvenient, to the point where I figured it was probably a bug. Is this the intended behavior? If so, why? And how do I get around it so I can use variable in my weapons?

I'll replicate the bug in a controlled wad and post it when I get a chance.
Guest

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Guest »

Umm... I can't figure out how to attach wad files like the forum requested, so I'll just put up the decorate in a code box.

Code: Select all

actor ShockWaveDoomImp : DoomImp replaces DoomImp
{
  var int user_theta;
  states
  {
  Missile:
    TROO EF 8 A_FaceTarget
    TROO G 0 A_SetUserVar("user_theta",0)
  Shock:
    TROO G 0 A_CustomMissile("DoomImpBall",32,0,user_theta)
    TROO G 1 A_SetUserVar("user_theta",user_theta+5)
    TROO G 0 A_JumpIf(user_theta==360,"EndShock")
    Loop
  EndShock:
    TROO G 6
    Goto See
  }
}

actor AlteredBFG : BFG9000 replaces BFG9000
{
  var int user_theta;
  states
  {
  Fire:
    BFGG A 20 A_BFGSound
    BFGG B 10 A_GunFlash
  Shock:
    BFGG B 0 A_FireCustomMissile("DoomImpBall",user_theta,0)
    BFGG B 1 A_SetUserVar("user_theta",user_theta+5)
    BFGG B 0 A_JumpIf(user_theta==360,"EndShock")
    Loop
  EndShock:
    BFGG B 20 A_ReFire
	goto Ready
  }
}

ACTOR Xerxes : DoomPlayer
{
  var int user_theta;
  Player.DisplayName "AlteredMarine"
}
So, first, run it as a normal marine. When you do so, the BFG, instead of firing in a circle around you, like it does for the imp, it will shoot an infinite number of imp fireballs in a stream in front of you, and tell you that user_theta isn't a valid variable in doomplayer.

Next, play as the AlteredMarine. When you do so, the error message goes away. However, you still shoot an infinite number of imp fireballs in a line in front of you.

Next, delete the "var int user_theta;" in the weapon definition. When you do so, the game will no longer load, but instead crashes when it reaches the decorate definitions involving user_theta.

I hope this sufficiently demonstrates my problem. Let me know if I need to do anything else to help.

On an unrelated note, what is the etymology of "Cyril Fudgelot"?
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Xaser »

Sir Fudgelot was one of the original Knights of the Chocolate Table who defended the Cocoa Kingdom from the evils of peanuts and their by-products. Despite his noble efforts in the Great Candy War of 1930, he met a tragic end at the Battle of Caramel when he was betrayed by his liege, King Mars. The Cocoa Kingdom was defeated by the evil peanuts, who assimilated their cultures together into a vile mix of deliciousness and disgust. Thus, Snickers was born.


*ahem*, I mean, it's just a byproduct of the random guest name generator the forums have installed. Unless your register your own account, a random name is picked per-thread for any guests who happen to post there. The bugs forum is the only one that allows guests, as an aside, and (I think) you can't upload anything to the boards as a guest either (note that I could be wrong here: if you recieved a message like "the board upload quota has been reached," it's something else entirely).

Hmm, I haven't tried using uservars much myself, mainly for some of the same concerns this thread has shown. A bit of an unknown field I haven't yet ventured to. Hopefully something is resolved -- ownership is such a clusterfunk as it is.
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Major Cooke »

I have to agree with you here, this is bugging the hell out of me as to why it's not bloody working.

Then again, if you type "developer 2" in console, then fire the BFG you'll see it repeats the not-valid-variable stuff with each and every shot. :roll:
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by NeuralStunner »

I've tried using them for a stat (I.E. Strength, Agility) system, but it frustrated me so much I ended up using Dummy Inventory items.
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Major Cooke »

Wait... Don't give up yet. http://zdoom.org/Changelog/1933/files

If I'm reading that last line correctly, we may need to set up an array first in order to access it. That just might be the solution to this problem.

http://zdoom.org/wiki/Arrays
http://zdoom.org/wiki/A_SetUserArray

If anyone comes up with something and it works, please do spell it out.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by NeuralStunner »

Um, well, ACS arrays aren't the same as UserVar ones. (Still, a regular, non-array user variable should work on its own.)

Inventory functions in Weapons/CustomInventory items reference the "owning" Player's Inventory, I'd think this should as well. It doesn't though. :(
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Major Cooke »

Yeah but with arrays, these are meant to actually store them for other uses, or so I think. I believe one might be able to make a global array which then can be accessed via the decorate commands, which can then define the variables for any/all to use... I'll have to do some experimenting.

Yeah, you can give the actors their own variables but as you and I noticed, we can't touch them with other actors.
Guest

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Guest »

Every time we use a cheap hack to do what we want to do in ZDoom instead of waiting for them to release the proper codefix and doing things the way we're supposed to do them, it makes Graf cry inside. (Just look at the Afrit, for example.) I'm about 90% sure that the behavior I'm seeing isn't what Randy or Graf intended to happen when user variables are used with weapons, so I want to be patient and let Graf sort it out. Until then, one of the two behaviors I'm looking to create by using user variables can be done with inventory "markers" instead, so I'll use that. The other behavior I'm looking to create will just have to wait until this is fixed, which is cool. I respect that Graf and Randy are doing this in their free time, and though I haven't seen the code (nor would I understand it if I did see it) I'm guessing that this isn't a quick, easy fix, so I'll just be happy for whenever they happen to get around to it. Though if one of them happened to stop by this thread and say "Yeah, I've noticed this problem and plan to fix it when I get around to it," it'd make my whole day. :mrgreen:
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by randi »

How about now?
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Major Cooke »

I'll give it a shot. I'm awaiting for the DRD upload first.

In the mean time, is it possible to allow masters/minions/siblings so they are able to modify a specific user variable which is shared between all of them? This is also assuming the master has the "var int user_adultcount;" at his beginning too.
Guest

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Guest »

How about now?
As in, you're working on it now? Freak, that'd make my whole week! :D
User avatar
Major Cooke
Posts: 8212
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Major Cooke »

http://zdoom.org/Changelog

He posted that when he said "how bout now".
Guest

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Guest »

Ah. As in: "How is it working now?"

Week made. You guys are awesome. This is why I love Zdoom.
Guest

Re: [2.4.1] User variables in weapons have inconsistent owne

Post by Guest »

I hate to bug you, but I downloaded the most recent build from DRDteam, and the decorate code I posted above still isn't working:

*When I run it as normal, it shoots a stream of fireballs forward and slightly to the right.
*When I comment out the user_theta in the weapon definition, it will not load.
*When I comment out the user_theta in the player definition, it does the same thing as when the user_theta is there. However, this time, it doesn't give an error message, like it did before.

Perhaps my decorate code is wrong? Could I get somebody else to see if user variables in weapons are working, so I know it's not just me?
Post Reply

Return to “Closed Bugs [GZDoom]”