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

Player-Housing –- Trying to re-implement it


Admiral Refuge
 Share

Recommended Posts

**Well, I got that problem out of the way, but new one arises: http://www.touchofdeathforums.com/smf/index.php/topic,48806.msg504348.html#msg504348**

Okay, I was trying to target the issue in the playerhousing system.

So far, it is able to detect when the player steps on a house tile (the map type needs to be type "house", of course); if the house requires money, it successfully sends to the client propmting the user if he wants to buy the house.  If the user hits "yes", it successfully goes back to the server and activates the following sub:
```
Public Sub Packet_BuyHouse(ByVal index As Long)
Call PlayerMsg(index, "HI!", RED)
    Dim I As Long
    Dim MapNum As Long

    MapNum = GetPlayerMap(index)

    If Map(MapNum).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_HOUSE Then
        Call PlayerMsg(index, "You need to be on a house tile to buy it!", BRIGHTRED)
        Exit Sub
    End If

    If GetVar("Data.ini", "Config", "OneHouseOnly") = 1 Then
        If GetVar("Scripts\Housing.ini", "OWNERS", "" & GetPlayerName(index) & "") = "1" Then
            Call PlayerMsg(index, "You already own a house, you can not buy another until you sell the one you have first.", BRIGHTRED)
            Exit Sub
        End If
    End If

    If Map(MapNum).Tile(GetPlayerX(index), GetPlayerY(index)).Data1 = 0 Then
        Map(MapNum).Owner = GetPlayerName(index)
        Map(MapNum).Name = GetPlayerName(index) & "'s House"
        Map(MapNum).Revision = Map(MapNum).Revision + 1
        Call SaveMap(MapNum)
        Call PutVar("Scripts\Housing.ini", "OWNERS", "" & GetPlayerName(index) & "", 1)
        Call MapCache_Create(MapNum)
        Call SendDataToMap(MapNum, "CHECKFORMAP" & SEP_CHAR & MapNum & SEP_CHAR & (Map(MapNum).Revision + 1) & END_CHAR)
        Call PlayerMsg(index, "You now own this house!", BRIGHTGREEN)

        Exit Sub
    End If

    For I = 1 To MAX_INV
        If GetPlayerInvItemNum(index, I) = Map(MapNum).Tile(GetPlayerX(index), GetPlayerY(index)).Data1 Then
            If Item(GetPlayerInvItemNum(index, I)).Type = ITEM_TYPE_CURRENCY Then
                If GetPlayerInvItemValue(index, I) >= Map(MapNum).Tile(GetPlayerX(index), GetPlayerY(index)).Data2 Then
                    Call SetPlayerInvItemValue(index, I, GetPlayerInvItemValue(index, I) - Map(MapNum).Tile(GetPlayerX(index), GetPlayerY(index)).Data2)

                    If GetPlayerInvItemValue(index, I) = 0 Then
                        Call SetPlayerInvItemNum(index, I, 0)
                    End If

                    Map(MapNum).Owner = GetPlayerName(index)
                    Map(MapNum).Name = GetPlayerName(index) & "'s House"
                    Map(MapNum).Revision = Map(GetPlayerMap(index)).Revision + 1
                    Call SaveMap(MapNum)
                    Call SendInventory(index)
                    Call PlayerMsg(index, "You have bought a new house!", BRIGHTGREEN)
                    Call PutVar("Scripts\Housing.ini", "OWNERS", "" & GetPlayerName(index) & "", 1)
                Call MapCache_Create(MapNum)
                Call SendDataToMap(MapNum, "CHECKFORMAP" & SEP_CHAR & MapNum & SEP_CHAR & (Map(MapNum).Revision + 1) & END_CHAR)
                End If
            Else
                If GetPlayerWeaponSlot(index) <> I And GetPlayerArmorSlot(index) <> I And GetPlayerShieldSlot(index) <> I And GetPlayerHelmetSlot(index) <> I And GetPlayerLegsSlot(index) <> I And GetPlayerRingSlot(index) <> I And GetPlayerNecklaceSlot(index) <> I Then
                    Call SetPlayerInvItemNum(index, I, 0)

                    Map(MapNum).Owner = GetPlayerName(index)
                    Map(MapNum).Name = GetPlayerName(index) & "'s House"
                    Map(MapNum).Revision = Map(MapNum).Revision + 1

                    Call SaveMap(MapNum)
                    Call SendInventory(index)
                    Call PlayerMsg(index, "You now own a new house!", BRIGHTGREEN)
                    Call PutVar("Scripts\Housing.ini", "OWNERS", "" & GetPlayerName(index) & "", 1)
                Call MapCache_Create(MapNum)
                Call SendDataToMap(MapNum, "CHECKFORMAP" & SEP_CHAR & MapNum & SEP_CHAR & (Map(MapNum).Revision + 1) & END_CHAR)
                End If
            End If

            If GetPlayerWeaponSlot(index) <> I And GetPlayerArmorSlot(index) <> I And GetPlayerShieldSlot(index) <> I And GetPlayerHelmetSlot(index) <> I And GetPlayerLegsSlot(index) <> I And GetPlayerRingSlot(index) <> I And GetPlayerNecklaceSlot(index) <> I Then
                Exit Sub
            End If
        End If
    Next I

    Call PlayerMsg(index, "You don't have enough to buy this house!", BRIGHTRED)
End Sub

```I put the "Call PlayerMsg" there (debugging reasons), and yes, it does display "HI" like it's suppose to, but after that, nothing else happens.  Is anything wrong with this sub, or?
Link to comment
Share on other sites

