Mirage Source

Free ORPG making software.
It is currently Thu Mar 28, 2024 3:20 pm

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1413 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 57  Next
Author Message
PostPosted: Tue Oct 21, 2008 6:44 pm 
Offline
Regular
User avatar

Joined: Tue Sep 30, 2008 6:04 pm
Posts: 47
How do i make it so the background thats pink doesnt show inside of the inventory and so it doesnt show ingame too..because If the background is white in my inventory then its white in the game .


Top
 Profile  
 
PostPosted: Mon Nov 03, 2008 5:33 pm 
Offline
Newbie

Joined: Thu Oct 30, 2008 7:54 pm
Posts: 21
When I try to add this I'm getting this error:
DD_ItemSurf (Variable not defined)


Top
 Profile  
 
PostPosted: Wed Nov 05, 2008 8:41 pm 
Offline
Knowledgeable

Joined: Sat Jul 08, 2006 8:24 am
Posts: 339
One way to improve this is remove the useless dims

Dim x As Long
Dim y As Long

in first sub

Dim i As Long

in the second sub. and third, and fourth

I suppose the Temp Rec is a bit of a waste as well, you only use the vars you input there once, might as well just copy over that data.

Dimming both offsets public and using them only once sounds like a waste as well.

So seems the code is good, but can be cleared up a bit.


Top
 Profile  
 
PostPosted: Sat Dec 13, 2008 3:09 am 
Offline
Regular

Joined: Wed Jan 16, 2008 8:50 pm
Posts: 60
Johny050 wrote:
When I try to add this I'm getting this error:
DD_ItemSurf (Variable not defined)


I'm pretty sure Johny050 figured this one out by now, but for anyone else trying to add this, just replace

Code:
Call DD_ItemSurf.BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos)


With

Code:
Call DDS_Item.BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos)


Real simple fix. Also there is alot of work to do for anyone who wants to add this in, its not just a C & P (thought C & P gets the actual picture box to work like it should.)


Top
 Profile  
 
PostPosted: Mon Jan 05, 2009 12:13 pm 
Offline
Regular

Joined: Wed Jan 16, 2008 8:50 pm
Posts: 60
Sorry for the double post, however, I have a question about how to get this to work.

Here is the problem, the sub works ALMOST correctly. It see's the items as the first pixels in the upper lefthand part of the picVisInv, not the actual blting of the item.

I tried messing with the InvPosX, InvPosY, X, Y, and I still can't seem to get it to move off of those pixels. Can anyone help me out with this? I have the standard 32 * 32 pixel items, and a 5 pixel offset between the top and sides of the picVisInv, and 5 pixel offset between the item pics. I know that I need to add in the offset, and the 32 * 32 pixels for the pics so the picItemDesc shows up when actually on the pictue. I wouldn't be too worried about this, I might take it out, however the other subs to drop and use the items are based on this, so scrolling over the actual item and double-clicking etc. does nothing.

SPOILER: (click to show)
Code:
Private Sub picVisInv_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Long
Dim InvNum As Long
Dim ItemNum As Long

    InvPosX = X
    InvPosY = Y

    InvNum = IsItem(X, Y)
   
    If InvNum <> 0 Then

        ItemNum = GetPlayerInvItemNum(MyIndex, InvNum)

        lblItemName.Caption = Trim$(Item(ItemNum).Name)

        picItemDesc.Visible = True
        Exit Sub
    Else
        lblItemName.Caption = ""
    End If

End Sub


Edit: I've been thinking a little more into this, and I still do not know what to do to fix this, however I believe that what I need to change is not in the above sub, it's in the IsItem Function. I'm using the default IsItem Function (with only a change of the 4 - 8, just changing the amount of columns of items in the visual inventory. I posted the code below, for anyone to lazy to go look at it above, or who wants a look at my specific code.

