Multi-Floor System

Zwiebelchen

You can change this now in User CP.
Reaction score
60
A system that allows 2 coordinate layers instead of just the default one.

Basicly, the system grants you the possibility to create walkable bridges that also allow to walk beneath them.
It could also be used to create two-floor houses for FPS/TPS styled games.

The system provides the following functions:
JASS:
public function GetFloor takes unit u returns integer

The function simply returns the floor-layer the unit is currently at.
0 is the standard terrain layer, 1 is the bridge layer.
JASS:
public function SetFloor takes unit u, integer level returns nothing

Allows to switch between terrain and bridge layer.
This is optional, in case you want to switch layers by using an elevator instead of "ordinary" stairs, where the system does the switching automaticly.

In order to get this system to work, you require the following registry functions:
JASS:
public function RegisterFloorArea takes real minx, real miny, real maxx, real returns nothing

Defines the areas the multi-floors are in.

JASS:
public function RegisterUnitMorphs takes integer unitground, integer unitfly, integer ground2fly, integer fly2ground returns nothing

Registers the unit types to the system that should be able to pass the bridge-layer.
Every registered unit types needs:
- an equivalent flying unit type
- two chaos-based morph abilities, to switch between ground and flying type


Comments & Discussion
The system is not very efficient.
True. However, I wrote this only for testing purposes. Maybe someone has a use for this.

How does it work?
All you need to do, is to use the register functions and place the "Walk Indicator" destructable like you would with an invisible platform. After that add air-pathing blockers to your area and you are done.

My unit doesn't step up the stairs automaticly!
Then maybe the z-offset for the first stair was to high. Either increase the offset setting in the system's constants, or lower the first "Walk Indicator" placed at your stairs.

The unit controls suck and the selection circle is still on the ground ...
Indeed. This is something the flawed engine of warcraft III messes up.
However, this system may still be very useful for those people that use 3rd person styled camera systems and arrow key controls. For this, its perfect.

Units on the ground layer behave weird when they try to pass air-pathing blockers
Yes ... this seems to be another bug in the wc3 engine. Air-pathing blockers suck.


JASS:

library MFS initializer Init

    globals
        private constant integer WalkIndicatorId = 'B001'
        private constant integer FloorChangeMaxOffset = 40
        private constant real HeightChangeVelocity = 1200
        private constant integer DummyId = 'h000'
        private constant player DummyOwner = Player(PLAYER_NEUTRAL_PASSIVE)
        private constant real Update = 0.05
    
    
        private unit dummy = null
        private rect array Rects
        private integer RectCount = 0
        private constant group enum = CreateGroup()
        private constant hashtable FloorHash = InitHashtable()
    endglobals
    
    public function GetFloor takes unit u returns integer
        if u != null then
            return LoadInteger(FloorHash, GetHandleId(u), 0)
        endif
        return 0
    endfunction
    
    public function SetFloor takes unit u, integer level returns nothing
        if u != null then
            call SaveInteger(FloorHash, GetHandleId(u), 0, level)
        endif
    endfunction
    
    public function RegisterFloorArea takes real minx, real miny, real maxx, real maxy returns nothing
        set Rects[RectCount] = Rect(minx, miny, maxx, maxy)
        set RectCount = RectCount+1
    endfunction
    
    public function RegisterUnitMorphs takes integer unitground, integer unitfly, integer ground2fly, integer fly2ground returns nothing
        call SaveInteger(FloorHash, unitground, 0, ground2fly)
        call SaveInteger(FloorHash, unitfly, 0, fly2ground)
    endfunction

    private function GetZ takes real x, real y returns integer
        local location l = null
        local real z = 0
        call SetUnitX(dummy, x)
        call SetUnitY(dummy, y)
        set l = GetUnitLoc(dummy)
        set z = GetLocationZ(l)
        call RemoveLocation(l)
        set l = null
        return R2I(z)
    endfunction
    
    private function RegisterWalkIndicator takes destructable d returns nothing
        local integer x = R2I(GetDestructableX(d))
        local integer y = R2I(GetDestructableY(d))
        local integer tempx = x-32
        local integer tempy = y-32
        local integer z = GetZ(tempx, tempy)
        if LoadInteger(FloorHash, tempx, tempy) < z then
            call SaveInteger(FloorHash, tempx, tempy, z)
        endif
        set tempy = y+32
        set z = GetZ(tempx, tempy)
        if LoadInteger(FloorHash, tempx, tempy) < z then
            call SaveInteger(FloorHash, tempx, tempy, z)
        endif
        set tempx = x+32
        set z = GetZ(tempx, tempy)
        if LoadInteger(FloorHash, tempx, tempy) < z then
            call SaveInteger(FloorHash, tempx, tempy, z)
        endif
        set tempy = y-32
        set z = GetZ(tempx, tempy)
        if LoadInteger(FloorHash, tempx, tempy) < z then
            call SaveInteger(FloorHash, tempx, tempy, z)
        endif
        call RemoveDestructable(d)
    endfunction
    
    private function ModInt takes integer dividend, integer divisor returns integer
        return dividend - (dividend / divisor) * divisor
    endfunction
    
    private function XToGridX takes real x returns integer
        if x < 0 then
            return R2I(x) - ModInt(R2I(x), 64) - 32  
        else
            return R2I(x) - ModInt(R2I(x), 64) + 32
        endif
    endfunction
    
    private function UpdateZ takes nothing returns boolean
        local unit u = GetFilterUnit()
        local integer z = LoadInteger(FloorHash, XToGridX(GetUnitX(u)), XToGridX(GetUnitY(u)))
        if HaveSavedInteger(FloorHash, GetUnitTypeId(u), 0) then //only perform update for registered unit-types
            if GetFloor(u) > 0 then
                if z == 0 then
                    call SetFloor(u, 0)
                    call UnitAddAbility(u, LoadInteger(FloorHash, GetUnitTypeId(u), 0))
                endif
                if R2I(GetUnitFlyHeight(u)) != z then
                    call SetUnitFlyHeight(u, z, HeightChangeVelocity)
                endif
            else
                if z > 0 and z < FloorChangeMaxOffset then
                    call SetFloor(u, 1)
                    call UnitAddAbility(u, LoadInteger(FloorHash, GetUnitTypeId(u), 0))
                    if R2I(GetUnitFlyHeight(u)) != z then
                        call SetUnitFlyHeight(u, z, HeightChangeVelocity)
                    endif
                endif
            endif
        endif
        set u = null
        return false
    endfunction
       
    private function UpdateAllRects takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i >= RectCount
            call GroupEnumUnitsInRect(enum, Rects<i>, Condition(function UpdateZ))
            set i = i + 1
        endloop
    endfunction
    
    private function RegisterAllWalkIndicators takes nothing returns nothing
        local destructable d = GetEnumDestructable()
        if GetDestructableTypeId(d) == WalkIndicatorId then
            call RegisterWalkIndicator(d)
        endif
        set d = null
    endfunction
    
    private function Init takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t, Update, true, function UpdateAllRects)
        set t = null
        set dummy = CreateUnit(DummyOwner, DummyId, 0, 0, 0)
        call SetUnitPathing(dummy, false)
        call EnumDestructablesInRect(bj_mapInitialPlayableArea, null, function RegisterAllWalkIndicators)
    endfunction