@ᴆᴎᴧ:

> Admiral, I thought you were a mighty epic scripter!

I am a good scripter (sadscript aka vbscirpt).
On the other hand, I'm not proficient in Visual Basic, though I can recognize the syntax (to an extent) I cannot solve all the problems I come by, hence this topic.
Link to comment
Share on other sites

This my friend is what breakpoints are for.

Click upon the "gutter" (the blank column before the code near the line numbers) to place a breakpoint. When execution of the code reaches that line it will "pause" allowing you to examine the running state to see if anything is wrong.

While "paused", highlighting any expression or hovering your mouse over any variable will show what it evaluates too. Use this to find out exactly what is going wrong.

(I would do it myself but it's mighty late)
Link to comment
Share on other sites

Yea, I know what's wrong…. The house system works perfect now (should have seen it earlier!).

GetVar returns a string, and this line won't work (also, I think it's case sensitive):
```
If GetVar("Data.ini", "Config", "OneHouseOnly") = 1 Then
```It should have been:
```
If GetVar("Data.ini", "CONFIG", "OneHouseOnly") = "1" Then
```

Now, if only I could get the house editor to work; I may be able to figure it out now.

**EDIT: Okay, something doesn't seem right (may just be me).**

When you invoke the house editor, it runs this code:
```
        Case "requestedithouse"
            If GetVar("Data.ini", "CONFIG", "PresetHousing") = 0 Then
                Call Packet_RequestEditHouse(index)
                Exit Sub
            End If

```Which in-turn, runs this code:
```
Public Sub Packet_RequestEditHouse(ByVal index As Long)
    If Map(GetPlayerMap(index)).Moral <> MAP_MORAL_HOUSE Then
        Call PlayerMsg(index, "This is not a house!", BRIGHTRED)
        Exit Sub
    End If

    If Map(GetPlayerMap(index)).Owner <> GetPlayerName(index) Then
        Call PlayerMsg(index, "This is not your house!", BRIGHTRED)
        Exit Sub
    End If

    Call SendDataTo(index, "EDITHOUSE" & END_CHAR)
End Sub

```With a result of running this (in the client):
```
Sub SendRequestEditHouse()
    Call SendData("requestedithouse" & END_CHAR)
End Sub

```Could you guess where that's going to go?

