Ideally, ZDoom would have a player property, say PROP_TOTALLYFROZENML, that acted exactly as PROP_TOTALLYFROZEN, except they were additionally allowed to mouselook in addition to "+use". Thus, they would be frozen in place, unable to do anything, except look around (and "+use").
It doesn't seem like there is such a thing however. Given this, is there an easy way I can imitate this behavior?
PROP_TOTALLYFROZEN with mouselook
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Re: PROP_TOTALLYFROZEN with mouselook
Yup, totally possible. You can read the player's input (the data that's being sent from your hardware to the game) even when he's frozen. See attached example
- Attachments
-
freezelook.zip
- (1.43 KiB) Downloaded 77 times
Re: PROP_TOTALLYFROZEN with mouselook
Awesome. Perfect solution. Thanks!
Re: PROP_TOTALLYFROZEN with mouselook
Curious: Is there any advantage to using while(1) to loop as opposed to just placing restart; at the end of the script?
- Caligari87
- Admin
- Posts: 6236
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: PROP_TOTALLYFROZEN with mouselook
Functionally I think it works just about the same from an end-user perspective. Intuitively I feel like there may be some overhead / garbage collection / memory management penalties from repeatedly trashing and re-initializing variables, but I don't know for sure and it's probably minimal at best, if it happens at all.
Personally though, I'd recommend just using the while loop for cleanliness and to clearly state "this thing loops!" instead of just implying it with a restart.

Personally though, I'd recommend just using the while loop for cleanliness and to clearly state "this thing loops!" instead of just implying it with a restart.

Re: PROP_TOTALLYFROZEN with mouselook
You can put a condition in the brackets in a while loop, if you need to make the script break when a condition becomes false. For example, while(GetPlayerHealth > 0) will only keep looping the script as long as the player's health is not 0; as soon as his health is 0, the loop will break and code under the while block will execute (and eventually delete the script from running, if you have no more other commands).
EDIT: Here's a real world example, the while block at the top actually prevents all that stuff below from happening until the gameInstance variable has been set. This is needed because I need to control PRECISELY when the player is manipulated, and across multiple running scripts, this is the only way to get them to talk to each other (hope that makes sense)
EDIT: Here's a real world example, the while block at the top actually prevents all that stuff below from happening until the gameInstance variable has been set. This is needed because I need to control PRECISELY when the player is manipulated, and across multiple running scripts, this is the only way to get them to talk to each other (hope that makes sense)
Code: Select all
//===========================================================================
//
// PLAYER SETUP
//
//===========================================================================
script "Script_PlayerSetup" (void)
{
int pn = PlayerNumber();
// do nothing and wait for game instance
while(gameInstanceCount == 0)
{
Delay(1);
}
// world has been created, time to setup the player pawn
// for regular gameplay
// set a TID
Thing_ChangeTID(0, TID_PLAYER + pn);
int ptid = ActivatorTID();
// turn on instant weapon switching
SetPlayerProperty(0, ON, PROP_INSTANTWEAPONSWITCH);
// buddha mode so we have total control of death
SetPlayerProperty(0, ON, PROP_BUDDHA);
// [TO DO] start position needs to be more complex than this
// (make a new function CalculatePlayerStart or something)
SetActorPosition(0, 0.0, 0.0, 0.0, FALSE);
// set player pieces [testing]
player[pn].stat.sex = CHARACTER_SEX_MALE;
player[pn].stat.curUnderpants = 1;
player[pn].stat.curPants = 1;
player[pn].stat.curUndershirt = 1;
player[pn].stat.curShirt = 1;
player[pn].stat.containerID = 1;
player[pn].stat.curShoes = 1;
player[pn].stat.curWeapon = 1;
// spawn sound emitters
ACS_NamedExecuteAlways("Script_SpawnPlayerSoundEmitter", 0, ptid, pn);
// Set the initial rain crossfade volume depending on player's start position
player[pn].rainxfade = CheckIsOutside(ptid) ? 1.0 : 0;
// spawn modular player parts
ACS_NamedExecuteAlways("Script_SpawnModularPlayer", 0, ptid, pn);
// spawn fake chase camera
ACS_NamedExecuteAlways("Script_SpawnFakeChaseCamera", 0);
// activate sun glare renderer
ACS_NamedExecuteAlways("Script_LoopDrawSunGlare", 0);
// activate halo renderer
ACS_NamedExecuteAlways("Script_LoopDrawHalo", 0);
// setup complete; run player loop
ACS_NamedExecuteAlways("Script_LoopPlayer", 0);
// test print language string
//SetFont("smallfont");
//SetHudSize(640, 400, 1);
//Print(s:ParseLanguage("Z_STRING_TEST"));
// fade in the player's view
V_FadeIn(1.2);
}