endlibrary</i>
 

Attachments

  • MultiFloorSystem.w3x
    17.3 KB · Views: 417
Code?

Just took a look in the code. You can make each grid become a struct for it.
 
First, how is this possible?
Second, is it possible to have two units at the same spot, on different levels?
And third, please post the code...
 
True. However, I wrote this only for testing purposes. Maybe someone has a use for this.

Daxtreme said:
We want Quality, not Quantity. Thus, submit only what you think is good! If your post contains something like "check out my crappy spell" it will hit graveyard right away.


Also, why dont you use [noparse]
JASS:
[/noparse] tags? It looks much neater that way.
 
Code?

Just took a look in the code. You can make each grid become a struct for it.
Why? I need an unlimited two-dimensional array here and I only store 1 variable to each grid center, so a hashtable is the most efficient way to do it in this case.

Second, is it possible to have two units at the same spot, on different levels?
That is the whole purpose of this system.

We want quality, not quantity
Okay, maybe you misunderstood me here:
The system itself is pretty effective; however, it has serious flaws in terms of graphic style and unit-mouse controls that I could not fix, as they are hardcoded to the game engine.
However, all of these can be removed by using keyboard controled unit movement instead of mouse control.
 
Units on the second level can walk right through eachother.
 
Fun to play around with, but as you say, wc3 can't support it so it becomes .. bad.

Is this something similar to what they used in that FPS map? (Doubt there's more than one)

Anyways, just as that map, its something new and cool and all that, but it breaks in so many ways that it becomes relatively useless.

//==GooS
 
I agree. However, as I already said I wrote this almost only for the reason to find out wether it is generally possible.

I think in SC2, you are able to do far better than that, as the most crucial drawbacks of this are negated in SC2:

1) Shadows will be dynamicly generated by your graphics card in SC2, so they don't look weird on the second layer anymore
2) As SC2 allows changing of unit data directly through triggers, no more "flying unit" change is required and the selection circle remains at your unit correctly
3) SC2 might be able to directly get a destructables or doodads Z value, so no more dummy platforms are required
4) Possibly a better dynamic way of pathing blocking

The only issue that will still suck in terms of multi-floor-ability on SC2 is the fact that you would still have the problem with the mouse ordering of units - but most funmaps on SC2 will have 3rd person view and arrow key controls anyways.:D
 
Would this system stop melee units from attacking other units that are above them?
 
As far as i understood Ziebelchen units on the second layer are "flying units" so melee units which cannot attack flying units cannot attack units on the second layer as well.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • tom_mai78101 tom_mai78101:
    Currently in the middle of getting the probate process going. We're doing the informal probate process.
    +3
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new
  • Ghan Ghan:
    Good stuff.
  • Ghan Ghan:
    Just make sure it is secure. :)

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top