SPOILER: (click to show)
Code:
Private Function IsItem(ByVal X As Single, ByVal Y As Single) As Long
Dim tempRec As RECT
Dim i As Long

    For i = 1 To MAX_INV
        If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i) <= MAX_ITEMS Then
            With tempRec
                .Top = InvY + ((InvOffsetY + 32) * ((i - 1) \ 8))
                .Bottom = .Top + PIC_Y
                .Left = InvX + ((InvOffsetX + 32) * (((i - 1) Mod 8)))
                .Right = .Left + PIC_X
            End With
           
            If X >= tempRec.Left And X <= tempRec.Right Then
                If Y >= tempRec.Top And Y <= tempRec.Bottom Then
                   
                    IsItem = i
                    Exit Function
                End If
            End If
        End If
    Next i
   
    IsItem = 0
End Function


Top
 Profile  
 
PostPosted: Mon Jan 05, 2009 3:37 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Ok so finally figured out the problem some people were having with the interaction code.

First change:
Code:
Public Const InvX As Byte = 11
Public Const InvY As Byte =30

To:
Code:
Public Const InvX As Byte = 30
Public Const InvY As Byte = 11


Then in BltInventory:
Code:
With rec_pos
                    .top = InvX + ((InvOffsetY + 32) * ((i - 1) \ 4))
                    .Bottom = .top + PIC_Y
                    .Left = InvY + ((InvOffsetX + 32) * (((i - 1) Mod 4)))
                    .Right = .Left + PIC_X
                End With

To:
Code:
With rec_pos
                    .top = InvY + ((InvOffsetY + 32) * ((i - 1) \ 4))
                    .Bottom = .top + PIC_Y
                    .Left = InvX + ((InvOffsetX + 32) * (((i - 1) Mod 4)))
                    .Right = .Left + PIC_X
                End With


If there are any more problems let me know.


Top
 Profile  
 
PostPosted: Mon Jan 19, 2009 11:47 am 
Offline
Regular

Joined: Sat Sep 13, 2008 1:41 am
Posts: 97
I added all the code plus all the changes but when i click inventory it not showing the visual inventory


Top
 Profile  
 
PostPosted: Mon Jan 19, 2009 1:50 pm 
Offline
Regular

Joined: Wed Jan 16, 2008 8:50 pm
Posts: 60
Is it not showing the visual inventory or not showing the picture box? If it isn't showing the picture box, then you just need to add in picVisInv.visible = true into the click inventory button, or if you added it to the frmMirage, you may need to change the height of the frm when you click inventory. If you are talking about the actual items not showing up, make sure that the box is at least 64*64 (that won't be big enough, but it should show at least the first item) and make sure you add "Call BltInventory" into the click of the inventory button.


Top
 Profile  
 
PostPosted: Mon Jan 19, 2009 2:33 pm 
Offline
Regular

Joined: Sat Sep 13, 2008 1:41 am
Posts: 97
Im just wondering would it be easier if i made a new form or if i did it in form mirage. I will prolly go with a new form.


Top
 Profile  
 
PostPosted: Mon Jan 19, 2009 5:23 pm 
skillzalot wrote:
Im just wondering would it be easier if i made a new form or if i did it in form mirage. I will prolly go with a new form.


A new form is pointless and will just bloat the fuck out of your exe.


Top
  
 
PostPosted: Mon Jan 19, 2009 9:25 pm 
Offline
Regular

Joined: Wed Jan 16, 2008 8:50 pm
Posts: 60
What I did was add it to the bottom of my frmMirage, and when the inventory button was pressed, increased the height as needed, and when the close button was pressed, it set it back to normal.


Top
 Profile  
 
PostPosted: Fri Feb 27, 2009 7:27 am 
Offline
Regular
User avatar

Joined: Tue Mar 13, 2007 3:42 am
Posts: 49
Location: Doorstep, Southampton, UK
deathknight wrote:
Code:
Call DD_ItemSurf.BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos)


With

Code:
Call DDS_Item.BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos)


I'm trying to work this out, everything is perfect and correct but the compiler is being an ass hole and showing me "Invalid Qualifier" for the "DDS_Item".

Any ideas?

_________________
Image
Be a member of the mafia! Kill people! :P or play DF...
Lochie - Modern Mischief


Top
 Profile  
 
PostPosted: Fri Feb 27, 2009 4:51 pm 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
Lochie wrote:
deathknight wrote:
Code:
Call DD_ItemSurf.BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos)


With

Code:
Call DDS_Item.BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos)


I'm trying to work this out, everything is perfect and correct but the compiler is being an ass hole and showing me "Invalid Qualifier" for the "DDS_Item".

