player view height variable

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: player view height variable

Re: player view height variable

by Ed the Bat » Fri Aug 09, 2013 7:13 am

Re: player view height variable

by Ed the Bat » Wed May 22, 2013 11:46 pm

Makes sense. It's all a great deal over my head; I was just trying to rearrange things to resemble other functions I saw. As is clear, I haven't the skillset to do the real work for what aims to be done here, but I'm admittedly growing anxious over time, as working functions for this would be tremendously valuable to me, yet so far appear to be out of my reach.

Re: player view height variable

by FDARI » Wed May 22, 2013 11:39 pm

Since the retrieved "viewheight" is a dynamic value (factoring other things than direct assignment) it isn't really a good candidate for an assignment counterpart.

Viewheight really returns "current viewheight", and your counterpart assignment function appears to set current viewheight as well. With your function, if you set the viewheight of a crouching player, the player will be a lot taller when standing up again.

I recommend SetActorBaseViewHeight and GetActorBaseViewHeight to have a pair of functions that act on the stored value without caring about crouching.

You can't assign to the return value of GetMetaFixed. That function just returns a number, it does not map to the place where it found that value, and therefore it cannot place your args[1] value anywhere. There may be such a function as SetMetaFixed, but I doubt it, and more importantly, it belongs to the actor class, so you shouldn't change it at all (because you would modify the entire class/every actor of that class, and because class definitions are part of the wad and not part of the saved game, so it would not persist).

It seems that a monster's camera height cannot be changed in this way. (Not without adding a property to the actor definition so that all actors can set their own viewheight anyway).

This leads to SetPlayerViewHeight and GetPlayerViewHeight setting and getting actor->player->mo->ViewHeight, and doing nothing/returning 0 for monsters. (The set function should probably return 0 in this case, to indicate that it could not perform the requested action)

NB: This is based on the code you put here, not on my own research of zdoom source.

Re: player view height variable

by Ed the Bat » Tue May 21, 2013 1:26 am

This is tangentially related, but it seems that, contrary to what the Wiki states, GetActorViewHeight is fully able to accept Tid 0 to represent the activator. However, it does return different values depending on if a player is crouching or not, which could potentially complicate matters...

But, as for setting the viewheight... I'm poking around with the source code. I'm not well versed in raw source at all, and I could be totally off base here, but... trying to follow the format as I can see it, using the code for GetActorViewHeight:

Code: Select all

ACSF_GetActorViewHeight:
	actor = SingleActorFromTID(args[0], activator);
	if (actor != NULL)
	{
		if (actor->player != NULL)
		{
			return actor->player->mo->ViewHeight + actor->player->crouchviewdelta;
		}
		else
		{
			return actor->GetClass()->Meta.GetMetaFixed(AMETA_CameraHeight, actor->height/2);
		}
	}
	else return 0;
...would a SetActorViewHeight function look something like this?

Code: Select all

ACSF_SetActorViewHeight:
	actor = SingleActorFromTID(args[0], activator);
	if (actor != NULL)
	{
		if (actor->player != NULL)
		{
			actor->player->mo->ViewHeight = args[1] - actor->player->crouchviewdelta ;
			return 1;
		}
		else
		{
			actor->GetClass()->Meta.GetMetaFixed(AMETA_CameraHeight, actor->height/2) = args[1];
			return 1;
		}
	}
	else return 0;
Again, I have no real experience with source code, but I'm really eager to see this feature develop.

Re: player view height variable

by DOOMERO-21 » Thu May 16, 2013 4:46 pm

and??? is possible?

Re: player view height variable

by Ed the Bat » Mon Mar 04, 2013 10:48 pm

After pondering this issue for a few weeks, it occurred to me that maybe there's a reason GetActorViewHeight existed as a separate function. If SetActorProperty proves unable to reasonably handle this matter, then maybe it would be prudent to instead fix GetActorViewHeight to be able to accept Tid 0 as the activator, and create a sibling function for SetActorViewHeight.

Re: player view height variable

by DOOMERO-21 » Thu Jan 31, 2013 2:40 pm

Ed the Bat wrote:The effect that crouching has on a player's viewheight may also need to be taken into account. So, checking this property on a crouched player may need to understand that it's 1/2 of the 'real' current viewheight.
good point.

Re: player view height variable

by Ed the Bat » Thu Jan 31, 2013 1:32 pm

The effect that crouching has on a player's viewheight may also need to be taken into account. So, checking this property on a crouched player may need to understand that it's 1/2 of the 'real' current viewheight.

Re: player view height variable

by Xaser » Thu Jan 31, 2013 1:27 pm

Ah, okay. I guess the tricky part though would be that the function can't readily assume a single property, since for players there's a special case. I guess this is why there's a separate function for this in the first place. Dunno off the top of my head how hard/hacky it would be to wrap this up into SetActorProperty.

Re: player view height variable

by Ed the Bat » Thu Jan 31, 2013 10:08 am

Ryan Cordell wrote:SetPlayerProperty doesn't really influence the player's properties in any way. SetActorProperty is sooner what one would be looking for.
Right, right, that's the one I was thinking of. My mistake.
Xaser wrote:Does anything but a player have a "viewheight" sort of variable, though?
Looks like it.

Re: player view height variable

by Nash » Thu Jan 31, 2013 9:04 am

According to http://zdoom.org/wiki/Actor_properties every actor has a CameraHeight property. I don't know if the player uses the same variable or if the player's viewheight is something different?

Re: player view height variable

by Xaser » Thu Jan 31, 2013 8:14 am

Does anything but a player have a "viewheight" sort of variable, though? It probably only exists in the player_t struct, so it'd be undefined for any nonplayer actors. Set/GetActorProperty wouldn't really be the place for it, as such.

Re: player view height variable

by Ral22 » Thu Jan 31, 2013 7:24 am

I could gladly live with either one. If we maybe wanted to wrangle with more additions, like a setting on whether the height change is instant or goes up/down at a rate, it should be a separate function.

Re: player view height variable

by Ryan Cordell » Thu Jan 31, 2013 4:19 am

SetPlayerProperty doesn't really influence the player's properties in any way. SetActorProperty is sooner what one would be looking for. There is, also, ACSF_GetActorViewHeight in the source, so one should wonder if "APROP_ViewHeight" should be a SetActorProperty only thing or a separate ACS function?

Re: player view height variable

by Ral22 » Thu Jan 31, 2013 1:45 am

Ryan Cordell wrote:Think I'll give it a shot and prototype it in ToB today, see how it turns out.
Man, Ryan. Has anyone ever told you you're the best?

Top