Is there EVEN a house editor in EE2.7/2.8?
Link to comment
Share on other sites

@Umbra!:

> One way to tell.
> Is there a frmHouseEditor?
>
> If there isn't, then someone tried to remove playerhousing and never finished.

Yea, I just got done looking for evidence of the house editor (with no luck), and came to the conclusion that a developer somewhere down the road must have killed the house editor, then just looped the commands into themselves as an easy fix ><
Link to comment
Share on other sites

Nope, it doesn't loop into itself.

It works just like the mapeditor.
It sends "requestedithouse" from client->server when you type /houseeditor
The server gets the "requestedithouse" packet and checks if you can edit the house.
If you can, it sends "edithouse" to the client, where the client is suppose to load frmHouseEditor and load the tileset into the editor etc.

Buut, someone removed the "edithouse" packet client side, and the house editor. Probably whoever re-designed the mapeditor as the houseeditor is just a slightly changed copy of it.

Meh, I'll look into it tommorow. Right now it's mighty late.
Link to comment
Share on other sites

@Umbra!:

> Nope, it doesn't loop into itself.
>
> It works just like the mapeditor.
> It sends "requestedithouse" from client->server when you type /houseeditor
> The server gets the "requestedithouse" packet and checks if you can edit the house.
> If you can, it sends "edithouse" to the client, where the client is suppose to load frmHouseEditor and load the tileset into the editor etc.
>
> Buut, someone removed the "edithouse" packet client side, and the house editor. Probably whoever re-designed the mapeditor as the houseeditor is just a slightly changed copy of it.
>
> Meh, I'll look into it tommorow. Right now it's mighty late.

Well, I tried adding it, but I had no idea what I was doing; I'll explain what I did (of course, it didn't work; ran into afew problems, maybe you can figure it out).

I added to modHandleData:

```
    ' :::::::::::::::::::::::::::::::::::::::
    ' ::          House Editor            ::
    ' :::::::::::::::::::::::::::::::::::::::

    If casestring = "edithouse" Then
        Call HouseEditorInit
        Exit Sub
    End If
```

To modGameLogic:

