Print Page | Close Window

Level Requirement For Warp

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=233
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Level Requirement For Warp
Posted By: Sync
Subject: Level Requirement For Warp
Date Posted: 11 February 2006 at 3:42pm
Difficulty: Medium 3/5

Originaly Posted By: Jobs

not sure who made this one, but props to them, anyway:
What this does is adds a minimum level option to warps. Say you have a nice dungeon that you don't want noobs going into. With this you can make it only allow for example level 5+.
Can be reversed and make a maximum level also.
I recommend backing up your client and server before you do this. It is easy to press the wrong button and it can be a big pain to fix.
CLIENT
:::::modGameLogic:::::
Find this
Public InEditor As Boolean
Public EditorTileX As Long
Public EditorTileY As Long
Public EditorWarpMap As Long
Public EditorWarpX As Long
Public EditorWarpY As Long
Add this under it
Public EditorWarpLvl As Long


Search for
If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Type = TILE_TYPE_WARP Then
Add this under it:
If Map.Tile(GetPlayerX(MyIndex), GetPlayerY(MyIndex)).Data4 >= GetPlayerLevel(MyIndex) Then: Exit Sub

In sub EditorMouseDown find this
With Map.Tile(x1, y1)
If frmMirage.optBlocked.Value = True Then .Type = TILE_TYPE_BLOCKED
If frmMirage.optWarp.Value = True Then
.Type = TILE_TYPE_WARP
.Data1 = EditorWarpMap
.Data2 = EditorWarpX
.Data3 = EditorWarpY

Add this under it:
.Data4 = EditorWarpLvl
Find this in same sub, at the bottom
With Map.Tile(x1, y1)
.Type = 0
.Data1 = 0
.Data2 = 0
.Data3 = 0
Add this under it:
.Data4 = 0


:::::modClientTCP:::::
Find this in sub HandleData

For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
SaveMap.Tile(x, y).Ground = Val(Parse(n))
SaveMap.Tile(x, y).Mask = Val(Parse(n + 1))
SaveMap.Tile(x, y).Anim = Val(Parse(n + 2))
SaveMap.Tile(x, y).Fringe = Val(Parse(n + 3))
SaveMap.Tile(x, y).Type = Val(Parse(n + 4))
SaveMap.Tile(x, y).Data1 = Val(Parse(n + 5))
SaveMap.Tile(x, y).Data2 = Val(Parse(n + 6))
SaveMap.Tile(x, y).Data3 = Val(Parse(n + 7))

n = n + 8
Next x
Next y

Replace with this

For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
SaveMap.Tile(x, y).Ground = Val(Parse(n))
SaveMap.Tile(x, y).Mask = Val(Parse(n + 1))
SaveMap.Tile(x, y).Anim = Val(Parse(n + 2))
SaveMap.Tile(x, y).Fringe = Val(Parse(n + 3))
SaveMap.Tile(x, y).Type = Val(Parse(n + 4))
SaveMap.Tile(x, y).Data1 = Val(Parse(n + 5))
SaveMap.Tile(x, y).Data2 = Val(Parse(n + 6))
SaveMap.Tile(x, y).Data3 = Val(Parse(n + 7))
SaveMap.Tile(x, y).Data4 = Val(Parse(n + 8))

n = n + 9
Next x
Next y

Find this in sub SendMap
Packet = Packet & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR
Replace with this
Packet = Packet & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR & .Data4 & SEP_CHAR

:::::modTypes:::::

In modTypes find
Type TileRec
Ground As Integer
Mask As Integer
Anim As Integer
Fringe As Integer
Type As Byte
Data1 As Integer
Data2 As Integer
Data3 As Integer
Add this under it but before End Type
Data4 As Long
Find this in sub ClearMap
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Map.Tile(x, y).Ground = 0
Map.Tile(x, y).Mask = 0
Map.Tile(x, y).Anim = 0
Map.Tile(x, y).Fringe = 0
Map.Tile(x, y).Type = 0
Map.Tile(x, y).Data1 = 0
Map.Tile(x, y).Data2 = 0
Map.Tile(x, y).Data3 = 0
Add this under it:
Map.Tile(x, y).Data4 = 0

:::::frmMapWarp:::::

In frmMapWarp add a label and a textbox
Name the Textbox txtMinLVL and the label whatever
Put the label's caption as Lvl Req or whatever you want.

In subcmdOk_Click find this
EditorWarpMap = Val(txtMap.Text)
EditorWarpX = scrlX.Value
EditorWarpY = scrlY.Value
Add this under that but above Unload Me
EditorWarpLvl = Val(txtMinLVL.Text)

