3D Switches

Advanced OpenGL source port fork from ZDoom, picking up where ZDoomGL left off.
[Home] [Download] [Git builds (Win)] [Git builds (Mac)] [Wiki] [Repo] [Bugs&Suggestions]

Moderator: Graf Zahl

User avatar
solarsnowfall
Persecution Complex
Posts: 363
Joined: Fri Aug 05, 2005 8:51

Post by solarsnowfall »

If you are using 3d floors to make up the divisions between each floor, you would probably do best getting the the ceiling height, considering that's what you stand on when atop a 3d floor. Lets assume you have 3 floors you want to navigate within an elevator. Tag 1 will be the lowest, tag 2 in the middle, tag 3 the highest, and tag 4 the sector you are moving. I'll also assume that the floor of the elevator is in fact a floor, not a 3d floor (in which case the ceiling), and so is the bottom floor. Since the elevator functions seem to be a bit limitted in this regaurd, we won't use them.

Code: Select all

Script 1 (int SectorTag, int Speed)
{
    int Value;

    switch (SectorTag)
    {
        case 1: if (GetSectorFloorZ(4, 0, 0) != GetSectorFloorZ(1, 0, 0))
                {
                    Value = GetSectorFloorZ(4, 0, 0) - GetSectorFloorZ(1, 0, 0);
                    Floor_LowerByValue(4, Speed, Value >> 16);
                    Ceiling_LowerByValue(4, Speed, Value >> 16);
                }
                break;

        case 2: if (GetSectorFloorZ(4, 0, 0) < GetSectorCeilingZ(2, 0, 0))
                {
                    Value = GetSectorCeilingZ(2, 0, 0) - GetSectorFloorZ(4, 0, 0);
                    Floor_RaiseByValue(4, Speed, Value >> 16);
                    Ceiling_RaiseByValue(4, Speed, Value >> 16);
                }

                else if (GetSectorFloorZ(4, 0, 0) > GetSectorCeilingZ(2, 0, 0))
                {
                    Value = GetSectorFloorZ(4, 0, 0) - GetSectorCeilingZ(2, 0, 0)
                    Floor_LowerByValue(4, Speed, Value >> 16);
                    Ceiling_LowerByValue(4, Speed, Value >> 16);
                }
                break;

        case 3: if (GetSectorFloorZ(4, 0, 0) != GetSectorCeilingZ(3, 0, 0))
                {
                   Value = GetSectorCeilingZ(3, 0, 0) - GetSectorFloorZ(4, 0, 0);
                   Floor_RaiseByValue(4, Speed, Value >> 16);
                   Ceiling_RaiseByValue(4, Speed, Value >> 16);
                }
                break;
    }
}
[edit]This anything like what you're trying to do?
Attachments
multivator.zip
(1.79 KiB) Downloaded 71 times
User avatar
Syfo-Dyas
Posts: 182
Joined: Sun Oct 09, 2005 21:54
Location: Ohio
Contact:

Post by Syfo-Dyas »

Thankx man will check it out at home!
User avatar
solarsnowfall
Persecution Complex
Posts: 363
Joined: Fri Aug 05, 2005 8:51

Post by solarsnowfall »

And just to kill time, this would be a more flexible script.

Code: Select all

#define BOTTOM_FLOOR	1
#define TOP_FLOOR		3

Script 1 (int SectorTag, int Speed) 
{ 
    int Value; 

    switch (SectorTag) 
    {
        case BOTTOM_FLOOR:
         
            if (GetSectorFloorZ(4, 0, 0) != GetSectorFloorZ(1, 0, 0)) 
            { 
                Value = GetSectorFloorZ(4, 0, 0) - GetSectorFloorZ(1, 0, 0); 
                Floor_LowerByValue(4, Speed, Value >> 16); 
                Ceiling_LowerByValue(4, Speed, Value >> 16); 
            } 
            break; 

        default:
        
            if (GetSectorFloorZ(4, 0, 0) < GetSectorCeilingZ(SectorTag, 0, 0)) 
            { 
                Value = GetSectorCeilingZ(SectorTag, 0, 0) - GetSectorFloorZ(4, 0, 0); 
                Floor_RaiseByValue(4, Speed, Value >> 16); 
                Ceiling_RaiseByValue(4, Speed, Value >> 16); 
            } 

            else if (GetSectorFloorZ(4, 0, 0) > GetSectorCeilingZ(SectorTag, 0, 0)) 
            { 
                Value = GetSectorFloorZ(4, 0, 0) - GetSectorCeilingZ(SectorTag, 0, 0); 
                Floor_LowerByValue(4, Speed, Value >> 16); 
                Ceiling_LowerByValue(4, Speed, Value >> 16); 
            } 
            break; 

        case TOP_FLOOR: 
        	
            if (GetSectorFloorZ(4, 0, 0) != GetSectorCeilingZ(3, 0, 0)) 
            { 
                Value = GetSectorCeilingZ(3, 0, 0) - GetSectorFloorZ(4, 0, 0); 
                Floor_RaiseByValue(4, Speed, Value >> 16); 
                Ceiling_RaiseByValue(4, Speed, Value >> 16); 
            } 
            break; 
    } 
}
User avatar
Syfo-Dyas
Posts: 182
Joined: Sun Oct 09, 2005 21:54
Location: Ohio
Contact:

Post by Syfo-Dyas »

Ok, that's not what I was talking about. I'll dig out my example with Fraggle Script and upload it soon.
User avatar
The Ultimate DooMer
Persecution Complex
Posts: 152
Joined: Tue Nov 08, 2005 23:04
Location: Industrial Zone
Contact:

Post by The Ultimate DooMer »

I did something like this once to fake a multi-storey car park - I defined a "floor" variable to keep track of what floor the lift was on, and altered the variable when the lift went up or down. For your lift, it could go something like this:

Code: Select all


int floor = 1;    // starting on floor 1

script 1 (void)    // lift (to floor 1)

{
if (floor == 2)
        {
        FloorAndCeiling_LowerByValue (tag, speed, no.of units equal to 1 floor)
        }
if (floor == 3)
        {
        FloorAndCeiling_LowerByValue (tag, speed, no.of units equal to 2 floors)
        }
if (floor == 4)
        {
        FloorAndCeiling_LowerByValue (tag, speed, no.of units equal to 3 floors)
        }
floor = 1;
}

That'll make the lift go to floor 1 from whatever floor it's on.

Make a copy of the script for each of the other floors and alter the raise/lower values accordingly (using FloorAndCeiling_RaiseByValue for going up). And make the "floor" variable change to the floor no. of course
User avatar
The Ultimate DooMer
Persecution Complex
Posts: 152
Joined: Tue Nov 08, 2005 23:04
Location: Industrial Zone
Contact:

Post by The Ultimate DooMer »

Actually, for travelling on the lift it's the same set of scripts :P I did miss something important out though, so it's updated above.
Locked

Return to “GZDoom”