```
Public Sub HouseEditorInit()
    Dim i As Long

    InHouseEditor = True
    frmAttributes.Show vbModeless, frmMirage
    frmHouseEditor.Show vbModeless, frmMirage
    EditorSet = 0

    For i = 0 To 6
        If frmHouseEditor.mnuSet(i).Checked = True Then
            frmHouseEditor.picBackSelect.Picture = LoadPicture(App.Path & "\GFX\Tiles" & i & ".bmp")
            EditorSet = i
        End If
    Next i

    frmHouseEditor.scrlPicture.Max = Int((frmHouseEditor.picBackSelect.Height - frmHouseEditor.picBack.Height) / PIC_Y)
    frmHouseEditor.picBack.Width = frmHouseEditor.picBackSelect.Width
End Sub

Public Sub HouseEditorCancel()
    InHouseEditor = False
    frmHouseEditor.Visible = False
    frmAttributes.Visible = False
    frmMirage.Show
    frmHouseEditor.MousePointer = 1
    frmMirage.MousePointer = 1
    LoadMap (GetPlayerMap(MyIndex))
    'frmMirage.picMapEditor.Visible = False
End Sub

Public Sub HouseEditorChooseTile(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        EditorTileX = Int(X / PIC_X)
        EditorTileY = Int(Y / PIC_Y)
    End If
    frmHouseEditor.shpSelected.Top = Int(EditorTileY * PIC_Y)
    frmHouseEditor.shpSelected.Left = Int(EditorTileX * PIC_Y)
    'Call BitBlt(frmMapEditor.picSelect.hDC, 0, 0, PIC_X, PIC_Y, frmMapEditor.picBackSelect.hDC, EditorTileX * PIC_X, EditorTileY * PIC_Y, SRCCOPY)
End Sub

Public Sub HouseEditorTileScroll()
    frmHouseEditor.picBackSelect.Top = (frmHouseEditor.scrlPicture.Value * PIC_Y) * -1
End Sub

Public Sub HouseEditorSend()
    Call SendMap
    Call HouseEditorCancel
End Sub

Public Sub HouseEditorMouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim x1, y1 As Long
Dim x2 As Long, y2 As Long, PicX As Long

    If InHouseEditor Then
        x1 = Int(X / PIC_X)
        y1 = Int(Y / PIC_Y)

        If frmHouseEditor.MousePointer = 2 Then
            If frmHouseEditor.mnuType(1).Checked = True Then
                With Map(GetPlayerMap(MyIndex)).Tile(x1, y1)
                    If frmAttributes.optGround.Value = True Then
                        PicX = .Ground
                        EditorSet = .GroundSet
                    End If
                    If frmAttributes.optMask.Value = True Then
                        PicX = .Mask
                        EditorSet = .MaskSet
                    End If
                    If frmAttributes.optAnim.Value = True Then
                        PicX = .Anim
                        EditorSet = .AnimSet
                    End If
                    If frmAttributes.optMask2.Value = True Then
                        PicX = .Mask2
                        EditorSet = .Mask2Set
                    End If
                    If frmAttributes.optM2Anim.Value = True Then
                        PicX = .M2Anim
                        EditorSet = .M2AnimSet
                    End If
                    If frmAttributes.optFringe.Value = True Then
                        PicX = .Fringe
                        EditorSet = .FringeSet
                    End If
                    If frmAttributes.optFAnim.Value = True Then
                        PicX = .FAnim
                        EditorSet = .FAnimSet
                    End If
                    If frmAttributes.optFringe2.Value = True Then
                        PicX = .Fringe2
                        EditorSet = .Fringe2Set
                    End If
                    If frmAttributes.optF2Anim.Value = True Then
                        PicX = .F2Anim
                        EditorSet = .F2AnimSet
                    End If

                    EditorTileY = Int(PicX / TilesInSheets)
                    EditorTileX = (PicX - Int(PicX / TilesInSheets) * TilesInSheets)
                    frmHouseEditor.shpSelected.Top = Int(EditorTileY * PIC_Y)
                    frmHouseEditor.shpSelected.Left = Int(EditorTileX * PIC_Y)
                    frmHouseEditor.shpSelected.Height = PIC_Y
                    frmHouseEditor.shpSelected.Width = PIC_X
                End With
            End If
            frmHouseEditor.MousePointer = 1
            frmMirage.MousePointer = 1
        Else
            If (Button = 1) And (x1 >= 0) And (x1 <= MAX_MAPX) And (y1 >= 0) And (y1 <= MAX_MAPY) Then
                If frmHouseEditor.shpSelected.Height <= PIC_Y And frmMapEditor.shpSelected.Width <= PIC_X Then
                    If frmHouseEditor.mnuType(1).Checked = True Then
                        With Map(GetPlayerMap(MyIndex)).Tile(x1, y1)
                            If frmAttributes.optGround.Value = True Then
                                .Ground = EditorTileY * TilesInSheets + EditorTileX
                                .GroundSet = EditorSet
                            End If
                            If frmAttributes.optMask.Value = True Then
                                .Mask = EditorTileY * TilesInSheets + EditorTileX
                                .MaskSet = EditorSet
                            End If
                            If frmAttributes.optAnim.Value = True Then
                                .Anim = EditorTileY * TilesInSheets + EditorTileX
                                .AnimSet = EditorSet
                            End If
                            If frmAttributes.optMask2.Value = True Then
                                .Mask2 = EditorTileY * TilesInSheets + EditorTileX
                                .Mask2Set = EditorSet
                            End If
                            If frmAttributes.optM2Anim.Value = True Then
                                .M2Anim = EditorTileY * TilesInSheets + EditorTileX
                                .M2AnimSet = EditorSet
                            End If
                            If frmAttributes.optFringe.Value = True Then
                                .Fringe = EditorTileY * TilesInSheets + EditorTileX
                                .FringeSet = EditorSet
                            End If
                            If frmAttributes.optFAnim.Value = True Then
                                .FAnim = EditorTileY * TilesInSheets + EditorTileX
                                .FAnimSet = EditorSet
                            End If
                            If frmAttributes.optFringe2.Value = True Then
                                .Fringe2 = EditorTileY * TilesInSheets + EditorTileX
                                .Fringe2Set = EditorSet
                            End If
                            If frmAttributes.optF2Anim.Value = True Then
                                .F2Anim = EditorTileY * TilesInSheets + EditorTileX
                                .F2AnimSet = EditorSet
                            End If
                        End With
                  ElseIf frmHouseEditor.mnuType(2).Checked = True Then
                        With Map(GetPlayerMap(MyIndex)).Tile(x1, y1)
                            If .Type = TILE_TYPE_WALKABLE Then
                                If frmAttributes.optBlocked.Value = True Then .Type = TILE_TYPE_BLOCKED
                            End If
                        End With
                    End If
                Else
                    For y2 = 0 To Int(frmHouseEditor.shpSelected.Height / PIC_Y) - 1
                        For x2 = 0 To Int(frmHouseEditor.shpSelected.Width / PIC_X) - 1
                            If x1 + x2 <= MAX_MAPX Then
                                If y1 + y2 <= MAX_MAPY Then
                                    If frmHouseEditor.mnuType(1).Checked = True Then
                                        With Map(GetPlayerMap(MyIndex)).Tile(x1 + x2, y1 + y2)
                                            If frmAttributes.optGround.Value = True Then
                                                .Ground = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .GroundSet = EditorSet
                                            End If
                                            If frmAttributes.optMask.Value = True Then
                                                .Mask = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .MaskSet = EditorSet
                                            End If
                                            If frmAttributes.optAnim.Value = True Then
                                                .Anim = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .AnimSet = EditorSet
                                            End If
                                            If frmAttributes.optMask2.Value = True Then
                                                .Mask2 = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .Mask2Set = EditorSet
                                            End If
                                            If frmAttributes.optM2Anim.Value = True Then
                                                .M2Anim = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .M2AnimSet = EditorSet
                                            End If
                                            If frmAttributes.optFringe.Value = True Then
                                                .Fringe = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .FringeSet = EditorSet
                                            End If
                                            If frmAttributes.optFAnim.Value = True Then
                                                .FAnim = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .FAnimSet = EditorSet
                                            End If
                                            If frmAttributes.optFringe2.Value = True Then
                                                .Fringe2 = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .Fringe2Set = EditorSet
                                            End If
                                            If frmAttributes.optF2Anim.Value = True Then
                                                .F2Anim = (EditorTileY + y2) * TilesInSheets + (EditorTileX + x2)
                                                .F2AnimSet = EditorSet
                                            End If
                                        End With
                                    End If
                                End If
                            End If
                        Next x2
                    Next y2
                End If
            End If

            If (Button = 2) And (x1 >= 0) And (x1 <= MAX_MAPX) And (y1 >= 0) And (y1 <= MAX_MAPY) Then
                If frmHouseEditor.mnuType(1).Checked = True Then
                    With Map(GetPlayerMap(MyIndex)).Tile(x1, y1)
                        If frmAttributes.optGround.Value = True Then .Ground = 0
                        If frmAttributes.optMask.Value = True Then .Mask = 0
                        If frmAttributes.optAnim.Value = True Then .Anim = 0
                        If frmAttributes.optMask2.Value = True Then .Mask2 = 0
                        If frmAttributes.optM2Anim.Value = True Then .M2Anim = 0
                        If frmAttributes.optFringe.Value = True Then .Fringe = 0
                        If frmAttributes.optFAnim.Value = True Then .FAnim = 0
                        If frmAttributes.optFringe2.Value = True Then .Fringe2 = 0
                        If frmAttributes.optF2Anim.Value = True Then .F2Anim = 0
                    End With
                ElseIf frmHouseEditor.mnuType(2).Checked = True Then
                    With Map(GetPlayerMap(MyIndex)).Tile(x1, y1)
                    If .Type = TILE_TYPE_BLOCKED Then
                        .Type = 0
                        .Data1 = 0
                        .Data2 = 0
                        .Data3 = 0
                        .String1 = ""
                        .String2 = ""
                        .String3 = ""
                    End If
                    End With
                End If
            End If
        End If
    End If
End Sub
```
Added TE's frmAttributes
Added TE's frmHouseEditor

