tslusny Posted June 3, 2012 Author Share Posted June 3, 2012 Ok i fixed Alatars House System, i finnaly added tutorial ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)Default key for open house editor is: DELETEDefault key for house teleport is: HOMEDownload this: [Download from Mediafire](http://www.mediafire.com/?530ip9wrd91ucpe)TUTORIALSERVER SIDEmodConstantsFind:```Public Const MAP_MORAL_SAFE As Byte = 1```Add:```Public Const MAP_MORAL_HOUSE As Byte = 2```Find:```Public Const TILE_TYPE_SLIDE As Byte = 14```Add:```Public Const TILE_TYPE_SIGN As Byte = 15Public Const TILE_TYPE_THRESHOLD As Byte = 16```Find:```Public Const NPC_BEHAVIOUR_GUARD As Byte = 4```Add:```Public Const NPC_BEHAVIOUR_MANAGER As Byte = 5 ```modDatabaseFind:```Player(Index).Vital(Vitals.MP) = GetPlayerMaxVital(Index, Vitals.MP)```Add:```PutVar App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(Index).Name, 0```modGameLogicFind:```If IsSpell Then```Replace with:``` If IsSpell ThenIf Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER ThenCanAttackNpc = TrueExit FunctionEnd IfEnd If```Find:``` Case DIR_RIGHTNpcX = MapNpc(MapNum).Npc(MapNpcNum).x - 1NpcY = MapNpc(MapNum).Npc(MapNpcNum).yEnd Select```Below, replace the if sentence with this:```If NpcX = GetPlayerX(Attacker) ThenIf NpcY = GetPlayerY(Attacker) ThenIf Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_FRIENDLY And Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then 'House EditorCanPlayerAttackNpc = TrueElse'House EditorIf Npc(NpcNum).Behaviour = NPC_BEHAVIOUR_MANAGER ThenCall SendInitManager(Attacker, CInt(GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(Attacker).Name)), Npc(NpcNum).HMapNum, Npc(NpcNum).HBuy, Npc(NpcNum).HSell)End If'/House EditorIf Len(Trim$(Npc(NpcNum).AttackSay)) > 0 ThenPlayerMsg Attacker, Trim$(Npc(NpcNum).Name) & ": " & Trim$(Npc(NpcNum).AttackSay), WhiteEnd IfEnd IfEnd IfEnd If```modHandleDataAt bottom of Sub InitMessages add:```HandleDataSub(CRequestEditHouse) = GetAddress(AddressOf HandleRequestEditHouse)HandleDataSub(CHouseManager) = GetAddress(AddressOf HandleHouseManager)HandleDataSub(CCheckGold) = GetAddress(AddressOf HandleCheckGold)HandleDataSub(CWarpToHouse) = GetAddress(AddressOf HandleWarpToHouse)```In Sub HandleWarpMeTo find:```If GetPlayerAccess(Index) < ADMIN_MAPPER ThenExit SubEnd If```Replace it with this:```'[House Editor]If Not GetOwner(Index) = True ThenIf GetPlayerAccess(Index) < ADMIN_MAPPER ThenExit SubEnd IfEnd If'[/House Editor]```Find:```Map(MapNum).Tile(x, y).DirBlock = Buffer.ReadByte```Add:``` Map(MapNum).Tile(x, y).Data4 = Buffer.ReadString 'House Editor```At botom of ModHandleData add:```'Deathbeam - Alatar House system fixSub HandleRequestEditHouse(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim Owner As LongOwner = GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(index).Name)Set Buffer = New clsBufferBuffer.WriteLong SEditHouseBuffer.WriteLong OwnerSendDataTo index, Buffer.ToArray()Set Buffer = NothingEnd SubSub HandleHouseManager(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim HType As StringDim HMapNum As LongDim HGold As LongDim i As LongDim GoldItemNum As LongSet Buffer = New clsBufferBuffer.WriteBytes Data()HType = Buffer.ReadStringHMapNum = Buffer.ReadLongHGold = Buffer.ReadLongSet Buffer = NothingGoldItemNum = 1 'This works as the HOUSE_GOLD on serverSelect Case HTypeCase "Buy"If CheckGold(index, GoldItemNum, HGold) = True ThenCall PutVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(index).Name, "" & HMapNum)Call AddHouse(HMapNum)TakeInvItem index, GoldItemNum, HGoldElseHType = "Gold"End IfCase "Sell"Call PutVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(index).Name, 0)Call DeleteHouse(HMapNum)GiveInvItem index, GoldItemNum, HGoldEnd SelectSet Buffer = New clsBufferBuffer.WriteLong SSendHouseBuffer.WriteString HTypeBuffer.WriteLong HMapNumSendDataTo index, Buffer.ToArray()Set Buffer = NothingEnd SubSub HandleCheckGold(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim GoldItemNum As LongDim GoldAmount As LongDim HCancel As LongDim i As LongSet Buffer = New clsBufferBuffer.WriteBytes Data()GoldItemNum = Buffer.ReadLongGoldAmount = Buffer.ReadLongHCancel = Buffer.ReadLongSet Buffer = NothingIf Not HCancel = 1 ThenIf CheckGold(index, GoldItemNum, GoldAmount) = True ThenTakeInvItem index, GoldItemNum, GoldAmountSet Buffer = New clsBufferBuffer.WriteLong SGoldCheckedSendDataTo index, Buffer.ToArray()Set Buffer = NothingElsePlayerMsg index, "Not enought gold", BrightRedEnd IfElseGiveInvItem index, GoldItemNum, GoldAmountEnd IfEnd SubSub HandleWarpToHouse(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim House As LongHouse = GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(index).Name)If House = 0 ThenIf GetPlayerAccess(index) < ADMIN_MAPPER ThenExit SubEnd IfElseIf House < 0 Or House > MAX_MAPS ThenExit SubEnd IfCall PlayerWarp(index, House, GetPlayerX(index), GetPlayerY(index))Call PlayerMsg(index, "You have been warped to your house.", BrightBlue)Call AddLog(GetPlayerName(index) & " warped to map #" & House & ", his/her house.", ADMIN_LOG)End Sub'Deathbeam - Alatar House system fix```ModServerTCPFind:```Buffer.WriteByte .DirBlock```Add:```Buffer.WriteString .Data4 'House Editor```At bottom of ModServerTCP add:```'Deathbeam - Alatar House system fixSub SendInitManager(ByVal index As Long, ByVal MapOwner As Long, ByVal HMapNum As Long, ByVal HBuy As Long, ByVal HSell As Long)Dim Buffer As clsBufferDim HType As StringDim HGold As LongIf MapOwner = 0 ThenIf FindHouse(HMapNum) ThenCall PlayerMsg(index, "This house is already sold", White)ElseHType = "Buy"HGold = HBuyEnd IfElseIf MapOwner = HMapNum ThenHType = "Sell"HGold = HSellElseHType = "Nothing"HGold = 0End IfEnd IfSet Buffer = New clsBufferBuffer.WriteLong SInitManagerBuffer.WriteLong HMapNumBuffer.WriteString HTypeBuffer.WriteLong HGoldSendDataTo index, Buffer.ToArray()Set Buffer = NothingEnd Sub'Deathbeam - Alatar House system fix```ModTypes:Find type TileRec and add at bottom of it:```Data4 As String 'House Editor```Find Type NpcRec and add at bottom of it:```HMapNum As LongHBuy As LongHSell As Long```Find type ResourceRec and add at bottom of it:```Spot As Byte```modServerLoopIn UpdateMapLogic, find the if cause below this:```' Check to see if its time for the npc to walk```And replace it with:```If Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_SHOPKEEPER And Npc(NpcNum).Behaviour <> NPC_BEHAVIOUR_MANAGER Then 'House Editor```modEnumerationsFind:```' Make sure SMSG_COUNT is below everything else```Add above it:```'House Editor:SEditHouseSInitManagerSSendHouseSGoldChecked```Find:```' Make sure CMSG_COUNT is below everything else```Add above it:```'House Editor:CRequestEditHouseCHouseManagerCCheckGoldCWarpToHouse```Find:```Enum MapLayer```And add above Layer_Count:```Roof 'House Editor```modPlayerFind:```If .Type = TILE_TYPE_SLIDE ThenForcePlayerMove index, MOVING_WALKING, .Data1Moved = YESEnd If```Add below it:```'House EditorIf .Type = TILE_TYPE_HOUSESIGN ThenPlayerMsg index, "[Sign Reads]: " & .Data4, YellowEnd If'/House Editor```Add at bottom of ModPlayer:```'House EditorFunction CheckGold(ByVal index As Long, ByVal GoldItemNum As Long, ByVal GoldAmount As Long) As BooleanDim i As LongFor i = 1 To MAX_INVIf GetPlayerInvItemNum(index, i) = GoldItemNum ThenIf Item(GoldItemNum).Type = ITEM_TYPE_CURRENCY ThenIf GoldAmount <= GetPlayerInvItemValue(index, i) ThenCheckGold = True 'Enought goldElseCheckGold = False 'Not enought gold ![:(](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sad.png)End IfEnd IfEnd IfNextEnd FunctionFunction GetOwner(ByVal index As Long) As BooleanGetOwner = FalseIf index > MAX_PLAYERS Then Exit FunctionIf GetVar(App.Path & "\data\accounts\houses.ini", "OPTIONS", "" & Player(index).Name) = GetPlayerMap(index) ThenGetOwner = TrueEnd IfEnd Function'/House Editor```ModDatabaseAdd this at bottom of ModDatabase:```'Deathbeam - Alatar House system fixSub DeleteHouse(ByVal HMapNum As Long)Dim f1 As LongDim f2 As LongDim s As StringCall FileCopy(App.Path & "\data\accounts\houses.txt", App.Path & "\data\accounts\housestemp.txt")' Destroy house from housesf1 = FreeFileOpen App.Path & "\data\accounts\housestemp.txt" For Input As #f1f2 = FreeFileOpen App.Path & "\data\accounts\houses.txt" For Output As #f2Do While Not EOF(f1)Input #f1, sIf s <> HMapNum ThenPrint #f2, sEnd IfLoopClose #f1Close #f2Call Kill(App.Path & "\data\accounts\housestemp.txt")End SubSub AddHouse(ByVal HMapNum As Long)Dim F As LongF = FreeFileOpen App.Path & "\data\accounts\houses.txt" For Append As #FPrint #F, HMapNumClose #FEnd SubFunction FindHouse(ByVal HMapNum As Long) As BooleanDim F As LongDim s As StringF = FreeFileOpen App.Path & "\data\accounts\houses.txt" For Input As #FDo While Not EOF(F)Input #F, sIf s = HMapNum ThenFindHouse = TrueClose #FExit FunctionEnd IfLoopClose #FEnd Function'Deathbeam - Alatar House system fix```CLIENT SIDEIn Private Sub picScreen_MouseDown find:```If InMapEditor ThenCall MapEditorMouseDown(Button, x, y, False)Else```Replace it with this:```If InMapEditor Then'[House Editor]If InHouseEditor = True ThenCall HouseEditorMouseDown(Button, X, Y, False)Exit SubEnd If '[/House Editor]Call MapEditorMouseDown(Button, X, Y, False)Else```In the sub: picScreen_MouseMove find:```If InMapEditor ThenfrmEditor_Map.shpLoc.Visible = FalseIf Button = vbLeftButton Or Button = vbRightButton ThenCall MapEditorMouseDown(Button, x, y)End IfEnd If```Replace it with this:```If InMapEditor Then'[House Editor]If InHouseEditor = True ThenfrmEditor_House.shpLoc.visible = FalseIf Button = vbLeftButton Or Button = vbRightButton ThenCall HouseEditorMouseDown(Button, X, Y)End IfpicItemDesc.visible = FalseExit SubEnd If '[/House Editor]frmEditor_Map.shpLoc.visible = FalseIf Button = vbLeftButton Or Button = vbRightButton ThenCall MapEditorMouseDown(Button, X, Y)End IfEnd If```Find:```Case vbKeyInsert```Add this below it:```Case vbKeyDelete 'Deathbeam - Alatar House system fixSendRequestEditHouseCase vbKeyHomeIf Map.Moral = 1 ThenWarpToHouseEnd If 'Deathbeam - Alatar House system fix```At bottom of frmMain add:```Private Sub lblHouseOk_Click()Call SendHouseManager(lblHouseAsk.Tag, CInt(picHouse.Tag), CInt(lblHouseOk.Tag))End SubPrivate Sub lblHouseCancel_Click()picHouse.visible = FalselblHouseCancel = "Decline"End SubPrivate Sub lblHouseGoTo_Click()picHouse.visible = FalseWarpToHouseEnd Sub'[/House Editor]```FrmEditor_NpcFind this:```NPC(EditorIndex).Behaviour = cmbBehaviour.ListIndex```Add this below it:```'House EditorIf (cmbBehaviour.ListIndex = NPC_BEHAVIOUR_MANAGER) ThenfraHouse.visible = TrueElsefraHouse.visible = FalseEnd If '/House Editor```In Form Load, add:```scrlHouseMapNumber.Max = MAX_MAPS 'House Editor```At bottom of frmEditor_NPC add:```'/ALATAR'House EditorPrivate Sub scrlHouseMapNumber_Change()lblHouseMapNumber = "Map Number: " & scrlHouseMapNumber.ValueNPC(EditorIndex).HMapNum = scrlHouseMapNumber.ValueEnd SubPrivate Sub scrlHouseBuy_Change()lblHouseBuy = "House Buy: " & scrlHouseBuy.ValueNPC(EditorIndex).HBuy = scrlHouseBuy.ValueEnd SubPrivate Sub scrlHouseSell_Change()lblHouseSell = "House Sell: " & scrlHouseSell.ValueNPC(EditorIndex).HSell = scrlHouseSell.ValueEnd Sub '/House Editor```ModClientTCPFind:```Buffer.WriteByte .DirBlock```Add:```Buffer.WriteString .Data4```At bottom of ModClientTcp add this:```'Deathbeam - Alatar House system fixPublic Sub SendRequestEditHouse()Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CRequestEditHouseSendData Buffer.ToArray()Set Buffer = NothingEnd SubPublic Sub SendHouseManager(ByVal HType As String, ByVal HMapNum As Long, ByVal HGold As Long) 'ByVal HBuy As Long, ByVal HSell As Long)Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CHouseManagerBuffer.WriteString HTypeBuffer.WriteLong HMapNumBuffer.WriteLong HGoldSendData Buffer.ToArray()Set Buffer = NothingEnd SubPublic Sub SendCheckGold(ByVal GoldItemNum As Long, ByVal GoldAmount As Long, Optional HCancel As Long)Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CCheckGoldBuffer.WriteLong GoldItemNumBuffer.WriteLong GoldAmountBuffer.WriteLong HCancelSendData Buffer.ToArray()Set Buffer = NothingEnd SubPublic Sub WarpToHouse()Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CWarpToHouseSendData Buffer.ToArray()Set Buffer = NothingEnd Sub'Deathbeam - Alatar House system fix```modConstantsFind this:```' ********************************************************' * The values below must match with the server's values *' ********************************************************```Add this above:```'House Editor Normal ConstantsPublic Const HOUSE_TILESET As Integer = 3Public Const HOUSE_MAX_X As Byte = 30Public Const HOUSE_MAX_Y As Byte = 30Public Const HOUSE_MUSIC As String = "\Data Files\music\"'House Editor Attribute ConstantsPublic Const HOUSE_GOLD As Long = 1Public Const HOUSE_ATTR_B As Integer = 2Public Const HOUSE_ATTR_B_UNDO As Integer = 1Public Const HOUSE_ATTR_S As Integer = 2Public Const HOUSE_ATTR_S_UNDO As Integer = 1Public Const HOUSE_ATTR_U As Integer = 3Public Const HOUSE_ATTR_U_UNDO As Integer = 1Public Const HOUSE_ATTR_R As Integer = 400Public Const HOUSE_ATTR_R_UNDO As Integer = 40```Find:```Public Const MAP_MORAL_SAFE As Byte = 1```Add:```Public Const MAP_MORAL_HOUSE As Byte = 2 'House Editor```Find:```Public Const TILE_TYPE_SLIDE As Byte = 14```Add:```'House EditorPublic Const TILE_TYPE_SIGN As Byte = 15Public Const TILE_TYPE_THRESHOLD As Byte = 16```Find:```Public Const NPC_BEHAVIOUR_GUARD As Byte = 4```Add:```Public Const NPC_BEHAVIOUR_MANAGER As Byte = 5 'House Editor```modGlobalsAdd this at the bottom:```'House EditorPublic InHouseEditor As BooleanPublic HouseSign As StringPublic Threshold As BooleanPublic SpotNum As Long```modGameEditorsIn NPCEditorInit find:```.txtEXP.text = Npc(EditorIndex).EXP```Add:```'House Editor:.scrlHouseMapNumber.Value = Npc(EditorIndex).HMapNum.scrlHouseBuy.Value = Npc(EditorIndex).HBuy.scrlHouseSell.Value = Npc(EditorIndex).HSell```In ResourceEditorInit find:```frmEditor_Resource.scrlAnimation.Value = Resource(EditorIndex).Animation```Add this:```frmEditor_Resource.chkSpot.Value = Resource(EditorIndex).Spot 'House Editor```At bottom of ModGameEditors add this:```' //////////////////' // House Editor //' //////////////////Public Sub HouseEditorInit()Dim i As LongInMapEditor = TruefrmEditor_House.Visible = TruefrmEditor_House.Caption = "House Editor - '" & Trim$(Map.Name) & "'"InHouseEditor = TrueCall InitDDSurf("misc", DDSD_Misc, DDS_Misc)Call EditorHouse_BltTilesetfrmEditor_House.scrlPictureY.Max = (frmEditor_House.picBackSelect.height \ PIC_Y) - (frmEditor_House.picBack.height \ PIC_Y)frmEditor_House.scrlPictureX.Max = (frmEditor_House.picBackSelect.width \ PIC_X) - (frmEditor_House.picBack.width \ PIC_X)If frmEditor_House.fMusic.Path <> App.Path & HOUSE_MUSIC Then frmEditor_House.fMusic.Path = App.Path & HOUSE_MUSICWith frmEditor_House.cmdSend.Enabled = True.cmdCancel.Enabled = True.txtName.text = Trim$(Map.Name)If .fMusic.ListIndex >= 0 Then.fMusic.ListIndex = 0For i = 1 To .fMusic.ListIndexIf .fMusic.List(i) = Trim$(Map.Music) Then.fMusic.ListIndex = iEnd IfNextEnd IfIf Trim$(Map.Music) = vbNullString Then .chkMusic.Value = 1End WithEnd SubPublic Sub HouseEditorSetTile(ByVal X As Long, ByVal Y As Long, ByVal CurLayer As Long, Optional ByVal multitile As Boolean = False)Dim x2 As Long, y2 As LongIf Not multitile ThenWith Map.Tile(X, Y).Layer(CurLayer).X = EditorTileX.Layer(CurLayer).Y = EditorTileY.Layer(CurLayer).tileset = frmEditor_House.chkTileset.CaptionEnd WithElsey2 = 0For Y = CurY To CurY + EditorTileHeight - 1x2 = 0For X = CurX To CurX + EditorTileWidth - 1If X >= 0 And X <= Map.MaxX ThenIf Y >= 0 And Y <= Map.MaxY ThenWith Map.Tile(X, Y).Layer(CurLayer).X = EditorTileX + x2.Layer(CurLayer).Y = EditorTileY + y2.Layer(CurLayer).tileset = frmEditor_House.chkTileset.CaptionEnd WithEnd IfEnd Ifx2 = x2 + 1Nexty2 = y2 + 1NextEnd IfEnd SubPublic Sub HouseEditorMouseDown(ByVal Button As Integer, ByVal X As Long, ByVal Y As Long, Optional ByVal movedMouse As Boolean = True)Dim i As LongDim CurLayer As LongDim tmpDir As ByteFor i = 1 To MapLayer.Layer_Count - 1If frmEditor_House.optLayer(i).Value ThenCurLayer = iExit ForEnd IfNextIf Not isInBounds Then Exit SubIf Button = vbLeftButton ThenIf frmEditor_House.optLayers.Value ThenIf EditorTileWidth = 1 And EditorTileHeight = 1 ThenHouseEditorSetTile CurX, CurY, CurLayerElseHouseEditorSetTile CurX, CurY, CurLayer, TrueEnd IfElseIf frmEditor_House.optAttributes.Value ThenWith Map.Tile(CurX, CurY)If frmEditor_House.optBlocked.Value ThenIf .Type <> TILE_TYPE_BLOCKED Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_BElseIf frmEditor_House.optSign.Value ThenIf .Type <> TILE_TYPE_SIGN Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_SElseIf frmEditor_House.optThreshold.Value ThenIf .Type <> TILE_TYPE_THRESHOLD Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_UElseIf frmEditor_House.optSpot.Value ThenIf .Type <> TILE_TYPE_RESOURCE Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_REnd IfEnd WithEnd IfEnd IfIf Button = vbRightButton ThenIf frmEditor_House.optLayers.Value ThenWith Map.Tile(CurX, CurY).Layer(CurLayer).X = 0.Layer(CurLayer).Y = 0.Layer(CurLayer).tileset = 0End WithElseIf frmEditor_House.optAttributes.Value ThenWith Map.Tile(CurX, CurY)If .Type = TILE_TYPE_BLOCKED Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_B_UNDO, 1If .Type = TILE_TYPE_SIGN Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_S_UNDO, 1If .Type = TILE_TYPE_THRESHOLD Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_U_UNDO, 1If .Type = TILE_TYPE_RESOURCE Then SendCheckGold HOUSE_GOLD, HOUSE_ATTR_R_UNDO, 1.Type = 0.Data1 = 0.Data2 = 0.Data3 = 0End WithEnd IfEnd IfEnd SubPublic Sub HouseEditorChooseTile(Button As Integer, X As Single, Y As Single)If Button = vbLeftButton ThenEditorTileWidth = 1EditorTileHeight = 1EditorTileX = X \ PIC_XEditorTileY = Y \ PIC_YfrmEditor_House.shpSelected.top = EditorTileY * PIC_YfrmEditor_House.shpSelected.Left = EditorTileX * PIC_XfrmEditor_House.shpSelected.width = PIC_XfrmEditor_House.shpSelected.height = PIC_YEnd IfEnd SubPublic Sub HouseEditorDrag(Button As Integer, X As Single, Y As Single)If Button = vbLeftButton ThenX = (X \ PIC_X) + 1Y = (Y \ PIC_Y) + 1If X < 0 Then X = 0If X > frmEditor_House.picBackSelect.width / PIC_X Then X = frmEditor_House.picBackSelect.width / PIC_XIf Y < 0 Then Y = 0If Y > frmEditor_House.picBackSelect.height / PIC_Y Then Y = frmEditor_House.picBackSelect.height / PIC_YIf X > EditorTileX ThenEditorTileWidth = X - EditorTileXElse' TO DOEnd IfIf Y > EditorTileY ThenEditorTileHeight = Y - EditorTileYElse' TO DOEnd IffrmEditor_House.shpSelected.width = EditorTileWidth * PIC_XfrmEditor_House.shpSelected.height = EditorTileHeight * PIC_YEnd IfEnd SubPublic Sub HouseEditorTileScroll()frmEditor_House.picBackSelect.top = (frmEditor_House.scrlPictureY.Value * PIC_Y) * 1frmEditor_House.picBackSelect.Left = (frmEditor_House.scrlPictureX.Value * PIC_X) '* -1End SubPublic Sub HouseEditorSend()Call SendMapInMapEditor = FalsefrmEditor_House.Visible = FalseSet DDS_Misc = NothingEnd SubPublic Sub HouseEditorCancel()Dim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteLong CNeedMapBuffer.WriteLong 1SendData Buffer.ToArray()InMapEditor = FalsefrmEditor_House.Visible = FalseSet DDS_Misc = NothingEnd SubPublic Sub HouseEditorClearLayer()Dim i As LongDim X As LongDim Y As LongDim CurLayer As LongFor i = 1 To MapLayer.Layer_Count - 1If frmEditor_House.optLayer(i).Value ThenCurLayer = iExit ForEnd IfNextIf CurLayer = 0 Then Exit SubIf MsgBox("Are you sure you wish to clear this layer?", vbYesNo, Options.Game_Name) = vbYes ThenFor X = 0 To Map.MaxXFor Y = 0 To Map.MaxYMap.Tile(X, Y).Layer(CurLayer).X = 0Map.Tile(X, Y).Layer(CurLayer).Y = 0Map.Tile(X, Y).Layer(CurLayer).tileset = 0NextNextEnd IfEnd SubPublic Sub HouseEditorFillLayer()Dim i As LongDim X As LongDim Y As LongDim CurLayer As LongFor i = 1 To MapLayer.Layer_Count - 1If frmEditor_House.optLayer(i).Value ThenCurLayer = iExit ForEnd IfNextIf MsgBox("Are you sure you wish to fill this layer?", vbYesNo, Options.Game_Name) = vbYes ThenFor X = 0 To Map.MaxXFor Y = 0 To Map.MaxYMap.Tile(X, Y).Layer(CurLayer).X = EditorTileXMap.Tile(X, Y).Layer(CurLayer).Y = EditorTileYMap.Tile(X, Y).Layer(CurLayer).tileset = frmEditor_House.chkTileset.CaptionNextNextEnd IfEnd SubPublic Sub HouseEditorClearAttribs()Dim X As LongDim Y As LongIf MsgBox("Are you sure you wish to clear the attributes on this house?", vbYesNo, Options.Game_Name) = vbYes ThenFor X = 0 To Map.MaxXFor Y = 0 To Map.MaxYMap.Tile(X, Y).Type = 0NextNextEnd IfEnd SubPublic Sub HouseEditorLeaveMap()If InMapEditor ThenIf MsgBox("Save changes to current house?", vbYesNo) = vbYes ThenCall HouseEditorSendElseCall HouseEditorCancelEnd IfEnd IfEnd SubPublic Sub HideHouseAttributes()With frmEditor_House.fraHSign.Visible = False.fraHSpot.Visible = FalseEnd WithEnd Sub'[/HOUSE EDITOR]```ModDirectDraw7At bottom add this:```'House EditorPublic Sub BltHouseRoof(ByVal X As Long, ByVal Y As Long)Dim rec As DxVBLib.RECTDim i As LongWith Map.Tile(X, Y)i = MapLayer.RoofIf .Layer(i).tileset > 0 Thenrec.top = .Layer(i).Y * PIC_Yrec.Bottom = rec.top + PIC_Yrec.Left = .Layer(i).X * PIC_Xrec.Right = rec.Left + PIC_XIf Not Threshold = True ThenCall Engine_BltFast(ConvertMapX(X * PIC_X), ConvertMapY(Y * PIC_Y), DDS_Tileset(.Layer(i).tileset), rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)End IfEnd IfEnd WithEnd Sub'/House Editor'[House Editor]Public Sub EditorHouse_BltTileset()Dim height As LongDim width As LongDim tileset As ByteDim sRECT As DxVBLib.RECTDim dRECT As DxVBLib.RECT' find tileset numbertileset = frmEditor_House.chkTileset.Caption' exit out if doesn't existIf tileset < 0 Or tileset > NumTileSets Then Exit Sub' make sure it's loadedIf DDS_Tileset(tileset) Is Nothing ThenCall InitDDSurf("tilesets\" & tileset, DDSD_Tileset(tileset), DDS_Tileset(tileset))End Ifheight = DDSD_Tileset(tileset).lHeightwidth = DDSD_Tileset(tileset).lWidthdRECT.top = 0dRECT.Bottom = heightdRECT.Left = 0dRECT.Right = widthfrmEditor_House.picBackSelect.height = heightfrmEditor_House.picBackSelect.width = widthCall Engine_BltToDC(DDS_Tileset(tileset), sRECT, dRECT, frmEditor_House.picBackSelect)End Sub'[/House Editor]```Find this:```If NumTileSets > 0 ThenFor X = TileView.Left To TileView.RightFor Y = TileView.top To TileView.BottomIf IsValidMapPoint(X, Y) ThenCall BltMapFringeTile(X, Y)End IfNextNextEnd If```Under:```Call BltMapFringeTile(X, Y)```Add this:```Call BltHouseRoof(X, Y) 'House Editor```Find this:```' Blit out map attributesIf InMapEditor ThenCall BltMapAttributesEnd If```Replace it with this:```' Blit out map attributesIf InMapEditor ThenCall BltMapAttributesCall BltHouseAttributes 'House EditorEnd If```ModEnumerationsFind this:```' Make sure SMSG_COUNT is below everything else```Add this above:```'House Editor:SEditHouseSInitManagerSSendHouseSGoldChecked```Find this:```' Make sure CMSG_COUNT is below everything else```Add this above:```'House Editor:CRequestEditHouseCHouseManagerCCheckGoldCWarpToHouse```Find Enum MapLayer and add above:```Layer_Count```this:```Roof 'House Editor```ModHandleDataAt bottom of sub InitMessages add:```'House Editor:HandleDataSub(SEditHouse) = GetAddress(AddressOf HandleEditHouse)HandleDataSub(SInitManager) = GetAddress(AddressOf HandleInitManager)HandleDataSub(SSendHouse) = GetAddress(AddressOf HandleSendHouse)HandleDataSub(SGoldChecked) = GetAddress(AddressOf HandleGoldChecked)```Find:```Map.Tile(X, Y).DirBlock = Buffer.ReadByte``````Add this:Map.Tile(X, Y).Data4 = Buffer.ReadString 'House Editor```At bottom of ModHandleData add this:```'[House Editor]Private Sub HandleEditHouse(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Dim Owner As Long Set Buffer = New clsBuffer Buffer.WriteBytes Data() Owner = Buffer.ReadLong If Not Owner = GetPlayerMap(Index) Then Exit Sub Call HouseEditorInitEnd SubPrivate Sub HandleInitManager(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Dim HMapNum As Long Dim HType As String Dim HGold As Long Set Buffer = New clsBuffer Buffer.WriteBytes Data() HMapNum = Buffer.ReadLong HType = Buffer.ReadString HGold = Buffer.ReadLong Set Buffer = Nothing With frmMain Select Case HType Case "Buy" .picHouse.Visible = True .lblHouseOk.Visible = True .lblHouseCancel.Visible = True .lblHouseGoTo.Visible = False .lblHouseAsk = "Buy this house for " & HGold & "?" .picHouse.Tag = HMapNum .lblHouseAsk.Tag = HType .lblHouseOk.Tag = HGold Case "Sell" .picHouse.Visible = True .lblHouseOk.Visible = True .lblHouseCancel.Visible = True .lblHouseGoTo.Visible = False .lblHouseAsk = "Sell your house for " & HGold & "?" .picHouse.Tag = HMapNum .lblHouseAsk.Tag = HType .lblHouseOk.Tag = HGold Case "Nothing" Exit Sub End Select End WithEnd SubPrivate Sub HandleSendHouse(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Dim HType As String Dim HMapNum As Long Set Buffer = New clsBuffer Buffer.WriteBytes Data() HType = Buffer.ReadString HMapNum = Buffer.ReadLong Set Buffer = Nothing With frmMain Select Case HType Case "Buy" .lblHouseOk.Visible = False .lblHouseCancel.Visible = False .lblHouseGoTo.Visible = True .lblHouseAsk = "House bought!" .picHouse.Tag = HMapNum Case "Sell" .lblHouseOk.Visible = False .lblHouseCancel = "Close" .lblHouseAsk = "House sold!" .picHouse.Tag = 0 Case "Gold" .picHouse.Visible = False MsgBox "Not enought gold!", vbInformation, "" & Options.Game_Name End Select End WithEnd SubPrivate Sub HandleGoldChecked(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) If InHouseEditor = True Then With Map.Tile(CurX, CurY) If frmEditor_House.optBlocked.Value Then .Type = TILE_TYPE_BLOCKED .Data1 = 0 .Data2 = 0 .Data3 = 0 ElseIf frmEditor_House.optSign.Value Then .Type = TILE_TYPE_SIGN .Data1 = 0 .Data2 = 0 .Data3 = 0 .Data4 = CStr(HouseSign) ElseIf frmEditor_House.optThreshold.Value Then .Type = TILE_TYPE_THRESHOLD .Data1 = 0 .Data2 = 0 .Data3 = 0 ElseIf frmEditor_House.optSpot.Value Then .Type = TILE_TYPE_RESOURCE .Data1 = SpotNum .Data2 = 0 .Data3 = 0 End If End With End IfEnd Sub'[/House Editor]```frmEditor_ResourceAt the bottom, add:```'House Editor:Private Sub chkSpot_Click() Resource(EditorIndex).Spot = chkSpot.ValueEnd Sub```modTextAdd this:```'[House Editor]Public Function BltHouseAttributes() Dim X As Long Dim Y As Long Dim tX As Long Dim tY As Long If frmEditor_House.optAttributes.Value = True Then For X = TileView.Left To TileView.Right For Y = TileView.top To TileView.Bottom If IsValidMapPoint(X, Y) Then With Map.Tile(X, Y) tX = ((ConvertMapX(X * PIC_X)) - 4) + (PIC_X * 0.5) tY = ((ConvertMapY(Y * PIC_Y)) - 7) + (PIC_Y * 0.5) Select Case .Type Case TILE_TYPE_BLOCKED DrawText TexthDC, tX, tY, "B", QBColor(BrightRed) Case TILE_TYPE_SIGN DrawText TexthDC, tX, tY, "S", QBColor(Yellow) Case TILE_TYPE_THRESHOLD DrawText TexthDC, tX, tY, "T", QBColor(BrightCyan) Case TILE_TYPE_RESOURCE DrawText TexthDC, tX, tY, "S", QBColor(BrightGreen) End Select End With End If Next Next End IfEnd Function'[/House Editor]```modTypesIn TileRec, find DirBlock As ByteAdd this:```Data4 As String 'House Editor```In NPCRec, find Animation As LongAdd this:```'House Editor: HMapNum As Long HBuy As Long HSell As Long```In ResourceRec, find Animation As LongAdd this:```Spot As Byte 'House Editor```modGameLogicin Function CheckDirection, Find:```Case DIR_RIGHT X = GetPlayerX(MyIndex) + 1 Y = GetPlayerY(MyIndex) End Select```Add this below it:```'House Editor If Map.Tile(X, Y).Type = TILE_TYPE_THRESHOLD Then Threshold = Not Threshold Exit Function End If '/House Editor```In Public Sub UpdateDrawMapName() find:```Case MAP_MORAL_SAFE DrawMapNameColor = QBColor(White)```Add this below it:```Case MAP_MORAL_HOUSE DrawMapNameColor = QBColor(BrightCyan) '/House Editor```FORM WORK:Copy picHouse with everything in it from House Speech.frm, what i added to attachments (its in file HouseFiles.rar) , to your frmMain (this pic is used for talking with npc manager).Add frmEditor_House.frm to your project (its located in HouseFiles.rar too)Add checkbox to frmEditor_Resource with:Name: chkSpotCaption: Spot?In frmEditor_NPCadd to cmbBehavior list new item **Manager**add fraHouse with everything in it from House NPC Editor Frame.frm (included in HouseFiles.rar)to frmEditor_NPC (u must make some room for this)In frmEditor_MapPropertiesadd to cmbMoral list new item **House**And now youre done ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)I think i dont forget anything.Please post any bugs u found. Link to comment Share on other sites More sharing options...
erkro1 Posted June 3, 2012 Share Posted June 3, 2012 Can you maybe make a tutorial with what you've changed to fix it? Link to comment Share on other sites More sharing options...
tslusny Posted June 3, 2012 Author Share Posted June 3, 2012 Yea of course i can :DGive me few minutes :DI cant find original post so i must redo tutorial Link to comment Share on other sites More sharing options...
tslusny Posted June 3, 2012 Author Share Posted June 3, 2012 Ok tutorial finished :DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD Link to comment Share on other sites More sharing options...
JohnPony Posted June 3, 2012 Share Posted June 3, 2012 - Snip. FAIL! Link to comment Share on other sites More sharing options...
tslusny Posted June 3, 2012 Author Share Posted June 3, 2012 @John:> Here is the original tutorial: http://www.touchofdeathforums.com/smf2/index.php/topic,70502.560.html> took me some time to find it xDThis is link for Alatars Quest System, i think original house system post is deleted already Link to comment Share on other sites More sharing options...
JohnPony Posted June 3, 2012 Share Posted June 3, 2012 @Deathbeam:> This is link for Alatars Quest System, i think original house system post is deleted alreadyEpic fail on my part, i just seen Alatar's pop up after 10 minuets of searching and got excited xD Link to comment Share on other sites More sharing options...
tslusny Posted June 3, 2012 Author Share Posted June 3, 2012 :DD But + 1 for Effort :cheesy: Link to comment Share on other sites More sharing options...
Justn Posted June 3, 2012 Share Posted June 3, 2012 I don't see where u fixed the issue with people being able to buy houses owned by other players? Can u show where that part is?wait I found out where u fixed it at… Was bugging me I gave up on this awhile ago cause I couldn't fix that problem thanks a lot... You have any plans of converting the ini file to a utd? :p thanks for sharing and glad someone got it working correctly..Edit2: hmm how could I get it to not display the npcs name with a blank msg if the house is sold.. currently it displays it under the "this house is sold" message Link to comment Share on other sites More sharing options...
tslusny Posted June 4, 2012 Author Share Posted June 4, 2012 You mean this?```If MapOwner = 0 Then    If FindHouse(HMapNum) Then      Call PlayerMsg(index, "This house is already sold", White)    Else```Its in Sub SendInitManager Link to comment Share on other sites More sharing options...
JohnPony Posted June 4, 2012 Share Posted June 4, 2012 Im planning on converting this system to work with CS:DE sometime in the future, i just have to find the time. When i do i will also convert it to UDT. Link to comment Share on other sites More sharing options...
Vus Posted June 5, 2012 Share Posted June 5, 2012 Wow, great work, ill try this. Thanks :)P.S. teda, z tebe se stal uplnej codemaster, jen tak dal :DEDIT: I downloaded that EO with this tutorial, and once I tried to add some stuff into my house, when i hit Send, server displayed runtime error 9, subscript out of range. I tried to restart it, but it doesnt work. Link to comment Share on other sites More sharing options...
tslusny Posted June 5, 2012 Author Share Posted June 5, 2012 @Vus:> P.S. teda, z tebe se stal uplnej codemaster, jen tak dal :DSak potreboval som uz ten House system do hry a tak som teda spravil aj tutorial :cheesy: Link to comment Share on other sites More sharing options...
tslusny Posted June 12, 2012 Author Share Posted June 12, 2012 Cant fix that thing with ScrlPictureX and Y max Link to comment Share on other sites More sharing options...
Likestodraw Posted June 12, 2012 Share Posted June 12, 2012 Um… I downloaded the lazy version and it had RTE5- invalid cell arrangementIsn't that what happened with the other one? Link to comment Share on other sites More sharing options...
Growlith1223 Posted June 13, 2012 Share Posted June 13, 2012 is there a way to make it so the house is just added automatically instead of having to buy it?I have been trying to do that for ages xD Link to comment Share on other sites More sharing options...
tslusny Posted June 13, 2012 Author Share Posted June 13, 2012 @ZeroX8:> is there a way to make it so the house is just added automatically instead of having to buy it?> > I have been trying to do that for ages xDYes its possible you must modify handleaddchar or someting like it@Likestodraw:> Um… I downloaded the lazy version and it had RTE5- invalid cell arrangement> Isn't that what happened with the other one?Dont you deleted accounts folder on server? Becouse i dont added check if fileexist Houses.txt then create it, so u must make that text file in server/data/accounts Link to comment Share on other sites More sharing options...
Likestodraw Posted June 14, 2012 Share Posted June 14, 2012 Well it was just the lazy version (I wanted to play around with the housing system before I actually made my programmer put it in because housing is my favorite system out of any possible system in a game), so it should have been done… I'll check again...EDIT- It still won't work, and apparently RTE5 is invalid procedure or argument, but oh, well. Link to comment Share on other sites More sharing options...
tslusny Posted June 14, 2012 Author Share Posted June 14, 2012 @Likestodraw:> Well it was just the lazy version (I wanted to play around with the housing system before I actually made my programmer put it in because housing is my favorite system out of any possible system in a game), so it should have been done… I'll check again...> > EDIT- It still won't work, and apparently RTE5 is invalid procedure or argument, but oh, well.I dont know what doing this problem, but on my pc it works good, and i converted my game to CS:DE and i followed this tutorial to add it to game and no problems ( but u must make some changes to code to work with cs:de) Link to comment Share on other sites More sharing options...
DarkOne5890 Posted June 22, 2012 Share Posted June 22, 2012 @Deathbeam:> I dont know what doing this problem, but on my pc it works good, and i converted my game to CS:DE and i followed this tutorial to add it to game and no problems ( but u must make some changes to code to work with cs:de)WhatIsthe problem sorry for comenting on a diffrent post but look its weird Link to comment Share on other sites More sharing options...
Likestodraw Posted June 22, 2012 Share Posted June 22, 2012 @DarkBeast:> WhatIsthe problem sorry for comenting on a diffrent post but look its weirdUm… that confuses me.@DeathBeam- I'll try it again, but it probably won't work... Link to comment Share on other sites More sharing options...
tslusny Posted June 24, 2012 Author Share Posted June 24, 2012 @DarkBeast:> WhatIsthe problem sorry for comenting on a diffrent post but look its weirdYou dont added dim NpcY as Long at top of sub Link to comment Share on other sites More sharing options...
Likestodraw Posted June 25, 2012 Share Posted June 25, 2012 I re-downloaded the lazy version, tried again, and it still gets RTE5. Link to comment Share on other sites More sharing options...
Justn Posted June 25, 2012 Share Posted June 25, 2012 When do u get the error cause I downloaded it to play around with and it seemed to work fine for the 5-10 mins I was messing with it?? Link to comment Share on other sites More sharing options...
Likestodraw Posted June 28, 2012 Share Posted June 28, 2012 It's right when I open Eclipse. I got the same error when trying to use Eclipse Galaxy, and I got errors when trying to open EO 2.5 and 2.6\. I have no idea what could be causing this, and am really annoyed. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now