Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gravity Tiles
#1
Just something small I made for my game, and.. I've never written a tutorial yet, so I figured I should try and actually contribute something. This should work in a vanilla MSE, I can't see why it wouldn't.

Client Side:


Add this to your Constants, under the other tiles:
Code:
Public Const TILE_TYPE_GRAVITY = 7


Find:
Code:
If .Type = TILE_TYPE_KEYOPEN Then Call DrawText

Under it add:
Code:
If .Type = TILE_TYPE_GRAVITY Then Call DrawText(TexthDC, x * PIC_X + 8, y * PIC_Y + 8, "Grav", QBColor(Magenta))


Find:
Code:
If frmMirage.optKeyOpen.Value = True Then
                        .Type = TILE_TYPE_KEYOPEN
                        .Data1 = KeyOpenEditorX
                        .Data2 = KeyOpenEditorY
                        .Data3 = 0
                    End If


Under it add:
Code:
If frmMirage.OptGravity.Value = True Then
                        .Type = TILE_TYPE_GRAVITY
                        .Data1 = 0
                        .Data2 = 0
                        .Data3 = 0
                    End If


Now: Of course you need to go into frmMirage and add OptGravity to the other attributes for the map editor.




Server Side:

In your Server constants, add this under the other tiles:
Code:
Public Const TILE_TYPE_GRAVITY = 7



Finally, Find:
Code:
Sub PlayerMapDropItem

Then Dim these:
Code:
Dim Yloc As Long, x As Long, y As Long

In the Sub, find these lines:
Code:
' Send inventory update
            Call SendInventoryUpdate(Index, InvNum)

And right under them add this block of code:
Code:
' Apply Gravity
            Yloc = GetPlayerY(Index)
            For y = 0 To MAX_MAPY
                For x = 0 To MAX_MAPX
                    If Map(GetPlayerMap(Index)).Tile(x, Yloc).Type = TILE_TYPE_GRAVITY Then
                        Yloc = Yloc + 1
                    End If
                Next x
            Next y

And... you're done.
If a player tries to drop an object onto a gravity tile, it will move it down one space, if that tile is also gravity type, it will keep being pulled until it hits a non-gravity tile.

I used these for ladders in my game, becasue I thought it looked stupid when people dropped items floating on a ladder.
Now the itmes fall straight to the bottom of the ladder's base.


This can be expanded on easily too..
Maybe make NPCs fall down them, or something.



EDIT:

Cruzn Wrote:In Sub PlayerMapDropItem, Find:
Code:
Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index))
Replace With:
Code:
Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), Yloc)
Reply
#2
I think you're missing one last part. ;-)

-- Server Side

In Sub PlayerMapDropItem, Find:
Code:
Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index))
Replace With:
Code:
Call SpawnItemSlot(i, MapItem(GetPlayerMap(Index), i).Num, Ammount, MapItem(GetPlayerMap(Index), i).Dur, GetPlayerMap(Index), GetPlayerX(Index), Yloc)
Reply
#3
Hah, yeah forgot that, Updating right now, thanks.
Reply
#4
Props dude. This is a pretty neat tutorial. Big Grin
Reply
#5
I didnt really look at it that much since Im in a Internet cafe, but this could be used for a waterfall and such then?
Reply
#6
Yupp.

Could easily make it slide npcs and players.
Reply
#7
Change this to work for players and npc and you have yourself a side scrolling rpg.

Very Nice indeed.
Reply
#8
If you wanted it like that you'd do it with a timer.
Reply
#9
Right now I'm trying to make the item slide down gradually, instead of just jumping to the bottom, I will post when ever I get it figure out, (or someone can figure it out before me and post it.)
Reply
#10
Psst.


Look at the way the client uses the Y offset for NPCs and Players.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)