Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Adding the Sprite Tile in the Map Editor


Fbu
 Share

Recommended Posts

Largely based off what I learn from [Richy's code.](http://www.touchofdeathforums.com/smf/index.php/topic,68426.0.html) It will add an attribute that will change the player's sprite (according to what # you want) when they walk over it.

Both Client and Server:

Under modules in modConstants search for:
```
Public Const TILE_TYPE_SLIDE As Byte = 14
```

Add this under it:
```
Public Const TILE_TYPE_SPRITE As Byte = 16
```

Server Only:

Under modules in modPlayer in PlayerMove search for:
```
If .Type = TILE_TYPE_TRAP Then
            amount = .Data1
            SendActionMsg GetPlayerMap(index), "-" & amount, BrightRed, ACTIONMSG_SCROLL, GetPlayerX(index) * 32, GetPlayerY(index) * 32, 1
            If GetPlayerVital(index, HP) - amount <= 0 Then
                KillPlayer index
                PlayerMsg index, "You died.", BrightRed
            Else
                SetPlayerVital index, HP, GetPlayerVital(index, HP) - amount
                PlayerMsg index, "You were hurt.", BrightRed
                Call SendVital(index, HP)
            End If
            Moved = YES
        End If
```

Add this under it:
```
        'Checks for sprite tile
        If .Type = TILE_TYPE_SPRITE Then
            amount = .Data1
            Call SetPlayerSprite(index, amount)
            Call SendPlayerData(index)
            Moved = YES
        End If
```
–-----------------Optional-------------------

If you want to make your sprites cost money then follow these intructions.

Thanks to Alatar for [his code](http://www.touchofdeathforums.com/smf/index.php/topic,65616.0.html) which this is based off of.

Go back to this code:
```
        'Checks for sprite tile
        If .Type = TILE_TYPE_SPRITE Then
            amount = .Data1
            Call SetPlayerSprite(index, amount)
            Call SendPlayerData(index)
            Moved = YES
        End If
```
And change it to this:
```
        'Checks for sprite tile
        If .Type = TILE_TYPE_SPRITE Then
            amount = .Data1
If CheckCash(Index, x, y) = True Then 'x=itemnum of your cash y=amount you want sprites to cost
    TakeInvItem (Index, x, y) 'x=itemnum of your cash y=amount you want sprites to cost
                  Call SetPlayerSprite(index, amount)
              Call SendPlayerData(index)
Else
  Call PlayerMsg(index, "You don't have enough cash!", Yellow)
End If
        Else
            Moved = YES
        End If
```Replace x and y with the itemnum of your currency(x) and the amount of currency you want to take away(y).

Then add this to the bottom of modPlayer:
```
Function CheckCash(ByVal Index As Long, ByVal CashItemNum As Long, ByVal CashAmount As Long) As Boolean

    Dim I As Long

    For I = 1 To MAX_INV
        If GetPlayerInvItemNum(Index, I) = CashItemNum Then
            If Item(CashItemNum).Type = ITEM_TYPE_CURRENCY Then
                If CashAmount <= GetPlayerInvItemValue(Index, I) Then
                    CheckCash = True
                Else
                    CheckCash = False
                End If
            End If
        End If
    Next
End Function
```
–--------------------------------------------

Client Only:

Under modules in modGlobals search for:
```
' Used for map editor heal & trap & slide tiles
Public MapEditorHealType As Long
Public MapEditorHealAmount As Long
Public MapEditorSlideDir As Long
```

Add this underneath it:
```
Public TileSprite As Long
```

Under modules in modText in BltMapAttributes search for:
```
                            Case TILE_TYPE_SLIDE
                                DrawText TexthDC, tX, tY, "S", QBColor(BrightCyan)
```

Add this underneath it:
```
                            Case TILE_TYPE_SPRITE
                                DrawText TexthDC, tX, tY, "S", QBColor(Pink)
```

Under modules in modGameEditors in MapEditorMouseDown search for:
```
                ' slide
                If frmEditor_Map.optSlide.Value Then
                    .Type = TILE_TYPE_SLIDE
                    .Data1 = MapEditorSlideDir
                    .Data2 = 0
                    .Data3 = 0
                End If
```

Add this underneath it:
```
                'sprite
                If frmEditor_Map.optSprite.Value Then
                .Type = TILE_TYPE_SPRITE
                .Data1 = TileSprite
                .Data2 = 0
                .Data3 = 0
                End If
```
Now open up the frmEditorMap.

Create an option box in the Attributes frame. Name it optSprite and then Caption it as Sprite.
![](http://img.photobucket.com/albums/v15/BFU22/1-5.png)

Now create a frame in the picAttributes picturebox. Name this fraSprite and then caption it as Sprite. Make sure the visible is set to **false**.
Now create two labels within the frame. Name one Label3 and caption it as Sprite Number:.
Name the second label SpriteNum and then caption it as 0.
Now create a HScrollBar under the two labels. Name it HScroll2.
Finally create a CommandButton under the scroll bar. Name it cmdSprite and caption it as Okay.
![](http://img.photobucket.com/albums/v15/BFU22/2-5.png)

Double click on the HScroll2\. It should pop-up with this:
```
Private Sub HScroll2_Change()
End Sub
```
Change it to this:
```
Private Sub HScroll2_Change()
frmEditor_Map.SpriteNum = HScroll2.Value
End Sub
```
Double click your cmdSprite. It should look like this:
```
Private Sub cmdSprite_Click()
End Sub
```
Change it to this:
```
Private Sub cmdSprite_Click()
  ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    TileSprite = HScroll2.Value
    picAttributes.Visible = False
    fraSprite.Visible = False

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "cmdSprite_Click", "frmEditor_Map", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Now double click on your optSprite. It should show this:
```
Private Sub optSprite_Click()
End Sub
```
Replace it with this:
```
Private Sub optSprite_Click()
  ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    ClearAttributeDialogue
    picAttributes.Visible = True
    fraSprite.Visible = True

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "optSprite_Click", "frmEditor_Map", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Compile both the server and the client.

If all goes well you should now be able to add the sprite tile in your game. (:
Example Screenie:
![](http://img.photobucket.com/albums/v15/BFU22/3-7.png)
Link to comment
Share on other sites

no…

it changes your players sprite to the one defined in the editor xd

nice tut, I missed that feature from old eclipse, was gonna add  it myself too :)

Dami

edit, i am adding money cost to the tile, i suggest you do that too, and add it to tut.

that way players can buy the sprites :)
Link to comment
Share on other sites

@Dami:

> no…
>
> it changes your players sprite to the one defined in the editor xd
>
> nice tut, I missed that feature from old eclipse, was gonna add  it myself too :)
>
> Dami
>
> edit, I am adding money cost to the tile, I suggest you do that too, and add it to tut.
>
> that way players can buy the sprites :)

Orite! Thanks for releasing this then, Fbu <3.
Link to comment
Share on other sites

@Dami:

> I am adding money cost to the tile, I suggest you do that too, and add it to tut.
>
> that way players can buy the sprites :)

Great idea! I don't need it for my game but I can see a lot of people wanting it.

Thanks to Alatar for [his code](http://www.touchofdeathforums.com/smf/index.php/topic,65616.0.html) which this is based off of.

To add price to sprites go back here:
```
        'Checks for sprite tile
        If .Type = TILE_TYPE_SPRITE Then
            amount = .Data1
            Call SetPlayerSprite(index, amount)
            Call SendPlayerData(index)
            Moved = YES
        End If
```
And change it to this:
```
        'Checks for sprite tile
        If .Type = TILE_TYPE_SPRITE Then
            amount = .Data1
If CheckCash(Index, x, y) = True Then 'x=itemnum of your cash y=amount you want sprites to cost
    TakeInvItem (Index, x, y) 'x=itemnum of your cash y=amount you want sprites to cost
                  Call SetPlayerSprite(index, amount)
              Call SendPlayerData(index)
Else
  Call PlayerMsg(index, "You don't have enough cash!", Yellow)
End If
        Else
            Moved = YES
        End If
```
Then add this to the bottom of modPlayer:
```
Function CheckCash(ByVal Index As Long, ByVal CashItemNum As Long, ByVal CashAmount As Long) As Boolean

    Dim i As Long

    For i = 1 To MAX_INV
        If GetPlayerInvItemNum(Index, i) = CashItemNum Then
            If Item(CashItemNum).Type = ITEM_TYPE_CURRENCY Then
                If CashAmount <= GetPlayerInvItemValue(Index, i) Then
                    CheckCash = True
                Else
                    CheckCash = False
                End If
            End If
        End If
    Next
End Function
```
Link to comment
Share on other sites

  • 3 weeks later...
It's supposed to be either:
```
TakeInvItem Index,x,y
```or
```
Call TakeInvItem(Index,x,y)
```
That's what's causing your issue, without the call command but with brackets VB6 assumes it's a function that should return a value, hence asking for the = symbol. The above methods will solve this issue.
Link to comment
Share on other sites

Ah, no it doesn't work like that. You need to REPLACE the X and Y inside the brackets with your numbers, not place it after the command, so it should be like:
```
Call TakeInvItem(Index, 1, 2000) ' 1 is your currency(X), and 2000 is the amount taken.(Y)
```
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 1 month later...
I have a problem, I use the E.O Modification(S) (by Ritchi), and I take the  code with the option: paying sprite ( the part optional ) but an error :s
When I clic on

[![](http://s3.noelshack.com/uploads/images/16679027850408_spritenudem.png)](http://s3.noelshack.com/upload/16679027850408_spritenudem.png)

The error :

[![](http://s3.noelshack.com/uploads/images/20681040759093_spritenum.png)](http://s3.noelshack.com/upload/20681040759093_spritenum.png)

The fraSprite not appear..  :huh:
Link to comment
Share on other sites

hmm, this one works for me…
and it worked for you to compile? cuz i used Modification(S) and it was bugged so i wasnt able to source edit it

btw, does any1 know how to fix mine error?
as i said, everything works, until i step on that tile, appears runtime error 9, subscript out of range :(
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...