Any ideas?


DDS_Item is now stored in an array. You'll need to re-write the code so that'll it load the surface with the item's number, something like:


Code:
Call DDS_Item(ItemNum).BltToDC(frmMirage.picVisInv.hdc, rec, rec_pos)


And you'll need to edit 'rec' to something like:

Code:
rec.top = 0
rec.bottom = 32
rec.left = 0
rec.right = 32


You'll also need to copy and paste the code from one of the other surface checks to make sure the item surface is already loaded, as DFA edited it so unused graphics are unloaded from memory. Tbh, you should make a quick function to handle a check like I did, as it allows use of the graphics loaded into surfaces much easier.

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Fri Feb 27, 2009 4:59 pm 
Offline
Regular
User avatar

Joined: Tue Mar 13, 2007 3:42 am
Posts: 49
Location: Doorstep, Southampton, UK
Yeah worked it out. Thanks though.

The function check is a good idea, I'll do that tomorrow or something. Can't be bothered to code much, going out tonight so already got alcohol in me. I'll end up either killing the source or scripting something stupid. :?

_________________
Image
Be a member of the mafia! Kill people! :P or play DF...
Lochie - Modern Mischief


Top
 Profile  
 
PostPosted: Fri Feb 27, 2009 5:23 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
When I get time I'll update the tut to be up to date.


Top
 Profile  
 
PostPosted: Mon Mar 09, 2009 5:20 pm 
Offline
Pro
User avatar

Joined: Tue Apr 22, 2008 2:15 am
Posts: 597
alright, i can't figure this one out. i've rewritten the code so that is "should" work, yet of course, it doesn't. When i bring the inventory up, it doesn't blt anything, and then when i click the button again, it gives me a "subscript out of range" error, and then i can see it start to blt.

Code:
Public Sub BltInventory()
Dim i As Long
Dim PicNum As Integer
Dim sRECT As DXVBLib.RECT
Dim dRECT As DXVBLib.RECT

