Actor UserVariables not saved in ZDS

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.

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: Actor UserVariables not saved in ZDS

Re: Actor UserVariables not saved in ZDS

by DnB-Freak » Mon Sep 22, 2014 11:38 am

FishyClockwork wrote:I think I found the culprit behind your problem. SmartShotgunGuy inherits from ShotgunGuy2. Both actors define user_MaxHealth or rather ShotgunGuy2 defines it and SmartShotgunGuy redefines it. (Because he already has it just by inheriting from ShotgunGuy2.)

I commented out "var int user_MaxHealth" in SmartShotgunGuy's actor definition and then ran your test (kill imp, save game, press switch, die, load save). Things seemed to work as expected, IE SmartShotty's health was still 606/606 after loading the save.
wow, just that? It's might an user error after all.
and I thought uservariables couldn't be inherited or overridden.
Thanks very much, Fishy, problem solved.

Re: Actor UserVariables not saved in ZDS

by Graf Zahl » Sun Sep 21, 2014 12:15 am

Ah, of course that kind of variable name duplication should not be allowed.
This will produce a compile error now.

Re: Actor UserVariables not saved in ZDS

by edward850 » Sat Sep 20, 2014 7:34 pm

There is, however, still an actual problem with serializing uservars, because that suggests that the keys are overwriting each other while still being able to exist independently in the playsim. One of these needs to change (probably the latter, as there is no reason why two keys with the same name in the same class should exist).

Re: Actor UserVariables not saved in ZDS

by Fishytza » Sat Sep 20, 2014 6:24 pm

I think I found the culprit behind your problem. SmartShotgunGuy inherits from ShotgunGuy2. Both actors define user_MaxHealth or rather ShotgunGuy2 defines it and SmartShotgunGuy redefines it. (Because he already has it just by inheriting from ShotgunGuy2.)

I commented out "var int user_MaxHealth" in SmartShotgunGuy's actor definition and then ran your test (kill imp, save game, press switch, die, load save). Things seemed to work as expected, IE SmartShotty's health was still 606/606 after loading the save.

Re: Actor UserVariables not saved in ZDS

by DnB-Freak » Wed Sep 10, 2014 9:31 am

Graf Zahl wrote:
Chickenlegz wrote:
Nightfall wrote:In my experience APROP_SpawnHealth has worked perfectly fine for non-players too.
Do you mean:
SetActorProperty(1, APROP_SPAWNHEALTH, 999); ?

I've tested this about 20 times for several different monsters, doesn't do anything at all.
Which build version do you use btw?

Well, obviously. The spawn health is a class property which cannot be altered for single actors.
Yes, I know that :( Thats why I had to workaround and use uservars to create a fake spawn health which could be altered in ACS from certain maps.
Unfortunately this doesn't work properly. I'm not quite sure if it's actually a bug, however the actors uservars seems lost after save game.
Loading the uservars via script from a saved game afterwards returns nullified values.
It can be proved in the attached demo. Please, let me know, Thanks in advance.

Re: Actor UserVariables not saved in ZDS

by Graf Zahl » Tue Sep 09, 2014 2:55 am

Chickenlegz wrote:
Nightfall wrote:In my experience APROP_SpawnHealth has worked perfectly fine for non-players too.
Do you mean:
SetActorProperty(1, APROP_SPAWNHEALTH, 999); ?

I've tested this about 20 times for several different monsters, doesn't do anything at all.
Which build version do you use btw?

Well, obviously. The spawn health is a class property which cannot be altered for single actors.

Re: Actor UserVariables not saved in ZDS

by ZzZombo » Tue Sep 09, 2014 2:29 am

Nightfall wrote:In my experience APROP_SpawnHealth has worked perfectly fine for non-players too.
It only gets the spawn health of an actor, but can't set it for non-players.

Re: Actor UserVariables not saved in ZDS

by DnB-Freak » Sun Aug 31, 2014 1:04 pm

Nightfall wrote:In my experience APROP_SpawnHealth has worked perfectly fine for non-players too.
Do you mean:
SetActorProperty(1, APROP_SPAWNHEALTH, 999); ?

I've tested this about 20 times for several different monsters, doesn't do anything at all.
Which build version do you use btw?

Re: Actor UserVariables not saved in ZDS

by Nightfall » Sun Aug 31, 2014 12:40 pm

In my experience APROP_SpawnHealth has worked perfectly fine for non-players too.

Actor UserVariables not saved in ZDS

by DnB-Freak » Sun Aug 31, 2014 11:57 am

I'm trying to make a dynamic healthbar over here using actor uservars and map scripts.
There are some information which is not saved in the .zds and only when custom monsters are involved.

Technical:
The healthbar is shown in integer numbers XXX / XXX health.
When pointing on a monster the global script displays the health on the screen as a hud.
Actors health can be manipulated via map scripts like the following code:

Code: Select all

Script 1 OPEN
{
	SetActorProperty(3, APROP_HEALTH, 352);
	SetActorProperty(4, APROP_HEALTH, 404);
	SetActorProperty(5, APROP_HEALTH, 606);
}
Because APROP_SPAWNHEALTH is for players only it cannot be used as a solution.
To define a max health and make the map script to do it is possible using this method in DECORATE for each monster:

Code: Select all

ACTOR ZombieMan2: ZombieMan replaces ZombieMan 3004
{
	var int user_MaxHealth;
	States
	{
	Spawn:
		POSS AA 1
		POSS A 0 A_SetUserVar("user_MaxHealth", Health)
	Idle:
		POSS AB 10 A_Look
		Loop
	}
}
The Spawn state defines the max health that can be extended via a map script that is executed BEFORE the uservariable is set,
this explains the 2 tic delay at the start of the spawn.
The rest of the time the monster will return to Idle state, not spawn, so the healthbar limits can only be set once, but are never saved in zdoom savegame files *.zds.

Debugging
Run
demo.wad
Example
(4.27 KiB) Downloaded 33 times
Feel free to take a look inside the WAD for relevant information.
There is a custom monster called SmartShotgunGuy which doesn't replace any original monster.
Patch the demo on DOOM2.WAD and simply run it despite skill.

Kill the imp and the save the game.
Press the switch and target at the SmartShotgunGuy in the middle, his health starts with 606, set via scripting.
Then die by letting them shot you or write "kill" in the console.
Your recent save is loaded. Now pull the switch again and target the SmartShotgunGuy again, his health not starts on 92, not 606.
The other monsters are OK so this error seem to affect only custom monsters.

What happened? The map script was executed after the save, but the actor's decorate Spawn state was never entered,
showing of the spawnhealth given to the script not the health passed over first time.

Analysis appreciated.
Have best wishes to get it fixed.

Top