Thats it! Your done with the client, now server.

SERVER

:::::modDatabase:::::
Find this in ConvertOldMapsToNew
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
NewMap.Tile(x, y).Ground = OldMap.Tile(x, y).Ground
NewMap.Tile(x, y).Mask = OldMap.Tile(x, y).Mask
NewMap.Tile(x, y).Anim = OldMap.Tile(x, y).Anim
NewMap.Tile(x, y).Fringe = OldMap.Tile(x, y).Fringe
NewMap.Tile(x, y).Type = OldMap.Tile(x, y).Type
NewMap.Tile(x, y).Data1 = OldMap.Tile(x, y).Data1
NewMap.Tile(x, y).Data2 = OldMap.Tile(x, y).Data2
NewMap.Tile(x, y).Data3 = OldMap.Tile(x, y).Data3
Add this under it but before Next x
NewMap.Tile(x, y).Data4 = OldMap.Tile(x, y).Data4

:::::modTypes:::::
Find this
Type TileRec
Ground As Integer
Mask As Integer
Anim As Integer
Fringe As Integer
Type As Byte
Data1 As Integer
Data2 As Integer
Data3 As Integer
Add this under that but before End Type
Data4 As Long

In sub ClearMap find this
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Map(MapNum).Tile(x, y).Ground = 0
Map(MapNum).Tile(x, y).Mask = 0
Map(MapNum).Tile(x, y).Anim = 0
Map(MapNum).Tile(x, y).Fringe = 0
Map(MapNum).Tile(x, y).Type = 0
Map(MapNum).Tile(x, y).Data1 = 0
Map(MapNum).Tile(x, y).Data2 = 0
Map(MapNum).Tile(x, y).Data3 = 0
put this under thatbut above Next x
Map(MapNum).Tile(x, y).Data4 = 0

:::::modGameLogic:::::
Find this
If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_WARP Then
MapNum = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1
x = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data2
y = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data3

Call PlayerWarp(Index, MapNum, x, y)
Moved = YES
End If
Replace that with this:

If Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Type = TILE_TYPE_WARP Then
MapNum = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data1
x = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data2
y = Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data3
If GetPlayerLevel(Index) >= Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data4 Then

Call PlayerWarp(Index, MapNum, x, y)
Moved = YES
Else
Call PlayerMsg(Index, "You must be at least level " & Map(GetPlayerMap(Index)).Tile(GetPlayerX(Index), GetPlayerY(Index)).Data4 & ".", Red)
End If
End If

:::::modServerTCP:::::
FInd this in HandleData
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Map(MapNum).Tile(x, y).Ground = Val(Parse(n))
Map(MapNum).Tile(x, y).Mask = Val(Parse(n + 1))
Map(MapNum).Tile(x, y).Anim = Val(Parse(n + 2))
Map(MapNum).Tile(x, y).Fringe = Val(Parse(n + 3))
Map(MapNum).Tile(x, y).Type = Val(Parse(n + 4))
Map(MapNum).Tile(x, y).Data1 = Val(Parse(n + 5))
Map(MapNum).Tile(x, y).Data2 = Val(Parse(n + 6))
Map(MapNum).Tile(x, y).Data3 = Val(Parse(n + 7))

n = n + 8
Next x
Next y
Replace with this:
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Map(MapNum).Tile(x, y).Ground = Val(Parse(n))
Map(MapNum).Tile(x, y).Mask = Val(Parse(n + 1))
Map(MapNum).Tile(x, y).Anim = Val(Parse(n + 2))
Map(MapNum).Tile(x, y).Fringe = Val(Parse(n + 3))
Map(MapNum).Tile(x, y).Type = Val(Parse(n + 4))
Map(MapNum).Tile(x, y).Data1 = Val(Parse(n + 5))
Map(MapNum).Tile(x, y).Data2 = Val(Parse(n + 6))
Map(MapNum).Tile(x, y).Data3 = Val(Parse(n + 7))
Map(MapNum).Tile(x, y).Data4 = Val(Parse(n + 8))

n = n + 9
Next x
Next y
Find this in SendMap
Packet = Packet & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR
Replace with this
Packet = Packet & .Ground & SEP_CHAR & .Mask & SEP_CHAR & .Anim & SEP_CHAR & .Fringe & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR & .Data4 & SEP_CHAR
Thats it! I tested it and it worked.
There is probably not the best way to do it because I kind of rushed ready to finish, but it works. Comments and constructive criticism are welcome.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info