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

[EO 2 & 3]Target-Details Tutorial


abhi2011
 Share

Recommended Posts

Hey there, this is a new tutorial of mine. It has 1 part unfinished which I will have to finish soon. Don't worry about it. It will be done ASAP.

**CLIENT SIDE**

Download the attachment. It has a picture box containing the details tab.

After adding the tab make a label. Name it whatever you like. Caption can also be whatever you like. (This part is the button that opens up the tab. Like the inv button. Since I don't have a picture for a button I am using the method of a label.)

Okay now double click on your new label and add the following lines of code.

>! ![](http://i.imgur.com/nUkxBT2.png)

```

picOppDetails.Visible = True

picInventory.Visible = False

picCharacter.Visible = False

picSpells.Visible = False

picOptions.Visible = False

picParty.Visible = False

```
I suppose that is self explanatory. Now we have to make the target details tab invisible when another tab is open. To do that, find this line of code.

```

If Not picInventory.Visible Then

```
Now add this line of code in each case.

```

picOppDetails.Visible = False

```
Now that that is done we have to declare our packets.

In modEnumerations find

```

' Make sure SMSG_COUNT is below everything else

SMSG_COUNT

```
Above that add

```

STargetDetails

```
Now in modHandleData in the sub InitMessages add

```

HandleDataSub(STargetDetails) = GetAddress(AddressOf HandleTargetDetails)
```
Now at the end of the module add

```

Private Sub HandleTargetDetails(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

Dim Name As String, maxHp As Long, HP As Long, Level As Long, Stat(1 To Stats.Stat_Count - 1) As Byte

Dim i As Long

Dim Buffer As clsBuffer

Set Buffer = New clsBuffer

Buffer.WriteBytes Data()

Name = Buffer.ReadString

Level = Buffer.ReadByte

maxHp = Buffer.ReadLong

HP = Buffer.ReadLong

For i = 1 To Stats.Stat_Count - 1

Stat(i) = Buffer.ReadByte

Next i

With frmMain

If Not Name = vbNullString Then

.lblOppName.Caption = Name

Else

.lblOppName.Caption = "No Target"

End If

.lblOppLevel.Caption = Level

For i = 1 To Stats.Stat_Count - 1

.lblOppStat(i).Caption = Stat(i)

Next i

If Not maxHp = 0 Then

.lblOppHp = HP & "/" & maxHp

Else

.lblOppHp = "No Target"

End If

End With

Set Buffer = Nothing

End Sub

```
in the same module find,

```

frmMain.imgHPBar.width = ((GetPlayerVital(MyIndex, Vitals.HP) / HPBar_Width) / (GetPlayerMaxVital(MyIndex, Vitals.HP) / HPBar_Width)) * HPBar_Width

```
Underneath, before the " error handler " add this

```

if mytargettype = target_type_player then

If myTarget = MyIndex Then

frmMain.lblOppHp = GetPlayerVital(MyIndex, HP) & "/" & Player(MyIndex).MaxVital(HP)

End If

end if

```
in the same module find

```
MapNpc(MapNpcNum).Vital(i) = Buffer.ReadLong
```
below that add

```
If myTargetType = TARGET_TYPE_NPC Then

If myTarget = MapNpc(MapNpcNum).num Then

frmMain.lblOppHp.Caption = MapNpc(MapNpcNum).Vital(HP) & "/" & Npc(myTarget).HP

End If

End If

```
I suppose that is the end of Client Side. There might be more. Just Don't remember ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

**SERVER-SIDE**

Lets declare our packet. Go to modEnumeration and find

```

' Make sure SMSG_COUNT is below everything else

SMSG_COUNT

```
Above that add

```
STargetDetails
```
Go to modHandleData and find this

```
Private Sub HandleSearch(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
```
In this sub above every

```
sendtarget index
```
add

```
sendtargetdetails index
```
Now in modServerTCP add this at the bottom

```

Public Sub SendtargetDetails(ByVal index As Long)

Dim Buffer As clsBuffer

Dim target As Long, targetType As Long

Dim i As Long

target = TempPlayer(index).target

targetType = TempPlayer(index).targetType

Set Buffer = New clsBuffer

Buffer.WriteLong stargetdetails

Select Case targetType

Case TARGET_TYPE_PLAYER

Buffer.WriteString GetPlayerName(target)

Buffer.WriteByte GetPlayerLevel(target)

Buffer.WriteLong GetPlayerMaxVital(target, HP)

Buffer.WriteLong GetPlayerVital(target, HP)

For i = 1 To Stats.Stat_Count - 1

Buffer.WriteByte Player(target).stat(i)

Next i

Case TARGET_TYPE_NPC

With Npc(MapNpc(GetPlayerMap(index)).Npc(target).Num)

Buffer.WriteString Trim$(.Name)

Buffer.WriteByte .Level

Buffer.WriteLong .HP

Buffer.WriteLong MapNpc(GetPlayerMap(index)).Npc(target).Vital(HP)

For i = 1 To Stats.Stat_Count - 1

Buffer.WriteByte .stat(i)

Debug.Print .stat(i)

Next i

End With

Case TARGET_TYPE_NONE

Buffer.WriteString vbNullString

Buffer.WriteByte 1

Buffer.WriteLong 0

Buffer.WriteLong 0

For i = 1 To Stats.Stat_Count - 1

Buffer.WriteByte 0

Next i

End Select

SendDataTo index, Buffer.ToArray

Set Buffer = Nothing

End Sub

```
in modCombat find

```

' purge target info of anyone who targetted dead guy

For i = 1 To Player_HighIndex

If IsPlaying(i) And IsConnected(i) Then

If Player(i).Map = GetPlayerMap(attacker) Then

If TempPlayer(i).target = TARGET_TYPE_PLAYER Then

If TempPlayer(i).target = victim Then

TempPlayer(i).target = 0

TempPlayer(i).targetType = TARGET_TYPE_NONE

SendTarget i

End If

End If

End If

End If

Next

```
Below ' SendTarget i ' ,add

```
sendtargetdetails i
```
in the same sub below

```
Call SendVital(victim, Vitals.HP)
```
below that add

```
sendtargetdetails(attacker)
```
find

```

'Loop through entire map and purge NPC from targets

For i = 1 To Player_HighIndex

If IsPlaying(i) And IsConnected(i) Then

If Player(i).Map = mapNum Then

If TempPlayer(i).targetType = TARGET_TYPE_NPC Then

If TempPlayer(i).target = mapNpcNum Then

TempPlayer(i).target = 0

TempPlayer(i).targetType = TARGET_TYPE_NONE

SendTarget i

End If

End If

End If

End If

Next

```
Below ' sendtarget i ' add

```
SendtargetDetails i
```

Use the full project search feature and find the following

```

sendtarget index

```
and add this bellow it

```

sendtargetdetails index

```
Thats all there is to the tutorials. If you think I missed something (like when you attack an update doesn't happen) post below.

And also if there are compile errors post below as well.
Link to comment
Share on other sites

  • 4 weeks later...
I, too have this problem. I can only view some NPC's HP. Other then that, it RTE9's on me. This is very upsetting. Mainly because this feature works so well, when it works. If there is a fix I'd recommend updating the tutorial. Thanks.
Link to comment
Share on other sites

Run in the IDE. When it errors, click debug in the box. (Make sure debug mode is off)

The errored line will be highlighted. Copy paste it here. Hover through all the variables in the line of code that errors and type in the variable value which has the errors. (Var value will be Subscript out of Range.)
Link to comment
Share on other sites

Ok, I didn't quite understand what you meant.. But here's what I found. (Excuse my ignorance, I'm not very advanced with VB6 at all.)

This is the line that errors:

Buffer.WriteLong MapNpc(GetPlayerMap(index)).NPC(mapNpcNum).Vital(HP)

When I hovered over everything I found this:

(GetPlayerMap(index)) = 1

.NPC(mapNpcNum) = 0

And out of these lines of code.. I found a few that (Subscript out of Range)'d

For i = 1 To Stats.Stat_Count - 1

Buffer.WriteByte .Stat(i) = (Subscript out of Range)

Debug.Print .Stat(i) = (Subscript out of Range)

Next i

End With

Also, for some reason it seems to display the stats of the first NPC in my NPC list.. Rather than the actual map NPC.. I'm very confused.
Link to comment
Share on other sites

> Ok, I didn't quite understand what you meant.. But here's what I found. (Excuse my ignorance, I'm not very advanced with VB6 at all.)
>
> This is the line that errors:
>
> Buffer.WriteLong MapNpc(GetPlayerMap(index)).NPC(mapNpcNum).Vital(HP)
>
> When I hovered over everything I found this:
>
> (GetPlayerMap(index)) = 1
>
> .NPC(mapNpcNum) = 0
>
> And out of these lines of code.. I found a few that (Subscript out of Range)'d
>
> For i = 1 To Stats.Stat_Count - 1
>
> Buffer.WriteByte .Stat(i) = (Subscript out of Range)
>
> Debug.Print .Stat(i) = (Subscript out of Range)
>
> Next i
>
> End With
>
> Also, for some reason it seems to display the stats of the first NPC in my NPC list.. Rather than the actual map NPC.. I'm very confused.

Have same error, this dont work :/
Link to comment
Share on other sites

> Ensure the following.
>
> i > 1 < stats.stat_count - 1
>
> target > 1 < Max_NPC

As far as I can see, the first one is correct.. I dont know where the hell MAX_NPC is. Though I found MAX_MAP_NPCS which is like this:

For i = 1 To MAX_MAP_NPCS

Still, I dont understand why when I hover over mapnpcnum… it says "mapnpcnum = 0"... Even though The code is written like this: mapnpcnum = i... Also when i hover over "i" it shows "i = 101"... wtfffff

MAYBE, if you uploaded a working version with the source.... I could see exactly what's wrong. ![:huh:](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/huh.png)
Link to comment
Share on other sites

> all you need is the npc num and its current vitals (which already get sent anyway)??

The vitals might be delayed, might get corrupted etc, etc. You should never trust the Clients values. (The client can be hacked.)

> Have same error, this dont work :/

I'll try fixing this ASAP.

> As far as I can see, the first one is correct.. I dont know where the hell MAX_NPC is. Though I found MAX_MAP_NPCS which is like this:
>
> For i = 1 To MAX_MAP_NPCS
>
> Still, I dont understand why when I hover over mapnpcnum… it says "mapnpcnum = 0"... Even though The code is written like this: mapnpcnum = i... Also when i hover over "i" it shows "i = 101"... wtfffff
>
> MAYBE, if you uploaded a working version with the source.... I could see exactly what's wrong. ![:huh:](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/huh.png)

It should be MAX_NPCS

> Would there be a way to put this into a skill, sort of like "Scan" from Final Fantasy?

If you mean player skills is shown, sure. You will need to add some more stuff though. (Or did you mean taking a peek into the players skills?)
Link to comment
Share on other sites

> The vitals might be delayed, might get corrupted etc, etc. You should never trust the Clients values. (The client can be hacked.)

If the client wants to hack client values then they can go ahead it wont do anything…

The vitals come directly from the server and you can display the information through targeting or combat system... i dont see how that is delayed..
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...