Added to picScreen_MouseDown,
```
    If (Button = 1 Or Button = 2) And InHouseEditor = True Then
        Call HouseEditorMouseDown(Button, Shift, (X + (NewPlayerX * PIC_X)), (Y + (NewPlayerY * PIC_Y)))
    End If
```
Added to picScreen_MouseMove,
```
    If (Button = 1 Or Button = 2) And InHouseEditor = True Then
        Call HouseEditorMouseDown(Button, Shift, (X + (NewPlayerX * PIC_X)), (Y + (NewPlayerY * PIC_Y)))
    End If

    frmHouseEditor.Caption = "House Editor - " & "X: " & Int((X + (NewPlayerX * PIC_X)) / 32) & " Y: " & Int((Y + (NewPlayerY * PIC_Y)) / 32)
```
Added under "Public InEditor As Boolean":
```
Public InHouseEditor As Boolean
```
Then, of course, I got errors.

It's 3am, I'm off to bed :icon_crap:
Link to comment
Share on other sites

  • 2 weeks later...
Is there a way to duplicate the frmMapEditor and edit out some of the things to make it a House Editor? Such as removing NPC's, making it always indoor, remove map warping and warp attributes, etc? That would solve the frmHouseEditor problem we have.
Link to comment
Share on other sites

@[SB:

> [Squi] Squiddle link=topic=48806.msg511285#msg511285 date=1249155470]
> Is there a way to duplicate the frmMapEditor and edit out some of the things to make it a House Editor? Such as removing NPC's, making it always indoor, remove map warping and warp attributes, etc? That would solve the frmHouseEditor problem we have.

That's EXACTLY how it was made in the first place.
Link to comment
Share on other sites

@Umbra!:

> Nope, it doesn't loop into itself.
>
> It works just like the mapeditor.
> It sends "requestedithouse" from client->server when you type /houseeditor
> The server gets the "requestedithouse" packet and checks if you can edit the house.
> If you can, it sends "edithouse" to the client, where the client is suppose to load frmHouseEditor and load the tileset into the editor etc.
>
> Buut, someone removed the "edithouse" packet client side, and the house editor. Probably whoever re-designed the mapeditor as the houseeditor is just a slightly changed copy of it.
>
> Meh, I'll look into it tommorow. Right now it's mighty late.

so this may be a long shot but here goes… if you did a copy on the mapediter form and edited it slightly to look like a house editor and have it load up a 'furniture' tile set with player only having the mask or mask 2 or woteva then sort the packet thing out then this may work?
Link to comment
Share on other sites

  • 4 weeks later...
Can it be made so that a player only has a certain tile set they can use instead of all of them?
Like if I made tiles8.bmp nothing but furnishings and stuff.
Link to comment
Share on other sites

you dont really need this if you source edit, i mean you could jsut make special items, i'm already starting it with kryce, make a seconds tile type in the maprec stuff, then just make it so it sets that as furniture with the players name stored in its data, that way you can make it blt furniture etc and if they stand on it and hit enter they pick it up. or you could make tiles that reprint over the maps current ground floor etc then save the map and send it.
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...