If frmMirage.picVisInv.Visible Then
    frmMirage.picVisInv.Cls

    For i = 1 To MAX_INV
        If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i) <= MAX_ITEMS Then
            PicNum = Item(i).Pic
                    With sRECT
                        .Top = 0
                        .Bottom = 32
                        .Left = 0
                        .Right = 32
                    End With
                   
                    With dRECT
                        .Top = InvY + ((InvOffsetY + 32) * ((i - 1) \ 4))
                        .Bottom = .Top + PIC_Y
                        .Left = InvX + ((InvOffsetX + 32) * (((i - 1) Mod 4)))
                        .Right = .Left + PIC_X
                    End With
       

            Call DD_ReadySurface("Items\" & PicNum, DDS_Item(PicNum))
            Call DDS_Item(PicNum).Surface.BltToDC(frmMirage.picVisInv.hdc, sRECT, dRECT)
        End If
    Next i
frmMirage.picVisInv.Refresh
End If
   
End Sub


and highlights this line
Code:
Call DD_ReadySurface("Items\" & PicNum, DDS_Item(PicNum))


i can't ever get anything to work that deals with blting it seems :S


Top
 Profile  
 
PostPosted: Mon Mar 09, 2009 5:37 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
I still haven't had the time to see what's new in MS4. One of these days...


Top
 Profile  
 
PostPosted: Mon Mar 09, 2009 5:54 pm 
The only thing new is the item icon array. Since it uses separate files and such, it has to be done differently.


Top
  
 
PostPosted: Mon Mar 09, 2009 8:28 pm 
Offline
Pro
User avatar

Joined: Tue Apr 22, 2008 2:15 am
Posts: 597
hence the ready surface, however it says that is what is causing the problem


Top
 Profile  
 
PostPosted: Mon Mar 09, 2009 11:15 pm 
Offline
Regular
User avatar

Joined: Tue Mar 13, 2007 3:42 am
Posts: 49
Location: Doorstep, Southampton, UK
Debug it.
I think I had a similar problem. It wasn't picking up the ItemNum value and was returning zero in one of the checks. That is what caused it to go out of range.
Have a browser through and Step Into the function to check what the values are.

_________________
Image
Be a member of the mafia! Kill people! :P or play DF...
Lochie - Modern Mischief


Top
 Profile  
 
PostPosted: Mon Mar 16, 2009 4:06 pm 
Follow this tutorial the same way as you normally would, but use this sub for BltInventory instead:

Code:
Public Sub BltInventory()
Dim i As Long, PicNum As Long
Dim rec As DxVBLib.RECT
Dim rec_pos As DxVBLib.RECT

    If frmMirage.picInvList.Visible Then
        frmMirage.picInvList.Cls
           
        For i = 1 To MAX_INV
            If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i) <= MAX_ITEMS Then
                With rec
                    .Top = 0 'Item(GetPlayerInvItemNum(MyIndex, i)).Pic * PIC_Y
                    .Bottom = 32 '.Top + PIC_Y
                    .Left = 0
                    .Right = 32 '.Left + PIC_X
                End With
               
                With rec_pos
                    .Top = InvY + ((InvOffsetY + 32) * ((i - 1) \ 4))
                    .Bottom = .Top + PIC_Y
                    .Left = InvX + ((InvOffsetX + 32) * (((i - 1) Mod 4)))
                    .Right = .Left + PIC_X
                End With
               
                PicNum = Item(PlayerInv(i).Num).Pic
               
                If DDS_Item(PicNum) Is Nothing Then
                    Call InitDDSurf("Items\" & PicNum, DDSD_Item(PicNum), DDS_Item(PicNum))
                End If
               
                Call DDS_Item(PicNum).BltToDC(frmMirage.picInvList.hDC, rec, rec_pos)
            End If
        Next i
           
        frmMirage.picInvList.Refresh
    End If
End Sub


EDIT: Updated it a bit so that it blits the correct item icon.


Top
  
 
PostPosted: Wed Mar 18, 2009 3:32 am 
Offline
Knowledgeable
User avatar

Joined: Sun Feb 10, 2008 7:40 pm
Posts: 200
I seem to have a problem, It won't show the item name.

_________________
I is back!


Top
 Profile  
 
PostPosted: Tue Apr 07, 2009 4:26 am 
Offline
Newbie

Joined: Tue Feb 05, 2008 3:44 am
Posts: 9
Im having a problem with the DDS_Item, Im getting a type mismatch before it loads the game windows.

Code:
Public Sub BltInventory()
Dim i As Long, PicNum As Long
Dim rec As DxVBLib.RECT
Dim rec_pos As DxVBLib.RECT


    If frmMirage.picInvList.Visible Then
        frmMirage.picInvList.Cls
           
        For i = 1 To MAX_INV
            If GetPlayerInvItemNum(MyIndex, i) > 0 And GetPlayerInvItemNum(MyIndex, i) <= MAX_ITEMS Then
                With rec
                    .Top = 0 'Item(GetPlayerInvItemNum(MyIndex, i)).Pic * PIC_Y
                    .Bottom = 32 '.Top + PIC_Y
                    .Left = 0
                    .Right = 32 '.Left + PIC_X
                End With
               
                With rec_pos
                    .Top = InvY + ((InvOffsetY + 32) * ((i - 1) \ 4))
                    .Bottom = .Top + PIC_Y
                    .Left = InvX + ((InvOffsetX + 32) * (((i - 1) Mod 4)))
                    .Right = .Left + PIC_X
                End With
               
                PicNum = Item(PlayerInv(i).Num).Pic
               
                If DDS_Item(PicNum) Is Nothing Then
                    Call InitDDSurf("Items\" & PicNum, DDSD_Item(PicNum), DDS_Item(PicNum))
                End If
               
                Call DDS_Item(PicNum).BltToDC(frmMirage.picInvList.hdc, rec, rec_pos)
            End If
        Next i
           
        frmMirage.picInvList.Refresh
    End If
End Sub


If anyone has an idea on whats happening it would be great if you could show me how to fix it =]


Top
 Profile  
 
PostPosted: Sun Aug 30, 2009 11:33 pm 
Offline
Regular

Joined: Thu Mar 19, 2009 9:42 am
Posts: 30
i have the same prblm :/


Top
 Profile  
 
PostPosted: Wed Dec 01, 2021 7:41 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1413 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 57  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group