PROP_TOTALLYFROZEN with mouselook

Archive of the old editing forum
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.
Locked
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

PROP_TOTALLYFROZEN with mouselook

Post by GleasSpty »

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?
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: PROP_TOTALLYFROZEN with mouselook

Post by Nash »

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
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: PROP_TOTALLYFROZEN with mouselook

Post by GleasSpty »

Awesome. Perfect solution. Thanks!
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: PROP_TOTALLYFROZEN with mouselook

Post by GleasSpty »

Curious: Is there any advantage to using while(1) to loop as opposed to just placing restart; at the end of the script?
User avatar
Caligari87
Admin
Posts: 6236
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: PROP_TOTALLYFROZEN with mouselook

Post by Caligari87 »

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.

8-)
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: PROP_TOTALLYFROZEN with mouselook

Post by Nash »

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)

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);
}
 
Locked

Return to “Editing (Archive)”